コード例 #1
0
ファイル: FireBullet.cs プロジェクト: tolpp/XNATowerDefence
 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;
 }
コード例 #2
0
ファイル: IceTower.cs プロジェクト: tolpp/XNATowerDefence
 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);
 }
コード例 #3
0
ファイル: Bullet.cs プロジェクト: tolpp/XNATowerDefence
 public Bullet(IServiceProvider serviceProvider, float damage, Vector2 position, Creep destinationCreep)
     : this(serviceProvider, damage)
 {
     this.position = position;
     this.destinationCreep = destinationCreep;
 }
コード例 #4
0
ファイル: Bullet.cs プロジェクト: tolpp/XNATowerDefence
        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));
        }
コード例 #5
0
ファイル: Bullet.cs プロジェクト: tolpp/XNATowerDefence
 private bool collisionCheck(Creep creep)
 {
     if (distanceToCreep(creep) <= (creep.Width / 2) + (this.Texture.Width / 2))
     {
         this.isAlive = false;
         return true;
     }
     return false;
 }
コード例 #6
0
ファイル: Tower.cs プロジェクト: tolpp/XNATowerDefence
        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;
        }
コード例 #7
0
ファイル: Tower.cs プロジェクト: tolpp/XNATowerDefence
        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;
        }