예제 #1
0
        protected override void doUpdate(GameTime currentTime)
        {
            if (Game1.videoPlayer.State == MediaState.Stopped)
            {
                if (playedThrough == false)
                {
                    Game1.videoPlayer.IsLooped = false;
                    Game1.videoPlayer.Play(video);

                    playedThrough = true;
                }
                else
                {
                    isComplete = true;
                }
            }

            if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.PauseButton) && !confirmPressed)
            {
                confirmPressed = true;
            }
            else if (!InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.PauseButton) && confirmPressed)
            {
                Game1.videoPlayer.Stop();
                confirmPressed = false;

                isComplete = true;
            }
        }
예제 #2
0
        //public TitleScreen(Model model, float aspectRatio, Texture2D texture)
        public TitleScreen(titleScreens screen_state)
        {
            menu_list = new List <TitleMenuOptions>(3);
            menu_list.Add(new TitleMenuOptions("START"));
            menu_list.Add(new TitleMenuOptions("OPTIONS"));
            menu_list.Add(new TitleMenuOptions("QUIT"));

            menu_item_selected = 0;

            screen = screen_state;

            fade_state = FadeState.fadeIn;

            storageDevicePrompted = false;

            InputDevice2.UnlockAllControllers();
        }
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            offset = (float)Math.Sin(currentTime.TotalGameTime.TotalMilliseconds / 1000f) * 0.2f;

            Player.PlayerItems items = parent.CurrentItemTypes;

            if (exit == null)
            {
                foreach (Entity en in parentWorld.EntityList)
                {
                    if (en is BetaEndLevelFag)
                    {
                        exit = (BetaEndLevelFag)en;
                    }
                }
            }
            else
            {
                theta = (float)(Math.Atan2(parent.CenterPoint.Y - exit.CenterPoint.Y, parent.CenterPoint.X - exit.CenterPoint.X) - Math.PI) + offset;

                drawPos = parent.CenterPoint + new Vector2((float)(2 * GlobalGameConstants.TileSize.X * Math.Cos(theta)), (float)(2 * GlobalGameConstants.TileSize.Y * Math.Sin(theta)));
            }

            if (items.item1 == GlobalGameConstants.itemType.Compass && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))
            {
                parent.Velocity = Vector2.Zero;
                parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation("idle");
                drawPointer = true;
            }
            else if (items.item2 == GlobalGameConstants.itemType.Compass && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))
            {
                parent.Velocity = Vector2.Zero;
                parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation("idle");
                drawPointer = true;
            }
            else
            {
                drawPointer = false;
                parentWorld.RenderNodeMap = false;
                parent.State            = Player.playerState.Moving;
                parent.Disable_Movement = false;
            }

            drawPos2 = parent.CenterPoint - img2.FrameDimensions / 2;
        }
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            Player.PlayerItems items = parent.CurrentItemTypes;

            if (items.item1 == GlobalGameConstants.itemType.DungeonMap && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))
            {
                parent.Velocity           = Vector2.Zero;
                parentWorld.RenderNodeMap = true;
            }
            else if (items.item2 == GlobalGameConstants.itemType.DungeonMap && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))
            {
                parent.Velocity           = Vector2.Zero;
                parentWorld.RenderNodeMap = true;
            }
            else
            {
                parentWorld.RenderNodeMap = false;
                parent.State            = Player.playerState.Moving;
                parent.Disable_Movement = false;
            }
        }
        protected override void doUpdate(GameTime currentTime)
        {
            screenTimePassed += currentTime.ElapsedGameTime.Milliseconds;

            if (screenTimePassed < numberTickingDuration)
            {
                view_timePassed  = ((int)((screenTimePassed / numberTickingDuration) * LevelState.ElapsedLevelTime / 1000)).ToString();
                view_timeElapsed = ((int)((screenTimePassed / numberTickingDuration) * GameCampaign.ElapsedCampaignTime / 1000)).ToString();

                view_levelCoins = ((int)((screenTimePassed / numberTickingDuration) * LevelState.ElapsedCoinAmount)).ToString();
                view_totalCoins = ((int)((screenTimePassed / numberTickingDuration) * GameCampaign.Player_Coin_Amount)).ToString();
            }
            else
            {
                view_timePassed  = ((int)(LevelState.ElapsedLevelTime / 1000)).ToString();
                view_timeElapsed = ((int)(GameCampaign.ElapsedCampaignTime / 1000)).ToString();

                view_levelCoins = (LevelState.ElapsedCoinAmount).ToString();
                view_totalCoins = (GameCampaign.Player_Coin_Amount).ToString();
            }

            if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.Confirm) && !confirmPressed)
            {
                confirmPressed = true;
            }
            else if (!InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.Confirm) && confirmPressed)
            {
                confirmPressed = false;

                if (screenTimePassed < 600f)
                {
                    screenTimePassed += 600;
                }
                else
                {
                    isComplete = true;
                }
            }
        }
예제 #6
0
        protected override void doUpdate(GameTime currentTime)
        {
            stateTimer += currentTime.ElapsedGameTime.Milliseconds;

            if (stateTimer > 1500f)
            {
                if ((InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.Confirm) != InputDevice2.PlayerPad.NoPad) && !player1ConfirmPressed)
                {
                    player1ConfirmPressed = true;
                }
                else if (!(InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.Confirm) != InputDevice2.PlayerPad.NoPad) && player1ConfirmPressed)
                {
                    player1ConfirmPressed = false;

                    isComplete = true;
                }
            }

            CampaignLobbyState.lineOffset += (currentTime.ElapsedGameTime.Milliseconds * CampaignLobbyState.lineMoveSpeed);
            if (CampaignLobbyState.lineOffset > 16.0f)
            {
                CampaignLobbyState.lineOffset -= 16.0f;
            }
        }
예제 #7
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.

            InputDevice2.Initalize();

            HighScoresState.InitalizeHighScores();

            //replace this with a join screen later
#if XBOX
            InputDevice2.LockController(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerPad.GamePad1);
#elif WINDOWS
            InputDevice2.LockController(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerPad.Keyboard);
#endif

            spriteBatch = new SpriteBatch(GraphicsDevice);

            AnimationLib al = new AnimationLib(GraphicsDevice, spriteBatch);
            AnimationLib.cacheAtlasFiles();

            //some of these assets are critical to render anything to the screen, and thus are not stored in a seperate thread
            saveIcon             = Content.Load <Texture2D>("gfx/saveIcon");
            debugFont            = Content.Load <SpriteFont>("testFont");
            whitePixel           = Content.Load <Texture2D>("whitePixel");
            pleaseWaitDialog     = Content.Load <Texture2D>("pleaseWait");
            asteroidsSpriteSheet = Content.Load <Texture2D>("ppg_asteroids");

            for (int i = 0; i < starCount; i++)
            {
                stars[i]        = new Vector2(rand.Next() % 2000 - 1000, rand.Next() % 2000 - 1000);
                starRotation[i] = (float)(rand.NextDouble() % (Math.PI * 2));
            }

            new Thread(loadSpine2).Start();
            new Thread(loadContent2).Start();
        }
예제 #8
0
        /// <summary>
        /// Creates a new high scores screen state.
        /// </summary>
        /// <param name="inGame">If the player has died or completed the game, set this to true. If simply checking the scores from the menu, set this to false</param>
        public HighScoresState(bool inGame, bool gameComplete)
        {
            InitalizeHighScores();

            HighScoreValue newScore = new HighScoreValue(GameCampaign.PlayerName, GameCampaign.Player_Coin_Amount, GameCampaign.ElapsedCampaignTime, GameCampaign.PlayerLevelProgress, GameCampaign.PlayerFloorHeight);

            this.inGame       = inGame;
            this.gameComplete = gameComplete;

            try
            {
                SignedInGamer gamer = Gamer.SignedInGamers[InputDevice2.GetPlayerGamePadIndex(InputDevice2.PPG_Player.Player_1)];
                isSignedIn = (gamer != null);
            }
            catch (Exception)
            {
                isSignedIn = false;
            }

            if (inGame)
            {
                highScores.Add(newScore);

                // if there are 11 high scores now, remove the lowest score
                if (highScores.Count > 10)
                {
                    HighScoreValue    lowestScore = highScores[0];
                    CompareHighScores comparer    = new CompareHighScores();

                    for (int i = 1; i < highScores.Count; i++)
                    {
                        if (comparer.Compare(highScores[i], lowestScore) < 0)
                        {
                            lowestScore = highScores[i];
                        }
                    }

                    highScores.Remove(lowestScore);
                }

                highScores.Sort(new CompareHighScores());
                highScores.Reverse();

                for (int i = 0; i < highScores.Count; i++)
                {
                    if (highScores[i].playerName == newScore.playerName && highScores[i].secondsElapsed == newScore.secondsElapsed && highScores[i].floorDiedOn == newScore.floorDiedOn)
                    {
                        newlyAddedScoreIndex = i;
                    }
                }

                SaveGameModule.saveGame();
            }
            else
            {
                highScores.Sort(new CompareHighScores());
                highScores.Reverse();
            }

            stateTimer = 0;

            if (isSignedIn)
            {
                SaveGameModule.loadGame();
            }
        }
        protected override void doUpdate(GameTime currentTime)
        {
            button_pressed_timer += currentTime.ElapsedGameTime.Milliseconds;
            zoom += currentTime.ElapsedGameTime.Milliseconds;

            switch (zoom_state)
            {
            case popUpZoomState.zoomIn:
                if (zoom > zoom_duration)
                {
                    pop_up_menu = true;
                    zoom_state  = popUpZoomState.zoomStay;
                    zoom        = 0.0f;
                }
                break;

            case popUpZoomState.zoomStay:
                zoom = 0.0f;
                break;

            case popUpZoomState.zoomOut:
                if (zoom > zoom_duration)
                {
                    zoom_state    = popUpZoomState.zoomStay;
                    pop_up_menu   = false;
                    pop_up_screen = false;
                    zoom          = 0.0f;
                }
                break;
            }

            if (!pop_up_menu)
            {
                if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.DownDirection))
                {
                    if (!down_pressed)
                    {
                        button_pressed_timer = 0.0f;
                    }
                    down_pressed = true;
                }

                if ((down_pressed && !InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.DownDirection)) || (down_pressed && InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.DownDirection) && button_pressed_timer > max_button_pressed_timer))
                {
                    button_pressed_timer = 0.0f;
                    down_pressed         = false;
                    AudioLib.playSoundEffect(menuBlipSound);
                    menu_item_select++;

                    if (menu_item_select >= options_list.Count())
                    {
                        menu_item_select = menu_item_select % options_list.Count();
                    }
                    else if (menu_item_select < 0)
                    {
                        menu_item_select += options_list.Count();
                    }
                }

                if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.UpDirection))
                {
                    if (!up_pressed)
                    {
                        button_pressed_timer = 0.0f;
                    }

                    up_pressed = true;
                }

                if ((up_pressed && !InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.UpDirection)) || (up_pressed && InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.UpDirection) && button_pressed_timer > max_button_pressed_timer))
                {
                    button_pressed_timer = 0.0f;
                    up_pressed           = false;
                    AudioLib.playSoundEffect(menuBlipSound);
                    menu_item_select--;

                    if (menu_item_select > 0)
                    {
                        menu_item_select = menu_item_select % options_list.Count();
                    }
                    else if (menu_item_select < 0)
                    {
                        menu_item_select += options_list.Count();
                    }
                }

                if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.Confirm))
                {
                    confirm_pressed = true;
                }
                else if (confirm_pressed)
                {
                    confirm_pressed = false;

                    switch (options_list[menu_item_select].text)
                    {
                    case "HIGH SCORE":
                        isComplete = true;
                        break;

                    case "ERASE HIGH SCORE":
                        pop_up_screen       = true;
                        popup_item_selected = 0;
                        zoom_state          = popUpZoomState.zoomIn;
                        HighScoresState.ResetHighScores();
                        SaveGameModule.saveGame();
                        break;

                    case "CREDITS":
                        isComplete = true;
                        break;

                    case "BACK":
                        isComplete = true;
                        break;

                    default:
                        break;
                    }
                }

                for (int i = 0; i < options_list.Count(); i++)
                {
                    if (i == menu_item_select)
                    {
                        options_list[menu_item_select].select = true;
                    }
                    else
                    {
                        options_list[i].select = false;
                    }

                    options_list[i].update(currentTime);
                }
            }
            /*************************************************************************************************************/
            else
            {
                if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.LeftDirection))
                {
                    if (!down_pressed)
                    {
                        button_pressed_timer = 0.0f;
                    }
                    down_pressed = true;
                }

                if ((down_pressed && !InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.LeftDirection)) || (down_pressed && InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.LeftDirection) && button_pressed_timer > max_button_pressed_timer))
                {
                    button_pressed_timer = 0.0f;
                    down_pressed         = false;

                    popup_item_selected++;

                    if (popup_item_selected >= popup_options.Count())
                    {
                        popup_item_selected = popup_item_selected % popup_options.Count();
                    }
                    else if (menu_item_select < 0)
                    {
                        popup_item_selected += popup_options.Count();
                    }
                }

                if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.RightDirection))
                {
                    if (!up_pressed)
                    {
                        button_pressed_timer = 0.0f;
                    }

                    up_pressed = true;
                }

                if ((up_pressed && !InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.RightDirection)) || (up_pressed && InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.RightDirection) && button_pressed_timer > max_button_pressed_timer))
                {
                    button_pressed_timer = 0.0f;
                    up_pressed           = false;

                    popup_item_selected--;

                    if (popup_item_selected > 0)
                    {
                        popup_item_selected = popup_item_selected % popup_options.Count();
                    }
                    else if (popup_item_selected < 0)
                    {
                        popup_item_selected += popup_options.Count();
                    }
                }

                if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.Confirm))
                {
                    confirm_pressed = true;
                }
                else if (confirm_pressed)
                {
                    confirm_pressed = false;

                    switch (popup_options[popup_item_selected].text)
                    {
                    case "NO":
                        zoom_state = popUpZoomState.zoomOut;
                        break;

                    case "YES":
                        zoom_state = popUpZoomState.zoomOut;
                        break;

                    default:
                        break;
                    }
                }

                for (int i = 0; i < popup_options.Count(); i++)
                {
                    if (i == popup_item_selected)
                    {
                        popup_options[popup_item_selected].select = true;
                    }
                    else
                    {
                        popup_options[i].select = false;
                    }

                    popup_options[i].update(currentTime);
                }
            }
        }
