Ejemplo n.º 1
0
        public override void Update(GameTime gameTime)
        {
            damageTimer -= gameTime.ElapsedGameTime.Milliseconds;

            if (StatsManager.GetShipLife() <= 0 &&
                GameStateManager.currentState == "OverworldState")
            {
                Game.stateManager.outroState.SetOutroType(OutroType.GameOver);
                Game.stateManager.ChangeState("OutroState");
            }

            foreach (Particle par in particles)
            {
                par.Update(gameTime, this);
            }

            if (IsUsed && !hyperspeedOn)
            {
                PlayerMovement(gameTime);
                base.Update(gameTime);
            }

            if (!IsControlsEnabled &&
                !Game.stateManager.overworldState.IsBurnOutEndingActivated)
            {
                AddParticle();
            }

            if (isInvincible)
            {
                UpdateInvincibility(gameTime);
            }

            #region UpdateHyperSpeed

            if (hyperspeedOn == true)
            {
                HyperSpeedMovement(gameTime);
                AddHyperSpeedParticle();
                base.Update(gameTime);
                angle = (float)(MathFunctions.RadiansFromDir(
                                    new Vector2(Direction.GetDirectionAsVector().X, Direction.GetDirectionAsVector().Y)) + (Math.PI * 90) / 180);

                if (currentHyperspeedDistance <= 20 || speed <= 0)
                {
                    hyperspeedOn = false;
                    CheckForMoreJumps();
                }
            }

            #endregion

            #region UpdateParticles

            for (int i = 0; i < particles.Count; i++)
            {
                if (particles[i].lifeSpawn <= 0)
                {
                    deadParticles.Add(particles[i]);
                }
            }

            RemoveParticle();

            #endregion
        }
Ejemplo n.º 2
0
        private void ButtonActions()
        {
            if (Game.menuBGController.DisplayButtons)
            {
                switch (buttons[buttonIndex].name.ToLower())
                {
                case "develop":
                    StatsManager.gameMode = GameMode.Develop;
                    MediaPlayer.Stop();
                    MainMenuState.LoadedOrNewGame = LoadedOrNewGame.New;
                    Game.shipInventoryManager.Initialize();
                    Game.stateManager.StartGame("OverworldState");
                    StatsManager.SetDevelopStats();
                    Game.player.UnlockDevelopHyperSpeed();
                    Game.GameStarted = true;

                    PlaySelectSound();
                    break;

                case "easy":
                    StatsManager.gameMode = GameMode.Easy;
                    MediaPlayer.Stop();
                    MainMenuState.LoadedOrNewGame = LoadedOrNewGame.New;
                    Game.shipInventoryManager.Initialize();
                    StatsManager.SetEasyStats();
                    Game.stateManager.StartGame("IntroFirstState");
                    Game.GameStarted = true;

                    PlaySelectSound();
                    break;

                case "normal":
                    StatsManager.gameMode = GameMode.Normal;
                    MediaPlayer.Stop();
                    MainMenuState.LoadedOrNewGame = LoadedOrNewGame.New;
                    KeyboardState current = Keyboard.GetState();
                    Game.shipInventoryManager.Initialize();
                    StatsManager.SetNormalStats();
                    Game.stateManager.StartGame("IntroFirstState");
                    Game.GameStarted = true;

                    PlaySelectSound();
                    break;

                case "hard":
                    StatsManager.gameMode = GameMode.Hard;
                    MediaPlayer.Stop();
                    MainMenuState.LoadedOrNewGame = LoadedOrNewGame.New;
                    Game.shipInventoryManager.Initialize();
                    StatsManager.SetHardStats();
                    Game.stateManager.StartGame("IntroFirstState");
                    Game.GameStarted = true;

                    PlaySelectSound();
                    break;

                case "hardcore":
                    StatsManager.gameMode = GameMode.Hardcore;
                    MediaPlayer.Stop();
                    MainMenuState.LoadedOrNewGame = LoadedOrNewGame.New;
                    Game.shipInventoryManager.Initialize();
                    StatsManager.SetHardcoreStats();
                    Game.stateManager.StartGame("IntroFirstState");
                    Game.GameStarted = true;

                    PlaySelectSound();
                    break;

                case "back":
                    Game.menuBGController.SetPreferredBackdropPosition(new Vector2(-101, -703), "MainMenuState");
                    buttonIndex = 0;

                    PlayLowPitchSelectSound();
                    break;
                }
            }
        }
        public override void Initialize()
        {
            base.Initialize();

            acceleration   = StatsManager.Acceleration();
            deAcceleration = StatsManager.Acceleration();

            maxSpeed = ShipInventoryManager.equippedPlating.Speed;

            playerShotHandler = new PlayerShotHandler(this, Game, spriteSheet);
            playerShotHandler.Initialize();

            Speed    = 0.0f;
            Position = new Vector2(Game1.ScreenSize.X / 2,
                                   Game1.ScreenSize.Y - Game.stateManager.shooterState.WindowHeightOffset - 75);
            IsKilled  = false;
            Direction = Vector2.Zero;

            HPmax = StatsManager.Armor();

            // If hardcore the life is fixed. Else, life is set to the ships armor.
            if (StatsManager.gameMode != GameMode.Hardcore)
            {
                HP = StatsManager.Armor();
            }
            else
            {
                HP = StatsManager.GetShipLife();
            }

            ShieldMax          = ShipInventoryManager.equippedShield.Capacity;
            Shield             = ShieldMax;
            conversionFactor   = ShipInventoryManager.equippedShield.ConversionFactor;
            shieldRegeneration = StatsManager.GetShieldRegeneration();

            MPmax       = ShipInventoryManager.equippedEnergyCell.Capacity;
            MP          = MPmax;
            MPtimer     = 0;
            MPgainedSec = StatsManager.GetEnergyRegeneration();

            ObjectClass       = "player";
            ObjectName        = "Player";
            TempInvincibility = 0;
            Damage            = 2000;
            DrawLayer         = 0.6f;

            lastTimeShotPrimary   = 10000;
            lastTimeShotSecondary = 10000;
            shootingDelay         = 300;

            //Animation
            anim.LoopTime = 1000;
            anim.AddFrame(spriteSheet.GetSubSprite(new Rectangle(216, 1, 23, 27)));

            shieldSprite = spriteSheet.GetSubSprite(new Rectangle(260, 100, 37, 37));

            BoundingSpace = 10;

            CenterPoint = new Vector2(anim.Width / 2, anim.Height / 2);
            angle       = (float)(Math.PI / 180) * 180;
        }
