#31 Z key now can make card
This commit is contained in:
parent
d4662ab3e6
commit
e5ef5dca35
File diff suppressed because it is too large
Load Diff
@ -6,6 +6,7 @@ using UnityEngine;
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace BlueWaterProject
|
||||
{
|
||||
[DefaultExecutionOrder(-1)]
|
||||
public class GameManager : Singleton<GameManager>
|
||||
{
|
||||
[Title("Controller")]
|
||||
|
@ -4,7 +4,7 @@ MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -1
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
@ -10,51 +10,51 @@ namespace BlueWaterProject
|
||||
{
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
[RequireComponent(typeof(PlayerInput))]
|
||||
[SelectionBase]
|
||||
public class Player : MonoBehaviour
|
||||
{
|
||||
[Title("Component")]
|
||||
[Title("Component")]
|
||||
private Rigidbody rb;
|
||||
private Vector2 movementInput;
|
||||
|
||||
[Title("쉽의 기본 설정")]
|
||||
[Tooltip("최대 스피드")]
|
||||
public float maxSpeed = 10f;
|
||||
[Tooltip("가속 수치")]
|
||||
public float acceleration = 2f;
|
||||
[Tooltip("감속 수치")]
|
||||
public float deceleration = 2f;
|
||||
[Tooltip("회전 속도")]
|
||||
public float turnSpeed = 10f;
|
||||
|
||||
[Title("캐릭터의 기본 설정")]
|
||||
|
||||
[Title("쉽의 기본 설정")]
|
||||
[Tooltip("최대 스피드")] public float maxSpeed = 10f;
|
||||
|
||||
[Tooltip("가속 수치")] public float acceleration = 2f;
|
||||
[Tooltip("감속 수치")] public float deceleration = 2f;
|
||||
[Tooltip("회전 속도")] public float turnSpeed = 10f;
|
||||
|
||||
[Title("캐릭터의 기본 설정")]
|
||||
private GameObject character;
|
||||
[Tooltip("캐릭터의 이동 속도")]
|
||||
public float characterSpeed = 10f;
|
||||
|
||||
[Title("레이더")]
|
||||
[Tooltip("캐릭터의 이동 속도")] public float characterSpeed = 10f;
|
||||
|
||||
[Title("레이더")]
|
||||
public Collider[] radar = new Collider[10];
|
||||
public List<Transform> inCameraRadar = new (10);
|
||||
public List<Transform> inCameraRadar = new(10);
|
||||
public Transform target;
|
||||
public bool IsTargeting { get; private set; }
|
||||
|
||||
[Title("캐논")]
|
||||
|
||||
[Title("캐논")]
|
||||
public Rigidbody projectilePrefab;
|
||||
public Transform launchPoint;
|
||||
public float timeOfFlight;
|
||||
public Transform predictedPos;
|
||||
[field: SerializeField]
|
||||
public List<Canon> Canons { get; private set; } = new (GlobalValue.MAX_CANON_COUNT);
|
||||
|
||||
[field: SerializeField] public List<Canon> Canons { get; private set; } = new(GlobalValue.MAX_CANON_COUNT);
|
||||
|
||||
[field: Title("Mode")]
|
||||
[field: SerializeField] public bool IsAssaultMode { get; set; }
|
||||
[field: SerializeField]
|
||||
public bool IsAssaultMode { get; set; }
|
||||
|
||||
[field: SerializeField] public bool IsInShipMode { get; set; }
|
||||
[field: SerializeField] public bool IsDredgeMode { get; set; }
|
||||
[field: SerializeField] public bool IsTakeAim { get; set; }
|
||||
|
||||
[Title("Interaction")]
|
||||
|
||||
[Title("Interaction")]
|
||||
public bool IsIslandInteraction { get; set; }
|
||||
private float rayLength;
|
||||
private LayerMask groundLayer;
|
||||
private Vector3 halfExtents; // 박스 크기의 절반을 나타내는 벡터값을 설정합니다.
|
||||
private List<Vector3> directions = new(8);
|
||||
|
||||
private void Init()
|
||||
{
|
||||
@ -64,14 +64,26 @@ namespace BlueWaterProject
|
||||
|
||||
rayLength = 15f;
|
||||
groundLayer = LayerMask.GetMask("Ground");
|
||||
halfExtents = new Vector3(5, 5, 5);
|
||||
directions = new List<Vector3>(8)
|
||||
{
|
||||
transform.forward,
|
||||
-transform.forward,
|
||||
transform.right,
|
||||
-transform.right,
|
||||
transform.forward + transform.right,
|
||||
transform.forward - transform.right,
|
||||
-transform.forward + transform.right,
|
||||
-transform.forward - transform.right
|
||||
};
|
||||
}
|
||||
|
||||
#region Unity Function
|
||||
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
Gizmos.color = Color.red;
|
||||
Gizmos.DrawWireSphere(transform.position, GlobalValue.RADAR_RANGE);
|
||||
RadarDrawGizmo();
|
||||
Raycast8DrawGizmo();
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
@ -98,14 +110,14 @@ namespace BlueWaterProject
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Movement
|
||||
|
||||
|
||||
public void OnMove(InputValue value) // WASD
|
||||
{
|
||||
movementInput = value.Get<Vector2>();
|
||||
}
|
||||
|
||||
|
||||
private void MoveShipPlayer()
|
||||
{
|
||||
var desiredVelocity = transform.forward * (movementInput.y * maxSpeed);
|
||||
@ -122,11 +134,12 @@ namespace BlueWaterProject
|
||||
|
||||
private void MoveCharacterPlayer()
|
||||
{
|
||||
var movement = character.transform.rotation * new Vector3(-movementInput.y, 0, movementInput.x) * (characterSpeed * Time.deltaTime);
|
||||
var movement = character.transform.rotation * new Vector3(-movementInput.y, 0, movementInput.x) *
|
||||
(characterSpeed * Time.deltaTime);
|
||||
|
||||
character.transform.position += movement;
|
||||
}
|
||||
|
||||
|
||||
private void HandleMovement()
|
||||
{
|
||||
if (IsInShipMode)
|
||||
@ -139,22 +152,22 @@ namespace BlueWaterProject
|
||||
RotatePlayer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void StopShipMovement()
|
||||
{
|
||||
rb.velocity = Vector3.zero;
|
||||
rb.angularVelocity = Vector3.zero;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region AssaultMode/DreadgeMode Switch
|
||||
|
||||
private void OnAssaultMode(InputValue value) // V
|
||||
{
|
||||
SwitchAssaultMode(!IsAssaultMode);
|
||||
}
|
||||
|
||||
|
||||
private void SwitchAssaultMode(bool isOn)
|
||||
{
|
||||
if (isOn)
|
||||
@ -173,7 +186,7 @@ namespace BlueWaterProject
|
||||
IsAssaultMode = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SwitchDredgeMode(bool isOn)
|
||||
{
|
||||
if (isOn)
|
||||
@ -193,16 +206,16 @@ namespace BlueWaterProject
|
||||
#endregion
|
||||
|
||||
#region Interaction Key
|
||||
|
||||
|
||||
private void OnTargeting(InputValue value) //Q
|
||||
{
|
||||
if(inCameraRadar.Count == 0) return;
|
||||
if (inCameraRadar.Count == 0) return;
|
||||
IsTargeting = true;
|
||||
UiManager.Inst.RadarUIOnOff(IsTargeting);
|
||||
|
||||
|
||||
FindTarget();
|
||||
}
|
||||
|
||||
|
||||
private void OnTargetingHold(InputValue value) //Q Hold
|
||||
{
|
||||
IsTargeting = false;
|
||||
@ -211,7 +224,7 @@ namespace BlueWaterProject
|
||||
|
||||
private void OnInteractionE(InputValue value) //E
|
||||
{
|
||||
if(IsTargeting) UiManager.Inst.CheckRadarOverlap();
|
||||
if (IsTargeting) UiManager.Inst.CheckRadarOverlap();
|
||||
}
|
||||
|
||||
private void OnInteraction(InputValue value) //F
|
||||
@ -221,7 +234,7 @@ namespace BlueWaterProject
|
||||
UiManager.Inst.DefaultInteractionOnOff(false);
|
||||
StopShipMovement();
|
||||
}
|
||||
|
||||
|
||||
private void OnInteractionHold(InputValue value) //F Hold
|
||||
{
|
||||
SwitchInShipMode(!IsInShipMode);
|
||||
@ -245,10 +258,10 @@ namespace BlueWaterProject
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private void OnZkey(InputValue value)
|
||||
{
|
||||
UiManager.Inst.AddCard();
|
||||
UiManager.Inst.AssaultCardInit();
|
||||
}
|
||||
|
||||
#region TakeAim
|
||||
@ -257,7 +270,7 @@ namespace BlueWaterProject
|
||||
{
|
||||
SwitchTakeAim(!IsTakeAim);
|
||||
}
|
||||
|
||||
|
||||
private void SwitchTakeAim(bool isOn)
|
||||
{
|
||||
if (isOn)
|
||||
@ -277,6 +290,7 @@ namespace BlueWaterProject
|
||||
Cursor.lockState = CursorLockMode.Confined;
|
||||
IsTakeAim = false;
|
||||
}
|
||||
|
||||
UiManager.Inst.AimOnOff(isOn);
|
||||
}
|
||||
|
||||
@ -286,7 +300,8 @@ namespace BlueWaterProject
|
||||
|
||||
private void FindInRadarRange()
|
||||
{
|
||||
Physics.OverlapSphereNonAlloc(transform.position, GlobalValue.RADAR_RANGE, radar, LayerMask.GetMask(GlobalValue.ENEMY_LAYER));
|
||||
Physics.OverlapSphereNonAlloc(transform.position, GlobalValue.RADAR_RANGE, radar,
|
||||
LayerMask.GetMask(GlobalValue.ENEMY_LAYER));
|
||||
}
|
||||
|
||||
private void FilterInCameraObjects()
|
||||
@ -295,13 +310,18 @@ namespace BlueWaterProject
|
||||
foreach (var col in radar)
|
||||
{
|
||||
if (col == null) continue;
|
||||
var screenPoint = GameManager.Inst.CameraController.MainCam.WorldToViewportPoint(col.transform.position);
|
||||
if (screenPoint.z > 0 && screenPoint.x >= 0 && screenPoint.x <= 1 && screenPoint.y >= 0 && screenPoint.y <= 1)
|
||||
var screenPoint =
|
||||
GameManager.Inst.CameraController.MainCam.WorldToViewportPoint(col.transform.position);
|
||||
if (screenPoint.z > 0 && screenPoint.x >= 0 && screenPoint.x <= 1 && screenPoint.y >= 0 &&
|
||||
screenPoint.y <= 1)
|
||||
{
|
||||
inCameraRadar.Add(col.transform);
|
||||
}
|
||||
}
|
||||
inCameraRadar.Sort((a, b) => Vector3.Distance(transform.position, a.position).CompareTo(Vector3.Distance(transform.position, b.position)));
|
||||
|
||||
inCameraRadar.Sort((a, b) =>
|
||||
Vector3.Distance(transform.position, a.position)
|
||||
.CompareTo(Vector3.Distance(transform.position, b.position)));
|
||||
}
|
||||
|
||||
private void FindTarget()
|
||||
@ -312,14 +332,12 @@ namespace BlueWaterProject
|
||||
{
|
||||
if (trans.Find("TestTarget") == null) continue;
|
||||
if (target != null && trans.Find("TestTarget").transform == oldTarget) continue;
|
||||
target = trans.Find("TestTarget").transform; // Set new target
|
||||
break; // Exit the loop
|
||||
target = trans.Find("TestTarget").transform;
|
||||
break;
|
||||
}
|
||||
|
||||
// Check if target has changed
|
||||
if (target != oldTarget)
|
||||
{
|
||||
// Call some method if target has changed
|
||||
UiManager.Inst.RadarTargetInit();
|
||||
}
|
||||
}
|
||||
@ -342,30 +360,18 @@ namespace BlueWaterProject
|
||||
private void Raycast8Direction()
|
||||
{
|
||||
if (!IsDredgeMode) return;
|
||||
|
||||
Vector3[] directions =
|
||||
{
|
||||
transform.forward,
|
||||
-transform.forward,
|
||||
transform.right,
|
||||
-transform.right,
|
||||
transform.forward + transform.right,
|
||||
transform.forward - transform.right,
|
||||
-transform.forward + transform.right,
|
||||
-transform.forward - transform.right
|
||||
};
|
||||
|
||||
Vector3 halfExtents = new Vector3(5, 5, 5); // 박스 크기의 절반을 나타내는 벡터값을 설정합니다.
|
||||
var isOn = false;
|
||||
|
||||
foreach (Vector3 dir in directions)
|
||||
{
|
||||
RaycastHit hit;
|
||||
|
||||
if (Physics.BoxCast(transform.position, halfExtents, dir, out hit, Quaternion.identity, rayLength, groundLayer))
|
||||
if (Physics.BoxCast(transform.position, halfExtents, dir, out hit, Quaternion.identity, rayLength,
|
||||
groundLayer))
|
||||
{
|
||||
isOn = true;
|
||||
|
||||
|
||||
var islandInfo = hit.transform.parent.parent.GetComponent<IslandInfo>();
|
||||
|
||||
if (GameManager.Inst.CameraController.AssaultCam != islandInfo.IslandCam)
|
||||
@ -376,6 +382,7 @@ namespace BlueWaterProject
|
||||
IsIslandInteraction = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// 박스가 Ground 레이어에 닿지 않았을 때 녹색으로 표시
|
||||
Debug.DrawRay(transform.position, dir * rayLength, Color.green);
|
||||
IsIslandInteraction = false;
|
||||
@ -385,5 +392,36 @@ namespace BlueWaterProject
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Gizmos
|
||||
|
||||
private void Raycast8DrawGizmo()
|
||||
{
|
||||
Gizmos.color = IsIslandInteraction ? Color.red : Color.green;
|
||||
|
||||
foreach (Vector3 dir in directions)
|
||||
{
|
||||
bool isHit = Physics.BoxCast(transform.position, halfExtents, dir, out RaycastHit hitInfo, Quaternion.identity, rayLength, groundLayer);
|
||||
|
||||
if (isHit)
|
||||
{
|
||||
// 박스가 Ground 레이어에 닿았을 때 빨간색으로 표시
|
||||
Gizmos.DrawWireCube(transform.position + dir.normalized * hitInfo.distance, halfExtents * 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 박스가 Ground 레이어에 닿지 않았을 때 녹색으로 표시
|
||||
Gizmos.DrawWireCube(transform.position + dir.normalized * rayLength, halfExtents * 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RadarDrawGizmo()
|
||||
{
|
||||
Gizmos.color = Color.red;
|
||||
Gizmos.DrawWireSphere(transform.position, GlobalValue.RADAR_RANGE);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -83,7 +83,7 @@ namespace BlueWaterProject
|
||||
Cursor.SetCursor(cursorTexture, hotSpot, CursorMode.Auto);
|
||||
}
|
||||
|
||||
private void AssaultCardInit()
|
||||
public void AssaultCardInit()
|
||||
{
|
||||
for (int i = 0; i < DataManager.Inst.CardList.Count; i++)
|
||||
{
|
||||
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a55ee4efaad27d948ba5f03fc6d7bc80
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed9b95dc6ed6d0647ad7f1a8f305385d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ff1f29eab234cf4490d9bb383892c44
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5789d13135b86645a366dac6583d1cd
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3643c0d76ec153646b1203880bfb64ed
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d7c4217783978e4abe6496ac71eee94
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 697b6e7dea1fde146b7e3e5cf3ed9e9f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 078b8f13a17171b49892ad10426d5af0
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9406a33814af9c47b352e77f079d798
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9aacf6f3043624194bb6f6fe9a580786
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4227764308e84f89a765fbf315e2945
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41e59f562b69648719f2424c438758f3
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b044a2387a61dac41bdf204adffdce9d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd287c84e887ea24a8679e67aac7c074
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f3f53ee059b45a4d9a5b9fc75e8aea9
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f211254f5bfad224ba88868f2c75432c
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4368c9be31b3c174dbfd80f2caf98889
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 617b3f1032a08c14ebfedfa340767cdf
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f597f19f656ba56eae4f6a3a7cc528f4
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48e08dc33330d11e9d4a1b246c52e4f6
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed09910c0094cb27be8f3ca264680da3
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc355dd4cf1e6173beaeb22c2858cbe1
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -28,7 +28,7 @@ TagManager:
|
||||
- Enemy
|
||||
- Weapon
|
||||
- HitBox
|
||||
-
|
||||
- ShipPlayer
|
||||
-
|
||||
-
|
||||
- Props
|
||||
|
Loading…
Reference in New Issue
Block a user