private static void placeSpiders() { Random r = new Random(); spiders = new List<MySpiderNode>(); while (spiderCount > 0) { int xl = r.Next() % gridSize; int yl = r.Next() % gridSize; MySpiderNode s; if (grid[xl, yl].IsWall) { if (r.Next() % 3 == 0) { grid[xl, yl].IsSpider = "big"; grid[xl, yl].IsWall = false; s = new MySpiderNode() { X = xl, Y = yl, IsDead = false }; s.setType = MySpiderNode.IsType.Big; spiders.Add(s); } else if (r.Next() % 3 == 1) { grid[xl, yl].IsSpider = "medium"; grid[xl, yl].IsWall = false; s = new MySpiderNode() { X = xl, Y = yl, IsDead = false }; s.setType = MySpiderNode.IsType.Medium; spiders.Add(s); } else if (r.Next() % 3 == 2) { grid[xl, yl].IsSpider = "small"; grid[xl, yl].IsWall = false; s = new MySpiderNode() { X = xl, Y = yl, IsDead = false }; s.setType = MySpiderNode.IsType.Small; spiders.Add(s); } spiderCount--; } } }
private static bool isThesusSafe(MyPathNode thesus, MySpiderNode spider) { if ((Math.Abs(spider.X - thesus.X) + Math.Abs(spider.Y - thesus.Y)) <= 2) { return false; } return true; }