public void Step(GameState gameState) { Sprite.Update(); if (Sprite.ImageIndex == 1 && !propogated && TTL > 0) { propogated = true; Point[] propogations = new Point[] { new Point(GridPos.X - 1, GridPos.Y), new Point(GridPos.X + 1, GridPos.Y), new Point(GridPos.X, GridPos.Y - 1), new Point(GridPos.X, GridPos.Y + 1) }; List <IEntity> explosions = gameState.Entities.FindAll(x => x is Explosion); foreach (Point check in propogations) { if (gameState.Map.IsGridPosInMap(GridPos)) { bool canPlace = true; foreach (IEntity entity in explosions) { if (entity.GridPos == check && ((Explosion)entity).id == id) { canPlace = false; break; } } if (canPlace) { gameState.AddEntity(new Explosion(id, TTL - 1, check, Owner, gameState)); } } } } }
public static Entity AddToState(this Entity self, GameState state) { state.AddEntity(self); foreach (var child in self.Children) { child.AddToState(state); } return(self); }
public void Destroy(GameState gameState, Player player = null) { TileDestroyed?.Invoke(this, player); Point point = new Point(GridPos.X, GridPos.Y); Explosion explosion = new Explosion(Utility.R.Next(), radius, point, Owner, gameState); gameState.AddEntity(explosion); }
public override void Update() { var message = ""; if (!po.HasBeenFulfilled) { message = "Status:\n" + $"Ag: {po.Resources.OfType<Resource.Silver>().Count()}/{po.Sale.RequestedSilver}\n" + $"Fe: {po.Resources.OfType<Resource.Iron>().Count()}/{po.Sale.RequestedIron}\n" + $"Cu: {po.Resources.OfType<Resource.Copper>().Count()}/{po.Sale.RequestedCopper}\n" + $"Zn: {po.Resources.OfType<Resource.Zinc>().Count()}/{po.Sale.RequestedZinc}\n" + (po.DueInRounds < 0 ? $"Over due!" : $"Due {Math.Abs(po.DueInRounds)}"); } else { message = "This PO has\n" + "been fulfilled!"; } added.ForEach(state.RemoveEntity); added.Clear(); var x = 0; foreach (var part in message.Split('\n')) { var c = Entity.Empty .AddComponent(new Transform { Position = new Vector2(12, 12 + (x * 16)) }) .AddComponent(new TextSprite(SpriteFont("status"), part, color: Color.Black)); Entity.AddChild(c); added.Add(c); state.AddEntity(c); x++; } }