예제 #1
0
        public override void DoUpdate(GameTime gameTime)
        {
            for (int S = 0; S < ListMagicSpell.Count; ++S)
            {
                ListMagicSpell[S].AddSkillEffectsToTarget(string.Empty);
            }

            for (int P = 0; P < ListProjectile.Count; P++)
            {
                Projectile ActiveProjectile = ListProjectile[P];

                if (ActiveProjectile.IsAlive)
                {
                    ActiveProjectile.Update(gameTime);
                    foreach (Polygon ProjectileCollision in ActiveProjectile.ListCollisionPolygon)
                    {
                        //Out of bound
                        if (Polygon.PolygonCollisionSAT(SandboxCollisionBox, ProjectileCollision, Vector2.Zero).Distance < 0 ||
                            Polygon.PolygonCollisionSAT(EnemyCollisionBox, ProjectileCollision, Vector2.Zero).Distance >= 0)
                        {
                            ActiveProjectile.IsAlive = false;
                        }
                    }
                }
            }

            if (KeyboardHelper.KeyPressed(Microsoft.Xna.Framework.Input.Keys.Escape))
            {
                ListActionMenuChoice.Remove(this);
            }
        }
예제 #2
0
        public override void Update(GameTime gameTime)
        {
            for (int i = 0; i < ListLayer.Count; ++i)
            {
                ListLayer[i].Update(gameTime);
            }

            if (!IsInit)
            {
                Init();
            }
            else if (MovementAnimation.Count > 0)
            {
                MoveSquad();
            }
            else if (ListPlayer.Count > 0)
            {
                if (!ListActionMenuChoice.HasMainPanel)
                {
                    if (ListPlayer[ActivePlayerIndex].IsHuman)
                    {
                        ListActionMenuChoice.AddToPanelListAndSelect(new ActionPanelPlayerDefault(this, ActivePlayerIndex));
                    }
                    else
                    {
                    }
                }

                ListActionMenuChoice.Last().Update(gameTime);
            }

            UpdateCursorVisiblePosition(gameTime);
        }
예제 #3
0
        public override void Update(GameTime gameTime)
        {
            if (GameMode == 1)
            {
                OnlinePlayers.Update();
            }
            if (!IsFrozen)
            {
                if ((KeyboardHelper.KeyHold(Keys.LeftControl) || KeyboardHelper.KeyHold(Keys.RightControl)) && KeyboardHelper.KeyPressed(Keys.K))
                {
                    ListLayer[0].LayerGrid = new Map3D(this, GraphicsDevice);
                }
                if ((KeyboardHelper.KeyHold(Keys.LeftControl) || KeyboardHelper.KeyHold(Keys.RightControl)) && KeyboardHelper.KeyPressed(Keys.L))
                {
                    ListLayer[0].LayerGrid = new CubeMap3D(this, GraphicsDevice);
                }
                if ((KeyboardHelper.KeyHold(Keys.LeftControl) || KeyboardHelper.KeyHold(Keys.RightControl)) && KeyboardHelper.KeyPressed(Keys.O))
                {
                    ListLayer[0].LayerGrid = new SphericalMap3D(this, GraphicsDevice);
                }
                if ((KeyboardHelper.KeyHold(Keys.LeftControl) || KeyboardHelper.KeyHold(Keys.RightControl)) && KeyboardHelper.KeyPressed(Keys.U))
                {
                    ListLayer[0].LayerGrid = ListLayer[0].OriginalLayerGrid;
                }

                foreach (MapLayer ActiveMapLayer in ListLayer)
                {
                    ActiveMapLayer.Update(gameTime);
                }

                if (ListNextAnimationScreen.Count > 0)
                {
                    PushScreen(ListNextAnimationScreen[0]);
                    ListNextAnimationScreen.Remove(ListNextAnimationScreen[0]);
                }
                else
                {
                    if (!IsInit)
                    {
                        Init();
                    }
                    else if (MovementAnimation.Count > 0)
                    {
                        MoveSquad();
                    }
                    else if (GameMode == 0 || (GameMode == 1 && !ListPlayer[ActivePlayerIndex].IsOnline))
                    {
                        ListActionMenuChoice.Last().Update(gameTime);
                    }

                    UpdateCursorVisiblePosition(gameTime);
                }
            }
        }
예제 #4
0
        public override void Init()
        {
            base.Init();
            GameRule.Init();

            if (IsClient)
            {
                ListActionMenuChoice.Add(new ActionPanelPhaseChange(this));
            }

            OnNewTurn();
        }
예제 #5
0
 public override void DoUpdate(GameTime gameTime)
 {
     if (ListNextAnimationScreen.Count > 0)
     {
         Map.PushScreen(ListNextAnimationScreen[0]);
         ListNextAnimationScreen.Remove(ListNextAnimationScreen[0]);
     }
     else
     {
         ListActionMenuChoice.RemoveAllSubActionPanels();
     }
 }
예제 #6
0
        public override void Draw(CustomSpriteBatch g)
        {
            g.End();
            g.Begin(SpriteSortMode.Deferred, null);

            if (IsOnTop)
            {
                if (ListActionMenuChoice.HasMainPanel)
                {
                    ListActionMenuChoice.Last().Draw(g);
                }
            }
        }
