CombatAi 움직이는 애니메이션 속도 조절

타워 타겟 지정
This commit is contained in:
NTG_Lenovo 2023-09-20 15:43:24 +09:00
parent 4e7987ee0d
commit c19186e666
18 changed files with 1281149 additions and 1281082 deletions

File diff suppressed because it is too large Load Diff

View File

@ -177,6 +177,8 @@ namespace BlueWaterProject
if (defendingIslandInfo == null) return;
defendingIslandInfo.RemoveListElement(defendingIslandInfo.EnemyList, transform);
defendingIslandInfo.RemoveListElement(defendingIslandInfo.ExceptHouseList, transform);
defendingIslandInfo.RemoveListElement(defendingIslandInfo.TargetAllList, transform);
}
protected void SetAnimatorController(string controllerName) => combatAnimator.runtimeAnimatorController =

View File

@ -227,9 +227,9 @@ namespace BlueWaterProject
print("AiStat.OffenseType == NONE Error");
break;
case EOffenseType.NORMAL:
if (attackingIslandInfo.EnemyList.Count > 0)
if (attackingIslandInfo.ExceptHouseList.Count > 0)
{
FindNearestTargetInList(attackingIslandInfo.EnemyList);
FindNearestTargetInList(attackingIslandInfo.ExceptHouseList);
}
else if (attackingIslandInfo.HouseList.Count > 0)
{
@ -241,9 +241,9 @@ namespace BlueWaterProject
{
FindNearestTargetInList(attackingIslandInfo.HouseList);
}
else if (attackingIslandInfo.EnemyList.Count > 0)
else if (attackingIslandInfo.ExceptHouseList.Count > 0)
{
FindNearestTargetInList(attackingIslandInfo.EnemyList);
FindNearestTargetInList(attackingIslandInfo.ExceptHouseList);
}
break;
default:

View File

@ -302,9 +302,9 @@ namespace BlueWaterProject
print("AiStat.OffenseType == NONE Error");
break;
case EOffenseType.NORMAL:
if (attackingIslandInfo.EnemyList.Count > 0)
if (attackingIslandInfo.ExceptHouseList.Count > 0)
{
FindNearestTargetInList(attackingIslandInfo.EnemyList);
FindNearestTargetInList(attackingIslandInfo.ExceptHouseList);
}
else if (attackingIslandInfo.HouseList.Count > 0)
{
@ -316,9 +316,9 @@ namespace BlueWaterProject
{
FindNearestTargetInList(attackingIslandInfo.HouseList);
}
else if (attackingIslandInfo.EnemyList.Count > 0)
else if (attackingIslandInfo.ExceptHouseList.Count > 0)
{
FindNearestTargetInList(attackingIslandInfo.EnemyList);
FindNearestTargetInList(attackingIslandInfo.ExceptHouseList);
}
break;
default:

View File

@ -1,8 +1,20 @@
using UnityEngine;
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
public class TowerAi : BaseAi
{
#region Properties and variables
[SerializeField] protected IslandInfo defendingIslandInfo;
#endregion
#region Custom methods
public void SetDefendingIslandInfo(IslandInfo value) => defendingIslandInfo = value;
#endregion
}
}

View File

@ -1,5 +1,6 @@
using System;
using System.Collections;
using RayFire;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.AI;
@ -215,10 +216,21 @@ namespace BlueWaterProject
private void Die()
{
RemoveIslandInfo();
StopAllCoroutines();
Destroy(gameObject);
}
private void RemoveIslandInfo()
{
if (defendingIslandInfo == null) return;
defendingIslandInfo.RemoveListElement(defendingIslandInfo.TowerList, transform);
defendingIslandInfo.RemoveListElement(defendingIslandInfo.ExceptHouseList, transform);
defendingIslandInfo.RemoveListElement(defendingIslandInfo.TargetAllList, transform);
}
private void SetCurrentHp(float value) => currentHp = value;
private void SetTargetCollider(Collider value) => targetCollider = value;

View File

@ -55,6 +55,7 @@ namespace BlueWaterProject
if (islandInfo == null) return;
islandInfo.RemoveListElement(islandInfo.HouseList, transform);
islandInfo.RemoveListElement(islandInfo.TargetAllList, transform);
}
public float GetCurrentHp() => currentHp;

