Ejemplo n.º 1
0
        public override void Update(GameTime gameTime, ref Peripherals IoController)
        {
            KeyboardState keyboard = Keyboard.GetState();

            if (_Duration >= _DurationLimit || keyboard.IsKeyDown(Keys.Enter))
            {
                _Game.ChangeState(new StateStartScreen(_Content, _Game, _GraphicsDevice, _Camera2D));
                Thread.Sleep(150);
            }
            else
            {
                _Duration += (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
        }
Ejemplo n.º 2
0
 protected void Move(Peripherals PeripheralIO, float deltaTime)
 {
     if (_IsPlayerControlled)
     {
         if (PeripheralIO.GetUp)
         {
             //WMove up (or whatever its  2D game, maybe ladders)
             MoveUp(deltaTime);
         }
         if (PeripheralIO.GetLeft)
         {
             //Move Left
             MoveLeft(deltaTime);
         }
         if (PeripheralIO.GetDown)
         {
             //WMove down (or whatever its  2D game, maybe ladders)
             MoveDown(deltaTime);
         }
         if (PeripheralIO.GetRight)
         {
             //Move Right
             MoveRight(deltaTime);
         }
         if (PeripheralIO.GetSprint)
         {
             Sprint();
         }
         else if (PeripheralIO.GetIsControllerButtonX)
         {
             Sprint();
         }
         else
         {
             StopSprint();
         }
         if (PeripheralIO.GetCrouch)
         {
             //Crouch
         }
         if (PeripheralIO.GetJump)
         {
             //Jump
         }
     }
 }
Ejemplo n.º 3
0
        public StateGamePlaying(ContentManager content, Game1 game, GraphicsDevice graphicsDevice, Camera2d camera2D) : base(content, game, graphicsDevice, camera2D)
        {
            _IoController = game.IoController;
            _AllSprites   = new List <Sprite>();

            _Levels = XmlContent.Levels;

            _CurrentLevel = _Levels[XmlContent.FirstLevel];

            _PlayerCharacter = new SpritePlayerCharacter(
                XmlContent.PlayerCharacterUpTextures,
                XmlContent.PlayerCharacterDownTextures,
                XmlContent.PlayerCharacterLeftTextures,
                XmlContent.PlayerCharacterRightTextures,
                _CurrentLevel.PlayerCharacterDefaultCoordinates, ref game.IoController);

            ChangeLevel(_Levels[XmlContent.FirstLevel]);

            //foreach (Sprite block in _CurrentLevel.Blocks)
            //{
            //    _AllSprites.Add(block);
            //}
        }
Ejemplo n.º 4
0
 public override void PostUpdate(GameTime gameTime, ref Peripherals IoController)
 {
 }
Ejemplo n.º 5
0
 public abstract void Update(GameTime gameTime, ref Peripherals IoController);
Ejemplo n.º 6
0
 public void Update(Peripherals IoController, float deltaTime)
 {
     Move(IoController, deltaTime);
 }
Ejemplo n.º 7
0
 public void SpriteMoveUpdate(Peripherals PeripheralIO, float deltaTime)
 {
     Move(PeripheralIO, deltaTime);
 }
Ejemplo n.º 8
0
 public void ControllerMoveY(Peripherals PeripheralIO, float deltaTime)
 {
     _CurrentY -= (_CurrentSpeed * PeripheralIO.GetControllerLeftY) * deltaTime;
 }
Ejemplo n.º 9
0
 public void Update(Peripherals IoController, float deltaTime)
 {
     Move(IoController, deltaTime);
     //Add reloading and User action
 }
Ejemplo n.º 10
0
 public SpritePlayerCharacter(List <Texture2D> uptextures, List <Texture2D> downtextures, List <Texture2D> lefttextures, List <Texture2D> righttextures, Vector2 defaultCoordinates, ref Peripherals IoController) :
     base(uptextures, downtextures, lefttextures, righttextures, defaultCoordinates)
 {
     _IsPlayerControlled = true;
 }
Ejemplo n.º 11
0
 public void ControllerMoveY(Peripherals PeripheralIO, float deltaTime)
 {
     _CurrentY -= (_CurrentSpeed * PeripheralIO.GetControllerLeftY) * deltaTime;
     Console.WriteLine("Moving Y");
 }
Ejemplo n.º 12
0
        public override void Update(GameTime gameTime, ref Peripherals IoController)
        {
            if (_NextLevel != null)
            {
                ChangeLevel(_NextLevel);
                _CurrentLevel = _NextLevel;



                _NextLevel = null;
            }

            for (int CollisionTargetIndex = 0; CollisionTargetIndex < _Blocks.Count; CollisionTargetIndex++)
            {
                if (_PlayerCharacter.IntersectsWith(_Blocks[CollisionTargetIndex]))
                {
                    if (_Blocks[CollisionTargetIndex].CurrentY > _PlayerCharacter.CurrentY)
                    {
                        _PlayerCharacter.CurrentY = _PlayerCharacter.CurrentY - 2;
                    }
                    else if (_Blocks[CollisionTargetIndex].Rectangle.Height < _PlayerCharacter.CurrentY)
                    {
                        _PlayerCharacter.CurrentY = _PlayerCharacter.CurrentY + 2;
                    }

                    if (_PlayerCharacter.CurrentX > _Blocks[CollisionTargetIndex].CurrentX)
                    {
                        _PlayerCharacter.CurrentX = _PlayerCharacter.CurrentX + 10;
                    }
                    else if (_PlayerCharacter.CurrentX < _Blocks[CollisionTargetIndex].CurrentX)
                    {
                        _PlayerCharacter.CurrentX = _PlayerCharacter.CurrentX - 10;
                    }
                }
                else
                {
                    Console.WriteLine("No collision");
                }
            }


            _Camera2D.Pos = _PlayerCharacter.CurrentCoordinates;
            _PlayerCharacter.Update(_IoController, 1.0f / 60.0f);


            foreach (SpritePortal portal in _Portals)
            {
                if (_PlayerCharacter.IntersectsWith(portal))
                {
                    _NextLevel = _Levels[portal.LinkedLevelName];
                }
            }


            foreach (IBadGuy badGuy in _badGuys)
            {
                badGuy.UpdatePlayerCharacterCoordinates(_PlayerCharacter.CurrentCoordinates);
            }

            //foreach(SpriteWormKing wormKing in _WormKings)
            //{
            //    //wormKing.Update(1.0f / 60.0f);
            //    wormKing.UpdatePlayerCharacterCoordinates(_PlayerCharacter.CurrentCoordinates);
            //}

            foreach (Sprite sprite in _SpritesWithUpdate)
            {
                sprite.Update(1.0f / 60.0f);
            }
        }