57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using Framework;
|
|
using Gameplay.Area;
|
|
using Gameplay.Character;
|
|
using Gameplay.Common;
|
|
using Gameplay.Unit;
|
|
using PhxhSDK;
|
|
using UnityEngine;
|
|
namespace Code.Scripts.Gameplay.Fight.Evacuate
|
|
{
|
|
public class EvacuatePoint
|
|
{
|
|
public readonly int cellIndex;
|
|
|
|
public GameObject viewObj;
|
|
|
|
private List<GameUnit> _inAreaUnits = new List<GameUnit>();
|
|
|
|
private int _evacuateCount;
|
|
public int evacuateCount
|
|
{
|
|
get
|
|
{
|
|
return _evacuateCount;
|
|
}
|
|
}
|
|
|
|
public EvacuatePoint(int cellIndex, int evacuateCount)
|
|
{
|
|
this.cellIndex = cellIndex;
|
|
_evacuateCount = evacuateCount;
|
|
}
|
|
|
|
public void Init(Transform parent)
|
|
{
|
|
_inAreaUnits.Clear();
|
|
_CreateView(parent);
|
|
}
|
|
|
|
private void _CreateView(Transform parent)
|
|
{
|
|
var isOnce = _evacuateCount == 1;
|
|
var prefabPath = isOnce ? PathDefine.Evacuate.EVACUATE_ONCE_POINT_PATH : PathDefine.Evacuate.EVACUATE_ALWAYS_POINT_PATH;
|
|
var sampleObj = AssetManager.Instance.GetPreLoadResult<GameObject>(prefabPath);
|
|
viewObj = Object.Instantiate(sampleObj, parent);
|
|
var worldPos = AreaManager.instance.GetWorldPosByIndex(cellIndex);
|
|
viewObj.transform.position = worldPos;
|
|
viewObj.name = "EvacuatePoint_" + cellIndex;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
Object.Destroy(viewObj);
|
|
}
|
|
}
|
|
}
|