Exemple #1
0
        /// <summary>
        /// Phân tích tín hiệu input để xử lý status cho Mario
        /// </summary>
        /// <param name="_Input"></param>
        /// <returns></returns>
        private void AnalysisInput(CInput _Input)
        {
            if (_Input.KeyDown(Keys.Right) && Status != IDStatus.MARIO_JUMP && !m_IsDisableRight)
            {
                Direction = IDDir.RIGHT;
                Accel     = new Vector2(0.01f, Accel.Y);
                Status    = IDStatus.MARIO_RUN;
            }

            if (_Input.KeyDown(Keys.Left) && Status != IDStatus.MARIO_JUMP && !m_IsDisableLeft)
            {
                Direction = IDDir.LEFT;
                Accel     = new Vector2(-0.01f, Accel.Y);
                Status    = IDStatus.MARIO_RUN;
            }

            if (_Input.KeyPressed(Keys.Up) && Status != IDStatus.MARIO_JUMP && !m_IsDisableUp)
            {
                Status   = IDStatus.MARIO_JUMP;
                Velocity = new Vector2(Velocity.X, -0.35f);
                if (IDObject == IDObject.SMALL_MARIO)
                {
                    CResourceManager.GetInstance().GetSoundEffect(IDResource.SFX_JUMP_SMALL).Play();
                }
                if (IDObject == IDObject.FIRE_MARIO || IDObject == IDObject.SUPER_MARIO)
                {
                    CResourceManager.GetInstance().GetSoundEffect(IDResource.SFX_JUMP_BIG).Play();
                }
            }

            if (_Input.KeyDown(Keys.Down) && Status != IDStatus.MARIO_JUMP && !m_IsDisableDown)
            {
                //Velocity = Vector2.Zero;
                Accel = new Vector2(0, Accel.Y);
                //Status = IDStatus.MARIO_RUN;
                Status = IDStatus.MARIO_DOWN;
            }

            if (_Input.KeyPressed(Keys.Z) && IDObject == IDObject.FIRE_MARIO)
            {
                AddBullet();
                if (Sprite.Animation.CurFrame != 5)
                {
                    Sprite.Animation.CurFrame = 5;
                    Sprite.Animation.SetLocalAnimation();
                }
                Status = IDStatus.MARIO_ATTACK;
            }

            Damping(_Input);
        }
Exemple #2
0
 public override void HandleInput(GameTime gameTime, CInput _Input)
 {
     if (_Input.KeyPressed(Keys.Back))
     {
         StateManager.getInst().ExitScreen();
         StateManager.getInst().AddScreen(new MenuState(IDGameState.MENU));
     }
     base.HandleInput(gameTime, _Input);
 }
Exemple #3
0
 /// <summary>
 /// Hãm vận tốc của Mario khi công còn nhận input
 /// </summary>
 /// <param name="_Input"></param>
 /// <returns></returns>
 private void Damping(CInput _Input)
 {
     if (!_Input.KeyDown(Keys.Left) && !_Input.KeyDown(Keys.Right))
     {
         Accel      = new Vector2(0, Accel.Y);
         m_Velocity = new Vector2(m_Velocity.X - m_Velocity.X * 0.1f, m_Velocity.Y);
         if (Math.Abs(m_Velocity.X) <= 0.001f)
         {
             m_Velocity = new Vector2(0.0f, m_Velocity.Y);
             if (!_Input.KeyDown(Keys.Up) && !_Input.KeyPressed(Keys.Z) && !_Input.KeyDown(Keys.Down) && Status != IDStatus.TELEPORT)
             {
                 Status = IDStatus.MARIO_STAND;
             }
         }
     }
 }
Exemple #4
0
 public override void HandleInput(GameTime gameTime, CInput _Input)
 {
     CoolDown += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
     if (CoolDown > 2000)
     {
         CoolDown = 0;
         StateManager.getInst().ExitScreen();
         StateManager.getInst().AddScreen(new MainGame(IDGameState.MAINGAME));
     }
     GlobalValue.IS_LOCK_KEYBOARD = false;
     if (_Input.KeyPressed(Keys.Delete))
     {
         GlobalValue.MARIO_LIFE++;
     }
     base.HandleInput(gameTime, _Input);
 }
Exemple #5
0
        public override void HandleInput(GameTime gameTime, CInput _Input)
        {
            #region Move icon
            if (CResourceManager.GetInstance().GetResource(IDResource.ICON).Position.Y >= 125 &&
                CResourceManager.GetInstance().GetResource(IDResource.ICON).Position.Y <= 150)
            {
                if (_Input.KeyPressed(Microsoft.Xna.Framework.Input.Keys.Down))
                {
                    SoundManager.PlaySound(ESound.SFX_COIN);
                    if (CResourceManager.GetInstance().GetResource(IDResource.ICON).Position.Y == 150)
                    {
                        if (CResourceManager.GetInstance().GetResource(IDResource.ICON).Position.X == 85)
                        {
                            CResourceManager.GetInstance().GetResource(IDResource.ICON).Position = new Vector2(85, 125);
                        }
                        else
                        {
                            CResourceManager.GetInstance().GetResource(IDResource.ICON).Position = new Vector2(195, 125);
                        }
                    }
                    else
                    {
                        CResourceManager.GetInstance().GetResource(IDResource.ICON).Position =
                            new Vector2(CResourceManager.GetInstance().GetResource(IDResource.ICON).Position.X,
                                        CResourceManager.GetInstance().GetResource(IDResource.ICON).Position.Y + 25);
                    }
                }

                if (_Input.KeyPressed(Microsoft.Xna.Framework.Input.Keys.Up))
                {
                    SoundManager.PlaySound(ESound.SFX_COIN);
                    if (CResourceManager.GetInstance().GetResource(IDResource.ICON).Position.Y == 125)
                    {
                        if (CResourceManager.GetInstance().GetResource(IDResource.ICON).Position.X == 85)
                        {
                            CResourceManager.GetInstance().GetResource(IDResource.ICON).Position = new Vector2(85, 150);
                        }
                        else
                        {
                            CResourceManager.GetInstance().GetResource(IDResource.ICON).Position = new Vector2(195, 150);
                        }
                    }
                    else
                    {
                        CResourceManager.GetInstance().GetResource(IDResource.ICON).Position =
                            new Vector2(CResourceManager.GetInstance().GetResource(IDResource.ICON).Position.X,
                                        CResourceManager.GetInstance().GetResource(IDResource.ICON).Position.Y - 25);
                    }
                }

                if (_Input.KeyPressed(Microsoft.Xna.Framework.Input.Keys.Right))
                {
                    SoundManager.PlaySound(ESound.SFX_COIN);
                    if (CResourceManager.GetInstance().GetResource(IDResource.ICON).Position.X == 85)
                    {
                        CResourceManager.GetInstance().GetResource(IDResource.ICON).Position = new Vector2(195, CResourceManager.GetInstance().GetResource(IDResource.ICON).Position.Y);
                    }
                    else
                    {
                        CResourceManager.GetInstance().GetResource(IDResource.ICON).Position = new Vector2(85, CResourceManager.GetInstance().GetResource(IDResource.ICON).Position.Y);
                    }
                }

                if (_Input.KeyPressed(Microsoft.Xna.Framework.Input.Keys.Left))
                {
                    SoundManager.PlaySound(ESound.SFX_COIN);
                    if (CResourceManager.GetInstance().GetResource(IDResource.ICON).Position.X == 85)
                    {
                        CResourceManager.GetInstance().GetResource(IDResource.ICON).Position = new Vector2(195, CResourceManager.GetInstance().GetResource(IDResource.ICON).Position.Y);
                    }
                    else
                    {
                        CResourceManager.GetInstance().GetResource(IDResource.ICON).Position = new Vector2(85, CResourceManager.GetInstance().GetResource(IDResource.ICON).Position.Y);
                    }
                }
            }
            #endregion
            #region Btn stattuts
            Vector2 Temp = CResourceManager.GetInstance().GetResource(IDResource.ICON).Position;

            if (Temp == new Vector2(85, 125))
            {
                ListButtons[0].Focus = true;
            }
            else
            {
                ListButtons[0].Focus = false;
            }

            if (Temp == new Vector2(85, 150))
            {
                ListButtons[1].Focus = true;
            }
            else
            {
                ListButtons[1].Focus = false;
            }

            if (Temp == new Vector2(195, 125))
            {
                ListButtons[2].Focus = true;
            }
            else
            {
                ListButtons[2].Focus = false;
            }

            if (Temp == new Vector2(195, 150))
            {
                ListButtons[3].Focus = true;
            }
            else
            {
                ListButtons[3].Focus = false;
            }
            #endregion

            #region ChangeState
            if (_Input.KeyPressed(Microsoft.Xna.Framework.Input.Keys.Space) ||
                _Input.KeyPressed(Microsoft.Xna.Framework.Input.Keys.Enter))
            {
                if (ListButtons[0].Focus == true)
                {
                    GlobalValue.MARIO_LIFE  = 3;
                    GlobalValue.MARIO_SCORE = 0;
                    GlobalValue.MARIO_COIN  = 0;
                    StateManager.getInst().ExitScreen();
                    StateManager.getInst().AddScreen(new LoadGame(IDGameState.LOAD));
                }

                if (ListButtons[1].Focus == true)
                {
                    StateManager.getInst().ExitScreen();
                    StateManager.getInst().AddScreen(new OptionState(IDGameState.OPTION));
                }
                if (ListButtons[2].Focus == true)
                {
                    StateManager.getInst().ExitScreen();
                    StateManager.getInst().AddScreen(new AboutState(IDGameState.ABOUT));
                }
                if (ListButtons[3].Focus == true)
                {
                    StateManager.getInst().ClearAllScreen();
                    GlobalSetting.IsExit = !GlobalSetting.IsExit;
                }
            }
            #endregion
            base.HandleInput(gameTime, _Input);
        }