public void CreateGrid(int x, int y) { int l = -1 * (x / 2); for (float i = 0; i < 50 * 15; i += 15) { int h = -1 * (y / 2); for (float j = 0f; j < 50 * 15; j += 15) { Hut NewH = new Hut(this, new Vector2f(i, j), "[ " + l + " ; " + h + " ]", new Vector2i(l, h)); _grid.Add(new Vector2i(l, h), NewH); h++; } l++; } }
internal string NearbyHutOk(Hut hut) { string result = "Empty"; if (_game.GetGrid.ContainsKey(new Vector2i(hut.GetVec2I.X - 1, hut.GetVec2I.Y)) && _game.GetGrid[new Vector2i(hut.GetVec2I.X - 1, hut.GetVec2I.Y)].GetName != "Empty") { result = _game.GetGrid[new Vector2i(hut.GetVec2I.X - 1, hut.GetVec2I.Y)].GetName; } if (_game.GetGrid.ContainsKey(new Vector2i(hut.GetVec2I.X + 1, hut.GetVec2I.Y)) && _game.GetGrid[new Vector2i(hut.GetVec2I.X + 1, hut.GetVec2I.Y)].GetName != "Empty") { if (result != _game.GetGrid[new Vector2i(hut.GetVec2I.X + 1, hut.GetVec2I.Y)].GetName && result != "Empty") { return("Bad"); } else { result = _game.GetGrid[new Vector2i(hut.GetVec2I.X + 1, hut.GetVec2I.Y)].GetName; } } if (_game.GetGrid.ContainsKey(new Vector2i(hut.GetVec2I.X, hut.GetVec2I.Y - 1)) && _game.GetGrid[new Vector2i(hut.GetVec2I.X, hut.GetVec2I.Y - 1)].GetName != "Empty") { if (result != _game.GetGrid[new Vector2i(hut.GetVec2I.X, hut.GetVec2I.Y - 1)].GetName && result != "Empty") { return("Bad"); } else { result = _game.GetGrid[new Vector2i(hut.GetVec2I.X, hut.GetVec2I.Y - 1)].GetName; } } if (_game.GetGrid.ContainsKey(new Vector2i(hut.GetVec2I.X, hut.GetVec2I.Y + 1)) && _game.GetGrid[new Vector2i(hut.GetVec2I.X, hut.GetVec2I.Y + 1)].GetName != "Empty") { if (result != _game.GetGrid[new Vector2i(hut.GetVec2I.X, hut.GetVec2I.Y + 1)].GetName && result != "Empty") { return("Bad"); } else { result = _game.GetGrid[new Vector2i(hut.GetVec2I.X, hut.GetVec2I.Y + 1)].GetName; } } return(result); }