예제 #1
0
    public Coroutine UnitTowerDamage(Tower target, int damageAmount)
    {
        (int laneIndex, int sideIndex) = GetPositionIdentifier(target);
        TowerUI targetUI = towerManagers[sideIndex].towerUIs[laneIndex];

        UnitUI[] attackers = new UnitUI[] {
            FindUnitUI(gameManager.Lanes[laneIndex].Units[1 - sideIndex, 0]),
            FindUnitUI(gameManager.Lanes[laneIndex].Units[1 - sideIndex, 1])
        }.Where(unitUI => unitUI != null).ToArray();

        List <Func <Coroutine> > callbacks = new List <Func <Coroutine> >();

        callbacks.Add(() => damageTextManager.DamageTextPopup(
                          targetUI.transform.position,
                          $"-{damageAmount}"
                          ));
        callbacks.AddRange(
            attackers.Select <UnitUI, Func <Coroutine> >(attacker => () => attacker.AttackMove(AttackDirection(1 - sideIndex)))
            );

        targetUI.RenderTower();
        return(StartCoroutine(ParallelCoroutine(callbacks.ToArray())));
    }