#31 Z key now can make card

This commit is contained in:
M1_IDMhan 2023-09-20 18:06:45 +09:00
parent d4662ab3e6
commit e5ef5dca35
28 changed files with 875 additions and 197 deletions

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,7 @@ using UnityEngine;
// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace
namespace BlueWaterProject namespace BlueWaterProject
{ {
[DefaultExecutionOrder(-1)]
public class GameManager : Singleton<GameManager> public class GameManager : Singleton<GameManager>
{ {
[Title("Controller")] [Title("Controller")]

View File

@ -4,7 +4,7 @@ MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: -1 executionOrder: 0
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:

View File

@ -10,6 +10,7 @@ namespace BlueWaterProject
{ {
[RequireComponent(typeof(Rigidbody))] [RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(PlayerInput))] [RequireComponent(typeof(PlayerInput))]
[SelectionBase]
public class Player : MonoBehaviour public class Player : MonoBehaviour
{ {
[Title("Component")] [Title("Component")]
@ -17,19 +18,15 @@ namespace BlueWaterProject
private Vector2 movementInput; private Vector2 movementInput;
[Title("쉽의 기본 설정")] [Title("쉽의 기본 설정")]
[Tooltip("최대 스피드")] [Tooltip("최대 스피드")] public float maxSpeed = 10f;
public float maxSpeed = 10f;
[Tooltip("가속 수치")] [Tooltip("가속 수치")] public float acceleration = 2f;
public float acceleration = 2f; [Tooltip("감속 수치")] public float deceleration = 2f;
[Tooltip("감속 수치")] [Tooltip("회전 속도")] public float turnSpeed = 10f;
public float deceleration = 2f;
[Tooltip("회전 속도")]
public float turnSpeed = 10f;
[Title("캐릭터의 기본 설정")] [Title("캐릭터의 기본 설정")]
private GameObject character; private GameObject character;
[Tooltip("캐릭터의 이동 속도")] [Tooltip("캐릭터의 이동 속도")] public float characterSpeed = 10f;
public float characterSpeed = 10f;
[Title("레이더")] [Title("레이더")]
public Collider[] radar = new Collider[10]; public Collider[] radar = new Collider[10];
@ -42,11 +39,12 @@ namespace BlueWaterProject
public Transform launchPoint; public Transform launchPoint;
public float timeOfFlight; public float timeOfFlight;
public Transform predictedPos; public Transform predictedPos;
[field: SerializeField] [field: SerializeField] public List<Canon> Canons { get; private set; } = new(GlobalValue.MAX_CANON_COUNT);
public List<Canon> Canons { get; private set; } = new (GlobalValue.MAX_CANON_COUNT);
[field: Title("Mode")] [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 IsInShipMode { get; set; }
[field: SerializeField] public bool IsDredgeMode { get; set; } [field: SerializeField] public bool IsDredgeMode { get; set; }
[field: SerializeField] public bool IsTakeAim { get; set; } [field: SerializeField] public bool IsTakeAim { get; set; }
@ -55,6 +53,8 @@ namespace BlueWaterProject
public bool IsIslandInteraction { get; set; } public bool IsIslandInteraction { get; set; }
private float rayLength; private float rayLength;
private LayerMask groundLayer; private LayerMask groundLayer;
private Vector3 halfExtents; // 박스 크기의 절반을 나타내는 벡터값을 설정합니다.
private List<Vector3> directions = new(8);
private void Init() private void Init()
{ {
@ -64,14 +64,26 @@ namespace BlueWaterProject
rayLength = 15f; rayLength = 15f;
groundLayer = LayerMask.GetMask("Ground"); 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 #region Unity Function
private void OnDrawGizmosSelected() private void OnDrawGizmosSelected()
{ {
Gizmos.color = Color.red; RadarDrawGizmo();
Gizmos.DrawWireSphere(transform.position, GlobalValue.RADAR_RANGE); Raycast8DrawGizmo();
} }
private void Awake() private void Awake()
@ -122,7 +134,8 @@ namespace BlueWaterProject
private void MoveCharacterPlayer() 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; character.transform.position += movement;
} }
@ -248,7 +261,7 @@ namespace BlueWaterProject
private void OnZkey(InputValue value) private void OnZkey(InputValue value)
{ {
UiManager.Inst.AddCard(); UiManager.Inst.AssaultCardInit();
} }
#region TakeAim #region TakeAim
@ -277,6 +290,7 @@ namespace BlueWaterProject
Cursor.lockState = CursorLockMode.Confined; Cursor.lockState = CursorLockMode.Confined;
IsTakeAim = false; IsTakeAim = false;
} }
UiManager.Inst.AimOnOff(isOn); UiManager.Inst.AimOnOff(isOn);
} }
@ -286,7 +300,8 @@ namespace BlueWaterProject
private void FindInRadarRange() 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() private void FilterInCameraObjects()
@ -295,13 +310,18 @@ namespace BlueWaterProject
foreach (var col in radar) foreach (var col in radar)
{ {
if (col == null) continue; if (col == null) continue;
var screenPoint = GameManager.Inst.CameraController.MainCam.WorldToViewportPoint(col.transform.position); var screenPoint =
if (screenPoint.z > 0 && screenPoint.x >= 0 && screenPoint.x <= 1 && screenPoint.y >= 0 && screenPoint.y <= 1) 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.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() private void FindTarget()
@ -312,14 +332,12 @@ namespace BlueWaterProject
{ {
if (trans.Find("TestTarget") == null) continue; if (trans.Find("TestTarget") == null) continue;
if (target != null && trans.Find("TestTarget").transform == oldTarget) continue; if (target != null && trans.Find("TestTarget").transform == oldTarget) continue;
target = trans.Find("TestTarget").transform; // Set new target target = trans.Find("TestTarget").transform;
break; // Exit the loop break;
} }
// Check if target has changed
if (target != oldTarget) if (target != oldTarget)
{ {
// Call some method if target has changed
UiManager.Inst.RadarTargetInit(); UiManager.Inst.RadarTargetInit();
} }
} }
@ -343,26 +361,14 @@ namespace BlueWaterProject
{ {
if (!IsDredgeMode) return; 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; var isOn = false;
foreach (Vector3 dir in directions) foreach (Vector3 dir in directions)
{ {
RaycastHit hit; 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; isOn = true;
@ -376,6 +382,7 @@ namespace BlueWaterProject
IsIslandInteraction = true; IsIslandInteraction = true;
break; break;
} }
// 박스가 Ground 레이어에 닿지 않았을 때 녹색으로 표시 // 박스가 Ground 레이어에 닿지 않았을 때 녹색으로 표시
Debug.DrawRay(transform.position, dir * rayLength, Color.green); Debug.DrawRay(transform.position, dir * rayLength, Color.green);
IsIslandInteraction = false; IsIslandInteraction = false;
@ -384,6 +391,37 @@ namespace BlueWaterProject
UiManager.Inst.DefaultInteractionOnOff(isOn); UiManager.Inst.DefaultInteractionOnOff(isOn);
} }
#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 #endregion
} }
} }