예제 #10
0
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            item_direction = parent.Direction_Facing;
            play_sfx       = true;
            switch (flamethrower_state)
            {
            case FlameThrowerState.Neutral:
                if (((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Right_Item : GameCampaign.Player2_Item_1) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1)) || ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2)))
                {
                    position = new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY);
                    switch (parent.Direction_Facing)
                    {
                    case GlobalGameConstants.Direction.Right:
                        angle1 = (float)(-1 * Math.PI / 12);
                        angle2 = (float)(Math.PI / 12);
                        break;

                    case GlobalGameConstants.Direction.Left:
                        angle1 = (float)(1 * Math.PI / 1.09);
                        angle2 = (float)(-1 * Math.PI / 1.09);
                        break;

                    case GlobalGameConstants.Direction.Up:
                        angle1 = (float)(-1 * Math.PI / 1.71);
                        angle2 = (float)(-1 * Math.PI / 2.4);
                        break;

                    default:
                        angle1 = (float)(Math.PI / 2.4);
                        angle2 = (float)(Math.PI / 1.71);
                        break;
                    }
                }

                if ((parent.Index == InputDevice2.PPG_Player.Player_1) ? GameCampaign.Player_Ammunition >= 0.1 : GameCampaign.Player2_Ammunition >= 0.1)
                {
                    flamethrower_state             = FlameThrowerState.Fire;
                    parent.Velocity                = Vector2.Zero;
                    parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation("idle");
                }
                else
                {
                    parent.State       = Player.playerState.Moving;
                    flamethrower_state = FlameThrowerState.Neutral;
                }
                break;

            case FlameThrowerState.Fire:
                parentWorld.Particles.pushFlame(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY), (float)((int)parent.Direction_Facing * Math.PI / 2));

                if (parent.Index == InputDevice2.PPG_Player.Player_1)
                {
                    GameCampaign.Player_Ammunition -= 0.1f;
                }
                else if (parent.Index == InputDevice2.PPG_Player.Player_2)
                {
                    GameCampaign.Player2_Ammunition -= 0.1f;
                }

                foreach (Entity en in parentWorld.EntityList)
                {
                    if (hitTest(en))
                    {
                        Vector2 direction = en.CenterPoint - parent.CenterPoint;
                        en.knockBack(direction, knockback_magnitude, damage, parent);
                    }
                }

                if (parent.Index == InputDevice2.PPG_Player.Player_1)
                {
                    if ((GameCampaign.Player_Right_Item == ItemType() && !InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1)) || (GameCampaign.Player_Left_Item == ItemType() && !InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1)) || GameCampaign.Player_Ammunition < 1)
                    {
                        play_sfx           = false;
                        flamethrower_state = FlameThrowerState.Neutral;
                        parent.State       = Player.playerState.Moving;
                    }
                }
                else if (parent.Index == InputDevice2.PPG_Player.Player_2)
                {
                    if ((GameCampaign.Player2_Item_1 == ItemType() && !InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1)) || (GameCampaign.Player2_Item_2 == ItemType() && !InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1)) || GameCampaign.Player2_Ammunition < 1)
                    {
                        play_sfx           = false;
                        flamethrower_state = FlameThrowerState.Neutral;
                        parent.State       = Player.playerState.Moving;
                    }
                }

                AudioLib.playFlameSoundEffect(play_sfx);

                break;

            case FlameThrowerState.Reset:
                break;
            }
        }
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            updateBullets(parentWorld, currentTime);
            if (state == WaveMotionState.Wait)
            {
                if (GameCampaign.Player_Ammunition >= 5)
                {
                    shotTime = 0.0f;
                    parent.Disable_Movement = true;
                    parent.Velocity         = Vector2.Zero;

                    float shotDirection = 0.0f;

                    switch (parent.Direction_Facing)
                    {
                    case GlobalGameConstants.Direction.Up:
                        shotDirection = (float)Math.PI / -2;
                        break;

                    case GlobalGameConstants.Direction.Down:
                        shotDirection = (float)Math.PI / 2;
                        break;

                    case GlobalGameConstants.Direction.Left:
                        shotDirection = (float)Math.PI;
                        break;

                    case GlobalGameConstants.Direction.Right:
                        shotDirection = 0.0f;
                        break;
                    }

                    Vector2 bulletPos = Vector2.Zero;

                    if (GameCampaign.Player_Right_Item == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))
                    {
                        if (parent.Index == InputDevice2.PPG_Player.Player_1)
                        {
                            GameCampaign.Player_Ammunition -= ammo_consumption;
                        }
                        else
                        {
                            GameCampaign.Player2_Ammunition -= ammo_consumption;
                        }
                        parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lRayGun" : "rRayGun");
                        bulletPos = new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY);
                    }
                    else if (GameCampaign.Player_Left_Item == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))
                    {
                        GameCampaign.Player_Ammunition -= ammo_consumption;
                        parent.LoadAnimation.Animation  = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rRayGun" : "lRayGun");
                        bulletPos = new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldY);
                    }

                    if (!bullet1.active)
                    {
                        bullet1 = new WaveMotionBullet(bulletPos, shotDirection);
                    }
                    else if (!bullet2.active)
                    {
                        bullet2 = new WaveMotionBullet(bulletPos, shotDirection);
                    }
                    else if (!bullet3.active)
                    {
                        bullet3 = new WaveMotionBullet(bulletPos, shotDirection);
                    }

                    AudioLib.playSoundEffect("waveShot");

                    state = WaveMotionState.Shooting;
                    parent.Animation_Time = 0.0f;

                    parent.LoopAnimation = false;
                }
                else
                {
                    parent.State = Player.playerState.Moving;
                    return;
                }
            }
            else if (state == WaveMotionState.Shooting)
            {
                shotTime += currentTime.ElapsedGameTime.Milliseconds;

                if (shotTime > shotWaitTime)
                {
                    parent.Disable_Movement = false;
                    parent.State            = Player.playerState.Moving;

                    state = WaveMotionState.Wait;
                }
            }
        }
예제 #12
0
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            if (!shot.active && delayTimer > reloadDuration)
            {
                float direction = -1.0f;

                switch (parent.Direction_Facing)
                {
                case GlobalGameConstants.Direction.Up:
                    direction = (float)(3 * Math.PI / 2);
                    break;

                case GlobalGameConstants.Direction.Down:
                    direction = (float)(Math.PI / 2);
                    break;

                case GlobalGameConstants.Direction.Left:
                    direction = (float)(Math.PI);
                    break;

                case GlobalGameConstants.Direction.Right:
                    direction = 0.0f;
                    break;
                }

                shot       = new MagicalShot(parent.CenterPoint, direction);
                delayTimer = 0;

                if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Right_Item : GameCampaign.Player2_Item_1) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))
                {
                    parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lWand" : "rWand");
                }
                else if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))
                {
                    parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rWand" : "lWand");
                }

                parent.LoopAnimation  = false;
                parent.Animation_Time = 0;
                parent.Velocity       = Vector2.Zero;
            }

            delayTimer += currentTime.ElapsedGameTime.Milliseconds;

            updateShot(parent, currentTime, parentWorld);

            if (delayTimer > delayDuration)
            {
                parent.Disable_Movement = false;
                parent.State            = Player.playerState.Moving;
            }
        }
