public override void updateTime(float timeSinceLastFrameUpdate) { base.updateTime(timeSinceLastFrameUpdate); BunkerTile bunkerTile = (BunkerTile)levelTile; rotateGun((float)bunkerTile.Angle); }
public void SoldierRegistryTest() { BunkerTile bunker = null; foreach (LevelTile tile in this.level.BunkersList) { bunker = tile as BunkerTile; if (bunker != null) { bunker.Destroy(); } } }
public override void updateTime(float timeSinceLastFrameUpdate) { base.updateTime(timeSinceLastFrameUpdate); BunkerTile bunkerTile = (BunkerTile)levelTile; float yaw = 0; float pitch = bunkerTile.Angle; if (bunkerTile is FlakBunkerTile) { FlakBunkerTile fbt = (bunkerTile as FlakBunkerTile); yaw = fbt.YAngle; if (fbt.Direction == Direction.Left) // jesli dzialko jest w polowie obrotu { pitch = Math.PI - pitch; } } rotateGun(pitch, yaw); if (bunkerTile.UsingReflector) { rotateReflector(bunkerTile.ReflectorAngle); if (bunkerTile.IsIlluminatedShot) { foreach (SceneNode n in reflectorSubNodes) { n.SetScale(54.0f, 1.0f, 14.0f); } } else { foreach (SceneNode n in reflectorSubNodes) { n.SetScale(24.0f, 1.0f, 10.0f); } } if ((bunkerTile.IsDestroyed && reflectorNode != null) && flickeringReflectorWhenDestroyed) { if (Math.RangeRandom(0.0f, 1.0f) > 0.9f) { reflectorNode.SetVisible(false); } if (Math.RangeRandom(0.0f, 1.0f) > 0.9f) { reflectorNode.SetVisible(true); } } } }
public void OnBunkerFire(BunkerTile bunker, Plane plane) { Console.WriteLine(bunker.ToString() + "Samolot: " + plane.ToString()); }
public override void Move(int time) { //Jesli zolnierz zyje. if (IsAlive) { int tileIndex = Mathematics.PositionToIndex(xPos); if (tileIndex != startPosition) { leftBornTile = true; } if (canReEnter && //czy moze wejsc ponownie do bunkra. (tileIndex != startPosition) && //jesli bunkier nie jest rodzicem. IsBunker(tileIndex) && //jesli to jest bunkier. (time % ProbabilityCoefficient == 0)) //losowosc. { BunkerTile bunker = refToLevel.LevelTiles[tileIndex] as BunkerTile; if (bunker.IsDestroyed && bunker.CanReconstruct) { bunker.Reconstruct(); refToLevel.Controller.OnTileRestored(bunker); } if (!bunker.IsDestroyed) { //dodaje zolnierza do bunkra. bunker.AddGeneral(); //wyslam sygnal do controllera aby usunal zolnierza z widoku. refToLevel.Controller.UnregisterSoldier(this); //usuwam zolnierza z planszy. _soldierStatus = SoldierStatus.InBunker; } else { ChangeLocation(time); } } else { ChangeLocation(time); } //sprawdza czy ulynal czas bezsmiertelnosci if (!canDie) { protectedTime += time; if (protectedTime >= TimeUnit) { canDie = true; } } //sprawdza czy ponownie moze wejsc do bunkra. if (!canReEnter) { homelessCounterTime += time; if (homelessCounterTime >= GameConsts.Soldier.HomelessTime) { canReEnter = true; } } } }
public void CreateGrid() { StreamReader sr = new StreamReader(@"Level1.txt"); List <string> stringList = new List <string>(); while (!sr.EndOfStream) { stringList.Add(sr.ReadLine()); } grid = new Tile[GlobalValues.HOLE_LENGTH / GlobalValues.TILE_SIZE, GlobalValues.HOLE_HEIGHT / GlobalValues.TILE_SIZE]; for (int i = 0; i < GlobalValues.HOLE_HEIGHT / GlobalValues.TILE_SIZE; i++) { var line = stringList[i]; for (int k = 0; k < GlobalValues.HOLE_LENGTH / GlobalValues.TILE_SIZE && k < line.Length; k++) { switch (line[k]) { case 'G': grid[k, i] = new GreenTile(TextureLibrary.green, new Vector2(k * GlobalValues.TILE_SIZE, i * GlobalValues.TILE_SIZE)); tiles.Add(grid[k, i]); break; case 'F': grid[k, i] = new FairwayTile(TextureLibrary.fairway, new Vector2(k * GlobalValues.TILE_SIZE, i * GlobalValues.TILE_SIZE)); tiles.Add(grid[k, i]); break; case 'R': grid[k, i] = new RoughTile(TextureLibrary.rough, new Vector2(k * GlobalValues.TILE_SIZE, i * GlobalValues.TILE_SIZE)); tiles.Add(grid[k, i]); break; case 'C': grid[k, i] = new CupTile(TextureLibrary.cup, new Vector2(k * GlobalValues.TILE_SIZE, i * GlobalValues.TILE_SIZE)); tiles.Add(grid[k, i]); break; case 'B': grid[k, i] = new BunkerTile(TextureLibrary.bunker, new Vector2(k * GlobalValues.TILE_SIZE, i * GlobalValues.TILE_SIZE)); tiles.Add(grid[k, i]); break; case 'S': grid[k, i] = new StoneTile(TextureLibrary.stone, new Vector2(k * GlobalValues.TILE_SIZE, i * GlobalValues.TILE_SIZE)); tiles.Add(grid[k, i]); break; case 'W': grid[k, i] = new WaterTile(TextureLibrary.water, new Vector2(k * GlobalValues.TILE_SIZE, i * GlobalValues.TILE_SIZE)); tiles.Add(grid[k, i]); break; case 'M': grid[k, i] = new MudTile(TextureLibrary.mud, new Vector2(k * GlobalValues.TILE_SIZE, i * GlobalValues.TILE_SIZE)); tiles.Add(grid[k, i]); break; case 'P': grid[k, i] = new FlagStickTile(TextureLibrary.flagpost, new Vector2(k * GlobalValues.TILE_SIZE, i * GlobalValues.TILE_SIZE)); tiles.Add(grid[k, i]); break; case 'Q': grid[k, i] = new FlagTile(TextureLibrary.flag, new Vector2(k * GlobalValues.TILE_SIZE, i * GlobalValues.TILE_SIZE)); tiles.Add(grid[k, i]); break; case 'X': ballStartPos = new Vector2(k * GlobalValues.TILE_SIZE, i * GlobalValues.TILE_SIZE); break; } } } }
/// <summary> /// Funkcja zostaje wywolana gdy zolnierz odbudowuje bunkier. /// </summary> /// <param name="restoredBunker">Odbudowany bunkier.</param> public void OnTileRestored(BunkerTile restoredBunker) { AddJob(MethodBase.GetCurrentMethod().Name, new object[] { restoredBunker }); }
/// <summary> /// Funkcja rejestruje strzal do samolotu. /// </summary> /// <param name="bunker">Bunkier ktory strzelil.</param> /// <param name="plane">Samolot gracza.</param> /// <author>Michal Ziober</author> public void OnBunkerFire(BunkerTile bunker, Plane plane, bool planeHit) { AddJob(MethodBase.GetCurrentMethod().Name, new object[] { bunker, plane, planeHit }); }
public void OnBunkerFire(BunkerTile bunker, Plane plane, bool planeHit) { }
public void OnTileRestored(BunkerTile restoredBunker) { }
public void OnBunkerFire(BunkerTile bunker, Plane plane) { }
/// <summary> /// Zmienia pozycje zolnierza. /// </summary> /// <param name="time">Czas od ostatniego ruchu w milisekundach.</param> public virtual void Move(int time) { //Jesli zolnierz zyje. if (IsAlive) { int tileIndex = Mathematics.PositionToIndex(xPos); bool isBunker = IsBunker(tileIndex); if (tileIndex != startPosition) { leftBornTile = true; } if (canReEnter && //czy moze wejsc ponownie do bunkra. (tileIndex != startPosition) && //jesli bunkier nie jest rodzicem. isBunker && //jesli to jest bunkier. (time % ProbabilityCoefficient == 0)) //losowosc. { BunkerTile bunker = refToLevel.LevelTiles[tileIndex] as BunkerTile; if (bunker.IsDestroyed && bunker.CanReconstruct) { bunker.Reconstruct(); refToLevel.Controller.OnTileRestored(bunker); } if (!bunker.IsDestroyed && bunker.CanAddSoldier) { //dodaje zolnierza do bunkra. bunker.AddSoldier(); //wyslam sygnal do controllera aby usunal zolnierza z widoku. refToLevel.Controller.UnregisterSoldier(this); //usuwam zolnierza z planszy. ReturnToBunker(); } else { ChangeLocation(time); } } else { // czy zolnierz moze strzelac? if (!isBunker && canDie && ShouldFire && CanFire) { if (preparingToFireTime == 0) { // zolnierz zaczyna sie przygotowywać refToLevel.Controller.OnSoldierPrepareToFire(this, firePrepareDelay); } preparingToFireTime += time; if (preparingToFireTime >= firePrepareDelay) { Random r = new Random(); // strzal preparingToFireTime = 0; PointD dir = refToLevel.UserPlane.Position - Position; dir.Normalise(); PointD moveVector = GameConsts.Rocket.BaseSpeed * RocketSpeedMultiplier * dir; dir.X *= (moveVector.X >= 0) ? 1.0f : -1.0f; float relative = dir.Angle; lastFireTick = Environment.TickCount; Rocket rocket = Weapon.RocketFire(relative, moveVector, bazookaRotationPerSecond); rocket.MaxDistanceToOwner *= RocketDistanceMultiplier * Mathematics.RangeRandom(0.8f, 1.2f); rocket.MaxHeightDistanceToOwner *= RocketDistanceMultiplier * Mathematics.RangeRandom(0.8f, 1.2f); // zmniejsz zasieg rakiet refToLevel.Controller.OnSoldierEndPrepareToFire(this); } } else if (!isBunker && canDie && CanFire) { // !ShouldFire -> samolot jest poza zasiegiem if (preparingToFireTime > 0) { // wracamy do punktu wyjscia bez strzalu preparingToFireTime = 0; refToLevel.Controller.OnSoldierEndPrepareToFire(this); } else { ChangeLocation(time); } } else { ChangeLocation(time); } } //sprawdza czy ulynal czas bezsmiertelnosci if (!canDie) { protectedTime += time; if (protectedTime >= TimeUnit) { canDie = true; } } //sprawdza czy ponownie moze wejsc do bunkra. if (!canReEnter) { homelessCounterTime += time; if (homelessCounterTime >= GameConsts.Soldier.HomelessTime) { canReEnter = true; } } } }