View File

@ -83,7 +83,7 @@ namespace BlueWaterProject
Cursor.SetCursor(cursorTexture, hotSpot, CursorMode.Auto); Cursor.SetCursor(cursorTexture, hotSpot, CursorMode.Auto);
} }
private void AssaultCardInit() public void AssaultCardInit()
{ {
for (int i = 0; i < DataManager.Inst.CardList.Count; i++) for (int i = 0; i < DataManager.Inst.CardList.Count; i++)
{ {

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a55ee4efaad27d948ba5f03fc6d7bc80
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ed9b95dc6ed6d0647ad7f1a8f305385d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4ff1f29eab234cf4490d9bb383892c44
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f5789d13135b86645a366dac6583d1cd
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3643c0d76ec153646b1203880bfb64ed
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3d7c4217783978e4abe6496ac71eee94
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 697b6e7dea1fde146b7e3e5cf3ed9e9f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 078b8f13a17171b49892ad10426d5af0
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f9406a33814af9c47b352e77f079d798
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9aacf6f3043624194bb6f6fe9a580786
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f4227764308e84f89a765fbf315e2945
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 41e59f562b69648719f2424c438758f3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b044a2387a61dac41bdf204adffdce9d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: cd287c84e887ea24a8679e67aac7c074
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5f3f53ee059b45a4d9a5b9fc75e8aea9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f211254f5bfad224ba88868f2c75432c
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4368c9be31b3c174dbfd80f2caf98889
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 617b3f1032a08c14ebfedfa340767cdf
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f597f19f656ba56eae4f6a3a7cc528f4
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 48e08dc33330d11e9d4a1b246c52e4f6
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ed09910c0094cb27be8f3ca264680da3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: cc355dd4cf1e6173beaeb22c2858cbe1
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -28,7 +28,7 @@ TagManager:
- Enemy - Enemy
- Weapon - Weapon
- HitBox - HitBox
- - ShipPlayer
- -
- -
- Props - Props