private void OnCollisionEnter2D(Collision2D collision) { //Destroy(gameObject); IProjectileHandler handler = collision.collider.GetComponent <IProjectileHandler>(); //IProjectileHandler handler = collision.gameObject.GetComponent<IProjectileHandler>(); if (handler != null) { handler.OnProjectileHit(this); } }
public MissleTurret(Texture2D upgrade1, Texture2D upgrade2, Texture2D upgrade3, Texture2D bulletTexture, Texture2D platformTexture, int xPos, int yPos, IProjectileHandler handler, List <Enemy> enemies) { this.Textures = new List <Texture2D>() { upgrade1 }; this._bulletTexture = bulletTexture; //Settings this.Name = "MISSLE"; this.Price = 400; this._shootSpeed = 3; this.Upgrade1Price = 200; this.Upgrade2Price = 200; this._shootsAir = true; this._shootsGround = false; this.Damage = Settings.TowerDefenseSettings.TURRET_DAMAGES[2]; this.ShootRate = Settings.TowerDefenseSettings.TURRET_FIRE_RATES[2]; this.Range = Settings.TowerDefenseSettings.TURRET_RANGES[2]; this.UpgradeLevel = 1; this._upgrade1 = upgrade1; this._upgrade2 = upgrade2; this._upgrade3 = upgrade3; this.XPos = xPos; this.YPos = yPos; this._handler = handler; var position = MapGrid.GetPosition(XPos, YPos); _animatedSprite = new AnimatedSprite(new Vector2(1, 1), position, position, 0, 200, Textures, new int[] { 1000 }); this._enemies = enemies; this._platformTexture = platformTexture; }