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; }
private void OnLeaderSelected(Leader leader) { SelectedLeader = leader; CurrentState = State.Selection; IsFactionWillingToFight = leader.GetDebt() <= 0; // HashSet<int> enemyFactions = new HashSet<int>(); // enemyFactions.Add(SelectedLeader.FactionId); // foreach (Unit enemyUnit in SelectedLeader.GetUnits()) // { // enemyFactions.Add(enemyUnit.GetFactionId()); // } // IsFactionWillingToFight = true; // foreach (Unit playerUnit in PlayerLeader.GetUnits()) // { // if (enemyFactions.Contains(playerUnit.GetFactionId())) // { // IsFactionWillingToFight = false; // } // } }