Example #1
0
        public Main()
        {
            Options = new Options();

            Graphics = new GraphicsDeviceManager(this)
            {
                PreferredBackBufferWidth = (int) Preferences.BackBuffer.X,
                PreferredBackBufferHeight = (int) Preferences.BackBuffer.Y,
            };

            IsFixedTimeStep = true;
            TargetElapsedTime = new TimeSpan(0, 0, 0, 0, (int) Preferences.TargetElapsedTimeMs);
            Content.RootDirectory = "Content";
            Window.AllowUserResizing = false;

            if (Preferences.Target == Core.Utilities.Setting.Xbox360)
                Components.Add(new GamerServicesComponent(this));

            Instance = this;

            LevelsFactory = new LevelsFactory();
            MusicController = new XACTMusicController();
            NewsController = new NewsController();
            SaveGameController = new SaveGameController();
            CheatsController = new CheatsController();

            Boot = BootSequence.Initial;

            Activated += new EventHandler<EventArgs>(DoWindowsFocusGained);
            Deactivated += new EventHandler<EventArgs>(DoWindowsFocusLost);
        }
        public override bool FireEvent(Event E)
        {
            if (E.ID == "GetInventoryActions")
            {
                EventParameterGetInventoryActions IA = E.GetParameter("Actions") as EventParameterGetInventoryActions;
                if (ParentObject.pPhysics.Equipped != null)
                {
                    IA.AddAction("Activate", 'a', false, "&Wa&yctivate", "InvCommandActivate");
                }
                return(true);
            }
            if (E.ID == "InvCommandActivate")
            {
                if (ParentObject.pPhysics.Equipped == null)
                {
                    return(false);
                }

                BootSequence part = ParentObject.GetPart <BootSequence>();
                if (part != null && part.BootTimeLeft > 0)
                {
                    if (ParentObject.pPhysics.Equipped.IsPlayer())
                    {
                        Popup.Show(ParentObject.The + ParentObject.DisplayNameOnly + " " + ParentObject.Is + " unresponsive.", true);
                    }
                }
                else if (ParentObject.UseCharge(ChargeUse))
                {
                    ScanTarget();
                }
                else
                {
                    if (ParentObject.pPhysics.Equipped.IsPlayer())
                    {
                        Popup.Show("This cell does not contain enough charge to execute the scan.", true);
                    }
                }

                return(true);
            }

            return(base.FireEvent(E));
        }
Example #3
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            switch (Boot)
            {
                case BootSequence.Initial:
                    SaveGameController.LoadSharedSave();
                    Boot = BootSequence.LoadingSharedSaveGame;
                    break;

                case BootSequence.LoadingSharedSaveGame:
                    if (SaveGameController.IsSharedSaveGameLoaded)
                    {
                        Options.ShowHelpBar = SaveGameController.SharedSaveGame.ShowHelpBar;
                        Options.FullScreen = SaveGameController.SharedSaveGame.FullScreen;
                        Options.MusicVolume = SaveGameController.SharedSaveGame.MusicVolume;
                        Options.SfxVolume = SaveGameController.SharedSaveGame.SfxVolume;
                        Options.FullScreenChanged += new BooleanHandler(DoFullScreenChanged);
                        Options.ShowHelpBarChanged += new BooleanHandler(DoShowHelpBarChanged);
                        Options.VolumeMusicChanged += new Integer2Handler(DoVolumeMusicChanged);
                        Options.VolumeSfxChanged += new Integer2Handler(DoVolumeSfxChanged);
                        Options.FullScreenChanged += new BooleanHandler(SaveGameController.DoFullScreenChanged);
                        Options.ShowHelpBarChanged += new BooleanHandler(SaveGameController.DoShowHelpBarChanged);
                        Options.VolumeMusicChanged += new Integer2Handler(SaveGameController.DoVolumeMusicChanged);
                        Options.VolumeSfxChanged += new Integer2Handler(SaveGameController.DoVolumeSfxChanged);

                        Audio.Initialize(Options.MusicVolume / 10f, Options.SfxVolume / 10f);
                        XACTAudio.Initialize(Content.RootDirectory + @"\audio\Audio.xgs");

                        DoFullScreenChanged(Options.FullScreen);

                        Visuals.Initialize(Graphics, (int) Preferences.BackBuffer.X, (int) Preferences.BackBuffer.Y, Content);

                        Inputs.Initialize(new Vector2(Window.ClientBounds.Center.X, Window.ClientBounds.Center.Y));

                        //todo: pass the Player Class to Inputs so it can spawn players on the fly
                        Inputs.AddPlayer(new Player());
                        Inputs.AddPlayer(new Player());
                        Inputs.AddPlayer(new Player());
                        Inputs.AddPlayer(new Player());

                        Inputs.Ready();

                        CheatsController.Initialize();

                        Persistence.LoadPackage(@"loading");
                        Boot = BootSequence.LoadingMinimalPackage;
                    }
                    break;

                case BootSequence.LoadingMinimalPackage:
                    if (Persistence.IsPackageLoaded(@"loading"))
                    {
                        Visuals.TransitionAnimations = new List<ITransitionAnimation>()
                        {
                            new AnimationTransitionAsteroids(500, VisualPriorities.Foreground.Transition),
                            new AnimationTransitionAlienBattleship(500, VisualPriorities.Foreground.Transition),
                            new AnimationTransitionAlienMothership(750, VisualPriorities.Foreground.Transition)
                        };

                        Visuals.AddScene(new LoadingScene());

                        Boot = BootSequence.Running;
                    }
                    break;

                case BootSequence.Running:
                    if (!IsActive)
                        return;
                    
                    Visuals.Update(gameTime);
                    Inputs.Update(gameTime);
                    CheatsController.Update();

                    if (Persistence.IsPackageLoaded(@"principal"))
                    {
                        Audio.Update(gameTime);
                        XACTAudio.Update();
                    }

                    break;
            }

            Persistence.Update(gameTime);
        }