private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Unit"))
        {
            Unit _targetUnit = collision.GetComponent <Unit>();
            switch (TargetTeam)
            {
            case EnumInfo.TargetTeam.SameTeam:
                if (entity.ownUnit._teamType == _targetUnit._teamType)
                {
                    _nextBehaviour.DoBehaviour(_targetUnit);
                }

                break;

            case EnumInfo.TargetTeam.OppositeTeam:
                if (entity.ownUnit._teamType != _targetUnit._teamType)
                {
                    _nextBehaviour.DoBehaviour(_targetUnit);
                }
                break;

            case EnumInfo.TargetTeam.Both:
                _nextBehaviour.DoBehaviour(_targetUnit);
                break;
            }
        }
    }
Exemple #2
0
    IEnumerator ProgressArriveAtUnit(Unit _tUnit)
    {
        while (true)
        {
            yield return(null);

            if (Vector2.SqrMagnitude(entity.tr.position - _tUnit._tr.position) <= 0.2)
            {
                _nextBehaviour.DoBehaviour(_tUnit);
                break;
            }
        }
    }
 public void CallEntity(Unit _tUnit)
 {
     behaviour.DoBehaviour(_tUnit);
 }