#78 배에서 포 쏘는 로직 구성 중
This commit is contained in:
parent
43cd84c48e
commit
29380edf79
@ -991,7 +991,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 168896972}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.14710695, y: 0.69163543, z: -0.14710692, w: 0.6916355}
|
||||
m_LocalRotation: {x: 0.14710693, y: 0.69163543, z: -0.14710695, w: 0.69163543}
|
||||
m_LocalPosition: {x: -57.299995, y: 13.42, z: 0.0000023841858}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
@ -3258,10 +3258,11 @@ MonoBehaviour:
|
||||
acceleration: 4
|
||||
deceleration: 2
|
||||
turnSpeed: 1
|
||||
projectilePrefab: {fileID: 5479992, guid: d8aca1dfdbd0741fca61f68fd3bc8119, type: 3}
|
||||
launchPoint: {fileID: 1608292909}
|
||||
timeOfFlight: 1
|
||||
predictedPos: {fileID: 0}
|
||||
chargingSpeed: 1
|
||||
isFireMode: 0
|
||||
chargingCannon: 0
|
||||
chargingGauge: 0
|
||||
previousGauge: 0
|
||||
--- !u!114 &476261172
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -6813,7 +6814,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 776161953}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.14710695, y: 0.69163543, z: -0.14710692, w: 0.6916355}
|
||||
m_LocalRotation: {x: 0.14710693, y: 0.69163543, z: -0.14710695, w: 0.69163543}
|
||||
m_LocalPosition: {x: -57.299995, y: 13.42, z: 0.0000023841858}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
@ -7162,7 +7163,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_SizeDelta: {x: 50, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1001 &878124045
|
||||
PrefabInstance:
|
||||
@ -8744,10 +8745,11 @@ MonoBehaviour:
|
||||
acceleration: 2
|
||||
deceleration: 2
|
||||
turnSpeed: 1
|
||||
projectilePrefab: {fileID: 0}
|
||||
launchPoint: {fileID: 0}
|
||||
timeOfFlight: 0
|
||||
predictedPos: {fileID: 0}
|
||||
chargingSpeed: 1
|
||||
isFireMode: 0
|
||||
chargingCannon: 0
|
||||
chargingGauge: 0
|
||||
previousGauge: 0
|
||||
--- !u!114 &1181634886
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -10530,7 +10532,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1485085414}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.3802242, y: 0.6187545, z: -0.46297562, w: 0.50815946}
|
||||
m_LocalRotation: {x: 0.3802241, y: 0.61875457, z: -0.46297565, w: 0.5081595}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
@ -11615,12 +11617,6 @@ NavMeshObstacle:
|
||||
m_CarveOnlyStationary: 1
|
||||
m_Center: {x: -0.09900001, y: 2.229, z: 0.049000002}
|
||||
m_TimeToStationary: 0.5
|
||||
--- !u!4 &1608292909 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 1055643547297219040, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 1939761122}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1001 &1621372727
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -161,6 +161,15 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
},
|
||||
{
|
||||
""name"": ""Mouse1"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""2d9a2349-b5a2-4926-a6e8-41abf2e24a3a"",
|
||||
""expectedControlType"": ""Button"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
}
|
||||
],
|
||||
""bindings"": [
|
||||
@ -383,6 +392,17 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
|
||||
""action"": ""Mouse0"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""9a454696-c796-4188-88db-0c0b82e77c98"",
|
||||
""path"": ""<Mouse>/rightButton"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Keyboard&Mouse"",
|
||||
""action"": ""Mouse1"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -561,6 +581,7 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
|
||||
m_Player_Roll = m_Player.FindAction("Roll", throwIfNotFound: true);
|
||||
m_Player_UseSkill = m_Player.FindAction("UseSkill", throwIfNotFound: true);
|
||||
m_Player_Mouse0 = m_Player.FindAction("Mouse0", throwIfNotFound: true);
|
||||
m_Player_Mouse1 = m_Player.FindAction("Mouse1", throwIfNotFound: true);
|
||||
// Camera
|
||||
m_Camera = asset.FindActionMap("Camera", throwIfNotFound: true);
|
||||
m_Camera_Zoom = m_Camera.FindAction("Zoom", throwIfNotFound: true);
|
||||
@ -646,6 +667,7 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
|
||||
private readonly InputAction m_Player_Roll;
|
||||
private readonly InputAction m_Player_UseSkill;
|
||||
private readonly InputAction m_Player_Mouse0;
|
||||
private readonly InputAction m_Player_Mouse1;
|
||||
public struct PlayerActions
|
||||
{
|
||||
private @BlueWater m_Wrapper;
|
||||
@ -665,6 +687,7 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
|
||||
public InputAction @Roll => m_Wrapper.m_Player_Roll;
|
||||
public InputAction @UseSkill => m_Wrapper.m_Player_UseSkill;
|
||||
public InputAction @Mouse0 => m_Wrapper.m_Player_Mouse0;
|
||||
public InputAction @Mouse1 => m_Wrapper.m_Player_Mouse1;
|
||||
public InputActionMap Get() { return m_Wrapper.m_Player; }
|
||||
public void Enable() { Get().Enable(); }
|
||||
public void Disable() { Get().Disable(); }
|
||||
@ -719,6 +742,9 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
|
||||
@Mouse0.started += instance.OnMouse0;
|
||||
@Mouse0.performed += instance.OnMouse0;
|
||||
@Mouse0.canceled += instance.OnMouse0;
|
||||
@Mouse1.started += instance.OnMouse1;
|
||||
@Mouse1.performed += instance.OnMouse1;
|
||||
@Mouse1.canceled += instance.OnMouse1;
|
||||
}
|
||||
|
||||
private void UnregisterCallbacks(IPlayerActions instance)
|
||||
@ -768,6 +794,9 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
|
||||
@Mouse0.started -= instance.OnMouse0;
|
||||
@Mouse0.performed -= instance.OnMouse0;
|
||||
@Mouse0.canceled -= instance.OnMouse0;
|
||||
@Mouse1.started -= instance.OnMouse1;
|
||||
@Mouse1.performed -= instance.OnMouse1;
|
||||
@Mouse1.canceled -= instance.OnMouse1;
|
||||
}
|
||||
|
||||
public void RemoveCallbacks(IPlayerActions instance)
|
||||
@ -936,6 +965,7 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
|
||||
void OnRoll(InputAction.CallbackContext context);
|
||||
void OnUseSkill(InputAction.CallbackContext context);
|
||||
void OnMouse0(InputAction.CallbackContext context);
|
||||
void OnMouse1(InputAction.CallbackContext context);
|
||||
}
|
||||
public interface ICameraActions
|
||||
{
|
||||
|
@ -139,6 +139,15 @@
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "Mouse1",
|
||||
"type": "Button",
|
||||
"id": "2d9a2349-b5a2-4926-a6e8-41abf2e24a3a",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
@ -361,6 +370,17 @@
|
||||
"action": "Mouse0",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "9a454696-c796-4188-88db-0c0b82e77c98",
|
||||
"path": "<Mouse>/rightButton",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard&Mouse",
|
||||
"action": "Mouse1",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -17,17 +17,25 @@ namespace BlueWaterProject
|
||||
[Tooltip("감속 수치")] public float deceleration = 2f;
|
||||
[Tooltip("회전 속도")] public float turnSpeed = 10f;
|
||||
|
||||
[Title("캐논")]
|
||||
public Rigidbody projectilePrefab;
|
||||
public Transform launchPoint;
|
||||
public float timeOfFlight;
|
||||
public Transform predictedPos;
|
||||
[Title("캐논")]
|
||||
[SerializeField] private float chargingSpeed = 1f;
|
||||
[SerializeField] private bool isFireMode;
|
||||
[SerializeField] private bool chargingCannon;
|
||||
[SerializeField] private float chargingGauge;
|
||||
[SerializeField] private float previousGauge;
|
||||
|
||||
// public Rigidbody projectilePrefab;
|
||||
// public Transform launchPoint;
|
||||
// public float timeOfFlight;
|
||||
// public Transform predictedPos;
|
||||
|
||||
private Rigidbody rb;
|
||||
private PlayerInput playerInput;
|
||||
|
||||
private void Init()
|
||||
{
|
||||
rb = GetComponent<Rigidbody>();
|
||||
playerInput = GetComponent<PlayerInput>();
|
||||
}
|
||||
|
||||
#region Unity Function
|
||||
@ -38,6 +46,22 @@ namespace BlueWaterProject
|
||||
Init();
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
playerInput.actions.FindAction("Mouse0").started += _ => ChargeCannon();
|
||||
playerInput.actions.FindAction("Mouse0").canceled += _ => FireCannon();
|
||||
playerInput.actions.FindAction("Mouse1").started += _ => ToggleFireMode();
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
playerInput.actions.FindAction("Mouse0").started += _ => ChargeCannon();
|
||||
playerInput.actions.FindAction("Mouse0").canceled += _ => FireCannon();
|
||||
playerInput.actions.FindAction("Mouse1").started += _ => ToggleFireMode();
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
|
||||
@ -50,7 +74,7 @@ namespace BlueWaterProject
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
|
||||
HandleFireCannon();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -83,6 +107,22 @@ namespace BlueWaterProject
|
||||
rb.angularVelocity = Vector3.zero;
|
||||
}
|
||||
|
||||
private void HandleFireCannon()
|
||||
{
|
||||
if (!isFireMode || !chargingCannon) return;
|
||||
|
||||
if (chargingGauge < 1f)
|
||||
{
|
||||
chargingGauge += chargingSpeed * Time.deltaTime;
|
||||
chargingGauge = Mathf.Clamp(chargingGauge, 0f, 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
chargingGauge = 1f;
|
||||
}
|
||||
UiManager.Inst.OceanUi.ProcessBar.SetFillAmount(chargingGauge);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Interaction Key
|
||||
@ -116,12 +156,46 @@ namespace BlueWaterProject
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void OnZkey(InputValue value)
|
||||
|
||||
private void OnZkey(InputValue value) // Z
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void ChargeCannon()
|
||||
{
|
||||
if (!isFireMode) return;
|
||||
|
||||
chargingCannon = true;
|
||||
chargingGauge = 0f;
|
||||
}
|
||||
|
||||
private void FireCannon()
|
||||
{
|
||||
if (!isFireMode || !chargingCannon) return;
|
||||
|
||||
// TODO : 대포(작살) 발사 로직 만들기
|
||||
|
||||
print("게이지 : " + chargingGauge);
|
||||
previousGauge = chargingGauge;
|
||||
chargingCannon = false;
|
||||
|
||||
// TODO : previousGauge 위치에 선 남기기
|
||||
|
||||
|
||||
UiManager.Inst.OceanUi.ProcessBar.SetFillAmount(0f);
|
||||
}
|
||||
|
||||
private void ToggleFireMode()
|
||||
{
|
||||
isFireMode = !isFireMode;
|
||||
print("공격 모드 : " + isFireMode);
|
||||
|
||||
UiManager.Inst.OceanUi.ProcessBar.SetActive(isFireMode);
|
||||
|
||||
// TODO : 방향 표시 UI 또는 오브젝트 켜고 끄기
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -9,14 +9,20 @@ namespace BlueWaterProject
|
||||
[Serializable]
|
||||
public class ProcessBar
|
||||
{
|
||||
[field: SerializeField] public GameObject Obj { get; set; }
|
||||
[field: SerializeField] public Image Fill { get; set; }
|
||||
|
||||
public ProcessBar(GameObject obj, Image fill)
|
||||
{
|
||||
Obj = obj;
|
||||
Fill = fill;
|
||||
|
||||
SetFillAmount(0f);
|
||||
}
|
||||
|
||||
[field: SerializeField] public GameObject Obj { get; set; }
|
||||
[field: SerializeField] public Image Fill { get; set; }
|
||||
public void SetActive(bool value) => Obj.SetActive(value);
|
||||
public void SetPosition(Vector3 value) => Obj.transform.position = value;
|
||||
public void SetFillAmount(float value) => Fill.fillAmount = value;
|
||||
}
|
||||
|
||||
public class OceanUi : MonoBehaviour
|
||||
@ -28,8 +34,18 @@ namespace BlueWaterProject
|
||||
private void Awake()
|
||||
{
|
||||
UiManager.Inst.OceanUi = this;
|
||||
ProcessBar.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (ProcessBar.Obj.activeSelf)
|
||||
{
|
||||
var mousePos = Input.mousePosition;
|
||||
ProcessBar.SetPosition(mousePos);
|
||||
}
|
||||
}
|
||||
|
||||
[Button("셋팅 초기화")]
|
||||
private void Init()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user