예제 #7
0
        public override void Update(double ElapsedSeconds)
        {
            GameTime UpdateTime = new GameTime(TimeSpan.Zero, TimeSpan.FromSeconds(ElapsedSeconds));

            if (!IsInit)
            {
                if (ListGameScreen.Count == 0)
                {
                    Load();
                    Init();
                    TogglePreview(true);

                    if (ListGameScreen.Count == 0)
                    {
                        foreach (IOnlineConnection ActivePlayer in GameGroup.Room.ListOnlinePlayer)
                        {
                            ActivePlayer.Send(new ServerIsReadyScriptServer());
                        }
                    }
                    else
                    {
                        IsInit = false;
                    }
                }
                else
                {
                    ListGameScreen[0].Update(UpdateTime);
                    if (!ListGameScreen[0].Alive)
                    {
                        ListGameScreen.RemoveAt(0);
                    }

                    if (ListGameScreen.Count == 0)
                    {
                        foreach (IOnlineConnection ActivePlayer in GameGroup.Room.ListOnlinePlayer)
                        {
                            ActivePlayer.Send(new ServerIsReadyScriptServer());
                        }

                        IsInit = true;
                    }
                }
            }

            LayerManager.Update(UpdateTime);

            if (!ListPlayer[ActivePlayerIndex].IsPlayerControlled && ListActionMenuChoice.HasMainPanel)
            {
                ListActionMenuChoice.Last().Update(UpdateTime);
            }
        }
예제 #8
0
        public override void Draw(CustomSpriteBatch g)
        {
            g.End();
            g.Begin(SpriteSortMode.Deferred, null);
            MapGrid.Draw(g);
            int Y = Constants.Height - 30;
            DrawBox(g, new Vector2(0, Y), 400, 30, Color.White);
            DrawText(g, "Ressources", new Vector2(5, Y + 5), Color.White);
            DrawTextRightAligned(g, ListPlayer[ActivePlayerIndex].EnergyReserve.ToString(), new Vector2(150, Y + 5), Color.White);
            DrawText(g, "Unit", new Vector2(155, Y + 5), Color.White);
            DrawTextRightAligned(g, ListPlayer[ActivePlayerIndex].ListUnit.Count.ToString(), new Vector2(220, Y + 5), Color.White);
            DrawText(g, "Constructions", new Vector2(225, Y + 5), Color.White);
            DrawTextRightAligned(g, ListPlayer[ActivePlayerIndex].ListConstruction.Count.ToString(), new Vector2(360, Y + 5), Color.White);

            if (ListActionMenuChoice.HasMainPanel)
            {
                ListActionMenuChoice.Last().Draw(g);
            }
        }
예제 #9
0
        public override void Update(GameTime gameTime)
        {
            if (!IsInit)
            {
                Init();
            }
            else if (MovementAnimation.Count > 0)
            {
                MoveSquad();
            }
            else if (GameMode == 0)
            {
                if (!ListActionMenuChoice.HasMainPanel)
                {
                    if (ListPlayer[ActivePlayerIndex].IsHuman)
                    {
                        ListActionMenuChoice.Add(new ActionPanelPlayerHumanStep(this));
                    }
                    else
                    {
                    }
                }

                ListActionMenuChoice.Last().Update(gameTime);
            }

            UpdateCursorVisiblePosition(gameTime);

            for (int P = 0; P < ListPlayer.Count; P++)
            {
                for (int U = 0; U < ListPlayer[P].ListConstruction.Count; U++)
                {
                    ListPlayer[P].ListConstruction[U].SpriteMap.Update(gameTime);
                    if (ListPlayer[P].ListConstruction[U].SpriteMap.AnimationEnded)
                    {
                        ListPlayer[P].ListConstruction[U].SpriteMap.RestartAnimation();
                    }
                }
            }
        }
예제 #10
0
        /// <summary>
        /// Called every time a player has finished his actions.
        /// </summary>
        public void OnNewPhase()
        {
            ListActionMenuChoice.RemoveAllActionPanels();
            if (FMODSystem.sndActiveBGMName != sndBattleThemeName && !string.IsNullOrEmpty(sndBattleThemeName))
            {
                sndBattleTheme.Stop();
                sndBattleTheme.SetLoop(true);
                sndBattleTheme.PlayAsBGM();
                FMODSystem.sndActiveBGMName = sndBattleThemeName;
            }

            do
            {
                ActivePlayerIndex++;
                if (ActivePlayerIndex >= ListPlayer.Count)
                {
                    OnNewTurn();
                }
            }while (!ListPlayer[ActivePlayerIndex].IsAlive);

            for (int U = 0; U < ListPlayer[ActivePlayerIndex].ListUnit.Count; U++)
            {
                UnitConquest ActiveUnit = ListPlayer[ActivePlayerIndex].ListUnit[U];
                ActivateAutomaticSkills(null, ListPlayer[ActivePlayerIndex].ListUnit[U], "Player Phase Start Requirement");

                //Repair passive bonus.
                if (ActiveUnit.Boosts.RepairModifier)
                {
                    ActiveUnit.HealUnit((int)(ActiveUnit.MaxHP * 0.05));
                }

                //Resupply passive bonus.
                if (ActiveUnit.Boosts.ResupplyModifier)
                {
                    ActiveUnit.RefillEN((int)(ActiveUnit.MaxEN * 0.05));
                }
            }
        }
예제 #11
0
        public override void Draw(CustomSpriteBatch g)
        {
            g.End();
            g.Begin(SpriteSortMode.Deferred, null);
            if (ShowAllLayers)
            {
                for (int i = 0; i < ListLayer.Count; ++i)
                {
                    ListLayer[i].Draw(g);
                }
            }
            else
            {
                ListLayer[ActiveLayerIndex].Draw(g);
            }

            if (IsOnTop)
            {
                if (ListActionMenuChoice.HasMainPanel)
                {
                    ListActionMenuChoice.Last().Draw(g);
                }
            }
        }
