Ejemplo n.º 1
0
    // e.g. R
    private void OnNorthPress()
    {
        var targetPlayer = actionPhase.GetTargetPlayer(PhaseHandler.RowPosition.Front);

        if (actionPhase.CanPlayerAttack(targetPlayer))
        {
            print("selected FrontRow");
            decisionPhase.PlayChangeTargetRowAnimation(actionPhase.CanPlayerAttack(targetPlayer));
            decisionPhase.ChangeTargetRow(PhaseHandler.RowPosition.Front);
        }
        else
        {
            print("wanted to select FrontRow, but the target is invalid");
        }
    }
Ejemplo n.º 2
0
    PhaseHandler.RowPosition GetRandomTargetRow(ActionPhase actionPhase = null)
    {
        print("selecting a random target row");
        if (actionPhase == null)
        {
            actionPhase = this;
        }

        Array values = Enum.GetValues(typeof(PhaseHandler.RowPosition));

        System.Random            random          = new System.Random();
        PhaseHandler.RowPosition randomTargetRow = (PhaseHandler.RowPosition)values.GetValue(random.Next(values.Length));

        var targetPlayer = actionPhase.GetTargetPlayer(randomTargetRow);

        print("validating whether the randomly chosen target is valid");
        if (actionPhase.CanPlayerAttack(targetPlayer))
        {
            print($"got valid random target row: {randomTargetRow} (player {targetPlayer.playerName})");
            return(randomTargetRow);
        }
        else
        {
            // this is ugly since it will only work for 2 rows but its okay for our usecase now
            print($"got invalid target row: {randomTargetRow}, therefore choosing the other one");
            return(randomTargetRow == PhaseHandler.RowPosition.Front ? PhaseHandler.RowPosition.Back : PhaseHandler.RowPosition.Front);
        }
    }