Esempio n. 1
0
 public FireBullet(IServiceProvider serviceProvider, float damage, Vector2 position, Creep destinationCreep)
     : base(serviceProvider, damage,position,destinationCreep)
 {
     base.position = position;
     base.destinationCreep = destinationCreep;
     base.texture = content.Load<Texture2D>("Bullets/FireBullet");
     base.speed = 4;
 }
Esempio n. 2
0
 public override void shootTheCreep(Creep creep)
 {
     Vector2 towerCenter = new Vector2(this.Position.X + this.Width / 2, this.Position.Y + this.Height / 2);
     Bullet bullet = new IceBullet(serviceProvider, this.Damage, towerCenter, creep);
     AliveBullets.Add(bullet);
 }
Esempio n. 3
0
 public Bullet(IServiceProvider serviceProvider, float damage, Vector2 position, Creep destinationCreep)
     : this(serviceProvider, damage)
 {
     this.position = position;
     this.destinationCreep = destinationCreep;
 }
Esempio n. 4
0
        private double distanceToCreep(Creep creep)
        {
            double creepCenterX = ((double)(destinationCreep.Position.X*2 + destinationCreep.Width)) / 2;
            double creepCenterY = ((double)(destinationCreep.Position.Y*2 + destinationCreep.Height)) / 2;

            double bulletCenterX = ((double)(this.Position.X*2 + this.Texture.Width)) / 2;
            double bulletCenterY = ((double)(this.Position.Y*2 + this.Texture.Height)) / 2;

            return Math.Sqrt((creepCenterX - bulletCenterX) * (creepCenterX - bulletCenterX) + (creepCenterY - bulletCenterY) * (creepCenterY - bulletCenterY));
        }
Esempio n. 5
0
 private bool collisionCheck(Creep creep)
 {
     if (distanceToCreep(creep) <= (creep.Width / 2) + (this.Texture.Width / 2))
     {
         this.isAlive = false;
         return true;
     }
     return false;
 }
Esempio n. 6
0
        private double distanceToCreep(Creep creep)
        {
            double creepCenterX = ((double)(creep.Position.X * 2 + creep.Width)) / 2;
            double creepCenterY = ((double)(creep.Position.Y * 2 + creep.Height)) / 2;

            double towerCenterX = ((double)(this.Position.X * 2 + this.Texture.Width)) / 2;
            double towerCenterY = ((double)(this.Position.Y * 2 + this.Texture.Height)) / 2;

            double distance = Math.Sqrt((creepCenterX - towerCenterX) * (creepCenterX - towerCenterX) + (creepCenterY - towerCenterY) * (creepCenterY - towerCenterY));

            return distance;
        }
Esempio n. 7
0
        public bool isCreepInRange(Creep creep)
        {
            float creepCenterX = ((float)(creep.Position.X + creep.Width)) / 2;
            float creepCenterY = ((float)(creep.Position.Y + creep.Height)) / 2;

            float towerCenterX = ((float)(this.Position.X + this.Width)) / 2;
            float towerCenterY = ((float)(this.Position.Y + this.Height)) / 2;

            if (Math.Sqrt((towerCenterX - creepCenterX) * (towerCenterX - creepCenterX) + (towerCenterY - creepCenterY) * (towerCenterY - creepCenterY)) < this.Range)
            {
                return true;
            }

            return false;
        }