예제 #12
0
        public void InitPlayerBattle(bool IsActiveSquadOnRight)
        {
            int   FinalActivePlayerIndex = ActivePlayerIndex;
            int   FinalActiveSquadIndex  = ActiveSquadIndex;
            Squad FinalActiveSquad       = ActiveSquad;
            SupportSquadHolder FinalActiveSquadSupport = ActiveSquadSupport;

            int   FinalTargetPlayerIndex = TargetPlayerIndex;
            int   FinalTargetSquadIndex  = TargetSquadIndex;
            Squad FinalTargetSquad       = TargetSquad;
            SupportSquadHolder FinalTargetSquadSupport = TargetSquadSupport;

            if (TargetSquad.CurrentLeader.Boosts.AttackFirstModifier && !ActiveSquad.CurrentLeader.Boosts.AttackFirstModifier)
            {
                FinalActivePlayerIndex  = TargetPlayerIndex;
                FinalActiveSquadIndex   = TargetSquadIndex;
                FinalActiveSquad        = TargetSquad;
                FinalActiveSquadSupport = TargetSquadSupport;

                FinalTargetPlayerIndex  = ActivePlayerIndex;
                FinalTargetSquadIndex   = ActiveSquadIndex;
                FinalTargetSquad        = ActiveSquad;
                FinalTargetSquadSupport = ActiveSquadSupport;
            }

            bool ShowAnimation = Constants.ShowAnimation && FinalActiveSquad.CurrentLeader.CurrentAttack.GetAttackAnimations(Map.ActiveParser).Start.AnimationName != null;

            ListNextAnimationScreen.Clear();
            Map.NonDemoScreen.ListNonDemoBattleFrame.Clear();

            if (Map.IsOfflineOrServer)
            {
                AttackingResult = Map.CalculateFinalHP(FinalActiveSquad, FinalActiveSquadSupport.ActiveSquadSupport, FinalActivePlayerIndex,
                                                       Map.BattleMenuOffenseFormationChoice, FinalTargetSquad, FinalTargetSquadSupport.ActiveSquadSupport,
                                                       FinalTargetPlayerIndex, FinalTargetSquadIndex, true, true);

                DefendingResult = new SquadBattleResult(new BattleResult[1] {
                    new BattleResult()
                });
            }
            else
            {
                Map.CalculateFinalHP(FinalActiveSquad, FinalActiveSquadSupport.ActiveSquadSupport, FinalActivePlayerIndex,
                                     Map.BattleMenuOffenseFormationChoice, FinalTargetSquad, FinalTargetSquadSupport.ActiveSquadSupport,
                                     FinalTargetPlayerIndex, FinalTargetSquadIndex, true, true);
            }

            AnimationScreen.AnimationUnitStats UnitStats = new AnimationScreen.AnimationUnitStats(FinalActiveSquad, FinalTargetSquad, IsActiveSquadOnRight);
            AnimationBackground TargetSquadBackground    = null;
            AnimationBackground TargetSquadForeground    = null;

            if (ShowAnimation)
            {
                AnimationScreen.BattleAnimationTypes BattleAnimationType = AnimationScreen.BattleAnimationTypes.LeftAttackRight;

                if (IsActiveSquadOnRight)
                {
                    BattleAnimationType = AnimationScreen.BattleAnimationTypes.RightAttackLeft;
                }

                ListNextAnimationScreen.AddRange(Map.GenerateNextAnimationScreens(FinalActiveSquad, FinalActiveSquadSupport, FinalTargetSquad, FinalTargetSquadSupport, UnitStats, BattleAnimationType,
                                                                                  AttackingResult, out TargetSquadBackground, null, out TargetSquadForeground, null));
            }

            if (AttackingResult.ArrayResult[0].Target.ComputeRemainingHPAfterDamage(AttackingResult.ArrayResult[0].AttackDamage) > 0)
            {
                //Counter.
                if (FinalTargetSquad.CurrentLeader.BattleDefenseChoice == Unit.BattleDefenseChoices.Attack)
                {
                    if (Map.IsOfflineOrServer)
                    {
                        DefendingResult = Map.CalculateFinalHP(FinalTargetSquad, null, FinalTargetPlayerIndex,
                                                               Map.BattleMenuDefenseFormationChoice, FinalActiveSquad, null,
                                                               FinalActivePlayerIndex, FinalActiveSquadIndex, true, true);
                    }
                    else
                    {
                        Map.CalculateFinalHP(FinalTargetSquad, null, FinalTargetPlayerIndex,
                                             Map.BattleMenuDefenseFormationChoice, FinalActiveSquad, null,
                                             FinalActivePlayerIndex, FinalActiveSquadIndex, true, true);
                    }

                    if (ShowAnimation)
                    {
                        AnimationScreen.BattleAnimationTypes BattleAnimationType = AnimationScreen.BattleAnimationTypes.LeftConteredByRight;

                        if (IsActiveSquadOnRight)
                        {
                            BattleAnimationType = AnimationScreen.BattleAnimationTypes.RightConteredByLeft;
                        }

                        ListNextAnimationScreen.AddRange(Map.GenerateNextAnimationScreens(FinalActiveSquad, FinalActiveSquadSupport, FinalTargetSquad, FinalTargetSquadSupport, UnitStats,
                                                                                          BattleAnimationType, DefendingResult, out _, TargetSquadBackground, out _, TargetSquadForeground));
                    }
                }
            }

            if (Map.IsClient)
            {
                if (ShowAnimation)
                {
                    Map.PushScreen(ListNextAnimationScreen[0]);
                    ListNextAnimationScreen.RemoveAt(0);
                    ListNextAnimationScreen.Add(new EndBattleAnimationScreen(Map, FinalActiveSquad, FinalActiveSquadSupport, FinalActivePlayerIndex,
                                                                             FinalTargetSquad, FinalTargetSquadSupport, FinalTargetPlayerIndex, AttackingResult, DefendingResult));
                }
                else
                {
                    Map.NonDemoScreen.InitNonDemo(FinalActiveSquad, FinalActiveSquadSupport, FinalActivePlayerIndex, AttackingResult, Map.BattleMenuOffenseFormationChoice,
                                                  FinalTargetSquad, FinalTargetSquadSupport, FinalTargetPlayerIndex, DefendingResult, Map.BattleMenuDefenseFormationChoice, IsActiveSquadOnRight);

                    Map.NonDemoScreen.Alive = true;
                    Map.ListGameScreen.Insert(0, Map.NonDemoScreen);
                }
            }

            //AttackingSquad Activations.
            for (int U = 0; U < FinalActiveSquad.UnitsAliveInSquad; U++)
            {
                FinalActiveSquad[U].UpdateSkillsLifetime(SkillEffect.LifetimeTypeBattle);
            }
            //DefendingSquad Activations.
            for (int U = 0; U < FinalTargetSquad.UnitsAliveInSquad; U++)
            {
                FinalTargetSquad[U].UpdateSkillsLifetime(SkillEffect.LifetimeTypeBattle);
            }

            Map.FinalizeMovement(FinalActiveSquad, (int)Map.GetTerrain(FinalActiveSquad).MovementCost);
            FinalActiveSquad.EndTurn();

            if (Map.IsClient)
            {
                bool HasAfterAttack = false;
                ActionPanelDeathmatch AfterAttack = new ActionPanelMainMenu(Map, FinalActivePlayerIndex, FinalActiveSquadIndex);

                if (FinalActiveSquad.CurrentLeader.Boosts.PostAttackModifier.Attack)
                {
                    HasAfterAttack = true;
                    AfterAttack.AddChoiceToCurrentPanel(new ActionPanelAttackPart1(Map, FinalActivePlayerIndex, FinalActiveSquadIndex, FinalActiveSquad.CanMove));
                }

                if (FinalActiveSquad.CurrentLeader.Boosts.PostAttackModifier.Move)
                {
                    HasAfterAttack     = true;
                    Map.CursorPosition = FinalActiveSquad.Position;
                    AfterAttack.AddChoiceToCurrentPanel(new ActionPanelMovePart1(Map, FinalActivePlayerIndex, FinalActiveSquadIndex, FinalActiveSquad.Position, Map.CameraPosition, true));
                }

                if (HasAfterAttack)
                {
                    AfterAttack.AddChoiceToCurrentPanel(new ActionPanelWait(Map, FinalActiveSquad));
                    ListActionMenuChoice.Add(AfterAttack);
                }
            }
        }
