NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Condition/Conditions/ConditionCombatOccupy.cs

27 lines
920 B
C#

using System;
using System.Collections.Generic;
using cfg;
using Framework;
using Framework.Condition;
using Gameplay.Character;
using Gameplay.Level;
using UnityEngine;
public class ConditionCombatOccupy : ICondition
{
public EventManager.EventName SignalName => EventManager.EventName.LevelCharacterArriveBlock;
public bool Check(List<float> args)
{
if (!LevelManager.Instance.IsInLevel)
throw new Exception("current level is null!");
var level = LevelManager.Instance.CurrentLevel;
var position = new Vector2Int((int)args[0], (int)args[1]);
var characterManager = level.CharacterManager;
var map = level.Map;
var character = characterManager.FindOne(character =>
character.transData.cellIndex == map.BlockPosition2TGSCellIndex(position)
&& character.troopId == ETroopsId.Self);
return character != null;
}
}