94 lines
3.1 KiB
C#
94 lines
3.1 KiB
C#
using System.Collections.Generic;
|
|
using Framework;
|
|
using Gameplay.Area;
|
|
using Gameplay.Common;
|
|
using Gameplay.Unit;
|
|
using PhxhSDK;
|
|
using UnityEngine;
|
|
|
|
namespace Code.Scripts.Gameplay.Fight.Evacuate
|
|
{
|
|
public class EvacuatePoint
|
|
{
|
|
public readonly int cellIndex;
|
|
private Vector3 _worldPos;
|
|
|
|
private List<GameUnit> _inAreaUnits = new List<GameUnit>();
|
|
|
|
private int _evacuateCount;
|
|
public int evacuateCount
|
|
{
|
|
get
|
|
{
|
|
return _evacuateCount;
|
|
}
|
|
}
|
|
|
|
private GameObject _objIcon;
|
|
private GameObject _objGroundPoint;
|
|
private GameObject _objEffectLoop;
|
|
|
|
public EvacuatePoint(int cellIndex, int evacuateCount)
|
|
{
|
|
this.cellIndex = cellIndex;
|
|
_worldPos = AreaManager.instance.GetWorldPosByIndex(cellIndex);
|
|
_evacuateCount = evacuateCount;
|
|
}
|
|
|
|
public void Init(Transform parent)
|
|
{
|
|
_inAreaUnits.Clear();
|
|
_CreateObjs(parent);
|
|
}
|
|
|
|
private void _CreateObjs(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);
|
|
// _objIcon = Object.Instantiate(sampleObj, parent);
|
|
// _objIcon.transform.position = _worldPos;
|
|
EventManager.Instance.Send(EventManager.EventName.INFIGHT_UI_ADD_GRID_OBJ,
|
|
new UIGridTypeData(cellIndex, UIGridTypeNode.GridType.Retreat, this, isOnce));
|
|
}
|
|
{
|
|
var sampleObj = AssetManager.Instance.GetPreLoadResult<GameObject>(PathDefine.Evacuate.EVACUATE_GROUND_POINT_PATH);
|
|
_objGroundPoint = Object.Instantiate(sampleObj, parent);
|
|
_objGroundPoint.transform.position = _worldPos;
|
|
}
|
|
{
|
|
var sampleObj = AssetManager.Instance.GetPreLoadResult<GameObject>(PathDefine.Evacuate.EVACUATE_LOOP_EFFECT_PATH);
|
|
_objEffectLoop = Object.Instantiate(sampleObj, parent);
|
|
_objEffectLoop.transform.position = _worldPos;
|
|
}
|
|
}
|
|
|
|
private void _DestroyObjs()
|
|
{
|
|
// if (_objIcon != null)
|
|
// {
|
|
// Object.Destroy(_objIcon);
|
|
// _objIcon = null;
|
|
// }
|
|
EventManager.Instance.Send(EventManager.EventName.INFIGHT_UI_REMOVE_GRID_OBJ,
|
|
new UIGridTypeData(cellIndex, UIGridTypeNode.GridType.Retreat, this));
|
|
if (_objGroundPoint != null)
|
|
{
|
|
Object.Destroy(_objGroundPoint);
|
|
_objGroundPoint = null;
|
|
}
|
|
if (_objEffectLoop != null)
|
|
{
|
|
Object.Destroy(_objEffectLoop);
|
|
_objEffectLoop = null;
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_DestroyObjs();
|
|
}
|
|
}
|
|
}
|