예제 #13
0
 public DeathmatchMap(string BattleMapPath)
     : this(BattleMapPath, 0, new List <Squad>())
 {
     base.Init();
     ListActionMenuChoice.Add(new ActionPanelPhaseChange(this));
 }
예제 #14
0
        public override BattleMap LoadTemporaryMap(BinaryReader BR)
        {
            PlayerRoster = new Roster();
            PlayerRoster.LoadRoster();

            Load();
            DataScreen.LoadProgression(BR, PlayerRoster, DicUnitType, DicRequirement, DicEffect, DicAutomaticSkillTarget, DicManualSkillTarget);

            //Initialise the ScreenSize based on the map loaded.
            ScreenSize = new Point(Constants.Width / TileSize.X, Constants.Height / TileSize.Y);

            IsInit           = true;
            RequireDrawFocus = false;

            TogglePreview(true);

            int DicMapVariablesCount = BR.ReadInt32();

            DicMapVariables = new Dictionary <string, double>(DicMapVariablesCount);
            for (int i = 0; i < DicMapVariablesCount; ++i)
            {
                DicMapVariables.Add(BR.ReadString(), BR.ReadDouble());
            }

            CursorPosition.X = BR.ReadSingle();
            CursorPosition.Y = BR.ReadSingle();

            CameraPosition.X = BR.ReadSingle();
            CameraPosition.Y = BR.ReadSingle();

            ActivePlayerIndex = BR.ReadInt32();
            GameTurn          = BR.ReadInt32();

            VictoryCondition = BR.ReadString();
            LossCondition    = BR.ReadString();
            SkillPoint       = BR.ReadString();

            ListBackground.Clear();
            int ListBackgroundCount = BR.ReadInt32();

            for (int B = 0; B < ListBackgroundCount; ++B)
            {
                ListBackground.Add(AnimationBackground.LoadAnimationBackground(BR.ReadString(), Content, GraphicsDevice));
            }

            ListForeground.Clear();
            int ListForegroundCount = BR.ReadInt32();

            for (int F = 0; F < ListForegroundCount; ++F)
            {
                ListForeground.Add(AnimationBackground.LoadAnimationBackground(BR.ReadString(), Content, GraphicsDevice));
            }

            sndBattleThemeName = BR.ReadString();
            if (!string.IsNullOrEmpty(sndBattleThemeName))
            {
                FMODSound NewBattleTheme = new FMODSound(FMODSystem, "Content/Maps/BGM/" + sndBattleThemeName + ".mp3");

                NewBattleTheme.SetLoop(true);
                sndBattleTheme = NewBattleTheme;
            }

            string ThemePath     = BR.ReadString();
            uint   ThemePosition = BR.ReadUInt32();

            if (!string.IsNullOrEmpty(ThemePath))
            {
                FMODSound NewTheme = new FMODSound(FMODSystem, "Content/Maps/BGM/" + ThemePath + ".mp3");
                NewTheme.SetLoop(true);
                NewTheme.PlayAsBGM();
                FMODSystem.sndActiveBGMName = ThemePath;
                NewTheme.SetPosition(ThemePosition);
            }

            Dictionary <uint, Squad> DicLoadedSquad = new Dictionary <uint, Squad>();

            int ListPlayerCount = BR.ReadInt32();

            ListPlayer = new List <Player>(ListPlayerCount);
            for (int P = 0; P < ListPlayerCount; ++P)
            {
                string ActivePlayerName       = BR.ReadString();
                string ActivePlayerType       = BR.ReadString();
                bool   ActivePlayerIsHuman    = BR.ReadBoolean();
                int    ActivePlayerTeam       = BR.ReadInt32();
                byte   ActivePlayerColorRed   = BR.ReadByte();
                byte   ActivePlayerColorGreen = BR.ReadByte();
                byte   ActivePlayerColorBlue  = BR.ReadByte();

                Player NewPlayer = new Player(ActivePlayerName, ActivePlayerType, ActivePlayerIsHuman, false, ActivePlayerTeam,
                                              Color.FromNonPremultiplied(ActivePlayerColorRed, ActivePlayerColorGreen, ActivePlayerColorBlue, 255));

                ListPlayer.Add(NewPlayer);

                int ActivePlayerListSquadCount = BR.ReadInt32();
                for (int S = 0; S < ActivePlayerListSquadCount; ++S)
                {
                    Squad  NewSquad;
                    UInt32 ActiveSquadID                 = BR.ReadUInt32();
                    bool   CanMove                       = BR.ReadBoolean();
                    int    ActionsRemaining              = BR.ReadInt32();
                    float  ActiveSquadPositionX          = BR.ReadSingle();
                    float  ActiveSquadPositionY          = BR.ReadSingle();
                    float  ActiveSquadPositionZ          = BR.ReadSingle();
                    string ActiveSquadSquadName          = BR.ReadString();
                    string ActiveSquadCurrentMovement    = BR.ReadString();
                    bool   ActiveSquadIsFlying           = BR.ReadBoolean();
                    bool   ActiveSquadIsUnderTerrain     = BR.ReadBoolean();
                    bool   ActiveSquadIsPlayerControlled = BR.ReadBoolean();
                    string ActiveSquadSquadAI            = BR.ReadString();

                    int ActiveSquadUnitsInSquad = BR.ReadInt32();
                    int CurrentLeaderIndex      = BR.ReadInt32();
                    int CurrentWingmanAIndex    = BR.ReadInt32();
                    int CurrentWingmanBIndex    = BR.ReadInt32();

                    Unit[] ArrayNewUnit = new Unit[ActiveSquadUnitsInSquad];
                    for (int U = 0; U < ActiveSquadUnitsInSquad; ++U)
                    {
                        string UnitTypeName = BR.ReadString();
                        string RelativePath = BR.ReadString();
                        string TeamEventID  = BR.ReadString();

                        if (string.IsNullOrEmpty(TeamEventID))
                        {
                            ArrayNewUnit[U] = DicUnitType[UnitTypeName].FromFile(RelativePath, Content, DicRequirement, DicEffect, DicAutomaticSkillTarget);
                        }
                        else
                        {
                            foreach (Unit ActiveUnit in PlayerRoster.TeamUnits.GetAll())
                            {
                                if (ActiveUnit.TeamEventID == TeamEventID)
                                {
                                    ArrayNewUnit[U] = ActiveUnit;
                                    break;
                                }
                            }
                        }

                        ArrayNewUnit[U].QuickLoad(BR, Content, DicRequirement, DicEffect, DicAutomaticSkillTarget, DicManualSkillTarget);
                    }

                    NewSquad = new Squad(ActiveSquadSquadName, ArrayNewUnit[0],
                                         ArrayNewUnit.Length >= 2 ? ArrayNewUnit[1] : null,
                                         ArrayNewUnit.Length >= 3 ? ArrayNewUnit[2] : null);

                    int ListAttackedTeamCount = BR.ReadInt32();
                    NewSquad.ListAttackedTeam = new List <int>(ListAttackedTeamCount);
                    for (int U = 0; U < ListAttackedTeamCount; ++U)
                    {
                        NewSquad.ListAttackedTeam.Add(BR.ReadInt32());
                    }

                    NewSquad.SetLeader(CurrentLeaderIndex);
                    NewSquad.SetWingmanA(CurrentWingmanAIndex);
                    NewSquad.SetWingmanB(CurrentWingmanBIndex);

                    if (!CanMove)
                    {
                        NewSquad.EndTurn();
                    }

                    NewSquad.ActionsRemaining = ActionsRemaining;
                    NewSquad.SquadName        = ActiveSquadSquadName;
                    NewSquad.ID = ActiveSquadID;

                    DicLoadedSquad.Add(ActiveSquadID, NewSquad);

                    if (NewSquad.CurrentLeader != null)
                    {
                        //Do not spawn squads as it will trigger effect that were already activated
                        if (Content != null)
                        {
                            NewSquad.Unit3D = new UnitMap3D(GraphicsDevice, Content.Load <Effect>("Shaders/Squad shader 3D"), NewSquad.CurrentLeader.SpriteMap, 1);
                        }

                        if (!string.IsNullOrEmpty(ActiveSquadSquadAI))
                        {
                            NewSquad.SquadAI = new DeathmatchScripAIContainer(new DeathmatchAIInfo(this, NewSquad));
                            NewSquad.SquadAI.Load(ActiveSquadSquadAI);
                        }

                        NewPlayer.IsAlive = true;

                        ActivateAutomaticSkills(NewSquad, string.Empty);
                    }

                    NewSquad.UpdateSquad();

                    //Load the Battle Themes.
                    for (int U = 0; U < NewSquad.UnitsInSquad; ++U)
                    {
                        for (int C = NewSquad.At(U).ArrayCharacterActive.Length - 1; C >= 0; --C)
                        {
                            if (!string.IsNullOrEmpty(NewSquad.At(U).ArrayCharacterActive[C].BattleThemeName))
                            {
                                if (!Character.DicBattleTheme.ContainsKey(NewSquad.At(U).ArrayCharacterActive[C].BattleThemeName))
                                {
                                    Character.DicBattleTheme.Add(NewSquad.At(U).ArrayCharacterActive[C].BattleThemeName, new FMODSound(FMODSystem, "Content/Maps/BGM/" + NewSquad.At(U).ArrayCharacterActive[C].BattleThemeName + ".mp3"));
                                }
                            }
                        }
                    }

                    NewSquad.CurrentMovement    = ActiveSquadCurrentMovement;
                    NewSquad.IsFlying           = ActiveSquadIsFlying;
                    NewSquad.IsUnderTerrain     = ActiveSquadIsUnderTerrain;
                    NewSquad.IsPlayerControlled = ActiveSquadIsPlayerControlled;
                    NewSquad.SetPosition(new Vector3(ActiveSquadPositionX, ActiveSquadPositionY, ActiveSquadPositionZ));
                    NewPlayer.ListSquad.Add(NewSquad);
                }
            }

            GlobalQuickLoadContext.SetContext(DicLoadedSquad);

            for (int P = 0; P < ListPlayer.Count; P++)
            {
                for (int S = 0; S < ListPlayer[P].ListSquad.Count; S++)
                {
                    if (!ListPlayer[P].ListSquad[S].IsDead)
                    {
                        for (int U = 0; U < ListPlayer[P].ListSquad[S].UnitsInSquad; ++U)
                        {
                            for (int C = 0; C < ListPlayer[P].ListSquad[S].At(U).ArrayCharacterActive.Length; C++)
                            {
                                Character ActiveCharacter = ListPlayer[P].ListSquad[S].At(U).ArrayCharacterActive[C];
                                ActiveCharacter.Effects.QuickLoad(BR, ActiveParser, DicRequirement, DicEffect, DicAutomaticSkillTarget);
                            }
                        }
                    }
                }
            }

            for (int P = 0; P < ListPlayer.Count; ++P)
            {
                for (int S = 0; S < ListPlayer[P].ListSquad.Count; ++S)
                {
                    ListPlayer[P].ListSquad[S].ReloadSkills(DicUnitType, DicRequirement, DicEffect, DicAutomaticSkillTarget, DicManualSkillTarget);
                }
            }

            int ListMapScriptCount = BR.ReadInt32();

            if (ListMapScript.Count != ListMapScriptCount)
            {
                throw new Exception("An error occured while loading the map.");
            }

            for (int S = 0; S < ListMapScript.Count; S++)
            {
                ListMapScript[S].Load(BR);
            }

            ListActionMenuChoice.Add(new ActionPanelPhaseChange(this));

            return(this);
        }
예제 #15
0
        public override void Init()
        {
            base.Init();
            ListActionMenuChoice.Add(new ActionPanelPhaseChange(this));

            if (GameMode == 0)
            {
                ListPlayer.Clear();

                Player NewPlayer = new Player("Player", "Human", true, false, 0, Color.Blue);
                ListPlayer.Add(NewPlayer);

                if (ListSpawnSquad.Count > 0)
                {
                    int SpawnSquadIndex = 0;
                    for (int S = 0; S < ListSingleplayerSpawns.Count; S++)
                    {
                        if (ListSingleplayerSpawns[S].Tag == "P")
                        {
                            for (int U = 0; U < ListSpawnSquad[SpawnSquadIndex].UnitsInSquad; ++U)
                            {
                                ListSpawnSquad[SpawnSquadIndex].At(U).ReinitializeMembers(DicUnitType[ListSpawnSquad[SpawnSquadIndex].At(U).UnitTypeName]);
                            }
                            ListSpawnSquad[SpawnSquadIndex].ReloadSkills(DicRequirement, DicEffect, ManualSkillTarget.DicManualSkillTarget);
                            SpawnSquad(0, ListSpawnSquad[SpawnSquadIndex], 0, ListSingleplayerSpawns[S].Position);
                            ++SpawnSquadIndex;
                        }
                    }
                }
            }
            else if (GameMode == 1)
            {
                for (int P = 0; P < ListPlayer.Count; P++)
                {
                    ListPlayer[P].Color = ArrayMultiplayerColor[P];

                    for (int S = 0; S < ListPlayer[P].ListSpawnPoint.Count; S++)
                    {
                        if (string.IsNullOrEmpty(ListPlayer[P].ListSpawnPoint[S].LeaderTypeName))
                        {
                            continue;
                        }

                        Unit      NewLeaderUnit  = Unit.FromType(ListPlayer[P].ListSpawnPoint[S].LeaderTypeName, ListPlayer[P].ListSpawnPoint[S].LeaderName, Content, DicUnitType, DicRequirement, DicEffect);
                        Character NewLeaderPilot = new Character(ListPlayer[P].ListSpawnPoint[S].LeaderPilot, Content, DicRequirement, DicEffect);
                        NewLeaderPilot.Level = 1;
                        NewLeaderUnit.ArrayCharacterActive = new Character[1] {
                            NewLeaderPilot
                        };

                        Unit NewWingmanAUnit = null;
                        Unit NewWingmanBUnit = null;

                        if (!string.IsNullOrEmpty(ListPlayer[P].ListSpawnPoint[S].WingmanAName))
                        {
                            NewWingmanAUnit = Unit.FromType(ListPlayer[P].ListSpawnPoint[S].WingmanATypeName, ListPlayer[P].ListSpawnPoint[S].WingmanAName, Content, DicUnitType, DicRequirement, DicEffect);
                            Character NewWingmanAPilot = new Character(ListPlayer[P].ListSpawnPoint[S].WingmanAPilot, Content, DicRequirement, DicEffect);
                            NewWingmanAPilot.Level = 1;
                            NewWingmanAUnit.ArrayCharacterActive = new Character[1] {
                                NewWingmanAPilot
                            };
                        }

                        if (!string.IsNullOrEmpty(ListPlayer[P].ListSpawnPoint[S].WingmanBName))
                        {
                            NewWingmanBUnit = Unit.FromType(ListPlayer[P].ListSpawnPoint[S].WingmanBTypeName, ListPlayer[P].ListSpawnPoint[S].WingmanBName, Content, DicUnitType, DicRequirement, DicEffect);
                            Character NewWingmanBPilot = new Character(ListPlayer[P].ListSpawnPoint[S].WingmanBPilot, Content, DicRequirement, DicEffect);
                            NewWingmanBPilot.Level = 1;
                            NewWingmanBUnit.ArrayCharacterActive = new Character[1] {
                                NewWingmanBPilot
                            };
                        }

                        Squad NewSquad = new Squad("", NewLeaderUnit, NewWingmanAUnit, NewWingmanBUnit);

                        if (!ListPlayer[P].IsHuman)
                        {
                            NewSquad.SquadAI = new DeathmatchScripAIContainer(new DeathmatchAIInfo(this, NewSquad));
                            NewSquad.SquadAI.Load("SRWE Enemy AI");
                        }
                        else
                        {
                            NewSquad.IsPlayerControlled = true;
                        }

                        SpawnSquad(P, NewSquad, 0, ListPlayer[P].ListSpawnPoint[S].Position);
                    }
                }
            }
        }
