Esempio n. 1
0
        public override void Update(GameTime gameTime)
        {
            Map.CursorControl(Map.ListPlayer[Map.ActivePlayerIndex].InputManager);
            Map.UpdateCursorVisiblePosition(gameTime);
            //Loop through the players to find a Unit to control.
            for (int P = 0; P < Map.ListPlayer.Count; P++)
            {
                //Find if a current player Unit is under the cursor.
                int CursorSelect = Map.CheckForSquadAtPosition(P, Map.CursorPosition, Vector3.Zero);

                if (CursorSelect >= 0)
                {
                    if (BattlePreview == null)
                    {
                        BattlePreview = new BattlePreviewer(Map, P, CursorSelect, null);
                    }
                    BattlePreview.UpdateUnitDisplay();
                }
            }

            if (Map.ListPlayer[Map.ActivePlayerIndex].InputManager.InputConfirmPressed())
            {
                Squad TargetSquad = null;
                for (int P = Map.ListPlayer.Count - 1; P >= 0 && TargetSquad == null; --P)
                {
                    int SquadIndex = Map.CheckForSquadAtPosition(P, Map.CursorPosition, Vector3.Zero);
                    if (SquadIndex >= 0)
                    {
                        Context.SetContext(SkillSquad, SkillUnit, SkillPilot,
                                           Context.Map.ListPlayer[P].ListSquad[SquadIndex], Context.Map.ListPlayer[P].ListSquad[SquadIndex].CurrentLeader, Context.Map.ListPlayer[P].ListSquad[SquadIndex].CurrentLeader.Pilot, Context.Map.ActiveParser);

                        Context.EffectTargetUnit.UpdateSkillsLifetime(SkillEffect.LifetimeTypeOnAction);
                        if (ActiveSkill.CanActivateEffectsOnTarget(Context.EffectTargetCharacter.Effects))
                        {
                            TargetSquad = Map.ListPlayer[P].ListSquad[SquadIndex];
                        }
                    }
                }

                if (TargetSquad == null)
                {
                    return;
                }

                Context.SetContext(Context.EffectOwnerSquad, Context.EffectOwnerUnit, Context.EffectOwnerCharacter,
                                   TargetSquad, TargetSquad.CurrentLeader, TargetSquad.CurrentLeader.Pilot, Context.Map.ActiveParser);

                Owner.AddAndExecuteEffect(ActiveSkill, Context.EffectTargetCharacter.Effects);
                Context.EffectTargetUnit.UpdateSkillsLifetime(SkillEffect.LifetimeTypeOnAction);
                SkillPilot.SP -= ActiveSkill.SPCost;

                Map.CursorPosition        = SkillSquad.Position;
                Map.CursorPositionVisible = Map.CursorPosition;

                BattlePreview = null;

                if (SkillPilot.SP < ActiveSkill.SPCost)
                {
                    Map.Update(gameTime);//Remove the drawable points if needed
                    Map.RemoveScreen(this);
                }
            }
            else if (Map.ListPlayer[Map.ActivePlayerIndex].InputManager.InputCancelPressed())
            {
                Map.CursorPosition        = SkillSquad.Position;
                Map.CursorPositionVisible = Map.CursorPosition;
                Map.Update(gameTime);//Remove the drawable points if needed
                Map.RemoveScreen(this);
            }
        }