#30 Targeting and fire whit targetUI
This commit is contained in:
parent
c72b97cc61
commit
1a2f374fb5
@ -96912,12 +96912,30 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
power: 0
|
||||
reloadTime: 0
|
||||
reloadTime: 1
|
||||
radarTargetUI: {fileID: 0}
|
||||
projectilePrefab: {fileID: 0}
|
||||
launchPoint: {fileID: 0}
|
||||
timeOfFlight: 1
|
||||
predictedPos: {fileID: 0}
|
||||
predictedPos: {fileID: 1287417561}
|
||||
--- !u!1183024399 &619366763
|
||||
LookAtConstraint:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 619366757}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Weight: 1
|
||||
m_RotationAtRest: {x: 0, y: 0, z: 0}
|
||||
m_RotationOffset: {x: 0, y: 0, z: 0}
|
||||
m_Roll: 0
|
||||
m_WorldUpObject: {fileID: 0}
|
||||
m_UseUpObject: 0
|
||||
m_Active: 1
|
||||
m_IsLocked: 0
|
||||
m_Sources: []
|
||||
--- !u!1 &619911013
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -97525,22 +97543,22 @@ PrefabInstance:
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0.67404693
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0.21176523
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0.66609627
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0.23902294
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
@ -97571,6 +97589,10 @@ PrefabInstance:
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 622062901}
|
||||
- targetCorrespondingSourceObject: {fileID: 4836829392273355565, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 622062904}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 8c9e74631c8994b8cb728cde8efae49a, type: 3}
|
||||
--- !u!4 &622062898 stripped
|
||||
Transform:
|
||||
@ -97591,12 +97613,30 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
power: 0
|
||||
reloadTime: 0
|
||||
reloadTime: 1
|
||||
radarTargetUI: {fileID: 0}
|
||||
projectilePrefab: {fileID: 0}
|
||||
launchPoint: {fileID: 0}
|
||||
timeOfFlight: 1
|
||||
predictedPos: {fileID: 0}
|
||||
predictedPos: {fileID: 1287417561}
|
||||
--- !u!1183024399 &622062904
|
||||
LookAtConstraint:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 598889757}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Weight: 1
|
||||
m_RotationAtRest: {x: 0, y: 0, z: 0}
|
||||
m_RotationOffset: {x: 0, y: 0, z: 0}
|
||||
m_Roll: 0
|
||||
m_WorldUpObject: {fileID: 0}
|
||||
m_UseUpObject: 0
|
||||
m_Active: 1
|
||||
m_IsLocked: 0
|
||||
m_Sources: []
|
||||
--- !u!1 &622341546
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -98857,22 +98897,22 @@ PrefabInstance:
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0.67404693
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0.21176523
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0.66609627
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0.23902294
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
@ -98903,6 +98943,10 @@ PrefabInstance:
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1910056923}
|
||||
- targetCorrespondingSourceObject: {fileID: 4836829392273355565, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1910056926}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 8c9e74631c8994b8cb728cde8efae49a, type: 3}
|
||||
--- !u!4 &631284636 stripped
|
||||
Transform:
|
||||
@ -197552,22 +197596,22 @@ PrefabInstance:
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0.6661488
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0.23903932
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: -0.67399514
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: -0.21174636
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
@ -197598,6 +197642,10 @@ PrefabInstance:
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1647855425}
|
||||
- targetCorrespondingSourceObject: {fileID: 4836829392273355565, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1647855428}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 8c9e74631c8994b8cb728cde8efae49a, type: 3}
|
||||
--- !u!4 &1260016380 stripped
|
||||
Transform:
|
||||
@ -258972,12 +259020,30 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
power: 0
|
||||
reloadTime: 0
|
||||
reloadTime: 1
|
||||
radarTargetUI: {fileID: 0}
|
||||
projectilePrefab: {fileID: 0}
|
||||
launchPoint: {fileID: 0}
|
||||
timeOfFlight: 1
|
||||
predictedPos: {fileID: 0}
|
||||
predictedPos: {fileID: 1287417561}
|
||||
--- !u!1183024399 &1647855428
|
||||
LookAtConstraint:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1647855422}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Weight: 1
|
||||
m_RotationAtRest: {x: 0, y: 0, z: 0}
|
||||
m_RotationOffset: {x: 0, y: 0, z: 0}
|
||||
m_Roll: 0
|
||||
m_WorldUpObject: {fileID: 0}
|
||||
m_UseUpObject: 0
|
||||
m_Active: 1
|
||||
m_IsLocked: 0
|
||||
m_Sources: []
|
||||
--- !u!1 &1648071599
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -289190,7 +289256,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1871370245}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.6764068, y: -0, z: -0, w: 0.7365283}
|
||||
m_LocalRotation: {x: 0.67640686, y: -0.0000002980232, z: 0.0000002980232, w: 0.7365283}
|
||||
m_LocalPosition: {x: -0.0000002384187, y: 120, z: -10.000001}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
@ -294324,12 +294390,30 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
power: 0
|
||||
reloadTime: 0
|
||||
reloadTime: 1
|
||||
radarTargetUI: {fileID: 0}
|
||||
projectilePrefab: {fileID: 0}
|
||||
launchPoint: {fileID: 0}
|
||||
timeOfFlight: 1
|
||||
predictedPos: {fileID: 0}
|
||||
predictedPos: {fileID: 1287417561}
|
||||
--- !u!1183024399 &1910056926
|
||||
LookAtConstraint:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1910056920}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Weight: 1
|
||||
m_RotationAtRest: {x: 0, y: 0, z: 0}
|
||||
m_RotationOffset: {x: 0, y: 0, z: 0}
|
||||
m_Roll: 0
|
||||
m_WorldUpObject: {fileID: 0}
|
||||
m_UseUpObject: 0
|
||||
m_Active: 1
|
||||
m_IsLocked: 0
|
||||
m_Sources: []
|
||||
--- !u!1 &1911764924
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -323077,6 +323161,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_persistent: 0
|
||||
<RadarTargetUis>k__BackingField: []
|
||||
--- !u!1 &2105084994
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -328992,7 +329077,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 6b9354e94ca0743c98216572c03343d5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
<RotationSpeed>k__BackingField: -60
|
||||
<RotationSpeed>k__BackingField: -30
|
||||
--- !u!1001 &2685185313231177978
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -329019,22 +329104,22 @@ PrefabInstance:
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0.6661488
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0.23903932
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: -0.67399514
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: -0.21174636
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2155776711209515616, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
@ -329065,6 +329150,10 @@ PrefabInstance:
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 619366760}
|
||||
- targetCorrespondingSourceObject: {fileID: 4836829392273355565, guid: 8c9e74631c8994b8cb728cde8efae49a,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 619366763}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 8c9e74631c8994b8cb728cde8efae49a, type: 3}
|
||||
--- !u!1 &3000142793521421624
|
||||
GameObject:
|
||||
|
@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Blobcreate.ProjectileToolkit;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Animations;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace BlueWaterProject
|
||||
@ -8,8 +11,11 @@ namespace BlueWaterProject
|
||||
public class Canon : MonoBehaviour
|
||||
{
|
||||
public float power;
|
||||
public float reloadTime;
|
||||
public GameObject radarTargetUI;
|
||||
public float reloadTime = 1f;
|
||||
public RadarTargetUI radarTargetUI;
|
||||
private bool isReloading;
|
||||
|
||||
private LookAtConstraint canonLookAtConstraint;
|
||||
|
||||
public Rigidbody projectilePrefab;
|
||||
public Transform launchPoint;
|
||||
@ -20,6 +26,7 @@ namespace BlueWaterProject
|
||||
{
|
||||
projectilePrefab = DataManager.Inst.grenadeFire.GetComponent<Rigidbody>();
|
||||
launchPoint = transform.Find("FirePoint");
|
||||
canonLookAtConstraint = GetComponent<LookAtConstraint>();
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
@ -27,11 +34,39 @@ namespace BlueWaterProject
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!radarTargetUI.gameObject.activeInHierarchy && !isReloading)
|
||||
{
|
||||
StartCoroutine(ReloadCoroutine());
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator ReloadCoroutine()
|
||||
{
|
||||
isReloading = true;
|
||||
yield return new WaitForSeconds(reloadTime);
|
||||
radarTargetUI.Reactivate();
|
||||
isReloading = false;
|
||||
}
|
||||
|
||||
public void Fire()
|
||||
{
|
||||
var myRigid = Instantiate(projectilePrefab, launchPoint.position, launchPoint.rotation);
|
||||
var v = Projectile.VelocityByTime(myRigid.transform.position, predictedPos.position, timeOfFlight);
|
||||
myRigid.AddForce(v, ForceMode.VelocityChange);
|
||||
}
|
||||
|
||||
public void LookAtTarget()
|
||||
{
|
||||
canonLookAtConstraint.SetSources(new List<ConstraintSource>
|
||||
{
|
||||
new ConstraintSource
|
||||
{
|
||||
sourceTransform = predictedPos,
|
||||
weight = 1
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,8 @@ namespace BlueWaterProject
|
||||
public Collider[] radar = new Collider[10];
|
||||
public Transform[] inCameraRadar = new Transform[10];
|
||||
public Transform target;
|
||||
// 클래스 레벨 변수
|
||||
private List<Transform> visibleObjects;
|
||||
|
||||
[Title("캐논")]
|
||||
public Rigidbody projectilePrefab;
|
||||
@ -52,6 +54,8 @@ namespace BlueWaterProject
|
||||
{
|
||||
character = transform.Find("Character").gameObject;
|
||||
rb = GetComponent<Rigidbody>();
|
||||
GetComponentsInChildren(Canons);
|
||||
visibleObjects = new List<Transform>();
|
||||
}
|
||||
|
||||
#region Unity Function
|
||||
@ -61,24 +65,17 @@ namespace BlueWaterProject
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
CanonInit();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (IsInShipMode)
|
||||
{
|
||||
MoveCharacterPlayer();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveShipPlayer();
|
||||
RotatePlayer();
|
||||
}
|
||||
HandleMovement();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
FindInRadarRange();
|
||||
FilterInCameraObjects();
|
||||
FindTarget();
|
||||
LookAtTarget();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -111,6 +108,19 @@ namespace BlueWaterProject
|
||||
character.transform.position += movement;
|
||||
}
|
||||
|
||||
private void HandleMovement()
|
||||
{
|
||||
if (IsInShipMode)
|
||||
{
|
||||
MoveCharacterPlayer();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveShipPlayer();
|
||||
RotatePlayer();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AssaultMode/DreadgeMode Switch
|
||||
@ -142,7 +152,7 @@ namespace BlueWaterProject
|
||||
|
||||
#region Interaction Key
|
||||
|
||||
private void OnInteractionE(InputValue value)
|
||||
private void OnInteractionE(InputValue value) //E
|
||||
{
|
||||
UiManager.Inst.CheckRadarOverlap();
|
||||
}
|
||||
@ -181,7 +191,7 @@ namespace BlueWaterProject
|
||||
UiManager.Inst.AddCard();
|
||||
}
|
||||
|
||||
#region TakeAim & Fire
|
||||
#region TakeAim
|
||||
|
||||
private void OnTakeAim(InputValue value) // Space
|
||||
{
|
||||
@ -211,9 +221,48 @@ namespace BlueWaterProject
|
||||
|
||||
#endregion
|
||||
|
||||
private void CanonInit()
|
||||
#region CanonAndRader
|
||||
|
||||
private void FindInRadarRange()
|
||||
{
|
||||
GetComponentsInChildren(Canons);
|
||||
Physics.OverlapSphereNonAlloc(transform.position, GlobalValue.RADAR_RANGE, radar, LayerMask.GetMask(GlobalValue.ENEMY_LAYER));
|
||||
}
|
||||
|
||||
private void FilterInCameraObjects()
|
||||
{
|
||||
visibleObjects.Clear();
|
||||
foreach (var col in radar)
|
||||
{
|
||||
if (col == null) continue;
|
||||
var screenPoint = Camera.main.WorldToViewportPoint(col.transform.position);
|
||||
if (screenPoint.z > 0 && screenPoint.x >= 0 && screenPoint.x <= 1 && screenPoint.y >= 0 && screenPoint.y <= 1)
|
||||
{
|
||||
visibleObjects.Add(col.transform);
|
||||
}
|
||||
}
|
||||
visibleObjects.Sort((a, b) => Vector3.Distance(transform.position, a.position).CompareTo(Vector3.Distance(transform.position, b.position)));
|
||||
}
|
||||
|
||||
private void FindTarget()
|
||||
{
|
||||
foreach (var trans in visibleObjects)
|
||||
{
|
||||
if (trans.Find("TestTarget") == null) continue;
|
||||
target = trans.Find("TestTarget").transform;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void LookAtTarget()
|
||||
{
|
||||
if (target == null) return;
|
||||
foreach (var canon in Canons)
|
||||
{
|
||||
canon.predictedPos = target;
|
||||
canon.LookAtTarget();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -11,11 +11,9 @@ namespace BlueWaterProject
|
||||
public float RotationSpeed { get; set; }
|
||||
private float currentRotationZ = 0f;
|
||||
|
||||
private void Update()
|
||||
private void FixedUpdate()
|
||||
{
|
||||
currentRotationZ += RotationSpeed * Time.deltaTime;
|
||||
currentRotationZ = currentRotationZ % 360; // 360을 초과하지 않도록
|
||||
transform.eulerAngles = new Vector3(0, 0, currentRotationZ);
|
||||
transform.Rotate(0, 0, RotationSpeed * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@ -12,6 +13,7 @@ namespace BlueWaterProject
|
||||
private void OnEnable()
|
||||
{
|
||||
Image = GetComponent<Image>();
|
||||
transform.rotation = Quaternion.Euler(0, 0, RotationZ + Image.fillAmount * -180);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@ -29,5 +31,11 @@ namespace BlueWaterProject
|
||||
RotationZ = rotation;
|
||||
Image.fillAmount = fillAmount;
|
||||
}
|
||||
|
||||
public void Reactivate()
|
||||
{
|
||||
RadarTargetInit(Random.Range(0f, 360f), Random.Range(0.1f, 0.2f));
|
||||
transform.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace BlueWaterProject
|
||||
[Title("Radar")]
|
||||
private Transform radar;
|
||||
private Transform radarTargets;
|
||||
public List<RadarTargetUI> RadarTargetUis { get; } = new (GlobalValue.MAX_CANON_COUNT);
|
||||
[field: SerializeField] public List<RadarTargetUI> RadarTargetUis { get; private set; } = new (GlobalValue.MAX_CANON_COUNT);
|
||||
public RadarNeedle RadarNeedle { get; private set; }
|
||||
|
||||
|
||||
@ -49,10 +49,7 @@ namespace BlueWaterProject
|
||||
CursorTextureChange();
|
||||
AssaultCardInit();
|
||||
|
||||
for (var i = 0; i < GameManager.Inst.player.Canons.Count; i++)
|
||||
{
|
||||
RadarTargetInit();
|
||||
}
|
||||
RadarTargetInit();
|
||||
}
|
||||
|
||||
public void AddCard() //TODO Test button and function, delete later
|
||||
@ -87,10 +84,14 @@ namespace BlueWaterProject
|
||||
|
||||
public void RadarTargetInit()
|
||||
{
|
||||
var obj = Instantiate(DataManager.Inst.radarTargetUi, radarTargets);
|
||||
var radarTargetUi = obj.GetComponent<RadarTargetUI>();
|
||||
radarTargetUi.RadarTargetInit(Random.Range(0f, 360f), Random.Range(0.1f, 0.2f));
|
||||
RadarTargetUis.Add(radarTargetUi);
|
||||
for (var i = 0; i < GameManager.Inst.player.Canons.Count; i++)
|
||||
{
|
||||
var obj = Instantiate(DataManager.Inst.radarTargetUi, radarTargets);
|
||||
var radarTargetUi = obj.GetComponent<RadarTargetUI>();
|
||||
radarTargetUi.RadarTargetInit(Random.Range(0f, 360f), Random.Range(0.1f, 0.2f));
|
||||
RadarTargetUis.Add(radarTargetUi);
|
||||
GameManager.Inst.player.Canons[i].radarTargetUI = radarTargetUi;
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckRadarOverlap()
|
||||
@ -100,24 +101,21 @@ namespace BlueWaterProject
|
||||
for (var i = 0; i < RadarTargetUis.Count; i++)
|
||||
{
|
||||
var radarTargetUI = RadarTargetUis[i];
|
||||
var startAngle = radarTargetUI.RotationZ;
|
||||
var endAngle = radarTargetUI.RotationZ + radarTargetUI.Image.fillAmount * 360f;
|
||||
var canon = GameManager.Inst.player.Canons[i];
|
||||
var startAngle = radarTargetUI.RotationZ - radarTargetUI.Image.fillAmount * 180f;
|
||||
var endAngle = radarTargetUI.RotationZ + radarTargetUI.Image.fillAmount * 180f;
|
||||
|
||||
// 각도 비교 및 허용 오차 추가
|
||||
if (IsOverlap(needleRotationZ, startAngle, endAngle, GlobalValue.RADAR_OVERLAP_TOLERANCE)) // 5도의 오차 허용
|
||||
{
|
||||
radarTargetUI.gameObject.SetActive(false);
|
||||
}
|
||||
if (!IsOverlap(needleRotationZ, startAngle, endAngle, GlobalValue.RADAR_OVERLAP_TOLERANCE)) continue;
|
||||
if (!radarTargetUI.gameObject.activeSelf) continue;
|
||||
radarTargetUI.gameObject.SetActive(false);
|
||||
canon.Fire();
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsOverlap(float needleRotation, float startAngle, float endAngle, float tolerance = 0)
|
||||
{
|
||||
// 오프셋 보정 예시
|
||||
var correctedNeedleRotation = needleRotation + 36;
|
||||
|
||||
var correctedNeedleRotation = needleRotation;
|
||||
return correctedNeedleRotation >= (startAngle - tolerance) && correctedNeedleRotation <= (endAngle + tolerance);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ namespace BlueWaterProject
|
||||
|
||||
/// <summary> Radar 바늘이 레이더에 겹치는 허용 범위 </summary>
|
||||
public const float RADAR_OVERLAP_TOLERANCE = 5f;
|
||||
public const float RADAR_RANGE = 100f;
|
||||
public const string ENEMY_LAYER = "Enemy";
|
||||
|
||||
public enum UnitType
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 0.9263606, b: 0, a: 0.39215687}
|
||||
m_Color: {r: 1, g: 0.92549026, b: 0, a: 0.39215687}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
|
Loading…
Reference in New Issue
Block a user