예제 #1
0
 // inChaseZone sees if the player is in the kill zone
 // if so it takes approproate action
 public bool inChaseZone(Player p)
 {
     float distance = Math.Abs(Vector2.Distance(this.WorldOrigin, p.CentrePos));
         if (distance <= chaseRdaius)
             return true;
         return false;
 }
예제 #2
0
 public ChaseAndFire(Game g)
 {
     myEnemy = new ChasingEnemy(g,
         g.Content.Load<Texture2D>("Dragon_strip3"),
         new Vector2(40, 40), 3);
     //Sprite _site = new Sprite(g,g.Content.Load<Texture2D>("fireball_strip4"),Vector2.Zero,4);
     debug = g.Content.Load<SpriteFont>("debug");
     debugPrint.On = true;
     Sprite _explosion = new Sprite(g,g.Content.Load<Texture2D>("explosion_strip8"),Vector2.Zero,8);
     rocket _rocket = new rocket(g, g.Content.Load<Texture2D>("fireball_strip4"), _explosion, Vector2.Zero, 4);
     p = new Player(g, g.Content.Load<Texture2D>("wizard_strip3"), new Vector2(400, 400), 3);
     p.loadRocket(_rocket);
 }
예제 #3
0
        // folow a player if the player comes in the kill zone
        public void follow(Player p)
        {
            if (inChaseZone(p) )
            {
                Vector2 direction = p.position - this.position;
                direction.Normalize();
                angleOfRotation = (float)Math.Atan2(direction.Y, direction.X);

                if (direction.X > 0)
                    directionEffect = SpriteEffects.FlipHorizontally;
                else directionEffect = SpriteEffects.None;

                this.position += direction * Velocity;
            }
        }