View File

@ -13,34 +13,18 @@ namespace BlueWaterProject
[field: SerializeField] public string IslandName { get; private set; }
[field: SerializeField] public List<Transform> HouseList { get; private set; }
[field: SerializeField] public List<Transform> TowerList { get; private set; }
[field: SerializeField] public List<EnemyUnit> UnitList { get; private set; }
[field: SerializeField] public List<Transform> EnemyList { get; private set; }
[field: SerializeField] public List<Transform> ExceptHouseList { get; private set; }
[field: SerializeField] public List<Transform> TargetAllList { get; private set; }
[field: SerializeField] public CinemachineFreeLook IslandCam { get; private set; }
public IslandInfo()
{
IslandName = null;
HouseList = null;
UnitList = null;
EnemyList = null;
TargetAllList = null;
IslandCam = null;
}
public IslandInfo(string islandName, List<Transform> houseList, List<EnemyUnit> unitList, List<Transform> enemyList, List<Transform> targetAllList, CinemachineFreeLook islandCam)
{
IslandName = islandName;
HouseList = houseList;
UnitList = unitList;
EnemyList = enemyList;
TargetAllList = targetAllList;
IslandCam = islandCam;
}
#endregion
@ -60,10 +44,8 @@ namespace BlueWaterProject
private void InitIslandInfo()
{
HouseList = new List<Transform>(5);
var houses = transform.Find("Houses");
if (houses)
if (houses && houses.gameObject.activeSelf)
{
foreach (Transform house in houses)
{
@ -75,11 +57,24 @@ namespace BlueWaterProject
}
}
UnitList = new List<EnemyUnit>(20);
var units = transform.Find("Units");
TowerList = new List<Transform>(20);
var towers = transform.Find("Towers");
if (towers && towers.gameObject.activeSelf)
{
foreach (Transform tower in towers)
{
if (!tower.CompareTag("Tower") || !tower.gameObject.activeSelf) continue;
if (units)
var towerAi = tower.GetComponent<TowerAi>();
towerAi.SetDefendingIslandInfo(this);
TowerList.Add(towerAi.transform);
}
}
UnitList = new List<EnemyUnit>(20);
EnemyList = new List<Transform>(UnitList.Capacity * 16);
var units = transform.Find("Units");
if (units && units.gameObject.activeSelf)
{
foreach (Transform unit in units)
{
@ -87,24 +82,32 @@ namespace BlueWaterProject
UnitList.Add(unit.GetComponent<EnemyUnit>());
}
}
EnemyList = new List<Transform>(UnitList.Capacity * 16);
foreach (var unit in UnitList)
{
foreach (Transform enemy in unit.transform)
foreach (var unit in UnitList)
{
if (!unit.gameObject.activeSelf) continue;
foreach (Transform enemy in unit.transform)
{
if (!enemy.gameObject.activeSelf) continue;
var combatAi = enemy.GetComponent<CombatAi>();
combatAi.SetDefendingIslandInfo(this);
EnemyList.Add(enemy);
var combatAi = enemy.GetComponent<CombatAi>();
combatAi.SetDefendingIslandInfo(this);
EnemyList.Add(enemy);
}
}
}
TargetAllList = new List<Transform>(HouseList.Capacity + EnemyList.Capacity);
ExceptHouseList = new List<Transform>(TowerList.Capacity + EnemyList.Capacity);
foreach (var enemy in EnemyList)
{
ExceptHouseList.Add(enemy);
}
foreach (var tower in TowerList)
{
ExceptHouseList.Add(tower);
}
TargetAllList = new List<Transform>(HouseList.Capacity + TowerList.Capacity + EnemyList.Capacity);
foreach (var enemy in EnemyList)
{
TargetAllList.Add(enemy);
@ -115,6 +118,11 @@ namespace BlueWaterProject
TargetAllList.Add(house);
}
foreach (var tower in TowerList)
{
TargetAllList.Add(tower);
}
IslandCam = transform.Find("IslandCam").GetComponent<CinemachineFreeLook>();
}
@ -129,20 +137,6 @@ namespace BlueWaterProject
{
TargetAllList.Remove(element);
}
//CleanupList(list);
//CleanupList(TargetAllList);
}
private void CleanupList(List<Transform> list)
{
for (var i = list.Count - 1; i >= 0; i--)
{
if (list[i] == null || list[i].gameObject == null)
{
list.RemoveAt(i);
}
}
}
#endregion

