示例#1
0
 public override void Update()
 {
     base.Update();
     if (IsActive)
     {
         elapsedTime += Game.DeltaTime;
         RigidBody.SetYVelocity((float)Math.Cos(elapsedTime * 5) * 500);
         if (X + Width / 2 <= 0)
         {
             IsActive = false;
         }
     }
 }
示例#2
0
        public void Input()
        {
            if (IsActive)
            {
                shootCounter -= Game.DeltaTime;

                if (Game.NumJoysticks > 0)
                {
                    Vector2 axis = Game.Window.JoystickAxisLeft(joystickIndex);

                    RigidBody.Velocity = axis * horizontalSpeed;

                    if (shootCounter <= 0 && Game.Window.JoystickA(joystickIndex))
                    {
                        Shoot();
                        shootCounter = shootDelay;
                    }
                    if (Game.Window.JoystickY(joystickIndex))
                    {
                        if (!isZPressed)
                        {
                            ChangeBullets();
                            isZPressed = true;
                        }
                    }
                    else if (isZPressed)
                    {
                        isZPressed = false;
                    }
                }
                else
                {
                    if (Game.Window.GetKey(KeyCode.Right))
                    {
                        RigidBody.SetXVelocity(horizontalSpeed);
                    }
                    else if (Game.Window.GetKey(KeyCode.Left))
                    {
                        RigidBody.SetXVelocity(-horizontalSpeed);
                    }
                    else
                    {
                        RigidBody.SetXVelocity(0);
                    }

                    if (Game.Window.GetKey(KeyCode.Up))
                    {
                        RigidBody.SetYVelocity(-horizontalSpeed);
                    }
                    else if (Game.Window.GetKey(KeyCode.Down))
                    {
                        RigidBody.SetYVelocity(horizontalSpeed);
                    }
                    else
                    {
                        RigidBody.SetYVelocity(0);
                    }

                    if (shootCounter <= 0)
                    {
                        if (Game.Window.GetKey(KeyCode.Space))
                        {
                            Shoot();
                            shootCounter = shootDelay;
                        }
                        else if (Game.Window.GetKey(KeyCode.Z))
                        {
                            if (!isZPressed)
                            {
                                ChangeBullets();
                                isZPressed = true;
                            }
                        }
                        else if (isZPressed)
                        {
                            isZPressed = false;
                        }
                    }
                }
            }
        }
示例#3
0
 public override void Update()
 {
     base.Update();
     time += Game.DeltaTime;
     RigidBody.SetYVelocity((float)Math.Sin(time * 20) * 250);
 }