예제 #13
0
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            item_direction  = parent.Direction_Facing;
            parent.Velocity = Vector2.Zero;

            item_state_time += currentTime.ElapsedGameTime.Milliseconds;

            if (sword_state == Sword_State.preslash)
            {
                //sword is on the right hand side of the player, if hitboxes are different dimensions, need to adjust the position of sword.
                parent.Animation_Time = 0.0f;

                if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Right_Item : GameCampaign.Player2_Item_1) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))
                {
                    parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lSlash" : "rSlash");
                }
                else if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))
                {
                    parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rSlash" : "lSlash");
                }

                switch (item_direction)
                {
                case GlobalGameConstants.Direction.Right:
                    position.X = parent.Position.X + parent.Dimensions.X;
                    position.Y = parent.Position.Y;
                    break;

                case GlobalGameConstants.Direction.Left:
                    position.X = parent.Position.X - hitbox.X;
                    position.Y = parent.Position.Y;
                    break;

                case GlobalGameConstants.Direction.Up:
                    position.Y = parent.Position.Y - hitbox.Y;
                    position.X = parent.CenterPoint.X - hitbox.X / 2;
                    break;

                default:
                    position.Y = parent.CenterPoint.Y + parent.Dimensions.Y / 2;
                    position.X = parent.CenterPoint.X - hitbox.X / 2;
                    break;
                }
                if (item_state_time > delay)
                {
                    sword_state = Sword_State.slash;
                    sword_swing = true;

                    AudioLib.playSoundEffect(swordSound);
                }
            }
            else if (sword_state == Sword_State.slash)
            {
                for (int i = 0; i < parentWorld.EntityList.Count; i++)
                {
                    if (parentWorld.EntityList[i] is Enemy || parentWorld.EntityList[i] is ShopKeeper || parentWorld.EntityList[i] is Key || parentWorld.EntityList[i] is Coin || parentWorld.EntityList[i] is Pickup)
                    {
                        if (hitTest(parentWorld.EntityList[i]))
                        {
                            Vector2 direction = parentWorld.EntityList[i].CenterPoint - parent.CenterPoint;
                            parentWorld.EntityList[i].knockBack(direction, knockback_magnitude, sword_damage, parent);
                            AudioLib.playSoundEffect(hitSound);
                        }
                    }
                }

                sword_state = Sword_State.endslash;
            }
            //time delay for the player to be in this state
            else if (sword_state == Sword_State.endslash)
            {
                parent.State            = Player.playerState.Moving;
                item_state_time         = 0.0f;
                parent.Disable_Movement = true;
                sword_swing             = false;
                sword_state             = Sword_State.preslash;
            }
        }
예제 #14
0
        protected override void doUpdate(GameTime currentTime)
        {
            button_pressed_timer += currentTime.ElapsedGameTime.Milliseconds;
            fade += currentTime.ElapsedGameTime.Milliseconds;

            if (screen == titleScreens.menuScreen || screen == titleScreens.playScreen)
            {
                fade_duration = max_fade_menu_timer;
            }
            else
            {
                fade_duration = max_fade_timer;
            }

            switch (screen)
            {
            case titleScreens.introScreen:
                if (fade > max_fade_timer)
                {
                    fade       = 0.0f;
                    fade_state = (FadeState)(((int)fade_state + 1) % 3);
                    if (fade_state == FadeState.stay)
                    {
                        fade   = 0.0f;
                        screen = titleScreens.menuScreen;
                    }
                }
                break;

            /**************************************************************************************************************************/
            case titleScreens.logoScreen:
                if (fade > fade_duration)
                {
                    fade       = 0.0f;
                    fade_state = (FadeState)(((int)fade_state + 1) % 3);

                    if (fade_state == FadeState.fadeIn)
                    {
                        fade   = 0.0f;
                        screen = titleScreens.menuScreen;
                    }
                    else if (fade_state == FadeState.stay)
                    {
                        fade          = 0.0f;
                        fade_duration = logo_stay_timer;
                    }
                    else if (fade_state == FadeState.fadeOut)
                    {
                        fade          = 0.0f;
                        fade_duration = max_fade_timer;
                    }
                }
                break;

            /**************************************************************************************************************************/
            case titleScreens.menuScreen:
                if (!music_playing)
                {
                    BackGroundAudio.playSong("Menu", true);
                    music_playing = true;
                }

                if (Game1.videoPlayer.State == Microsoft.Xna.Framework.Media.MediaState.Stopped)
                {
                    Game1.videoPlayer.IsLooped = true;
                    Game1.videoPlayer.Play(Game1.titleScreenVideo);
                }


                if (fade > max_fade_menu_timer)
                {
                    fade       = 0.0f;
                    fade_state = FadeState.stay;
                    if (fade_state == FadeState.fadeIn)
                    {
                        fade   = 0.0f;
                        screen = titleScreens.menuScreen;
                    }
                }

                if (storageDevicePrompted)
                {
                    if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.DownDirection) != InputDevice2.PlayerPad.NoPad)
                    {
                        if (!down_pressed)
                        {
                            button_pressed_timer = 0.0f;
                        }

                        down_pressed = true;
                    }

                    if ((down_pressed && !(InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.DownDirection) != InputDevice2.PlayerPad.NoPad)) || (down_pressed && (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.DownDirection) != InputDevice2.PlayerPad.NoPad) && button_pressed_timer > max_button_pressed_timer))
                    {
                        down_pressed         = false;
                        button_pressed_timer = 0.0f;

                        menu_item_selected++;
                        AudioLib.playSoundEffect(menuBlipSound);
                        if (menu_item_selected >= menu_list.Count())
                        {
                            menu_item_selected = menu_item_selected % menu_list.Count();
                        }
                        else if (menu_item_selected < 0)
                        {
                            menu_item_selected += menu_list.Count();
                        }
                    }

                    if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.UpDirection) != InputDevice2.PlayerPad.NoPad)
                    {
                        if (!up_pressed)
                        {
                            button_pressed_timer = 0.0f;
                        }
                        up_pressed = true;
                    }

                    if ((up_pressed && !(InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.UpDirection) != InputDevice2.PlayerPad.NoPad)) || (up_pressed && (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.UpDirection) != InputDevice2.PlayerPad.NoPad) && button_pressed_timer > max_button_pressed_timer))
                    {
                        up_pressed           = false;
                        button_pressed_timer = 0.0f;

                        menu_item_selected--;
                        AudioLib.playSoundEffect(menuBlipSound);
                        if (menu_item_selected >= menu_list.Count())
                        {
                            menu_item_selected = menu_item_selected % menu_list.Count();
                        }
                        else if (menu_item_selected < 0)
                        {
                            menu_item_selected += menu_list.Count();
                        }
                    }

                    if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.Confirm) != InputDevice2.PlayerPad.NoPad)
                    {
                        confirm_pressed = true;

                        whoPressedConfirm = InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.Confirm);
                    }
                    else if (confirm_pressed)
                    {
                        confirm_pressed = false;

                        switch (menu_list[menu_item_selected].text)
                        {
                        case "START":
                            screen     = titleScreens.playScreen;
                            fade_state = FadeState.fadeOut;
                            fade       = 0.0f;
                            break;

                        case "OPTIONS":
                            InputDevice2.LockController(InputDevice2.PPG_Player.Player_1, whoPressedConfirm);
                            screen     = titleScreens.optionScreen;
                            fade_state = FadeState.fadeOut;
                            fade       = 0.0f;
                            break;

                        case "QUIT":
                            Game1.exitGame = true;
                            break;
                        }
                    }

                    for (int i = 0; i < menu_list.Count(); i++)
                    {
                        if (i == menu_item_selected)
                        {
                            menu_list[menu_item_selected].selected = true;
                        }
                        else
                        {
                            menu_list[i].selected = false;
                        }
                        menu_list[i].update(currentTime);
                    }
                }
                else
                {
                    if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.Confirm) != InputDevice2.PlayerPad.NoPad)
                    {
                        confirm_pressed = true;

                        whoPressedConfirm = InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.Confirm);
                    }
                    else if (confirm_pressed)
                    {
                        confirm_pressed = false;

                        SaveGameModule.selectStorageDevice((PlayerIndex)whoPressedConfirm);
                        SaveGameModule.loadGame();

                        storageDevicePrompted = true;
                    }
                }
                break;

            /*****************************************************************************************************/
            default:
                if (fade > max_fade_menu_timer)
                {
                    isComplete = true;
                    BackGroundAudio.stopAllSongs();
                    Game1.videoPlayer.Stop();
                }
                break;
            }
        }
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            for (int i = 0; i < laser_projectile.Count(); i++)
            {
                if (laser_projectile[i].active)
                {
                    laser_projectile[i].update(parentWorld, currentTime, parent);
                }
            }
            item_direction = parent.Direction_Facing;
            if (fire_projectile)
            {
                for (int i = 0; i < laser_projectile.Count(); i++)
                {
                    if (laser_projectile[i].active)
                    {
                        continue;
                    }
                    else
                    {
                        float bullet_angle = 0.0f;
                        if (item_direction == GlobalGameConstants.Direction.Right || item_direction == GlobalGameConstants.Direction.Left)
                        {
                            bullet_angle = 0.0f;
                        }
                        else
                        {
                            bullet_angle = (float)Math.PI / 2;
                        }

                        if ((GameCampaign.Player_Right_Item == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1)))
                        {
                            if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Ammunition : GameCampaign.Player2_Ammunition) >= ammo_consumption)
                            {
                                AudioLib.playSoundEffect("lazorFire");
                                laser_projectile[i] = new laserProjectile(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY), (parent.Direction_Facing == GlobalGameConstants.Direction.Right) ? new Vector2(10, 0) : (parent.Direction_Facing == GlobalGameConstants.Direction.Left) ? new Vector2(-10, 0) : (parent.Direction_Facing == GlobalGameConstants.Direction.Up) ? new Vector2(0, -10) : new Vector2(0, 10), bullet_angle);
                                if (parent.Index == InputDevice2.PPG_Player.Player_1)
                                {
                                    GameCampaign.Player_Ammunition -= ammo_consumption;
                                }
                                else
                                {
                                    GameCampaign.Player2_Ammunition -= ammo_consumption;
                                }
                            }
                        }
                        else if ((GameCampaign.Player_Left_Item == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2)))
                        {
                            if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Ammunition : GameCampaign.Player2_Ammunition) >= ammo_consumption)
                            {
                                AudioLib.playSoundEffect("lazorFire");

                                laser_projectile[i] = new laserProjectile(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldY), (parent.Direction_Facing == GlobalGameConstants.Direction.Right) ? new Vector2(15, 0) : (parent.Direction_Facing == GlobalGameConstants.Direction.Left) ? new Vector2(-15, 0) : (parent.Direction_Facing == GlobalGameConstants.Direction.Up) ? new Vector2(0, -15) : new Vector2(0, 15), bullet_angle);
                                if (parent.Index == InputDevice2.PPG_Player.Player_1)
                                {
                                    GameCampaign.Player_Ammunition -= ammo_consumption;
                                }
                                else
                                {
                                    GameCampaign.Player2_Ammunition -= ammo_consumption;
                                }
                            }
                        }
                        parent.State = Player.playerState.Moving;
                        parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lLaser" : "rLaser");
                        fire_timer      = 0.0f;
                        fire_projectile = false;
                        return;
                    }
                }
            }
            else
            {
                parent.State = Player.playerState.Moving;
            }
        }
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            updateBullets(parent, currentTime, parentWorld);
            if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Ammunition : GameCampaign.Player2_Ammunition) >= 1.0f)
            {
                if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Right_Item : GameCampaign.Player2_Item_1) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))
                {
                    fireTimer += currentTime.ElapsedGameTime.Milliseconds;

                    if (fireTimer > durationBetweenShots)
                    {
                        if (parent.Index == InputDevice2.PPG_Player.Player_1)
                        {
                            GameCampaign.Player_Ammunition -= ammo_consumption;
                        }
                        else
                        {
                            GameCampaign.Player2_Ammunition -= ammo_consumption;
                        }

                        fireTimer             = 0;
                        parent.Animation_Time = 0;
                        parentWorld.Particles.pushBulletCasing(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGun" : "rGun").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGun" : "rGun").WorldY));
                        pushBullet(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY), (float)((int)(parent.Direction_Facing) * (Math.PI / 2)));
                        parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lMGun" : "rMGun");
                        parent.Velocity = Vector2.Zero;
                    }
                }
                else if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))
                {
                    fireTimer += currentTime.ElapsedGameTime.Milliseconds;

                    if (fireTimer > durationBetweenShots)
                    {
                        if (parent.Index == InputDevice2.PPG_Player.Player_1)
                        {
                            GameCampaign.Player_Ammunition -= ammo_consumption;
                        }
                        else
                        {
                            GameCampaign.Player2_Ammunition -= ammo_consumption;
                        }

                        fireTimer             = 0;
                        parent.Animation_Time = 0;
                        parentWorld.Particles.pushBulletCasing(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGun" : "rGun").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGun" : "rGun").WorldY));
                        pushBullet(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldY), (float)((int)(parent.Direction_Facing) * (Math.PI / 2)));
                        parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rMGun" : "lMGun");
                        parent.Velocity = Vector2.Zero;
                        for (int i = 0; i < parentWorld.EntityList.Count; i++)
                        {
                            float distance = Vector2.Distance(parentWorld.EntityList[i].Position, new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY));
                            if (distance <= 600 && parentWorld.EntityList[i] is Enemy)
                            {
                                ((Enemy)parentWorld.EntityList[i]).Sound_Alert    = true;
                                ((Enemy)parentWorld.EntityList[i]).Sound_Position = new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY);
                            }
                        }
                    }
                }
                else
                {
                    fireTimer = float.MaxValue;

                    parent.Disable_Movement = false;
                    parent.State            = Player.playerState.Moving;

                    parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation("idle");
                }
            }
            else
            {
                parent.State = Player.playerState.Moving;
                return;
            }
        }
예제 #17
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
#if PROFILE
            elapsedTime += gameTime.ElapsedGameTime;

            if (elapsedTime > TimeSpan.FromMilliseconds(1))
            {
                elapsedTime -= TimeSpan.FromSeconds(1);
                frameRate    = frameCounter;
                frameCounter = 0;
            }

            if (GamePad.GetState(PlayerIndex.One).DPad.Up == ButtonState.Pressed)
            {
                Thread.Sleep(5);
            }

            if (GamePad.GetState(PlayerIndex.One).DPad.Down == ButtonState.Pressed)
            {
                return;
            }
#endif

#if WINDOWS
#if DEBUG
            // Allows the game to exit; win32 only
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }
#endif
#endif

            if (exitGame)
            {
                this.Exit();
            }

            if (!(preloadedAssets && preloadedJSon))
            {
                InputDevice2.Update(gameTime);

                if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.RightDirection) != InputDevice2.PlayerPad.NoPad)
                {
                    shipRotation += 0.02f;
                }
                else if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.LeftDirection) != InputDevice2.PlayerPad.NoPad)
                {
                    shipRotation -= 0.02f;
                }

                if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.Confirm) != InputDevice2.PlayerPad.NoPad)
                {
                    shipVelocity += new Vector2((float)(Math.Cos(shipRotation)), (float)(Math.Sin(shipRotation))) * shipThrust;
                    shipVelocity  = Vector2.Clamp(shipVelocity, new Vector2(-0.91f), new Vector2(0.91f));
                }

                shipPosition += shipVelocity * gameTime.ElapsedGameTime.Milliseconds;
                shipVelocity *= 0.99f;

                if (shipPosition.X < -1850)
                {
                    shipPosition.X = 1850;
                }
                if (shipPosition.X > 1850)
                {
                    shipPosition.X = -1850;
                }
                if (shipPosition.Y < -1300)
                {
                    shipPosition.Y = 1300;
                }
                if (shipPosition.Y > 1300)
                {
                    shipPosition.Y = -1300;
                }

                return;
            }

            gameIsRunningSlowly = gameTime.IsRunningSlowly;

            if (currentGameScreen.IsComplete)
            {
                currentGameScreen = ScreenState.SwitchToNewScreen(currentGameScreen.nextLevelState());
            }

            InputDevice2.Update(gameTime);

            currentGameScreen.update(gameTime);

            base.Update(gameTime);
        }
예제 #18
0
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            updateBullets(parent, currentTime, parentWorld);

            if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Ammunition : GameCampaign.Player2_Ammunition) >= 0.5)
            {
                if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Right_Item : GameCampaign.Player2_Item_1) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))
                {
                    fireTimer += currentTime.ElapsedGameTime.Milliseconds;

                    if (fireTimer > durationBetweenShots)
                    {
                        GameCampaign.Player_Ammunition -= energy_consumption;
                        fireTimer             = 0;
                        parent.Animation_Time = 0;
                        pushBullet(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY), (float)((int)(parent.Direction_Facing) * (Math.PI / 2)));
                        AudioLib.playSoundEffect("pistolTEST");
                        parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lPistol" : "rPistol");
                        parentWorld.Particles.pushBulletCasing(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGun" : "rGun").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGun" : "rGun").WorldY));
                        parent.Velocity = Vector2.Zero;
                    }
                }
                else if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))
                {
                    fireTimer += currentTime.ElapsedGameTime.Milliseconds;

                    if (fireTimer > durationBetweenShots)
                    {
                        if (parent.Index == InputDevice2.PPG_Player.Player_1)
                        {
                            GameCampaign.Player_Ammunition -= energy_consumption;
                        }
                        else
                        {
                            GameCampaign.Player2_Ammunition -= energy_consumption;
                        }

                        fireTimer             = 0;
                        parent.Animation_Time = 0;
                        pushBullet(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldY), (float)((int)(parent.Direction_Facing) * (Math.PI / 2)));
                        AudioLib.playSoundEffect("pistolTEST");
                        parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rPistol" : "lPistol");
                        parent.Velocity = Vector2.Zero;
                    }
                }
                else
                {
                    fireTimer = float.MaxValue;

                    parent.Disable_Movement = false;
                    parent.State            = Player.playerState.Moving;

                    parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation("idle");
                }
            }
            else
            {
                parent.State = Player.playerState.Moving;
                return;
            }
        }
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            updateRocketAndExplosion(parent, currentTime, parentWorld);


            if (state == RocketLauncherState.IdleWait)
            {
                if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Ammunition : GameCampaign.Player2_Ammunition) >= 20)
                {
                    if (!rocket.active && !explosion.active)
                    {
                        parent.Velocity = Vector2.Zero;

                        timer = 0;
                        state = RocketLauncherState.WindUp;

                        if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Right_Item : GameCampaign.Player2_Item_1) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))
                        {
                            slot1 = true;
                            parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lRocket" : "rRocket");
                        }
                        else if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))
                        {
                            slot1 = false;
                            parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rRocket" : "lRocket");
                        }

                        if (parent.Index == InputDevice2.PPG_Player.Player_1)
                        {
                            GameCampaign.Player_Ammunition -= ammo_consumption;
                        }
                        else
                        {
                            GameCampaign.Player2_Ammunition -= ammo_consumption;
                        }

                        parent.Animation_Time = 0;
                        parent.LoopAnimation  = false;
                    }
                    else
                    {
                        parent.Disable_Movement = false;
                        parent.State            = Player.playerState.Moving;
                    }
                }
                else
                {
                    parent.Disable_Movement = false;
                    parent.State            = Player.playerState.Moving;
                }
            }
            else if (state == RocketLauncherState.WindUp)
            {
                timer += currentTime.ElapsedGameTime.Milliseconds;

                if (timer > windUpDuration)
                {
                    timer = 0;
                    state = RocketLauncherState.Shooting;

                    AudioLib.playSoundEffect(rocketSound);

                    parentWorld.Particles.pushRocketCasing(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGun" : "lGun").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGun" : "lGun").WorldY));

                    if (slot1)
                    {
                        rocket = new Rocket(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY), parent.Direction_Facing);
                    }
                    else
                    {
                        rocket = new Rocket(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldY), parent.Direction_Facing);
                    }
                }


                for (int i = 0; i < parentWorld.EntityList.Count; i++)
                {
                    float distance = Vector2.Distance(parentWorld.EntityList[i].Position, new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY));
                    if (distance <= 1000 && parentWorld.EntityList[i] is Enemy)
                    {
                        ((Enemy)parentWorld.EntityList[i]).Sound_Alert    = true;
                        ((Enemy)parentWorld.EntityList[i]).Sound_Position = new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY);
                    }
                }
            }
            else if (state == RocketLauncherState.Shooting)
            {
                timer += currentTime.ElapsedGameTime.Milliseconds;

                if (timer > shootDuration)
                {
                    timer = 0;
                    state = RocketLauncherState.CoolDown;
                }
            }
            else if (state == RocketLauncherState.CoolDown)
            {
                parent.Disable_Movement = false;
                parent.State            = Player.playerState.Moving;

                timer += currentTime.ElapsedGameTime.Milliseconds;

                if (timer > coolDownDuration)
                {
                    timer = 0;
                    state = RocketLauncherState.IdleWait;
                }
            }
            else if (state == RocketLauncherState.InvalidState)
            {
                throw new Exception("Invalid Rocket Launcher State");
            }
        }
예제 #20
0
        public override void update(GameTime currentTime)
        {
            double delta = currentTime.ElapsedGameTime.Milliseconds;

            /*
             * if (Keyboard.GetState().IsKeyDown(Keys.Space))
             * {
             *  parentWorld.Particles.pushGib(CenterPoint);
             * }
             */


            if (index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Health <= 0.0f : GameCampaign.Player2_Health <= 0.0f)
            {
                if (!parentWorld.Player1Dead)
                {
                    BackGroundAudio.stopAllSongs();
                    AudioLib.playSoundEffect("missionFailed");

                    death = true;

                    parentWorld.Particles.pushBloodParticle(CenterPoint);
                    parentWorld.Particles.pushBloodParticle(CenterPoint);
                    parentWorld.Particles.pushBloodParticle(CenterPoint);
                    parentWorld.Particles.pushBloodParticle(CenterPoint);
                    parentWorld.Particles.pushBloodParticle(CenterPoint);
                    parentWorld.Particles.pushBloodParticle(CenterPoint);

                    animation_time = 0;
                    switch (Game1.rand.Next() % 3)
                    {
                    case 0:
                        current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("die");
                        break;

                    case 1:
                        current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("die2");
                        break;

                    default:
                        current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("die3");
                        break;
                    }
                }

                animation_time += currentTime.ElapsedGameTime.Milliseconds / 1000f;
                current_skeleton.Animation.Apply(current_skeleton.Skeleton, animation_time, false);

                death = true;
                parentWorld.Player1Dead = true;
                velocity = Vector2.Zero;
                return;
            }

            //update the world map if you've visited a new room
            int currentNodeX = (int)((CenterPoint.X / GlobalGameConstants.TileSize.X) / GlobalGameConstants.TilesPerRoomWide);
            int currentNodeY = (int)((CenterPoint.Y / GlobalGameConstants.TileSize.Y) / GlobalGameConstants.TilesPerRoomHigh);

            if (currentNodeX >= 0 && currentNodeX < parentWorld.NodeMap.GetLength(0) && currentNodeY >= 0 && currentNodeY < parentWorld.NodeMap.GetLength(1))
            {
                parentWorld.NodeMap[currentNodeX, currentNodeY].visited = true;
            }
            //knocked back
            if (disable_movement == true)
            {
                disable_movement_time += currentTime.ElapsedGameTime.Milliseconds;
                if (disable_movement_time > 300)
                {
                    velocity              = Vector2.Zero;
                    disable_movement      = false;
                    disable_movement_time = 0;
                }

                if (Player_Right_Item != null)
                {
                    Player_Right_Item.daemonupdate(this, currentTime, parentWorld);
                }
                if (Player_Left_Item != null)
                {
                    Player_Left_Item.daemonupdate(this, currentTime, parentWorld);
                }
            }
            else
            {
                if (state == playerState.Item1)
                {
                    if (Player_Right_Item == null)
                    {
                        state = playerState.Moving;
                    }
                    else
                    {
                        Player_Right_Item.update(this, currentTime, parentWorld);
                    }


                    if (Player_Left_Item != null)
                    {
                        Player_Left_Item.daemonupdate(this, currentTime, parentWorld);
                    }
                }
                else if (state == playerState.Item2)
                {
                    if (Player_Left_Item == null)
                    {
                        state = playerState.Moving;
                    }
                    else
                    {
                        Player_Left_Item.update(this, currentTime, parentWorld);
                    }

                    if (Player_Right_Item != null)
                    {
                        Player_Right_Item.daemonupdate(this, currentTime, parentWorld);
                    }
                }
                else if (state == playerState.Moving)
                {
                    loopAnimation = true;

                    if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.UseItem1))
                    {
                        state = playerState.Item1;
                    }
                    if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.UseItem2))
                    {
                        state = playerState.Item2;
                    }

                    if (disable_movement == false)
                    {
                        if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.RightDirection))
                        {
                            velocity.X       = playerMoveSpeed;
                            direction_facing = GlobalGameConstants.Direction.Right;
                        }
                        else if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.LeftDirection))
                        {
                            velocity.X       = -playerMoveSpeed;
                            direction_facing = GlobalGameConstants.Direction.Left;
                        }
                        else
                        {
                            velocity.X = 0.0f;
                        }

                        if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.UpDirection))
                        {
                            velocity.Y       = -playerMoveSpeed;
                            direction_facing = GlobalGameConstants.Direction.Up;
                        }
                        else if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.DownDirection))
                        {
                            velocity.Y       = playerMoveSpeed;
                            direction_facing = GlobalGameConstants.Direction.Down;
                        }
                        else
                        {
                            velocity.Y = 0.0f;
                        }

                        GlobalGameConstants.Direction analogDirection = InputDevice2.PlayerAnalogStickDirection(index);
                        direction_facing = (analogDirection != GlobalGameConstants.Direction.NoDirection) ? analogDirection : direction_facing;

                        switch (direction_facing)
                        {
                        case GlobalGameConstants.Direction.Down:
                            current_skeleton = walk_down;
                            current_skeleton.Skeleton.FlipX = false;
                            break;

                        case GlobalGameConstants.Direction.Up:
                            current_skeleton = walk_up;
                            current_skeleton.Skeleton.FlipX = false;
                            break;

                        case GlobalGameConstants.Direction.Left:
                            current_skeleton = walk_left;
                            current_skeleton.Skeleton.FlipX = true;
                            break;

                        case GlobalGameConstants.Direction.Right:
                            current_skeleton = walk_right;
                            current_skeleton.Skeleton.FlipX = false;
                            break;
                        }

                        //if player stands still then animation returns to idle
                        if (velocity.X == 0.0f && velocity.Y == 0.0f)
                        {
                            current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("idle");
                        }
                        else
                        {
                            current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("run");
                        }
                    }

                    bool itemTouched = false;

                    //Check to see if player has encountered a pickup item
                    for (int i = 0; i < parentWorld.EntityList.Count; i++)
                    {
                        if (parentWorld.EntityList[i] == this)
                        {
                            continue;
                        }

                        if (parentWorld.EntityList[i] is Pickup)
                        {
                            if (hitTest(parentWorld.EntityList[i]))
                            {
                                itemTouched = true;

                                if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.SwitchItem1) && !item1_switch_button_down)
                                {
                                    item1_switch_button_down = true;
                                }
                                else if (!InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.SwitchItem1) && item1_switch_button_down)
                                {
                                    item1_switch_button_down = false;

                                    Player_Right_Item = ((Pickup)parentWorld.EntityList[i]).assignItem(Player_Right_Item, currentTime);

                                    if (index == InputDevice2.PPG_Player.Player_1)
                                    {
                                        GameCampaign.Player_Right_Item = Player_Right_Item.ItemType();
                                    }
                                    else if (index == InputDevice2.PPG_Player.Player_2)
                                    {
                                        GameCampaign.Player2_Item_1 = Player_Right_Item.ItemType();
                                    }

                                    setAnimationWeapons(walk_down, GlobalGameConstants.Direction.Right);
                                    setAnimationWeapons(walk_right, GlobalGameConstants.Direction.Right);
                                    setAnimationWeapons(walk_left, GlobalGameConstants.Direction.Left);
                                    setAnimationWeapons(walk_up, GlobalGameConstants.Direction.Right);
                                }

                                if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.SwitchItem2) && !item2_switch_button_down)
                                {
                                    item2_switch_button_down = true;
                                }
                                else if (!InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.SwitchItem2) && item2_switch_button_down)
                                {
                                    item2_switch_button_down = false;

                                    Player_Left_Item = ((Pickup)parentWorld.EntityList[i]).assignItem(Player_Left_Item, currentTime);

                                    if (index == InputDevice2.PPG_Player.Player_1)
                                    {
                                        GameCampaign.Player_Left_Item = Player_Left_Item.ItemType();
                                    }
                                    else if (index == InputDevice2.PPG_Player.Player_2)
                                    {
                                        GameCampaign.Player2_Item_2 = Player_Left_Item.ItemType();
                                    }

                                    setAnimationWeapons(walk_down, GlobalGameConstants.Direction.Right);
                                    setAnimationWeapons(walk_right, GlobalGameConstants.Direction.Right);
                                    setAnimationWeapons(walk_left, GlobalGameConstants.Direction.Left);
                                    setAnimationWeapons(walk_up, GlobalGameConstants.Direction.Right);
                                }
                            }
                        }
                    }


                    if (!itemTouched && (item1_switch_button_down || item2_switch_button_down))
                    {
                        item1_switch_button_down = false;
                        item2_switch_button_down = false;
                    }

                    if (Player_Right_Item != null)
                    {
                        Player_Right_Item.daemonupdate(this, currentTime, parentWorld);
                    }
                    if (Player_Left_Item != null)
                    {
                        Player_Left_Item.daemonupdate(this, currentTime, parentWorld);
                    }
                }
            }

            Vector2 pos      = new Vector2(position.X, position.Y);
            Vector2 nextStep = new Vector2(position.X + velocity.X, position.Y + velocity.Y);

            Vector2 finalPos = parentWorld.Map.reloactePosition(pos, nextStep, dimensions);

            position = finalPos;

            animation_time += currentTime.ElapsedGameTime.Milliseconds / 1000f;
            current_skeleton.Animation.Apply(current_skeleton.Skeleton, animation_time, loopAnimation);
        }
        public override void update(GameTime currentTime)
        {
            animationTime += currentTime.ElapsedGameTime.Milliseconds / 1000f;

            if (health <= 0 && state != ShopKeeperState.Dying)
            {
                state             = ShopKeeperState.Dying;
                animationTime     = 0;
                projectile.active = false;

                this.death = true;

                directionAnims[(int)direction_facing].Animation = directionAnims[(int)direction_facing].Skeleton.Data.FindAnimation(Game1.rand.Next() % 3 == 0 ? "die" : Game1.rand.Next() % 2 == 0 ? "die2" : "die3");
            }

            if (state == ShopKeeperState.Dying)
            {
                windingUp = false;

                velocity = Vector2.Zero;
            }
            else if (state == ShopKeeperState.Enraged)
            {
                if (!windingUp && fireballDelayPassed > fireballDelay - 150f)
                {
                    animationTime = 0;
                    directionAnims[(int)direction_facing].Animation = directionAnims[(int)direction_facing].Skeleton.Data.FindAnimation("attack");
                    windingUp = true;
                }
                else if (windingUp)
                {
                    directionAnims[(int)direction_facing].Animation = directionAnims[(int)direction_facing].Skeleton.Data.FindAnimation("attack");
                }
                else if (!windingUp)
                {
                    directionAnims[(int)direction_facing].Animation = directionAnims[(int)direction_facing].Skeleton.Data.FindAnimation("chase");
                }

                if (attackerTarget != null)
                {
                    double theta = Math.Atan2(CenterPoint.Y - attackerTarget.CenterPoint.Y, CenterPoint.X - attackerTarget.CenterPoint.X);

                    if (theta > Math.PI / 4 && theta < (Math.PI) - (Math.PI / 4))
                    {
                        direction_facing = GlobalGameConstants.Direction.Up;
                    }
                    else if (theta > (Math.PI) - (Math.PI / 4) || theta < (-Math.PI) + (Math.PI / 4))
                    {
                        direction_facing = GlobalGameConstants.Direction.Right;
                    }
                    else if (theta < Math.PI / 4 && theta > Math.PI / -4)
                    {
                        direction_facing = GlobalGameConstants.Direction.Left;
                    }
                    else if (theta < Math.PI / -4 && theta > (-Math.PI) + (Math.PI / 4))
                    {
                        direction_facing = GlobalGameConstants.Direction.Down;
                    }

                    double angle = Math.Atan2(attackerTarget.Position.Y - position.Y, attackerTarget.Position.X - position.X);

                    if (Vector2.Distance(CenterPoint, attackerTarget.CenterPoint) - distanceToMaintainFromAttacker > GlobalGameConstants.TileSize.Y)
                    {
                        velocity = FireBall.fireBallVelocity / 4 * new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle));

                        velocity += FireBall.fireBallVelocity / 8 * new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle));
                    }
                    else if (Vector2.Distance(CenterPoint, attackerTarget.CenterPoint) - distanceToMaintainFromAttacker < -1 * GlobalGameConstants.TileSize.Y)
                    {
                        velocity = -1 * FireBall.fireBallVelocity / 4 * new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle));
                    }
                }
                if (projectile.active)
                {
                    projectile.position  += FireBall.fireBallVelocity * new Vector2((float)Math.Cos(projectile.direction), (float)Math.Sin(projectile.direction));
                    projectile.timeAlive += currentTime.ElapsedGameTime.Milliseconds;

                    if (projectile.timeAlive > FireBall.fireBallDurationTime || parentWorld.Map.hitTestWall(projectile.center))
                    {
                        projectile.active   = false;
                        fireballDelayPassed = 0.0f;
                        attackPoint         = new Vector2(-1, -1);
                    }

                    for (int i = 0; i < parentWorld.EntityList.Count; i++)
                    {
                        if (parentWorld.EntityList[i] == this || parentWorld.EntityList[i] is Pickup)
                        {
                            continue;
                        }

                        if (Vector2.Distance(projectile.center, parentWorld.EntityList[i].CenterPoint) < GlobalGameConstants.TileSize.X)
                        {
                            parentWorld.EntityList[i].knockBack(new Vector2((float)Math.Cos(projectile.direction), (float)Math.Sin(projectile.direction)), 4.0f, 10);
                            projectile.active   = false;
                            fireballDelayPassed = -200f;
                            attackPoint         = new Vector2(-1, -1);
                        }
                    }
                }
                else
                {
                    fireballDelayPassed += currentTime.ElapsedGameTime.Milliseconds;

                    if (attackerTarget != null)
                    {
                        if (fireballDelayPassed > fireballDelay && attackPoint != new Vector2(-1, -1))
                        {
                            projectile          = new FireBall(position, (float)Math.Atan2(attackPoint.Y - position.Y, attackPoint.X - position.X));
                            windingUp           = false;
                            fireballDelayPassed = 0;

                            parentWorld.Particles.pushDotParticle2(position, (float)Math.Atan2(attackPoint.Y - position.Y, attackPoint.X - position.X) + 0.2f, Color.OrangeRed, 5.0f);
                            parentWorld.Particles.pushDotParticle2(position, (float)Math.Atan2(attackPoint.Y - position.Y, attackPoint.X - position.X) - 0.2f, Color.OrangeRed, 5.0f);
                        }
                        else if (fireballDelayPassed > attackPointSetDelay && attackPoint == new Vector2(-1, -1))
                        {
                            attackPoint = attackerTarget.CenterPoint;
                        }
                    }
                }
            }
            else if (state == ShopKeeperState.Normal)
            {
                directionAnims[(int)direction_facing].Animation = directionAnims[(int)direction_facing].Skeleton.Data.FindAnimation("idle");

                //render prices
                if (Vector2.Distance(CenterPoint, parentWorld.CameraFocus.CenterPoint) > 720)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        InGameGUI.prices[i].active = false;
                    }
                }
                else
                {
                    for (int i = 0; i < 3; i++)
                    {
                        if (itemsForSale[i] != GlobalGameConstants.itemType.NoItem)
                        {
                            InGameGUI.prices[i].active = true;
                        }
                    }
                }

                if (Vector2.Distance(CenterPoint, parentWorld.CameraFocus.CenterPoint) < 500 && !playerInRange)
                {
                    playerInRange = true;

                    parentWorld.pushMessage(greetingMessage);
                }
                else if (Vector2.Distance(CenterPoint, parentWorld.CameraFocus.CenterPoint) > 500 && playerInRange)
                {
                    playerInRange = false;
                }

                for (int it = 0; it < parentWorld.EntityList.Count; it++)
                {
                    if (parentWorld.EntityList[it] is Player && ((Player)parentWorld.EntityList[it]).Index == InputDevice2.PPG_Player.Player_1)
                    {
                        if (distance(parentWorld.EntityList[it].Position, position) < GlobalGameConstants.TileSize.X * GlobalGameConstants.TilesPerRoomHigh / 2)
                        {
                            playerOverlap = false;

                            for (int i = 0; i < 3; i++)
                            {
                                Vector2 drawItemPos = position + new Vector2((-3 * GlobalGameConstants.TileSize.X) + (i * 3f * GlobalGameConstants.TileSize.X), (2.5f * GlobalGameConstants.TileSize.Y));

                                if (distance(drawItemPos + GlobalGameConstants.TileSize / 2, parentWorld.EntityList[it].CenterPoint) < 32 && itemsForSale[i] != GlobalGameConstants.itemType.NoItem)
                                {
                                    playerOverlap                = true;
                                    buyLocation                  = parentWorld.EntityList[it].Position - new Vector2(0, 48);
                                    overlapIndex                 = i;
                                    InGameGUI.prices[i].price    = InGameGUI.prices[i].description;
                                    InGameGUI.prices[i].position = position + new Vector2((-3 * GlobalGameConstants.TileSize.X) + (i * 3f * GlobalGameConstants.TileSize.X), (2.5f * GlobalGameConstants.TileSize.Y)) - (Game1.tenbyFive14.MeasureString(InGameGUI.prices[i].description) / 2) + new Vector2(0, 16);

                                    if (switchItemPressed && !(InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.SwitchItem1) || InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.SwitchItem2)) && GameCampaign.Player_Coin_Amount >= itemPrices[i])
                                    {
                                        items[i].Position = drawItemPos;

                                        purchaseTransaction(itemPrices[i]);
                                        itemsForSale[i]            = GlobalGameConstants.itemType.NoItem;
                                        InGameGUI.prices[i].active = false;
                                    }
                                }
                                else
                                {
                                    if ((int)itemsForSale[i] >= 0)
                                    {
                                        InGameGUI.prices[i].price    = GlobalGameConstants.WeaponDictionary.weaponInfo[(int)itemsForSale[i]].priceString;
                                        InGameGUI.prices[i].position = position + new Vector2((-3 * GlobalGameConstants.TileSize.X) + (i * 3f * GlobalGameConstants.TileSize.X), (2.5f * GlobalGameConstants.TileSize.Y)) - (Game1.tenbyFive14.MeasureString(InGameGUI.prices[i].price) / 2) + new Vector2(0, 16);
                                    }
                                }
                            }
                        }
                    }
                }

                if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.SwitchItem1) || (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.SwitchItem2)) && !switchItemPressed)
                {
                    switchItemPressed = true;
                }
                else if (!(InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.SwitchItem1) || InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.SwitchItem2)) && switchItemPressed)
                {
                    switchItemPressed = false;
                }
            }
            else if (state == ShopKeeperState.KnockBack)
            {
                directionAnims[(int)direction_facing].Animation = directionAnims[(int)direction_facing].Skeleton.Data.FindAnimation("hurt");

                knockBackTimer += currentTime.ElapsedGameTime.Milliseconds;

                if (knockBackTimer > knockBackDuration)
                {
                    state = ShopKeeperState.Enraged;
                }

                if (projectile.active)
                {
                    projectile.position  += FireBall.fireBallVelocity * new Vector2((float)Math.Cos(projectile.direction), (float)Math.Sin(projectile.direction));
                    projectile.timeAlive += currentTime.ElapsedGameTime.Milliseconds;

                    if (projectile.timeAlive > FireBall.fireBallDurationTime || parentWorld.Map.hitTestWall(projectile.center))
                    {
                        projectile.active   = false;
                        fireballDelayPassed = 0.0f;
                        attackPoint         = new Vector2(-1, -1);
                    }

                    for (int i = 0; i < parentWorld.EntityList.Count; i++)
                    {
                        if (parentWorld.EntityList[i] == this)
                        {
                            continue;
                        }

                        if (Vector2.Distance(projectile.center, parentWorld.EntityList[i].CenterPoint) < GlobalGameConstants.TileSize.X)
                        {
                            parentWorld.EntityList[i].knockBack(new Vector2((float)Math.Cos(projectile.direction), (float)Math.Sin(projectile.direction)), 4.0f, 10);
                            projectile.active   = false;
                            fireballDelayPassed = -200f;
                            attackPoint         = new Vector2(-1, -1);
                        }
                    }
                }
            }
            else if (state == ShopKeeperState.InvalidState)
            {
                throw new Exception("Shopkeeper was thrown into an invalid state: " + position.X + "," + position.Y);
            }

            directionAnims[(int)direction_facing].Animation.Apply(directionAnims[(int)direction_facing].Skeleton, animationTime, state == ShopKeeperState.KnockBack || state == ShopKeeperState.Dying || windingUp ? false : true);

            Vector2 step     = position + velocity;
            Vector2 finalPos = parentWorld.Map.reloactePosition(position, step, dimensions);

            position = finalPos;
        }
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            item_direction  = parent.Direction_Facing;
            parent.Velocity = Vector2.Zero;

            item_state_time += currentTime.ElapsedGameTime.Milliseconds;

            switch (bushido_state)
            {
            case BushidoState.preslash:
                parent.Animation_Time = 0.0f;

                if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Right_Item : GameCampaign.Player2_Item_1) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))
                {
                    parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lSlash" : "rSlash");
                }
                else if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))
                {
                    parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rSlash" : "lSlash");
                }

                switch (item_direction)
                {
                case GlobalGameConstants.Direction.Right:
                    position.X = parent.Position.X + parent.Dimensions.X;
                    position.Y = parent.Position.Y;
                    break;

                case GlobalGameConstants.Direction.Left:
                    position.X = parent.Position.X - hitbox.X;
                    position.Y = parent.Position.Y;
                    break;

                case GlobalGameConstants.Direction.Up:
                    position.Y = parent.Position.Y - hitbox.Y;
                    position.X = parent.CenterPoint.X - hitbox.X / 2;
                    break;

                default:
                    position.Y = parent.CenterPoint.Y + parent.Dimensions.Y / 2;
                    position.X = parent.CenterPoint.X - hitbox.X / 2;
                    break;
                }
                if (item_state_time > delay)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        parentWorld.Particles.pushDotParticle(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lHand" : "rHand").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lHand" : "rHand").WorldY), (float)(Game1.rand.NextDouble() * 2 * Math.PI), Color.Lerp(Color.Yellow, Color.YellowGreen, (float)Game1.rand.NextDouble()));
                    }

                    bushido_state = BushidoState.slash;
                    sword_swing   = true;
                }
                break;

            case BushidoState.slash:
                foreach (Entity en in parentWorld.EntityList)
                {
                    if (en is Enemy || en is ShopKeeper)
                    {
                        if (hitTest(en))
                        {
                            Vector2 betweenVector       = en.CenterPoint - parent.CenterPoint;
                            Vector2 betweenVectorNormal = Vector2.Normalize(betweenVector);

                            for (int i = 0; i < 6; i++)
                            {
                                parentWorld.Particles.pushDirectedParticle2(parent.CenterPoint + (betweenVector / 2), Color.Yellow, (float)(Math.PI * 2 * (i / 6f)));
                            }

                            for (int i = 0; i < 30; i++)
                            {
                                parentWorld.Particles.pushDotParticle2(parent.CenterPoint + (betweenVector / 2), (float)(Math.Atan2(betweenVector.Y, betweenVector.X) + Math.PI / 2), Color.YellowGreen, 5 + (i / 10.0f));
                                parentWorld.Particles.pushDotParticle2(parent.CenterPoint + (betweenVector / 2), (float)(Math.Atan2(betweenVector.Y, betweenVector.X) - Math.PI / 2), Color.YellowGreen, 5 + (i / 10.0f));
                            }

                            Vector2 direction = en.CenterPoint - parent.CenterPoint;
                            en.knockBack(direction, knockback_magnitude, sword_damage, parent);
                            enemy_explode          = true;
                            enemy_explode_position = en.CenterPoint - new Vector2(24.0f * 3.0f, 24.0f * 3.0f);
                        }
                    }
                }
                bushido_state = BushidoState.endslash;
                break;

            default:
                parent.State            = Player.playerState.Moving;
                item_state_time         = 0.0f;
                parent.Disable_Movement = true;
                sword_swing             = false;
                bushido_state           = BushidoState.preslash;
                break;
            }
        }
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            if (state == HermesSandalsState.Running)
            {
                switch (parent.Direction_Facing)
                {
                case GlobalGameConstants.Direction.Up:
                    parent.Velocity = new Vector2(0, -hermesRunSpeed);
                    break;

                case GlobalGameConstants.Direction.Down:
                    parent.Velocity = new Vector2(0, hermesRunSpeed);
                    break;

                case GlobalGameConstants.Direction.Left:
                    parent.Velocity = new Vector2(-hermesRunSpeed, 0);
                    break;

                case GlobalGameConstants.Direction.Right:
                    parent.Velocity = new Vector2(hermesRunSpeed, 0);
                    break;
                }

                if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Right_Item : GameCampaign.Player2_Item_1) == ItemType() && !InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))
                {
                    state = HermesSandalsState.Idle;

                    parent.Disable_Movement = false;
                    parent.State            = Player.playerState.Moving;
                }
                else if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && !InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))
                {
                    state = HermesSandalsState.Idle;

                    parent.Disable_Movement = false;
                    parent.State            = Player.playerState.Moving;
                }

                parent.Animation_Time += (currentTime.ElapsedGameTime.Milliseconds / 400f);

                if (Game1.rand.Next() % 2 == 0)
                {
                    parentWorld.Particles.pushDirectedParticle(parent.CenterPoint + new Vector2(-4, parent.Dimensions.Y / 2 - 12), Color.LightCyan, (float)(((int)(parent.Direction_Facing) * (Math.PI / 2)) + (Game1.rand.NextDouble() * (Math.PI / 4)) - (Math.PI / 8)));
                }
            }
            else if (state == HermesSandalsState.WindUp)
            {
                if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Right_Item : GameCampaign.Player2_Item_1) == ItemType() && !InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))
                {
                    state = HermesSandalsState.Idle;

                    parent.Disable_Movement = false;
                    parent.State            = Player.playerState.Moving;

                    return;
                }
                else if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && !InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))
                {
                    state = HermesSandalsState.Idle;

                    parent.Disable_Movement = false;
                    parent.State            = Player.playerState.Moving;

                    return;
                }

                windUpTime += currentTime.ElapsedGameTime.Milliseconds;

                parent.Animation_Time += (currentTime.ElapsedGameTime.Milliseconds / 400f);

                if (windUpTime > windUpDuration)
                {
                    if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Ammunition : GameCampaign.Player2_Ammunition) >= 10.0f)
                    {
                        if (parent.Index == InputDevice2.PPG_Player.Player_1)
                        {
                            GameCampaign.Player_Ammunition -= 10;
                        }
                        else
                        {
                            GameCampaign.Player2_Ammunition -= 10;
                        }

                        state = HermesSandalsState.Running;
                    }
                    else
                    {
                        state = HermesSandalsState.Idle;

                        parent.LoadAnimation.Skeleton.Data.FindAnimation("idle");

                        parent.Disable_Movement = false;
                        parent.State            = Player.playerState.Moving;
                    }
                }

                if (GameCampaign.Player_Ammunition >= 10.0f)
                {
                    parentWorld.Particles.pushDirectedParticle(parent.CenterPoint + new Vector2(0, parent.Dimensions.Y / 2 - 12), Color.LightCyan, (float)(Game1.rand.NextDouble() * Math.PI * 2));
                }
            }
            else if (state == HermesSandalsState.Idle)
            {
                state = HermesSandalsState.WindUp;

                windUpTime      = 0.0f;
                parent.Velocity = Vector2.Zero;

                parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation("run");
            }
            else
            {
                throw new Exception("invalid HermesSandals state");
            }
        }
        private void gameLogicUpdate(Microsoft.Xna.Framework.GameTime currentTime)
        {
            if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.PauseButton) && !player1Dead)
            {
                state = LoadingState.LevelPaused;
                pauseDialogMinimumTime = 0;
                pauseMenuItem          = 0;
                AudioLib.playSoundEffect("monitorOpening");
            }

            if (GameCampaign.Player_Ammunition < 0)
            {
                GameCampaign.Player_Ammunition = 0;
            }
            if (GameCampaign.Player2_Ammunition < 0)
            {
                GameCampaign.Player2_Ammunition = 0;
            }

            if (GameCampaign.Player_Ammunition > 100)
            {
                GameCampaign.Player_Ammunition = 100;
            }
            if (GameCampaign.Player2_Ammunition > 100)
            {
                GameCampaign.Player2_Ammunition = 100;
            }

            if (messageQueueState == PushMessageQueueState.Wait)
            {
                if (pushMessageQueue.Count > 0)
                {
                    messageQueueState = PushMessageQueueState.FadeIn;
                    queueTimer        = 0;
                }
            }
            else if (messageQueueState == PushMessageQueueState.ShowMessage)
            {
                queueTimer += currentTime.ElapsedGameTime.Milliseconds;

                if (queueTimer > 1000f + (25 * pushMessageQueue.Peek().Length))
                {
                    messageQueueState = PushMessageQueueState.FadeOut;
                    queueTimer        = 0;
                }
            }
            else if (messageQueueState == PushMessageQueueState.FadeIn)
            {
                queueTimer += currentTime.ElapsedGameTime.Milliseconds;

                if (queueTimer > 200f)
                {
                    messageQueueState = PushMessageQueueState.ShowMessage;
                    queueTimer        = 0;
                }
            }
            else if (messageQueueState == PushMessageQueueState.FadeOut)
            {
                queueTimer += currentTime.ElapsedGameTime.Milliseconds;

                if (queueTimer > 200f)
                {
                    messageQueueState = PushMessageQueueState.Wait;
                    queueTimer        = 0;
                    pushMessageQueue.Dequeue();
                }
            }

            for (int i = 0; i < entityList.Count; i++)
            {
                if (Vector2.Distance(cameraFocus.CenterPoint, entityList[i].CenterPoint) < 800 || entityList[i] is Player)
                {
                    entityList[i].update(currentTime);
                }
            }

            elapsedLevelTime += currentTime.ElapsedGameTime.Milliseconds;

            particleSet.update(currentTime);

#if WINDOWS
            entityList.RemoveAll(en => en.Remove_From_List == true);
#elif XBOX
            XboxTools.RemoveAll(entityList, XboxTools.IsEntityToBeRemoved);
            XboxTools.RemoveAll(acidSpitters, XboxTools.IsEntityToBeRemoved);
#endif

            if (cameraFocus != null)
            {
                int pointX = (int)cameraFocus.CenterPoint.X;
                int pointY = (int)cameraFocus.CenterPoint.Y;

                camera = Matrix.CreateTranslation(new Vector3((pointX * -1) + (GlobalGameConstants.GameResolutionWidth / 2), (pointY * -1) + (GlobalGameConstants.GameResolutionHeight / 2), 0.0f));
                //camera = Matrix.CreateScale(0.1f);
            }

            gui.update(currentTime);

            if (player1Dead)
            {
                fadeOutTime += currentTime.ElapsedGameTime.Milliseconds;

                gui.BlackFadeOverlay = fadeOutTime / fadeOutDuration;

                if (fadeOutTime >= fadeOutDuration)
                {
                    BackGroundAudio.stopAllSongs();
                    isComplete = true;
                }
            }

            if (endFlagReached)
            {
                BackGroundAudio.stopAllSongs();
                isComplete = true;
            }

#if DEBUG
            if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.SwitchItem2) != InputDevice2.PlayerPad.NoPad)
            {
                showStats = true;
            }
            else
            {
                showStats = false;
            }
#endif
        }
        private void pausedUpdate(Microsoft.Xna.Framework.GameTime currentTime)
        {
            pauseDialogMinimumTime += currentTime.ElapsedGameTime.Milliseconds;

            if (!player1DownPressed && InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.DownDirection))
            {
                player1DownPressed = true;
            }
            else if (player1DownPressed && !InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.DownDirection))
            {
                player1DownPressed = false;

                pauseMenuItem = (pauseMenuItem + 1) % 2;
                AudioLib.playSoundEffect("menuSelect");
            }

            if (!player1UpPressed && InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.UpDirection))
            {
                player1UpPressed = true;
            }
            else if (player1UpPressed && !InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.UpDirection))
            {
                player1UpPressed = false;

                pauseMenuItem--;
                if (pauseMenuItem < 0)
                {
                    pauseMenuItem = 1;
                }
                AudioLib.playSoundEffect("menuSelect");
            }

            if (!player1ConfirmPressed && InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.Confirm))
            {
                player1ConfirmPressed = true;
            }
            else if (player1ConfirmPressed && !InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.Confirm))
            {
                player1ConfirmPressed = false;

                if (pauseMenuItem == 0)
                {
                    state = LoadingState.LevelRunning;
                }
                else if (pauseMenuItem == 1)
                {
                    returnToTitle = true;

                    isComplete = true;
                }
            }

            if (!pauseButtonDown && InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.PauseButton))
            {
                pauseButtonDown = true;
            }
            else if (pauseButtonDown && !InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.PauseButton))
            {
                pauseButtonDown = false;

                if (pauseDialogMinimumTime > 300)
                {
                    state = LoadingState.LevelRunning;
                }
            }
        }
        protected override void doUpdate(Microsoft.Xna.Framework.GameTime currentTime)
        {
            CampaignLobbyState.lineOffset += (currentTime.ElapsedGameTime.Milliseconds * lineMoveSpeed);
            if (CampaignLobbyState.lineOffset > 16.0f)
            {
                CampaignLobbyState.lineOffset -= 16.0f;
            }

            if (!openingSoundMade)
            {
                AudioLib.playSoundEffect("monitorOpening");
                openingSoundMade = true;
            }

            if (state == LevelSelectStateState.AnimateIn && cursorAnimationTime > 500f)
            {
                state = LevelSelectStateState.Idle;
            }

            if (state == LevelSelectStateState.Idle)
            {
                if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.DownDirection) && !downPressed)
                {
                    downPressed = true;
                }
                else if (!InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.DownDirection) && downPressed)
                {
                    downPressed = false;

                    if (selectedLevelY < GameCampaign.levelMap.GetLength(1) - 1 && GameCampaign.levelMap[selectedLevelX, selectedLevelY + 1].visible && selectedLevelY - GameCampaign.PlayerFloorHeight < 1)
                    {
                        selectedLevelY++;
                        AudioLib.playSoundEffect(menuBlipSound);
                    }
                }

                if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.UpDirection) && !upPressed)
                {
                    upPressed = true;
                }
                else if (!InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.UpDirection) && upPressed)
                {
                    upPressed = false;

                    if (selectedLevelY > 0 && GameCampaign.levelMap[selectedLevelX, selectedLevelY - 1].visible && selectedLevelY - GameCampaign.PlayerFloorHeight > -1)
                    {
                        selectedLevelY--;
                        AudioLib.playSoundEffect(menuBlipSound);
                    }
                }

                selectedLevelX = GameCampaign.PlayerLevelProgress + 1;

                if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.Confirm) && !confirmPressed)
                {
                    confirmPressed = true;
                }
                else if (!InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.Confirm) && confirmPressed)
                {
                    confirmPressed = false;

                    GameCampaign.CurrentAlienRate    = GameCampaign.levelMap[selectedLevelX, selectedLevelY].alienRates;
                    GameCampaign.CurrentGuardRate    = GameCampaign.levelMap[selectedLevelX, selectedLevelY].guardRates;
                    GameCampaign.CurrentPrisonerRate = GameCampaign.levelMap[selectedLevelX, selectedLevelY].prisonerRates;

                    GameCampaign.currentContract = GameCampaign.levelMap[selectedLevelX, selectedLevelY].contract;

                    GameCampaign.PlayerLevelProgress = GameCampaign.PlayerLevelProgress + 1;
                    GameCampaign.PlayerFloorHeight   = selectedLevelY;

                    GameCampaign.floorProgress[GameCampaign.PlayerLevelProgress] = GameCampaign.PlayerFloorHeight;

                    state = LevelSelectStateState.AnimateOut;

                    isComplete = true;
                }
            }

            double cursorDir = Math.Atan2(((selectedLevelY * 96) + drawMapTestOffset.Y) - cursorPosition.Y, ((selectedLevelX * 128) + drawMapTestOffset.X) - cursorPosition.X);

            cursorPosition += currentTime.ElapsedGameTime.Milliseconds * cursorVelocity * new Vector2((float)(Math.Cos(cursorDir)), (float)(Math.Sin(cursorDir)));

            if (Vector2.Distance(cursorPosition, new Vector2(((selectedLevelX * 128) + drawMapTestOffset.X), ((selectedLevelY * 96) + drawMapTestOffset.Y))) < 10f)
            {
                cursorPosition = new Vector2(((selectedLevelX * 128) + drawMapTestOffset.X), ((selectedLevelY * 96) + drawMapTestOffset.Y));
            }

            cursorAnimationTime += currentTime.ElapsedGameTime.Milliseconds;
        }
예제 #27
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            if (!(preloadedAssets && preloadedJSon))
            {
                GraphicsDevice.Clear(Color.Black);

                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);

                for (int i = 0; i < starCount; i++)
                {
                    if (stars[i].X - shipPosition.X < -425 || stars[i].X - shipPosition.X > 425 || stars[i].Y - shipPosition.Y < -150 || stars[i].Y - shipPosition.Y > 150)
                    {
                        continue;
                    }

                    spriteBatch.Draw(asteroidsSpriteSheet, new Rectangle((GlobalGameConstants.GameResolutionWidth / 2 - 425) + 425 + (int)(stars[i].X - shipPosition.X), (GlobalGameConstants.GameResolutionHeight / 3 - 100) + 150 + (int)(stars[i].Y - shipPosition.Y), 20, 16), new Rectangle(555, 172, 30, 28), Color.White, starRotation[i], new Vector2(15, 14), SpriteEffects.None, 0.0f);
                }

                spriteBatch.Draw(asteroidsSpriteSheet, new Rectangle((GlobalGameConstants.GameResolutionWidth / 2 - 425) + 425, (GlobalGameConstants.GameResolutionHeight / 3 - 100) + 150, 30, 30), new Rectangle(0, 172, 120, 120), Color.White, shipRotation + (float)(Math.PI / 2), new Vector2(60), SpriteEffects.None, 0.0f);
                drawBox(spriteBatch, new Rectangle(GlobalGameConstants.GameResolutionWidth / 2 - 425, GlobalGameConstants.GameResolutionHeight / 3 - 100, 850, 300), Color.White, 2.0f);

                spriteBatch.Draw(pleaseWaitDialog, (new Vector2(GlobalGameConstants.GameResolutionWidth / 2, GlobalGameConstants.GameResolutionHeight * 0.75f) - new Vector2(pleaseWaitDialog.Width / 2, pleaseWaitDialog.Height / 2)), Color.White);

                spriteBatch.End();

                return;
            }

            currentGameScreen.render(spriteBatch);

            if (SaveGameModule.TouchingStorageDevice)
            {
                spriteBatch.Begin();
                spriteBatch.Draw(saveIcon, new Rectangle(1100, 588, 54, 59), new Rectangle(3, 28, 54, 59), Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, 0.5f);
                spriteBatch.End();
            }

#if CONTROLLER_DATA
            spriteBatch.Begin();

            try
            {
                spriteBatch.DrawString(Game1.tenbyFive14, "Player1: " + InputDevice2.GetPlayerGamePadIndex(InputDevice2.PPG_Player.Player_1).ToString(), new Vector2(32), Color.White);
            }
            catch (Exception)
            {
                spriteBatch.DrawString(Game1.tenbyFive14, "Player1: none", new Vector2(32), Color.White);
            }

            try
            {
                spriteBatch.DrawString(Game1.tenbyFive14, "Player2: " + InputDevice2.GetPlayerGamePadIndex(InputDevice2.PPG_Player.Player_2).ToString(), new Vector2(32, 64), Color.White);
            }
            catch (Exception)
            {
                spriteBatch.DrawString(Game1.tenbyFive14, "Player2: none", new Vector2(32, 64), Color.White);
            }

            spriteBatch.End();
#endif

#if PROFILE
            frameCounter++;

            string fps = string.Format("fps: {0}", frameRate);

            spriteBatch.Begin();

            spriteBatch.DrawString(font, fps, new Vector2(33, 33), Color.Black);
            spriteBatch.DrawString(font, fps, new Vector2(32, 32), Color.White);

            spriteBatch.End();
#endif
        }
예제 #28
0
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            position = parent.CenterPoint;

            for (int i = 0; i < pellet_count; i++)
            {
                if (shotgun_pellets[i].active == true)
                {
                    shotgun_pellets[i].update(parentWorld, currentTime, parent);

                    if (shotgun_pellets[i].hit_enemy && !damage_delay_flag)
                    {
                        damage_delay_flag  = true;
                        damage_delay_timer = 0.0f;
                    }
                }
            }

            if (pellet_count == max_pellets)
            {
                inactive_pellets = 0;
                for (int i = 0; i < pellet_count; i++)
                {
                    if (shotgun_pellets[i].active == false)
                    {
                        inactive_pellets++;
                    }
                }

                if (inactive_pellets == max_pellets)
                {
                    pellet_count = 0;
                }
            }

            if (shotgun_active == false && (parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Ammunition : GameCampaign.Player2_Ammunition) >= 5)
            {
                switch (parent.Direction_Facing)
                {
                case GlobalGameConstants.Direction.Right:
                    pellet_angle_direction = (float)(-1 * Math.PI / 12);
                    break;

                case GlobalGameConstants.Direction.Left:
                    pellet_angle_direction = (float)(Math.PI / 1.09);
                    break;

                case GlobalGameConstants.Direction.Up:
                    pellet_angle_direction = (float)(-1 * Math.PI / 1.74);
                    break;

                default:
                    pellet_angle_direction = (float)(Math.PI / 2.4);
                    break;
                }

                AudioLib.playSoundEffect(shot_gun_sound);
                parentWorld.Particles.pushShotGunCasing(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGun" : "lGun").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGun" : "lGun").WorldY));

                for (int i = 0; i < max_pellets; i++)
                {
                    parent.Animation_Time = 0;
                    float angle = (float)((Game1.rand.Next() % pellet_angle_interval) + pellet_angle_direction);

                    if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Right_Item : GameCampaign.Player2_Item_1) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))
                    {
                        shotgun_pellets[i]             = new Pellets(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY), angle);
                        parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lShotgun" : "rShotgun");

                        if (parent.Index == InputDevice2.PPG_Player.Player_1)
                        {
                            GameCampaign.Player_Ammunition -= 1;
                        }
                        else if (parent.Index == InputDevice2.PPG_Player.Player_2)
                        {
                            GameCampaign.Player2_Ammunition -= 1;
                        }
                    }
                    else if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))
                    {
                        shotgun_pellets[i]             = new Pellets(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldY), angle);
                        parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rShotgun" : "lShotgun");

                        if (parent.Index == InputDevice2.PPG_Player.Player_1)
                        {
                            GameCampaign.Player_Ammunition -= 1;
                        }
                        else if (parent.Index == InputDevice2.PPG_Player.Player_2)
                        {
                            GameCampaign.Player2_Ammunition -= 1;
                        }
                    }

                    pellet_count++;
                }
                shotgun_active       = true;
                shotgun_active_timer = 0.0f;
            }
            parent.State = Player.playerState.Moving;
        }