+ 부서지는 벽(RayFire) 테스트 + DestructiveObject, ShipPlayer 태그 추가 + GrenadeFireOBJ의 Layer 수정 (Default -> Skill) + Physics 수정 (Skill <-> Props) + IDestructible 인터페이스 추가 IDamageable 상속받는 인터페이스
This commit is contained in:
parent
9c7739f9c1
commit
8261e17478
File diff suppressed because it is too large
Load Diff
@ -7,16 +7,26 @@ using UnityEngine.InputSystem;
|
|||||||
namespace BlueWaterProject
|
namespace BlueWaterProject
|
||||||
{
|
{
|
||||||
[SelectionBase]
|
[SelectionBase]
|
||||||
public class ShipPlayer : MonoBehaviour, IDamageable
|
public class ShipPlayer : MonoBehaviour, IDestructible
|
||||||
{
|
{
|
||||||
[Title("초기화 방식")]
|
[Title("초기화 방식")]
|
||||||
[SerializeField] private bool autoInit = true;
|
[SerializeField] private bool autoInit = true;
|
||||||
|
|
||||||
[Title("쉽의 기본 설정")]
|
[Title("쉽의 기본 설정")]
|
||||||
[Tooltip("최대 스피드")] public float maxSpeed = 10f;
|
[Tooltip("최대 스피드")]
|
||||||
[Tooltip("가속 수치")] public float acceleration = 2f;
|
[SerializeField] private float maxSpeed = 10f;
|
||||||
[Tooltip("감속 수치")] public float deceleration = 2f;
|
[Tooltip("가속 수치")]
|
||||||
[Tooltip("회전 속도")] public float turnSpeed = 10f;
|
[SerializeField] private float acceleration = 2f;
|
||||||
|
[Tooltip("감속 수치")]
|
||||||
|
[SerializeField] private float deceleration = 2f;
|
||||||
|
[Tooltip("회전 속도")]
|
||||||
|
[SerializeField] private float turnSpeed = 10f;
|
||||||
|
[Tooltip("배의 최대 체력")]
|
||||||
|
[field: SerializeField] public float MaxHp { get; private set; } = 100;
|
||||||
|
[Tooltip("배의 현재 체력")]
|
||||||
|
[field: SerializeField] public float CurrentHp { get; private set; }
|
||||||
|
[Tooltip("배의 힘(충돌)")]
|
||||||
|
[field: SerializeField] public int Strength { get; set; } = 500;
|
||||||
|
|
||||||
[Title("캐논")]
|
[Title("캐논")]
|
||||||
[SerializeField] private Cannon cannon;
|
[SerializeField] private Cannon cannon;
|
||||||
@ -53,6 +63,8 @@ namespace BlueWaterProject
|
|||||||
directionIndicator.SetActive(false);
|
directionIndicator.SetActive(false);
|
||||||
|
|
||||||
waterLayer = LayerMask.GetMask("Water");
|
waterLayer = LayerMask.GetMask("Water");
|
||||||
|
|
||||||
|
SetCurrentHp(MaxHp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Unity Function
|
#region Unity Function
|
||||||
@ -332,14 +344,25 @@ namespace BlueWaterProject
|
|||||||
|
|
||||||
public void TakeDamage(float attackerPower, Vector3? attackPos = null)
|
public void TakeDamage(float attackerPower, Vector3? attackPos = null)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
var changeHp = Mathf.Max(CurrentHp - attackerPower, 0f);
|
||||||
|
|
||||||
|
SetCurrentHp(changeHp);
|
||||||
|
|
||||||
|
if (CurrentHp == 0f)
|
||||||
|
{
|
||||||
|
Die();
|
||||||
|
}
|
||||||
|
|
||||||
|
print("오브젝트 충돌 - 현재 체력 : " + CurrentHp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Die()
|
public void Die()
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
print("배 파괴 - 현재 체력 : " + CurrentHp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public void SetCurrentHp(float value) => CurrentHp = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
88
BlueWater/Assets/02.Scripts/DestructiveObject.cs
Normal file
88
BlueWater/Assets/02.Scripts/DestructiveObject.cs
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
using RayFire;
|
||||||
|
using Sirenix.OdinInspector;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
// ReSharper disable once CheckNamespace
|
||||||
|
namespace BlueWaterProject
|
||||||
|
{
|
||||||
|
public class DestructiveObject : MonoBehaviour
|
||||||
|
{
|
||||||
|
[Title("초기화 방식")]
|
||||||
|
[SerializeField] private bool autoInit = true;
|
||||||
|
|
||||||
|
[Title("기본 설정")]
|
||||||
|
[field: SerializeField] public int Strength { get; private set; } = 100;
|
||||||
|
[SerializeField] private float power = 10f;
|
||||||
|
[SerializeField] private float damageCooldown = 2f;
|
||||||
|
[SerializeField] private bool isHitting;
|
||||||
|
|
||||||
|
[SerializeField] private RayfireRigid rayfire;
|
||||||
|
[SerializeField] private Rigidbody rb;
|
||||||
|
|
||||||
|
[Button("셋팅 초기화")]
|
||||||
|
private void Init()
|
||||||
|
{
|
||||||
|
rayfire = GetComponent<RayfireRigid>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
if (autoInit)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
rb = GetComponent<Rigidbody>();
|
||||||
|
|
||||||
|
rb.isKinematic = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnCollisionEnter(Collision other)
|
||||||
|
{
|
||||||
|
if (other.collider.CompareTag("ShipPlayer"))
|
||||||
|
{
|
||||||
|
var iDestructible = other.collider.GetComponent<IDestructible>();
|
||||||
|
var otherStrength = iDestructible.Strength;
|
||||||
|
|
||||||
|
if (otherStrength > Strength)
|
||||||
|
{
|
||||||
|
DestroyObject();
|
||||||
|
}
|
||||||
|
else if (otherStrength < Strength)
|
||||||
|
{
|
||||||
|
if (isHitting) return;
|
||||||
|
|
||||||
|
Hit(iDestructible);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DestroyObject();
|
||||||
|
Hit(iDestructible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (other.collider.CompareTag("Missile"))
|
||||||
|
{
|
||||||
|
DestroyObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DestroyObject()
|
||||||
|
{
|
||||||
|
rb.isKinematic = false;
|
||||||
|
rayfire.Demolish();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Hit(IDestructible iDestructible)
|
||||||
|
{
|
||||||
|
isHitting = true;
|
||||||
|
iDestructible.TakeDamage(power);
|
||||||
|
|
||||||
|
if (!gameObject.activeSelf) return;
|
||||||
|
|
||||||
|
StartCoroutine(Utils.CoolDown(damageCooldown, () => isHitting = false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
BlueWater/Assets/02.Scripts/DestructiveObject.cs.meta
Normal file
11
BlueWater/Assets/02.Scripts/DestructiveObject.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9b69f7e57a6e2a641936534835f324ea
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
10
BlueWater/Assets/02.Scripts/Interface/IDestructible.cs
Normal file
10
BlueWater/Assets/02.Scripts/Interface/IDestructible.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
// ReSharper disable once CheckNamespace
|
||||||
|
namespace BlueWaterProject
|
||||||
|
{
|
||||||
|
public interface IDestructible : IDamageable
|
||||||
|
{
|
||||||
|
public int Strength { get; set; }
|
||||||
|
}
|
||||||
|
}
|
11
BlueWater/Assets/02.Scripts/Interface/IDestructible.cs.meta
Normal file
11
BlueWater/Assets/02.Scripts/Interface/IDestructible.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 56fa2f33a534b3046933e9b2dc37bcee
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -12,7 +12,7 @@ GameObject:
|
|||||||
- component: {fileID: 13576440}
|
- component: {fileID: 13576440}
|
||||||
- component: {fileID: 5479992}
|
- component: {fileID: 5479992}
|
||||||
- component: {fileID: 11464288}
|
- component: {fileID: 11464288}
|
||||||
m_Layer: 0
|
m_Layer: 25
|
||||||
m_Name: GrenadeFireOBJ
|
m_Name: GrenadeFireOBJ
|
||||||
m_TagString: Missile
|
m_TagString: Missile
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: b1d738c46034bc244bd356692577373c
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
AssetOrigin:
|
|
||||||
serializedVersion: 1
|
|
||||||
productId: 147990
|
|
||||||
packageName: Dynamic Water Physics 2
|
|
||||||
packageVersion: 2.21
|
|
||||||
assetPath: Assets/NWH/Dynamic Water Physics 2/OptionalPackages/Multiplayer/Mirror.unitypackage
|
|
||||||
uploadId: 628762
|
|
@ -1,14 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 2d6d5d59d45ce8a4784ba6c47984a23e
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
AssetOrigin:
|
|
||||||
serializedVersion: 1
|
|
||||||
productId: 147990
|
|
||||||
packageName: Dynamic Water Physics 2
|
|
||||||
packageVersion: 2.21
|
|
||||||
assetPath: Assets/NWH/Dynamic Water Physics 2/OptionalPackages/Multiplayer/PUN2.unitypackage
|
|
||||||
uploadId: 628762
|
|
@ -116,7 +116,7 @@ Material:
|
|||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _BaseColor: {r: 0.53773576, g: 0.53773576, b: 0.53773576, a: 1}
|
- _BaseColor: {r: 0.53773576, g: 0.53773576, b: 0.53773576, a: 1}
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
- _Color: {r: 0.5377357, g: 0.5377357, b: 0.5377357, a: 1}
|
||||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
@ -17,7 +17,7 @@ PhysicsManager:
|
|||||||
m_EnableAdaptiveForce: 0
|
m_EnableAdaptiveForce: 0
|
||||||
m_ClothInterCollisionDistance: 0.1
|
m_ClothInterCollisionDistance: 0.1
|
||||||
m_ClothInterCollisionStiffness: 0.2
|
m_ClothInterCollisionStiffness: 0.2
|
||||||
m_LayerCollisionMatrix: 0400000000000000010000004026020000000000000000000800000000000000000000000826220208262000000000000000000008262000000000000000000000000000080200000000000000000000000000000026000000000000000000000000000000020000000000000000000000000000000000000000000000000000
|
m_LayerCollisionMatrix: 0400000000000000010000004026020000000000000000000800000000000000000000000826220208262000000000000000000008262000000000000000000000000000080200000000000000000000000000000026000200000000000000000000000000022000000000000000000000000000000000000000000000000000
|
||||||
m_SimulationMode: 0
|
m_SimulationMode: 0
|
||||||
m_AutoSyncTransforms: 0
|
m_AutoSyncTransforms: 0
|
||||||
m_ReuseCollisionCallbacks: 0
|
m_ReuseCollisionCallbacks: 0
|
||||||
|
@ -17,6 +17,10 @@ TagManager:
|
|||||||
- Grid
|
- Grid
|
||||||
- HitBox
|
- HitBox
|
||||||
- DestructiveSkill
|
- DestructiveSkill
|
||||||
|
- Ship
|
||||||
|
- Water
|
||||||
|
- DestructiveObject
|
||||||
|
- ShipPlayer
|
||||||
layers:
|
layers:
|
||||||
- Default
|
- Default
|
||||||
- TransparentFX
|
- TransparentFX
|
||||||
|
Loading…
Reference in New Issue
Block a user