#7 근거리 무기(MeleeWeapon) 추가 #8 부대 제어 수정 필요(기획 변경) - Ai 버벅이던 현상 수정(Rigidbody interpolate 문제) - UnitController 상세화(인스펙터창) - 오펜스 관련 Ai 기본 설정 - Props 레이어 추가, House 태그 추가 - Physic 충돌 레이어 변경 - Ai 전체 프리팹 수정 - 테스트용 오펜스 ai 타겟 건물 추가 - Swordman 애니메이션 이벤트 누락 수정
103 lines
2.9 KiB
C#
103 lines
2.9 KiB
C#
using System.Collections.Generic;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace BlueWaterProject
|
|
{
|
|
public class IslandInfo : MonoBehaviour
|
|
{
|
|
#region Property and variable
|
|
|
|
[field: SerializeField] public string IslandName { get; private set; }
|
|
|
|
[field: SerializeField] public List<Transform> HouseList { get; private set; }
|
|
|
|
[field: SerializeField] public List<UnitController> UnitList { get; private set; }
|
|
|
|
[field: SerializeField] public List<Transform> EnemyList { get; private set; }
|
|
|
|
[field: SerializeField] public List<Transform> TargetAllList { get; private set; }
|
|
|
|
#endregion
|
|
|
|
#region Unity built-in Function
|
|
|
|
private void Awake()
|
|
{
|
|
InitIslandInfo();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Custom function
|
|
|
|
[GUIColor(0, 1, 0)]
|
|
[Button("섬 정보 추출")]
|
|
private void InitIslandInfo()
|
|
{
|
|
HouseList = new List<Transform>(5);
|
|
|
|
var houses = transform.Find("Houses");
|
|
foreach (Transform house in houses)
|
|
{
|
|
if (!house.CompareTag("House") || !house.gameObject.activeSelf) continue;
|
|
|
|
var houseInfo = house.GetComponent<HouseInfo>();
|
|
houseInfo.IslandInfo = this;
|
|
HouseList.Add(houseInfo.transform);
|
|
}
|
|
|
|
UnitList = new List<UnitController>(20);
|
|
|
|
var units = transform.Find("Units");
|
|
foreach (Transform unit in units)
|
|
{
|
|
if (!unit.CompareTag("Unit") || !unit.gameObject.activeSelf) continue;
|
|
|
|
UnitList.Add(unit.GetComponent<UnitController>());
|
|
}
|
|
|
|
EnemyList = new List<Transform>(UnitList.Capacity * 16);
|
|
|
|
foreach (var unit in UnitList)
|
|
{
|
|
foreach (Transform enemy in unit.transform)
|
|
{
|
|
if (!unit.gameObject.activeSelf) continue;
|
|
|
|
var aiController = enemy.GetComponent<AiController>();
|
|
aiController.IslandInfo = this;
|
|
EnemyList.Add(aiController.transform);
|
|
}
|
|
}
|
|
|
|
TargetAllList = new List<Transform>(HouseList.Capacity + EnemyList.Capacity);
|
|
|
|
foreach (var enemy in EnemyList)
|
|
{
|
|
TargetAllList.Add(enemy);
|
|
}
|
|
|
|
foreach (var house in HouseList)
|
|
{
|
|
TargetAllList.Add(house);
|
|
}
|
|
}
|
|
|
|
public void RemoveListElement(List<Transform> list, Transform element)
|
|
{
|
|
if (list.Contains(element))
|
|
{
|
|
list.Remove(element);
|
|
}
|
|
|
|
if (TargetAllList.Contains(element))
|
|
{
|
|
TargetAllList.Remove(element);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |