Ejemplo n.º 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;
            }
        }
Ejemplo n.º 2
0
        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;
                }
            }
        }
Ejemplo n.º 5
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;
            }
        }
        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;
            }
        }
        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;
        }
        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;
                }
            }
        }
        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;
            }
        }
        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");
            }
        }
        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;
                }
            }
        }
        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;
            }
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
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;
            }
        }
Ejemplo n.º 16
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)
        {
            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");
            }
        }
Ejemplo n.º 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;
            }
        }
        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);
                }
            }
        }
        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
        }
Ejemplo n.º 21
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;
        }