예제 #16
0
        public void InitPlayerBattle(Squad ActiveSquad, SupportSquadHolder ActiveSquadSupport, int AttackerPlayerIndex,
                                     Squad TargetSquad, SupportSquadHolder TargetSquadSupport, int DefenderPlayerIndex,
                                     bool IsActiveSquadOnRight)
        {
            if (TargetSquad.CurrentLeader.Boosts.AttackFirstModifier && !ActiveSquad.CurrentLeader.Boosts.AttackFirstModifier)
            {
                Squad ActiveSquadTemp = ActiveSquad;
                SupportSquadHolder ActiveSquadSupportTemp = ActiveSquadSupport;
                int AttackerPlayerIndexTemp = AttackerPlayerIndex;

                ActiveSquad         = TargetSquad;
                ActiveSquadSupport  = TargetSquadSupport;
                AttackerPlayerIndex = DefenderPlayerIndex;

                TargetSquad         = ActiveSquadTemp;
                TargetSquadSupport  = ActiveSquadSupportTemp;
                DefenderPlayerIndex = AttackerPlayerIndexTemp;
            }

            ActivePlayerIndex = AttackerPlayerIndex;
            ActiveSquadIndex  = ListPlayer[AttackerPlayerIndex].ListSquad.IndexOf(ActiveSquad);
            TargetPlayerIndex = DefenderPlayerIndex;
            TargetSquadIndex  = ListPlayer[TargetPlayerIndex].ListSquad.IndexOf(TargetSquad);

            bool ShowAnimation = Constants.ShowAnimation && ActiveSquad.CurrentLeader.CurrentAttack.Animations.Start.AnimationName != null;

            ListNextAnimationScreen.Clear();
            NonDemoScreen.ListNonDemoBattleFrame.Clear();
            ListActionMenuChoice.RemoveAllSubActionPanels();

            SquadBattleResult AttackingResult = CalculateFinalHP(ActiveSquad, ActiveSquadSupport.ActiveSquadSupport, ActivePlayerIndex,
                                                                 BattleMenuOffenseFormationChoice, TargetSquad, TargetSquadSupport.ActiveSquadSupport, TargetPlayerIndex, true, true);

            AnimationScreen.AnimationUnitStats UnitStats = new AnimationScreen.AnimationUnitStats(ActiveSquad, TargetSquad, IsActiveSquadOnRight);
            SquadBattleResult DefendingResult            = new SquadBattleResult(new BattleResult[1] {
                new BattleResult()
            });

            if (ShowAnimation)
            {
                if (IsActiveSquadOnRight)
                {
                    GenerateNextAnimationScreens(ActiveSquad, ActiveSquadSupport, TargetSquad, TargetSquadSupport, UnitStats, AnimationScreen.BattleAnimationTypes.RightAttackLeft, AttackingResult);
                }
                else
                {
                    GenerateNextAnimationScreens(ActiveSquad, ActiveSquadSupport, TargetSquad, TargetSquadSupport, UnitStats, AnimationScreen.BattleAnimationTypes.LeftAttackRight, AttackingResult);
                }
            }

            if (AttackingResult.ArrayResult[0].Target.ComputeRemainingHPAfterDamage(AttackingResult.ArrayResult[0].AttackDamage) > 0)
            {
                //Counter.
                if (TargetSquad.CurrentLeader.BattleDefenseChoice == Unit.BattleDefenseChoices.Attack)
                {
                    DefendingResult = CalculateFinalHP(TargetSquad, null, TargetPlayerIndex,
                                                       BattleMenuDefenseFormationChoice, ActiveSquad, null, ActivePlayerIndex, true, true);

                    if (ShowAnimation)
                    {
                        if (IsActiveSquadOnRight)
                        {
                            GenerateNextAnimationScreens(ActiveSquad, ActiveSquadSupport, TargetSquad, TargetSquadSupport, UnitStats, AnimationScreen.BattleAnimationTypes.RightConteredByLeft, DefendingResult);
                        }
                        else
                        {
                            GenerateNextAnimationScreens(ActiveSquad, ActiveSquadSupport, TargetSquad, TargetSquadSupport, UnitStats, AnimationScreen.BattleAnimationTypes.LeftConteredByRight, DefendingResult);
                        }
                    }
                }
            }

            if (ShowAnimation)
            {
                PushScreen(ListNextAnimationScreen[0]);
                ListNextAnimationScreen.RemoveAt(0);
                ListNextAnimationScreen.Add(new EndBattleAnimationScreen(this, ActiveSquad, ActiveSquadSupport, AttackerPlayerIndex,
                                                                         TargetSquad, TargetSquadSupport, DefenderPlayerIndex, AttackingResult, DefendingResult));
            }
            else
            {
                NonDemoScreen.InitNonDemo(ActiveSquad, ActiveSquadSupport, AttackerPlayerIndex, AttackingResult, BattleMenuOffenseFormationChoice,
                                          TargetSquad, TargetSquadSupport, DefenderPlayerIndex, DefendingResult, BattleMenuDefenseFormationChoice, IsActiveSquadOnRight);

                NonDemoScreen.Alive = true;
                ListGameScreen.Insert(0, NonDemoScreen);
            }

            //AttackingSquad Activations.
            for (int U = 0; U < ActiveSquad.UnitsAliveInSquad; U++)
            {
                ActiveSquad[U].UpdateSkillsLifetime(SkillEffect.LifetimeTypeBattle);
            }
            //DefendingSquad Activations.
            for (int U = 0; U < TargetSquad.UnitsAliveInSquad; U++)
            {
                TargetSquad[U].UpdateSkillsLifetime(SkillEffect.LifetimeTypeBattle);
            }

            FinalizeMovement(ActiveSquad, (int)GetTerrain(ActiveSquad).MovementCost);
            ActiveSquad.EndTurn();

            bool HasAfterAttack = false;
            ActionPanelDeathmatch AfterAttack = new ActionPanelMainMenu(this, ActiveSquad, AttackerPlayerIndex);

            if (ActiveSquad.CurrentLeader.Boosts.PostAttackModifier.Attack)
            {
                HasAfterAttack = true;
                AfterAttack.AddChoiceToCurrentPanel(new ActionPanelAttackPart1(ActiveSquad.CanMove, ActiveSquad, AttackerPlayerIndex, this));
            }

            if (ActiveSquad.CurrentLeader.Boosts.PostAttackModifier.Move)
            {
                HasAfterAttack = true;
                CursorPosition = ActiveSquad.Position;
                AfterAttack.AddChoiceToCurrentPanel(new ActionPanelMovePart1(this, ActiveSquad.Position, CameraPosition, ActiveSquad, AttackerPlayerIndex, true));
            }

            if (HasAfterAttack)
            {
                AfterAttack.AddChoiceToCurrentPanel(new ActionPanelWait(this, ActiveSquad));
                ListActionMenuChoice.Add(AfterAttack);
            }
        }
