Example #1
0
    private void OnBorrowDoneButtonPressed()
    {
        ButtonAudio.Play();
        Unit[] leaderSelectedUnits = SelectedLeader.GetSelectedUnits().ToArray();
        foreach (Unit unit in leaderSelectedUnits)
        {
            Vector2 offset = SelectedLeader.GetBodyGlobalPosition() - PlayerLeader.GetBodyGlobalPosition();
            unit.Position += PlayerLeader.GetBodyPosition() - SelectedLeader.GetBodyPosition() + offset;
        }
        Unit[] playerUnits = PlayerLeader.GetUnits().ToArray();
        SelectedLeader.RemoveSelectedUnits();
        List <Unit> totalSelectedUnits = new List <Unit>(leaderSelectedUnits);

        totalSelectedUnits.AddRange(playerUnits);
        PlayerLeader.AddUnits(totalSelectedUnits);
        CurrentState = State.Selection;
        SelectedLeader.StopBorrowMode();
        IsFactionWillingToFight = SelectedLeader.GetDebt() <= 0;
    }