Exemplo n.º 1
0
            public override void Enter()
            {
                base.Enter();
                Game.Instance.GameState = GameState.Playing;
                Game.Instance.CameraController.Init();
                Game.Instance.SilverYield            = 0;
                Game.Instance.PreviousMaxSilverYield = Program.Instance.Profile.GetMaxSilverYield(Game.Instance.LoadMapFilename);
                var m = Campaign.Campaign1().GetMapByFilename(Game.Instance.LoadMapFilename);

                if (m != null)
                {
                    Game.Instance.HasPreviouslyCompletedMap = Program.Instance.Profile.IsCompleted(m.MapName);
                }

                Game.Instance.CurrentStageInfos     = new Client.Game.Interface.StageInfo[Game.Instance.Map.Settings.Stages];
                Game.Instance.BestStagesInfos       = new Client.Game.Interface.StageInfo[Game.Instance.Map.Settings.Stages];
                Game.Instance.stagesControl.NStages = Game.Instance.Map.Settings.Stages;
                for (int i = 0; i < Game.Instance.BestStagesInfos.Length; i++)
                {
                    Game.Instance.BestStagesInfos[i] = Program.Instance.Profile.GetBestStage(Game.Instance.LoadMapFilename, i + 1);
                    Game.Instance.stagesControl.SetBestStage(i + 1, Game.Instance.BestStagesInfos[i]);
                }
                if (Game.Instance.Map.Settings.Stages > 0)
                {
                    Game.Instance.stagesControl.SetActive(1, true);
                }

                Game.Instance.FeedbackInfo = new FeedbackCommon.GameInstance
                {
                    Profile   = Program.Instance.Profile.FeedbackInfo,
                    StartTime = DateTime.Now,
                };

                if (Game.Instance.Map.Settings.MapType != Client.Game.Map.MapType.Cinematic)
                {
                    Program.Instance.Interface.AddFader();
                    ssc = new Interface.StartScreenControl
                    {
                        AvailableMeleeWeapons  = Program.Instance.Profile.AvailableMeleeWeapons,
                        SelectedMeleeWeapon    = Program.Instance.Profile.LastMeleeWeapon,
                        AvailableRangedWeapons = Program.Instance.Profile.AvailableRangedWeapons,
                        SelectedRangedWeapon   = Program.Instance.Profile.LastBulletType,
                        MapSettings            = Game.Instance.Map.Settings,
                        Localization           = Game.Instance.Map.StringLocalizationStorage
                    };
                    Program.Instance.Interface.AddChild(ssc);
                    ssc.Closed += new EventHandler(ssc_Closed);
                }
                else
                {
                    Game.Instance.ChangeState(new RunningState());
                }

                if (Game.Instance.Map.Settings.MapType != Client.Game.Map.MapType.Cinematic)
                {
                    var sm = Program.Instance.SoundManager;

                    if (Game.Instance.musicChannel1 == null)
                    {
                        if (Game.Instance.Map.Settings.MusicTrack1 != Client.Sound.Stream.EmptyTrack)
                        {
                            if (Game.Instance.Map.Settings.MusicTrack2 != Client.Sound.Stream.EmptyTrack && Game.Instance.Map.Settings.MusicTrack1 != Game.Instance.Map.Settings.MusicTrack2)
                            {
                                Game.Instance.musicChannel1 = sm.GetSoundResourceGroup(sm.GetStream(Game.Instance.Map.Settings.MusicTrack1), sm.GetStream(Game.Instance.Map.Settings.MusicTrack2)).PlayLoopedWithIntervals(0.5f, 1.5f, 0.5f, new Sound.PlayArgs());
                            }
                            else
                            {
                                Game.Instance.musicChannel1 = sm.GetStream(Game.Instance.Map.Settings.MusicTrack1).Play(new Client.Sound.PlayArgs {
                                    Looping = true
                                });
                            }
                        }
                        else if (Game.Instance.Map.Settings.MusicTrack2 != Client.Sound.Stream.EmptyTrack)
                        {
                            Game.Instance.musicChannel1 = sm.GetStream(Game.Instance.Map.Settings.MusicTrack2).Play(new Client.Sound.PlayArgs {
                                Looping = true
                            });
                        }
                    }

                    if (Game.Instance.ambienceChannel1 == null && Game.Instance.Map.Settings.AmbienceTrack1 != Client.Sound.Stream.EmptyTrack)
                    {
                        Game.Instance.ambienceChannel1 = sm.GetStream(Game.Instance.Map.Settings.AmbienceTrack1).Play(new Sound.PlayArgs {
                            Looping = true
                        });
                    }

                    if (Game.Instance.ambienceChannel2 == null && Game.Instance.Map.Settings.AmbienceTrack2 != Client.Sound.Stream.EmptyTrack && Game.Instance.Map.Settings.AmbienceTrack1 != Game.Instance.Map.Settings.AmbienceTrack2)
                    {
                        Game.Instance.ambienceChannel2 = sm.GetStream(Game.Instance.Map.Settings.AmbienceTrack2).Play(new Sound.PlayArgs {
                            Looping = true
                        });
                    }
                }
                else
                {
                    //run some ambience for the cut scenes
                }

                if (Game.Instance.LoadingScreen != null)
                {
                    Game.Instance.LoadingScreen.Remove();
                    Game.Instance.LoadingScreen = null;
                }
            }
            public override void Enter()
            {
                base.Enter();
                Game.Instance.GameState = GameState.Playing;
                Game.Instance.CameraController.Init();
                Game.Instance.SilverYield = 0;
                Game.Instance.PreviousMaxSilverYield = Program.Instance.Profile.GetMaxSilverYield(Game.Instance.LoadMapFilename);
                var m = Campaign.Campaign1().GetMapByFilename(Game.Instance.LoadMapFilename);
                if(m != null)
                    Game.Instance.HasPreviouslyCompletedMap = Program.Instance.Profile.IsCompleted(m.MapName);

                Game.Instance.CurrentStageInfos = new Client.Game.Interface.StageInfo[Game.Instance.Map.Settings.Stages];
                Game.Instance.BestStagesInfos = new Client.Game.Interface.StageInfo[Game.Instance.Map.Settings.Stages];
                Game.Instance.stagesControl.NStages = Game.Instance.Map.Settings.Stages;
                for (int i = 0; i < Game.Instance.BestStagesInfos.Length; i++)
                {
                    Game.Instance.BestStagesInfos[i] = Program.Instance.Profile.GetBestStage(Game.Instance.LoadMapFilename, i + 1);
                    Game.Instance.stagesControl.SetBestStage(i + 1, Game.Instance.BestStagesInfos[i]);
                }
                if(Game.Instance.Map.Settings.Stages > 0)
                    Game.Instance.stagesControl.SetActive(1, true);

                Game.Instance.FeedbackInfo = new FeedbackCommon.GameInstance
                {
                    Profile = Program.Instance.Profile.FeedbackInfo,
                    StartTime = DateTime.Now,
                };

                if (Game.Instance.Map.Settings.MapType != Client.Game.Map.MapType.Cinematic)
                {
                    Program.Instance.Interface.AddFader();
                    ssc = new Interface.StartScreenControl
                    {
                        AvailableMeleeWeapons = Program.Instance.Profile.AvailableMeleeWeapons,
                        SelectedMeleeWeapon = Program.Instance.Profile.LastMeleeWeapon,
                        AvailableRangedWeapons = Program.Instance.Profile.AvailableRangedWeapons,
                        SelectedRangedWeapon = Program.Instance.Profile.LastBulletType,
                        MapSettings = Game.Instance.Map.Settings,
                        Localization = Game.Instance.Map.StringLocalizationStorage
                    };
                    Program.Instance.Interface.AddChild(ssc);
                    ssc.Closed += new EventHandler(ssc_Closed);
                }
                else
                {
                    Game.Instance.ChangeState(new RunningState());
                }

                if (Game.Instance.Map.Settings.MapType != Client.Game.Map.MapType.Cinematic)
                {
                    var sm = Program.Instance.SoundManager;

                    if (Game.Instance.musicChannel1 == null)
                    {
                        if (Game.Instance.Map.Settings.MusicTrack1 != Client.Sound.Stream.EmptyTrack)
                        {
                            if (Game.Instance.Map.Settings.MusicTrack2 != Client.Sound.Stream.EmptyTrack && Game.Instance.Map.Settings.MusicTrack1 != Game.Instance.Map.Settings.MusicTrack2)
                                Game.Instance.musicChannel1 = sm.GetSoundResourceGroup(sm.GetStream(Game.Instance.Map.Settings.MusicTrack1), sm.GetStream(Game.Instance.Map.Settings.MusicTrack2)).PlayLoopedWithIntervals(0.5f, 1.5f, 0.5f, new Sound.PlayArgs());
                            else
                                Game.Instance.musicChannel1 = sm.GetStream(Game.Instance.Map.Settings.MusicTrack1).Play(new Client.Sound.PlayArgs { Looping = true });
                        }
                        else if (Game.Instance.Map.Settings.MusicTrack2 != Client.Sound.Stream.EmptyTrack)
                        {
                            Game.Instance.musicChannel1 = sm.GetStream(Game.Instance.Map.Settings.MusicTrack2).Play(new Client.Sound.PlayArgs { Looping = true });
                        }
                    }

                    if (Game.Instance.ambienceChannel1 == null && Game.Instance.Map.Settings.AmbienceTrack1 != Client.Sound.Stream.EmptyTrack)
                        Game.Instance.ambienceChannel1 = sm.GetStream(Game.Instance.Map.Settings.AmbienceTrack1).Play(new Sound.PlayArgs { Looping = true });

                    if (Game.Instance.ambienceChannel2 == null && Game.Instance.Map.Settings.AmbienceTrack2 != Client.Sound.Stream.EmptyTrack && Game.Instance.Map.Settings.AmbienceTrack1 != Game.Instance.Map.Settings.AmbienceTrack2)
                        Game.Instance.ambienceChannel2 = sm.GetStream(Game.Instance.Map.Settings.AmbienceTrack2).Play(new Sound.PlayArgs { Looping = true });
                }
                else
                {
                    //run some ambience for the cut scenes
                }

                if (Game.Instance.LoadingScreen != null)
                {
                    Game.Instance.LoadingScreen.Remove();
                    Game.Instance.LoadingScreen = null;
                }
            }