private void OnRetreated(Leader leader) { KingdomAudio.Play(); BattleAudio.Stop(); FollowCam.MakeCurrent(); // BattleCam.ClearCurrent(); CurrentState = State.Kingdom; Unit[] playerUnits = Battle.GetPlayerUnits().ToArray(); foreach (Unit playerUnit in playerUnits) { playerUnit.CollisionMask = 4; playerUnit.CollisionLayer = 4; } Battle.RemovePlayerUnits(); Kingdom.AddPlayerUnits(new List <Unit>(playerUnits), true); Unit[] enemyUnits = Battle.GetEnemyUnits().ToArray(); foreach (Unit enemyUnit in enemyUnits) { enemyUnit.CollisionMask = 4; enemyUnit.CollisionLayer = 4; } Battle.RemoveEnemyUnits(); leader.AddUnits(new List <Unit>(enemyUnits)); Kingdom.RaiseDebt(); }
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; }
private void PopulateUnits(Leader leader, List <int> unitPowers) { List <Unit> followers = new List <Unit>(); Random random = new Random(); for (int unitIdx = 0; unitIdx < unitPowers.Count; unitIdx++) { Unit unitInstance = (Unit)UnitScene.Instance(); unitInstance.Power = unitPowers[unitIdx]; unitInstance.Position = new Vector2(unitIdx * 140 - unitPowers.Count * 140 / 2, random.Next(-140, -100)); unitInstance.SetFactionId(leader.FactionId); unitInstance.SetIsCPU(leader.IsCPU); followers.Add(unitInstance); } leader.AddUnits(followers); }
public void AddPlayerUnits(List <Unit> units, Boolean forcePosition = false) { PlayerLeader.AddUnits(units, forcePosition); }