/// <summary> /// Spawns a certain Number of Ships /// </summary> public void SpawnShips() { sSelectShipList = new List <AShip>(); sAllShipList = new List <AShip>(); mAttackingShipList = new List <IBattleObject>(); mDefendingShipList = new List <IBattleObject>(); mRepairingShipList = new List <AShip>(); mEnteringShipList = new List <BattleShip>(); //instanziation FlagShip testShip = new FlagShip(new Vector2(20, 20)); BattleShip testBattleShip = new BattleShip(new Vector2(300, 100)); BattleShip testBattleShip2 = new BattleShip(new Vector2(550, 900)); FisherShip testFisherShip = new FisherShip(new Vector2(550, 700)); TradingShip testTradingShip = new TradingShip(new Vector2(100, 1000)); //initialization testBattleShip.Initialize(); testBattleShip2.Initialize(); testShip.Initialize(); testFisherShip.Initialize(); testTradingShip.Initialize(); //Owned testBattleShip.Owned = true; //add to List sAllShipList.Add(testShip); sAllShipList.Add(testBattleShip); sAllShipList.Add(testBattleShip2); sAllShipList.Add(testFisherShip); sAllShipList.Add(testTradingShip); //testing behaviour //testBattleShip2.Defend(mPathFinder.CalculatePath(testBattleShip2.Position, new Vector2(100, 150), true)); testTradingShip.Defend(mPathFinder.CalculatePath(testTradingShip.Position, new Vector2(100, 100), true));//4700, 1400 mDefendingShipList.Add(testTradingShip); //mDefendingShipList.Add(testBattleShip2); //testing repairing testBattleShip.Hp = 80; //testing QuadTree: mShipsQuadTree = new QuadTree(0, new Rectangle(0, 0, 5760, 5760));//testmap size is 1000*1000 }
public void Update(QuadTree quadTree) { if (mLightningactivated) { // damage a ship if its too close to a storm. FisherShip dummyShip = new FisherShip(new Vector2(mStormRegion.X + (mStormRegion.Width / 2), mStormRegion.Y + (mStormRegion.Height / 2))); var possibleCollisions = new List <AShip>(); quadTree.Retrieve(possibleCollisions, dummyShip); if (possibleCollisions.Count > 0) { foreach (var pCShip in possibleCollisions) { if (mStormRegion.Contains(pCShip.Position) && mCounter >= 500 && pCShip.Owned) { var lightning = new Lightning(mAnim, pCShip.Position - new Vector2(0, 75)); MapScreen.mSmallThingsManager.AddThing(lightning); if (pCShip.Owned) { SoundManager.PlayEfx("efx/ambience/Storm/rain_thunder"); } pCShip.Hp -= 1; mCounter = 0; } if (mStormRegion.Contains(pCShip.Position) && mCounter < 500) { mCounter += 1; } } } if (mLightningCounter >= mNewLightning) { var lightning = new Lightning(mAnim, new Vector2(mGenerator.Next(mStormRegion.X + 75, mStormRegion.X + mStormRegion.Width - 75), mGenerator.Next(mStormRegion.Y + 75, mStormRegion.Y + mStormRegion.Height - 75))); MapScreen.mSmallThingsManager.AddThing(lightning); mLightningCounter = 0; mNewLightning = mGenerator.Next(10, 100); mTimeToLive -= 1; if (mTimeToLive < 0) { SoundManager.Stop("efx/ambience/Storm/rain_thunder"); mDestroyed = true; EnvironmentManager.mStormNumber -= 1; Despawn(); if (mCheckCloud.mDespawnComplete) { foreach (var cloud in mStormClouds) { cloud.KillCloud(); } } } } else { mLightningCounter += 1; } } else { if (mCheckCloud.mFadingCompleted) { mLightningactivated = true; } } }
public void Update(QuadTree quadTree) { // repeat the vortexanimation if (mVortexAnim.IsDestroyed && !mDestroyed) { mVortexAnim = new VortexAnim(mAnim, mVortexRegion1.Location.ToVector2()); mVortexAnim2 = new VortexAnim(mAnim, mVortexRegion2.Location.ToVector2()); MapScreen.mSmallThingsManager.AddThing(mVortexAnim); MapScreen.mSmallThingsManager.AddThing(mVortexAnim2); } // damage a ship if its too close to a storm. FisherShip dummyShip1 = new FisherShip(new Vector2(mVortexRegion1.X, mVortexRegion1.Y)); var possibleCollisions1 = new List <AShip>(); quadTree.Retrieve(possibleCollisions1, dummyShip1); FisherShip dummyShip2 = new FisherShip(new Vector2(mVortexRegion1.X, mVortexRegion1.Y)); var possibleCollisions2 = new List <AShip>(); quadTree.Retrieve(possibleCollisions2, dummyShip2); if (possibleCollisions1.Count > 0 || possibleCollisions2.Count > 0) { foreach (var pCShip in possibleCollisions1) { if (mVortexRegion1.Contains(pCShip.Position) && pCShip.Owned && !mCoolDown) { SoundManager.PlayEfx("efx/warp"); pCShip.Position = mVortexRegion2.Location.ToVector2(); pCShip.Moving = false; /* * if (pCShip is FlagShip) * { * Game1.mMapScreen.mMapCamera.Position = (mVortexRegion2.Location.ToVector2() - new Vector2(60, 20)); * } */ mCoolDown = true; } if (mVortexRegion2.Contains(pCShip.Position) && pCShip.Owned && !mCoolDown) { SoundManager.PlayEfx("efx/warp"); pCShip.Position = mVortexRegion1.Location.ToVector2(); pCShip.Moving = false; /* * if (pCShip is FlagShip) * { * Game1.mMapScreen.mMapCamera.Position = (mVortexRegion1.Location.ToVector2() - * new Vector2(60, 20)); * } */ mCoolDown = true; } } } // cooldown for disallowing multiple teleportations if (mCoolDown) { if (mCoolDownCounter < 300) { mCoolDownCounter += 1; } else { mCoolDownCounter = 0; mCoolDown = false; } } mTimeToLive -= 1; if (mTimeToLive < 0) { mDestroyed = true; EnvironmentManager.mVortexNumber -= 1; mVortexAnim.KillVortex(); mVortexAnim2.KillVortex(); } }