Beispiel #1
0
        public void GetControl(GameTime gameTime, ref Vector2 position, ref Vector2 velocity, ref BulletFactory bf)
        {
            timer.Update(gameTime, Parameters.GameSpeed);


            position += velocity * (float)gameTime.ElapsedGameTime.TotalSeconds * Parameters.GameSpeed;

            if (target.NowHp() > target.GetHp() / 2)
            {
                if (position.X < 0 || position.X > Screen.GameWidth)
                {
                    velocity.X = -velocity.X;
                }
            }

            else if (target.NowHp() <= target.GetHp() / 2)
            {
                //Vector2 velo2 = Vector2.Subtract(destination, position);
                //fireTimer.Update(gameTime);
                if (position != destination)
                {
                    position += velocity * (float)gameTime.ElapsedGameTime.TotalSeconds * Parameters.GameSpeed;
                }

                if (position.X < 0 || position.X > Screen.GameWidth)
                {
                    velocity.X = -velocity.X;
                }
            }

            position.X = MathHelper.Clamp(position.X, 0, Screen.GameWidth);
            position.Y = MathHelper.Clamp(position.Y, 0, Screen.GameHeight);

            if (timer.IsTime())
            {
                if (target.NowHp() > target.GetHp() / 2)
                {
                    timer.Initialize();
                    direction = new Vector2(((float)Math.Cos(angle * (Math.PI / 180))) - (float)Math.Sin(angle * (Math.PI / 180)), ((float)Math.Sin(angle * (Math.PI / 180))) + (float)Math.Cos(angle * (Math.PI / 180)));
                    bf.Fire(direction * 70);
                    angle += 12;
                }
                else if (target.NowHp() <= target.GetHp() / 2)
                {
                    timer.Initialize();
                    bf.Fire(new Vector2(0, 1) * 150);
                }
            }
        }
Beispiel #2
0
        public void GetControl(GameTime gameTime, ref Vector2 position, ref Vector2 velocity, ref BulletFactory bf)
        {
            Vector2 velo2 = Vector2.Subtract(destination, position);

            fireTimer.Update(gameTime, Parameters.GameSpeed);
            if (position != destination)
            {
                position += velo2 * (float)gameTime.ElapsedGameTime.TotalSeconds * Parameters.GameSpeed;
            }

            if (position.X < 0 || position.X > Screen.GameWidth)
            {
                velocity.X = -velocity.X;
            }

            position.X = MathHelper.Clamp(position.X, 0, Screen.GameWidth);

            if (fireTimer.IsTime())
            {
                fireTimer.Initialize();
                direction = new Vector2(((float)Math.Cos(angle * (Math.PI / 180))) - (float)Math.Sin(angle * (Math.PI / 180)), ((float)Math.Sin(angle * (Math.PI / 180))) + (float)Math.Cos(angle * (Math.PI / 180)));
                bf.Fire(direction * 70);
                angle += 12;
            }
        }
Beispiel #3
0
        public void GetControl(GameTime gameTime, ref Vector2 position, ref Vector2 velocity, ref BulletFactory bf)
        {
            fireTimer.Update(gameTime, Parameters.GameSpeed);
            moveTimer.Update(gameTime, Parameters.GameSpeed);

            position += velocity * (float)gameTime.ElapsedGameTime.TotalSeconds * new Vector2(2, 1) * Parameters.GameSpeed;

            if (moveTimer.IsTime())
            {
                velocity.X = -velocity.X;
                moveTimer.Initialize();
            }
            if (position.X < 0 || position.X > Screen.GameWidth)
            {
                velocity.X = -velocity.X;
                moveTimer.Initialize();
            }
            position.X = MathHelper.Clamp(position.X, 0, Screen.GameWidth);

            if (fireTimer.IsTime())
            {
                fireTimer.Initialize();
                bf.Fire(new Vector2(0, 1) * 180);
            }
        }
Beispiel #4
0
 public void GetDeathControl(GameTime gameTime, ref Vector2 position, ref Vector2 velocity, ref BulletFactory bf)
 {
     if (!deathFire)
     {
         for (int i = 0; i < 12; i++)
         {
             bf.Fire(fireDirection * 200);
             fireDirection = Vector2.Transform(fireDirection, rotation);
         }
         deathFire = true;
     }
 }
Beispiel #5
0
        public void GetControl(GameTime gameTime, ref Vector2 position, ref Vector2 velocity, ref BulletFactory bf)
        {
            fireTimer.Update(gameTime, Parameters.GameSpeed);

            velocity  = input.Velocity() * player.MoveSpeed;
            position += velocity * (float)gameTime.ElapsedGameTime.TotalSeconds * Parameters.GameSpeed;

            position = Vector2.Clamp(position, Vector2.Zero, new Vector2(Screen.GameWidth, Screen.GameHeight));

            if (input.CheckDownKey(Keys.Space, Buttons.RightTrigger) && fireTimer.IsTime())
            {
                bf.Fire(fireDirection * 1000);
                fireTimer.Initialize();
                ShootingGame.GetGameDevice().GetSound().PlaySE("shot");
            }
        }
Beispiel #6
0
        public void GetControl(GameTime gameTime, ref Vector2 position, ref Vector2 velocity, ref BulletFactory bf)
        {
            Vector2 velo2 = Vector2.Subtract(destination, position);

            fireTimer.Update(gameTime, Parameters.GameSpeed);
            if (isFire)
            {
                waitFire.Update(gameTime);
            }
            if (isGetDestination && waitFire.IsTime())
            {
                position += new Vector2(0, -5) * Parameters.GameSpeed;
            }
            if (position != destination && isGetDestination == false)
            {
                position += velo2 * (float)gameTime.ElapsedGameTime.TotalSeconds * Parameters.GameSpeed;
            }
            if (Vector2.Distance(position, destination) <= 50)
            {
                isGetDestination = true;
            }

            if (position.X < 0 || position.X > Screen.GameWidth)
            {
                velocity.X = -velocity.X;
            }

            position.X = MathHelper.Clamp(position.X, 0, Screen.GameWidth);

            if (isGetDestination && fireTimer.IsTime() && isFire == false)
            {
                bf.Fire(new Vector2(0, 1) * 180);
                fireTimer.Initialize();
                isFire = true;
            }
        }