예제 #17
0
        public override void Draw(CustomSpriteBatch g)
        {
            if (!IsInit)
            {
                return;
            }

            //Handle screen shaking.
            if (IsShaking)
            {
                g.End();

                //Run during initialization
                ShakingRenderTraget = new RenderTarget2D(GraphicsDevice, Constants.Width, Constants.Height, false,
                                                         GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24);

                GraphicsDevice.SetRenderTarget(ShakingRenderTraget);

                g.Begin();
            }

            if (ShowAllLayers)
            {
                for (int i = 0; i < ListLayer.Count; ++i)
                {
                    ListLayer[i].Draw(g);
                }
            }
            else
            {
                ListLayer[ActiveLayerIndex].Draw(g);
            }

            if (IsOnTop)
            {
                if (ListActionMenuChoice.HasMainPanel)
                {
                    ListActionMenuChoice.Last().Draw(g);
                }
            }

            #region Handle screen shaking.

            if (IsShaking)
            {
                g.End();

                //Switches rendertarget back to backbuffer
                GraphicsDevice.SetRenderTarget(null);

                GraphicsDevice.Clear(Color.Black);

                g.Begin();

                // counter is a float initially set to zero
                ShakeCounter += 0.45f;
                Vector2 Translation = new Vector2(ShakeOffsetX + ShakeAngleVariation.X * (float)Math.Sin(ShakeCounter),
                                                  ShakeOffsetY + ShakeAngleVariation.Y * (float)Math.Sin(ShakeCounter));
                //Reached the peak of the sin function.
                if (ShakeCounter >= MathHelper.PiOver2)
                {
                    //Remember where and how the shake ended.
                    ShakeOffsetX = ShakeOffsetX + ShakeAngleVariation.X;
                    ShakeOffsetY = ShakeOffsetY + ShakeAngleVariation.Y;

                    //Calculate new shake angle.
                    ShakeAngle = (ShakeAngle + 150 + RandomHelper.Next(60)) % 360;
                    float Angle = MathHelper.ToRadians(ShakeAngle);
                    ShakeAngleVariation.X = (float)Math.Cos(Angle);
                    ShakeAngleVariation.Y = (float)Math.Sin(Angle);

                    float DestinationX = ShakeRadiusMax * ShakeAngleVariation.X;
                    float DestinationY = ShakeRadiusMax * ShakeAngleVariation.Y;

                    ShakeAngleVariation.X = DestinationX - ShakeOffsetX;
                    ShakeAngleVariation.Y = DestinationY - ShakeOffsetY;
                    ShakeCounter          = 0;

                    if (IsShakingEnded)
                    {
                        IsShaking = false;
                    }
                }

                g.Draw(ShakingRenderTraget, Translation, null, Color.White,
                       0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.9f);
            }

            #endregion

            #region Handle fade to black

            if (FadeIsActive)
            {
                g.Draw(sprPixel, new Rectangle(0, 0, Constants.Width, Constants.Height), Color.FromNonPremultiplied(0, 0, 0, (int)FadeAlpha));
            }

            #endregion
        }