Exemple #1
0
    private PlayerCombatController NextPlayer(TargetChangeDirection change)
    {
        float currentY = lastSinglePlayerCombatTarget.transform.position.y;
        float ny       = currentY;
        PlayerCombatController nextPlayer = null;

        switch (change)
        {
        case TargetChangeDirection.Up:
            foreach (PlayerCombatController player in battleController.playerActors)
            {
                float ey = player.transform.position.y;
                if (ey > currentY && (ey > ny || ny == currentY))
                {
                    ny         = ey;
                    nextPlayer = player;
                }
            }
            if (nextPlayer == null)
            {
                nextPlayer = BottomPlayer();
            }
            return(nextPlayer);

        case TargetChangeDirection.Down:
            foreach (PlayerCombatController player in battleController.playerActors)
            {
                float ey = player.transform.position.y;
                if (ey < currentY && (ey < ny || ny == currentY))
                {
                    ny         = ey;
                    nextPlayer = player;
                }
            }
            if (nextPlayer == null)
            {
                nextPlayer = TopPlayer();
            }
            return(nextPlayer);

        default:
            throw new System.ArgumentException("Unhandled switch case [" + change.ToString() + "]");
        }
    }
Exemple #2
0
    private EnemyCombatController NextEnemy(TargetChangeDirection change)
    {
        float currentX = lastSingleEnemyCombatTarget.transform.position.x;
        float nx       = currentX;
        float currentY = lastSingleEnemyCombatTarget.transform.position.y;
        float ny       = currentY;
        EnemyCombatController nextEnemy = null;

        switch (change)
        {
        case TargetChangeDirection.Left:
            foreach (EnemyCombatController enemy in battleController.enemyActors)
            {
                float ex = enemy.transform.position.x;
                if (ex < currentX && (ex > nx || nx == currentX))
                {
                    nx        = ex;
                    nextEnemy = enemy;
                }
            }
            return(nextEnemy);

        case TargetChangeDirection.Right:
            foreach (EnemyCombatController enemy in battleController.enemyActors)
            {
                float ex = enemy.transform.position.x;
                if (ex > currentX && (ex > nx || nx == currentX))
                {
                    nx        = ex;
                    nextEnemy = enemy;
                }
            }
            return(nextEnemy);

        case TargetChangeDirection.Up:
            foreach (EnemyCombatController enemy in battleController.enemyActors)
            {
                float ey = enemy.transform.position.y;
                if (ey > currentY && (ey > ny || ny == currentY))
                {
                    ny        = ey;
                    nextEnemy = enemy;
                }
            }
            if (nextEnemy == null)
            {
                nextEnemy = BottomEnemy();
            }
            return(nextEnemy);

        case TargetChangeDirection.Down:
            foreach (EnemyCombatController enemy in battleController.enemyActors)
            {
                float ey = enemy.transform.position.y;
                if (ey < currentY && (ey < ny || ny == currentY))
                {
                    ny        = ey;
                    nextEnemy = enemy;
                }
            }
            if (nextEnemy == null)
            {
                nextEnemy = TopEnemy();
            }
            return(nextEnemy);

        default:
            throw new System.ArgumentException("Unhandled switch case [" + change.ToString() + "]");
        }
    }