public override void Fire() { if (ammo.Value != 0) { bomb = new Bomb(mSceneMgr); bomb.SetPosition(GunPosition() + 50 * GunDirection()); MainClass.AddToList(bomb); ammo.Decrease(1); } }
///// <summary> // If the gun has ammo spawns a new Bomb and sets its position. -1 ammo ///// </summary> public override Projectile Fire() { if (ammo.Value >= 0) //check whether ammo.Value is zero { projectile = new Bomb(mSceneMgr, GunDirection()); //if it isn't create a new projectile of the correct type for the gun int spawnDistanceFromCannon = 25; projectile.SetPosition(/*-*/ GunPosition() + -spawnDistanceFromCannon * GunDirection() + 10); ammo.Decrease(1); //decrease ammo by 1 using the Decrease function return(projectile); } else { return(null); } }
/// <summary> /// This method generate a new bomb in the list /// </summary> private void AddBomb() { Bomb bomb = new Bomb(mSceneMgr); bomb.SetPosition(new Vector3(Mogre.Math.RangeRandom(0, 100), 100, Mogre.Math.RangeRandom(0, 100))); bombs.Add(bomb); }