Ejemplo n.º 4
0
        protected override void Initialize()
        {
            CreateDirectories();
            SetAvailableResolutions();
            GameStarted = false;

            settingsFile = new SaveFile(this);
            settingsFile.Load(SaveFilePath, "settings.ini");

            Vector2 defaultResolution = GetDefaultResolution();

            resolution = new Vector2(settingsFile.GetPropertyAsFloat("visual", "resolutionx", defaultResolution.X),
                                     settingsFile.GetPropertyAsFloat("visual", "resolutiony", defaultResolution.Y));
            ScreenSize = new Point((int)resolution.X, (int)resolution.Y);

            random = new Random(DateTime.Now.Millisecond);

            showFPS = settingsFile.GetPropertyAsBool("visual", "showfps", false);

            graphics.PreferredBackBufferWidth  = (int)resolution.X;
            graphics.PreferredBackBufferHeight = (int)resolution.Y;
            if (IsDualMonitor())
            {
                graphics.IsFullScreen = false;
            }
            else
            {
                graphics.IsFullScreen = settingsFile.GetPropertyAsBool("visual", "fullscreen", true);
            }
            graphics.SynchronizeWithVerticalRetrace = true;

            // Uncomment to unlock FPS
            //IsFixedTimeStep = false;
            //graphics.SynchronizeWithVerticalRetrace = false;

            graphics.ApplyChanges();

            CenterScreenWindow();

            IsMouseVisible = settingsFile.GetPropertyAsBool("game options", "showmouse", true);

            menuBGController = new MenuBackdropController(this);
            menuBGController.Initialize();

            musicManager = new MusicManager(this);
            musicManager.Initialize();

            soundEffectsManager = new SoundEffectsManager(this);
            soundEffectsManager.Initialize();

            fontManager = new FontManager(this);
            fontManager.Initialize();

            ControlManager.LoadControls(settingsFile);

            spriteSheetOverworld       = new Sprite(Content.Load <Texture2D>("Overworld-Sprites/smallObjectSpriteSheet"));
            spriteSheetVerticalShooter = new Sprite(Content.Load <Texture2D>("Vertical-Sprites/shooterSheet"));
            messageBoxSpriteSheet      = new Sprite(Content.Load <Texture2D>("Overworld-Sprites/messageBoxSpriteSheet"));
            spriteSheetItemDisplay     = new Sprite(Content.Load <Texture2D>("itemVisualSheet"));
            beaconMenuSprite           = new Sprite(Content.Load <Texture2D>("Overworld-Sprites/BeaconMenu"));
            CollisionHandlingOverWorld.LoadLineTexture(this);

            shipInventoryManager = new ShipInventoryManager(this);
            shipInventoryManager.Initialize();

            statsManager = new StatsManager(this);
            statsManager.Initialize();

            player = new PlayerOverworld(this, spriteSheetOverworld);
            player.Initialize();

            beaconMenu = new BeaconMenu(this, beaconMenuSprite);
            beaconMenu.Initialize();

            stateManager = new GameStateManager(this);
            stateManager.Initialize();

            missionManager = new MissionManager(this);
            missionManager.Initialize();

            tutorialManager = new TutorialManager(this);
            tutorialManager.Initialize();
            tutorialManager.TutorialsUsed = settingsFile.GetPropertyAsBool("game options", "tutorials", true);

            shopManager = new ShopManager();

            saveFile = new SaveFile(this);

            Portrait.InitializePortraitSpriteSheet(this);
            popupHandler = new PopupHandler(this, messageBoxSpriteSheet);
            popupHandler.Initialize();

            helper = new HelperBox(this);

            ShopManager.SetShopUpdateTime(ShopManager.PRESET_SHOPTIME);

            base.Initialize();
        }