Exemple #1
0
    private void OnSettleDebtDoneButtonPressed()
    {
        ButtonAudio.Play();
        Unit[] playerSelectedUnits = PlayerLeader.GetSelectedUnits().ToArray();
        foreach (Unit unit in playerSelectedUnits)
        {
            Vector2 offset = PlayerLeader.GetBodyGlobalPosition() - SelectedLeader.GetBodyGlobalPosition();
            unit.Position += SelectedLeader.GetBodyPosition() + offset - PlayerLeader.GetBodyPosition();
        }
        Unit[] enemyUnits = SelectedLeader.GetUnits().ToArray();
        PlayerLeader.RemoveSelectedUnits();
        List <Unit> totalSelectedUnits = new List <Unit>(playerSelectedUnits);
        int         credit             = 0;

        foreach (Unit playerUnit in playerSelectedUnits)
        {
            credit += playerUnit.Power;
        }
        SelectedLeader.Credit(credit);
        totalSelectedUnits.AddRange(enemyUnits);
        SelectedLeader.AddUnits(totalSelectedUnits);
        CurrentState = State.Selection;
        PlayerLeader.StopBorrowMode();
        IsFactionWillingToFight = SelectedLeader.GetDebt() <= 0;
    }