public void UpdateUnitDisplay() { if (UnitDisplayCounter < TimeToDisplay) { ++UnitDisplayCounter; if (UnitDisplayCounter == TimeToDisplay) { UnitDisplayCounter = 0; int SquadIndex = -1; for (int P = 0; P < Map.ListPlayer.Count && SquadIndex == -1; P++) { SquadIndex = Map.CheckForSquadAtPosition(P, Map.CursorPosition, Vector3.Zero); if (SquadIndex >= 0) { if (P == Map.ActivePlayerIndex) { BoxColor = Color.Green; } else { BoxColor = Color.Red; } Squad DefendingSquad = Map.ListPlayer[P].ListSquad[SquadIndex]; Map.TargetPlayerIndex = P; Map.TargetSquadIndex = SquadIndex; if (ActiveAttack != null) { SupportSquadHolder ActiveSquadSupport = new SupportSquadHolder(); SupportSquadHolder TargetSquadSupport = new SupportSquadHolder(); ActiveSquadSupport.PrepareAttackSupport(Map, PlayerIndex, ActiveSquad, P, SquadIndex); TargetSquadSupport.PrepareDefenceSupport(Map, P, DefendingSquad); BattleResult = Map.CalculateFinalHP(ActiveSquad, ActiveSquadSupport.ActiveSquadSupport, Map.ActivePlayerIndex, FormationChoices.Focused, DefendingSquad, TargetSquadSupport.ActiveSquadSupport, P, SquadIndex, true, false); } else { BattleResult.ArrayResult = new BattleResult[DefendingSquad.UnitsAliveInSquad]; for (int U = 0; U < DefendingSquad.UnitsAliveInSquad; ++U) { BattleResult.ArrayResult[U] = new BattleResult(); BattleResult.ArrayResult[U].SetTarget(P, SquadIndex, U, DefendingSquad[U]); } } } } } } }
public override void OnSelect() { TargetSquad = Map.ListPlayer[Target.Item1].ListSquad[Target.Item2]; Map.TargetPlayerIndex = Target.Item1; AITimer = AITimerBase; PrepareToAttack(); ActiveSquadSupport = new SupportSquadHolder(); ActiveSquadSupport.PrepareAttackSupport(Map, ActivePlayerIndex, ActiveSquad, TargetSquad); TargetSquadSupport = new SupportSquadHolder(); TargetSquadSupport.PrepareDefenceSupport(Map, Target.Item1, TargetSquad); }
public override void DoRead(ByteReader BR) { ActivePlayerIndex = BR.ReadInt32(); ActiveSquadIndex = BR.ReadInt32(); Target = new Tuple <int, int>(BR.ReadInt32(), BR.ReadInt32()); ActiveSquad = Map.ListPlayer[ActivePlayerIndex].ListSquad[ActiveSquadIndex]; TargetSquad = Map.ListPlayer[Target.Item1].ListSquad[Target.Item2]; Map.TargetPlayerIndex = Target.Item1; ActiveSquadSupport = new SupportSquadHolder(); ActiveSquadSupport.PrepareAttackSupport(Map, ActivePlayerIndex, ActiveSquad, Target.Item1, Target.Item2); TargetSquadSupport = new SupportSquadHolder(); TargetSquadSupport.PrepareDefenceSupport(Map, Target.Item1, TargetSquad); }
public override void OnSelect() { //Attack Support ActiveSquadSupport.PrepareAttackSupport(Map, Map.ActivePlayerIndex, ActiveSquad, TargetSquad); }
public override void DoUpdate(GameTime gameTime) { Map.LayerManager.AddDrawablePoints(ListAttackTerrain, Color.FromNonPremultiplied(255, 0, 0, 190)); if (ActiveInputManager.InputConfirmPressed()) { int TargetSelect = 0; //Verify if the cursor is over one of the possible MV position. while ((Map.CursorPosition.X != ListAttackChoice[TargetSelect].X || Map.CursorPosition.Y != ListAttackChoice[TargetSelect].Y) && ++TargetSelect < ListAttackChoice.Count) { ; } //If nothing was found. if (TargetSelect >= ListAttackChoice.Count) { return; } Map.TargetSquadIndex = -1; for (int P = 0; P < Map.ListPlayer.Count; P++) { //Find if a Unit is under the cursor. TargetSelect = Map.CheckForSquadAtPosition(P, Map.CursorPosition, Vector3.Zero); //If one was found. if (TargetSelect >= 0) { if (Map.ListPlayer[ActivePlayerIndex].Team != Map.ListPlayer[P].Team)//If it's an ennemy. { ActiveSquad.CurrentLeader.CurrentAttack.UpdateAttack(ActiveSquad.CurrentLeader, ActiveSquad.Position, Map.CursorPosition, ActiveSquad.ArrayMapSize, Map.ListPlayer[P].ListSquad[TargetSelect].CurrentMovement, ActiveSquad.CanMove); if (!ActiveSquad.CurrentLeader.CurrentAttack.CanAttack) { Map.sndDeny.Play(); return; } Map.PrepareSquadsForBattle(ActivePlayerIndex, ActiveSquadIndex, P, TargetSelect); SupportSquadHolder ActiveSquadSupport = new SupportSquadHolder(); ActiveSquadSupport.PrepareAttackSupport(Map, ActivePlayerIndex, ActiveSquad, P, TargetSelect); SupportSquadHolder TargetSquadSupport = new SupportSquadHolder(); TargetSquadSupport.PrepareDefenceSupport(Map, P, Map.ListPlayer[P].ListSquad[TargetSelect]); Map.ComputeTargetPlayerDefence(ActivePlayerIndex, ActiveSquadIndex, ActiveSquadSupport, P, TargetSelect, TargetSquadSupport); break; } } } Map.sndConfirm.Play(); } else { bool CursorMoved = Map.UpdateMapNavigation(ActiveInputManager); if (CursorMoved) { BattlePreview = new BattlePreviewer(Map, ActivePlayerIndex, ActiveSquadIndex, ActiveSquad.CurrentLeader.CurrentAttack); } BattlePreview.UpdateUnitDisplay(); } }