public Entity(int id, double x, double y, int type, int value, BusterState state) : base(x, y) { Id = id; Value = value; Type = type; State = state; }
public Buster(int id, int type, double x, double y, BusterState state, int value) : base(id, x, y, type, value, state) { StunTimer = 0; }
private static void Main(string[] args) { int bustersPerPlayer = int.Parse(Console.ReadLine()); // the amount of busters you control int ghostCount = int.Parse(Console.ReadLine()); // the amount of ghosts on the map myTeamId = int.Parse(Console.ReadLine()); // if this is 0, your base is on the top left of the map, if it is one, on the bottom right for (int i = BustRangeMax; i < MapWidth; i += BustRangeMax) { for (int j = BustRangeMax; j < MapHeight; j += BustRangeMax) { var state = MapState.Unexplored; if ((i < ReleaseArea && j < ReleaseArea) || (i > MapWidth - ReleaseArea || j > MapWidth - ReleaseArea)) { state = MapState.Base; } else { state = MapState.Unexplored; } var tile = new Entity(-1, i, j, -9, (int)state, BusterState.Idle); tile.Radius = 900; tiles.Add(tile); } } // game loop while (true) { int myCount = 0; int enemyCount = 0; //Console.Error.WriteLine(string.Format("TILES: {0}", string.Join(";",tiles.Select(t=> t.X+","+t.Y).ToArray()))); int entities = int.Parse(Console.ReadLine()); // the number of busters and ghosts visible to you for (int i = 0; i < entities; i++) { string[] inputs = Console.ReadLine().Split(' '); int entityId = int.Parse(inputs[0]); // buster id or ghost id int x = int.Parse(inputs[1]); int y = int.Parse(inputs[2]); // position of this buster / ghost int entityType = int.Parse(inputs[3]); // the team id if it is a buster, -1 if it is a ghost. BusterState state = (BusterState)Enum.Parse(typeof(BusterState), inputs[4]); // For busters: 0=idle, 1=carrying a ghost. int val = int.Parse(inputs[5]); // For busters: Ghost id being carried. For ghosts: number of busters attempting to trap this ghost. if (entityType == -1) { var ghost = activeEntities.OfType <Ghost>().FirstOrDefault(e => e.Id == entityId); if (ghost == null) { ghost = new Ghost(entityId, x, y, entityType, val, state); activeEntities.Add(ghost); } else { ghost.X = x; ghost.Y = y; ghost.Value = val; ghost.State = state; } foreach (var tile in tiles.Where(t => t.Distance(ghost) < t.Radius)) { tile.Value = (int)MapState.Ghost; } } else { var buster = activeEntities.OfType <Buster>().FirstOrDefault(e => e.Id == entityId); if (buster == null) { buster = new Buster(entityId, entityType, x, y, state, val); activeEntities.Add(buster); } else { if (buster.StunTimer > 0) { buster.StunTimer--; } buster.X = x; buster.Y = y; buster.State = state; buster.Value = val; } foreach (var tile in tiles.Where(t => t.Distance(buster) < t.Radius)) { tile.Value = (int)MapState.Buster; } } } var myBusters = activeEntities.OfType <Buster>().Where(b => b.Type == myTeamId); foreach (var buster in myBusters) { Console.Error.WriteLine(string.Format("BusterState: {0} {1}", buster.Id, buster.State)); switch (buster.State) { case BusterState.Carrying: buster.ReturnToBase(); break; case BusterState.Idle: case BusterState.Stunned: buster.Search(); break; case BusterState.Trapping: Console.WriteLine("BUST " + buster.Value); break; } } activeEntities.RemoveAll(e => e.Type == -1); } }
public Ghost(int id, double x, double y, int type, int value, BusterState state) : base(id, x, y, type, value, state) { }