Beispiel #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.001f, Accel.Y);
                Status = IDStatus.MARIO_RUN;
            }

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

            if (_Input.KeyPressed(Keys.Up) && m_IsJumping == false && !m_IsDisableUp && Status != IDStatus.MARIO_ATTACK)
            {
                Status = IDStatus.MARIO_JUMP;
                m_IsJumping = true;
                Velocity = new Vector2(Velocity.X, -0.35f);
                if (IDObject == IDObject.SMALL_MARIO)
                {
                    SoundManager.PlaySound(ESound.SFX_JUMP_SMALL);
                }
                if (IDObject == IDObject.FIRE_MARIO|| IDObject == IDObject.SUPER_MARIO)
                {
                    SoundManager.PlaySound(ESound.SFX_JUMP_BIG);
                }
            }

            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;
            }

            Damping(_Input);
        }
Beispiel #2
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;
             }
         }
     }
 }