View File

@ -63,7 +63,7 @@ namespace BlueWaterProject
{
if (isOffense)
{
if (other.gameObject.CompareTag("House"))
if (other.gameObject.CompareTag("House") || other.gameObject.CompareTag("Tower"))
{
var iDamageable = other.GetComponentInParent<IDamageable>();

View File

@ -59,7 +59,7 @@ namespace BlueWaterProject
{
if (!isOffense) return;
if (other.gameObject.CompareTag("House"))
if (other.gameObject.CompareTag("House") || other.gameObject.CompareTag("Tower"))
{
var iDamageable = other.GetComponentInParent<IDamageable>();

View File

@ -8845,7 +8845,7 @@ GameObject:
m_Layer: 0
m_Name: BaseHuman
m_TagString: Untagged
m_Icon: {fileID: 0}
m_Icon: {fileID: -964228994112308473, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1

View File

@ -43,6 +43,7 @@ GameObject:
- component: {fileID: 8726458248037506361}
- component: {fileID: 8190100621632311398}
- component: {fileID: 3766443407819787020}
- component: {fileID: 1494480357464926368}
- component: {fileID: 9087576015726480415}
m_Layer: 16
m_Name: ArrowTower
@ -138,6 +139,22 @@ BoxCollider:
serializedVersion: 3
m_Size: {x: 2.930729, y: 3.065148, z: 3.854234}
m_Center: {x: 0.07538414, y: -0.21270323, z: 0.4423293}
--- !u!208 &1494480357464926368
NavMeshObstacle:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8848616787261608530}
m_Enabled: 1
serializedVersion: 3
m_Shape: 1
m_Extents: {x: 1.4653645, y: 1.532574, z: 1.927117}
m_MoveThreshold: 0.1
m_Carve: 1
m_CarveOnlyStationary: 1
m_Center: {x: 0.07538414, y: -0.21270323, z: 0.4423293}
m_TimeToStationary: 0.5
--- !u!114 &9087576015726480415
MonoBehaviour:
m_ObjectHideFlags: 0
@ -150,6 +167,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: bd421891d0204bc5a748862f0ac9c0f1, type: 3}
m_Name:
m_EditorClassIdentifier:
defendingIslandInfo: {fileID: 0}
isDrawGizmosInFieldOfView: 1
isPredictAttack: 0
aiType: 2

View File

@ -26,7 +26,7 @@ BlendTree:
m_Mirror: 0
- serializedVersion: 2
m_Motion: {fileID: 7400000, guid: 57f4b6d8e4aaa67469ac9e22f15acb33, type: 3}
m_Threshold: 1
m_Threshold: 6
m_Position: {x: 0, y: 0}
m_TimeScale: 1
m_CycleOffset: 0
@ -35,7 +35,7 @@ BlendTree:
m_BlendParameter: Speed
m_BlendParameterY: Blend
m_MinThreshold: 0
m_MaxThreshold: 1
m_MaxThreshold: 6
m_UseAutomaticThresholds: 0
m_NormalizedBlendValues: 0
m_BlendType: 0
@ -516,7 +516,7 @@ AnimatorState:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Blend Tree
m_Speed: 1
m_Speed: 1.2
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []

View File

@ -26,7 +26,7 @@ BlendTree:
m_Mirror: 0
- serializedVersion: 2
m_Motion: {fileID: 7400000, guid: 3e26d22a6afd2244a9c4ecaf6b9adf6e, type: 3}
m_Threshold: 1
m_Threshold: 6
m_Position: {x: 0, y: 0}
m_TimeScale: 1
m_CycleOffset: 0
@ -35,7 +35,7 @@ BlendTree:
m_BlendParameter: Speed
m_BlendParameterY: Blend
m_MinThreshold: 0
m_MaxThreshold: 1
m_MaxThreshold: 6
m_UseAutomaticThresholds: 0
m_NormalizedBlendValues: 0
m_BlendType: 0
@ -516,7 +516,7 @@ AnimatorState:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Blend Tree
m_Speed: 1
m_Speed: 1.2
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []

View File

@ -26,7 +26,7 @@ BlendTree:
m_Mirror: 0
- serializedVersion: 2
m_Motion: {fileID: 7400000, guid: b64e60e3fcbf21f4392f475291f62731, type: 3}
m_Threshold: 1
m_Threshold: 6
m_Position: {x: 0, y: 0}
m_TimeScale: 1
m_CycleOffset: 0
@ -35,7 +35,7 @@ BlendTree:
m_BlendParameter: Speed
m_BlendParameterY: Blend
m_MinThreshold: 0
m_MaxThreshold: 1
m_MaxThreshold: 6
m_UseAutomaticThresholds: 0
m_NormalizedBlendValues: 0
m_BlendType: 0
@ -359,43 +359,43 @@ AnimatorController:
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: AttackType
m_Type: 3
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: DeathType
m_Type: 3
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Attack
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: TakeDamage
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Death
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Shield
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base
@ -575,7 +575,7 @@ AnimatorState:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Blend Tree
m_Speed: 1
m_Speed: 1.2
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []

View File

@ -26,7 +26,7 @@ BlendTree:
m_Mirror: 0
- serializedVersion: 2
m_Motion: {fileID: 7400000, guid: 90db24b13a227fd46a43bb6cf2c5f729, type: 3}
m_Threshold: 1
m_Threshold: 6
m_Position: {x: 0, y: 0}
m_TimeScale: 1
m_CycleOffset: 0
@ -35,7 +35,7 @@ BlendTree:
m_BlendParameter: Speed
m_BlendParameterY: Blend
m_MinThreshold: 0
m_MaxThreshold: 1
m_MaxThreshold: 6
m_UseAutomaticThresholds: 0
m_NormalizedBlendValues: 0
m_BlendType: 0
@ -491,7 +491,7 @@ AnimatorState:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Blend Tree
m_Speed: 1
m_Speed: 1.2
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []

View File

@ -26,7 +26,7 @@ BlendTree:
m_Mirror: 0
- serializedVersion: 2
m_Motion: {fileID: 7400000, guid: 0db21fc102c66a444a2d99ddd0c4168b, type: 3}
m_Threshold: 1
m_Threshold: 6
m_Position: {x: 0, y: 0}
m_TimeScale: 1
m_CycleOffset: 0
@ -35,7 +35,7 @@ BlendTree:
m_BlendParameter: Speed
m_BlendParameterY: Blend
m_MinThreshold: 0
m_MaxThreshold: 1
m_MaxThreshold: 6
m_UseAutomaticThresholds: 0
m_NormalizedBlendValues: 0
m_BlendType: 0
@ -600,7 +600,7 @@ AnimatorState:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Blend Tree
m_Speed: 1
m_Speed: 1.2
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []

View File

@ -26,7 +26,7 @@ BlendTree:
m_Mirror: 0
- serializedVersion: 2
m_Motion: {fileID: 7400000, guid: 39c5a1e19d6559345aa3c57adb589874, type: 3}
m_Threshold: 1
m_Threshold: 6
m_Position: {x: 0, y: 0}
m_TimeScale: 1
m_CycleOffset: 0
@ -35,7 +35,7 @@ BlendTree:
m_BlendParameter: Speed
m_BlendParameterY: Blend
m_MinThreshold: 0
m_MaxThreshold: 1
m_MaxThreshold: 6
m_UseAutomaticThresholds: 0
m_NormalizedBlendValues: 0
m_BlendType: 0
@ -516,7 +516,7 @@ AnimatorState:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Blend Tree
m_Speed: 1
m_Speed: 1.2
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []