示例#1
0
        private void AttackUpdate(float deltaTime)
        {
            mAttackTimer.Update(deltaTime);
            if (mAttackTimer.IsTime())
            {
                mAttackTimer.Initialize();
                int min = 0;
                int max = 0;
                if (mCurrentDir == Direction.Right)
                {
                    min = 0;
                    max = 2;
                }
                else
                {
                    min = -1;
                    max = 1;
                }

                if (mHitPoint <= mMaxHitPoint / 2)
                {
                    if (mCurrentDir == Direction.Right)
                    {
                        min = 0;
                        max = 3;
                    }
                    else
                    {
                        min = -2;
                        max = 1;
                    }
                }

                for (int i = min; i < max; i++)
                {
                    for (int j = -1; j < 2; j++)
                    {
                        new BossAttack("boss", new Vector2(64, 64), mOrigin, new Vector2(i, j));
                    }
                }
                GameDevice.Instance().GetSound().PlaySE("shotSE");
                mAttackState = AttackState.Stay;
            }
            else
            {
                mVelocity.X = GameDevice.Instance().GetRandom().Next(-1, 2) * mSpeed;
            }
        }
示例#2
0
        private void StayUpdate(float deltaTime)
        {
            mStayTimer.Update(deltaTime);
            mVelocity.X = 0;

            if (ObjectManager.Instance().GetPlayer() != null)
            {
                float playerDir = ObjectManager.Instance().GetPlayer().GetOrigin().X - mOrigin.X;
                if (playerDir > 0)
                {
                    mCurrentDir = Direction.Right;
                }
                else
                {
                    mCurrentDir = Direction.Left;
                }
            }

            if (mCurrentDir == Direction.Left)
            {
                mName = "boss_left";
            }
            if (mCurrentDir == Direction.Right)
            {
                mName = "boss_right";
            }

            if (mStayTimer.IsTime())
            {
                mStayTimer.Initialize();
                if (ObjectManager.Instance().GetPlayer() != null)
                {
                    if (Vector2.Distance(ObjectManager.Instance().GetPlayer().GetOrigin(), mOrigin) >= Screen.WIDTH / 3)
                    {
                        mAttackState = (AttackState)GameDevice.Instance().GetRandom().Next((int)AttackState.Dash, (int)AttackState.Jump + 1);
                        //mAttackState = AttackState.Dash;
                    }
                    else
                    {
                        mAttackState = (AttackState)GameDevice.Instance().GetRandom().Next((int)AttackState.Jump, (int)AttackState.Attack + 1);
                    }
                }
            }
        }
示例#3
0
        private void WeakAttack(float deltaTime)
        {
            if (Input.GetKeyTrigger(Keys.Z) && mAttackState == AttackState.None)
            {
                GameDevice.Instance().GetSound().PlaySE("shotSE");
                new PlayerWeakAttack("sikaku", new Vector2(32, 32), mOrigin, (int)mCurrentDir, new CountDownTimer(0.1f));
                mAttackState = AttackState.WeakAttack;
            }

            if (mAttackState == AttackState.WeakAttack)
            {
                mVelocity = Vector2.Zero;
                mWeakAttackTimer.Update(deltaTime);
                if (mWeakAttackTimer.IsTime())
                {
                    mWeakAttackTimer.Initialize();
                    mAttackState = AttackState.None;
                }
            }
        }
示例#4
0
        private void JumpUpdate(float deltaTime)
        {
            mJumpTimer.Update(deltaTime);
            if (mJumpTimer.Rate() <= 0.1f)
            {
                mVelocity.Y = -mJumpPower;
                if (mHitPoint <= mMaxHitPoint / 2)
                {
                    mVelocity.Y = -mJumpPower * 1.2f;
                }
            }
            mVelocity.X = ((int)mCurrentDir - 2) * mSpeed;
            if (mHitPoint <= mMaxHitPoint / 2)
            {
                mVelocity.X = ((int)mCurrentDir - 2) * mSpeed * 1.2f;
            }

            if (mJumpTimer.IsTime())
            {
                mJumpTimer.Initialize();
                mAttackState = AttackState.Stay;
            }
        }