NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/Flag/FlagInst.cs

67 lines
2.1 KiB
C#

using Framework;
using Gameplay.Area;
using Gameplay.Common;
using Gameplay.Effect;
using PhxhSDK;
using UnityEngine;
namespace Gameplay.Fight.Flag
{
public class FlagInst
{
public int cellIndex;
private Vector3 _worldPos;
private GameObject _displayObj;
private GameObject _groundPointObj;
public FlagInst(int cellIndex)
{
this.cellIndex = cellIndex;
_worldPos = AreaManager.instance.GetWorldPosByIndex(cellIndex);
_CreateObjs();
}
private void _CreateObjs()
{
{
// var sampleObj = AssetManager.Instance.GetPreLoadResult<GameObject>(PathDefine.HoldFlag.FLAG_ON_GROUND_PATH);
// _displayObj = Object.Instantiate(sampleObj);
// _displayObj.transform.position = _worldPos;
EventManager.Instance.Send(EventManager.EventName.INFIGHT_UI_ADD_GRID_OBJ,
new UIGridTypeData(cellIndex, UIGridTypeNode.GridType.Flag, this));
}
{
var sampleObj = AssetManager.Instance.GetPreLoadResult<GameObject>(PathDefine.HoldFlag.FLAG_GROUND_POINT_PATH);
_groundPointObj = Object.Instantiate(sampleObj);
_groundPointObj.transform.position = _worldPos;
}
}
private void _DestroyObjs()
{
// if (_displayObj != null)
// {
// Object.Destroy(_displayObj);
// _displayObj = null;
//
// }
EventManager.Instance.Send(EventManager.EventName.INFIGHT_UI_REMOVE_GRID_OBJ,
new UIGridTypeData(cellIndex, UIGridTypeNode.GridType.Flag, this));
if (_groundPointObj != null)
{
Object.Destroy(_groundPointObj);
_groundPointObj = null;
}
}
public void Dispose()
{
_DestroyObjs();
EffectManager.instance.PlayEffectById(CodeDefine.Fight.HoldFlag.EFFECT_ID_PICKUP, _worldPos);
}
}
}