public GameBoardViewResolver(IEventSystem eventSystem, IEntityDatabase entityDatabase, IUnityInstantiator instantiator, FloorTiles floorTiles, OuterWallTiles outerWallTiles) : base(eventSystem, entityDatabase, instantiator) { _floorTiles = floorTiles; _outerWallTiles = outerWallTiles; }
public GameBoardViewResolver(IEventSystem eventSystem, IEntityCollectionManager collectionManager, IUnityInstantiator instantiator, FloorTiles floorTiles, OuterWallTiles outerWallTiles) : base(eventSystem, collectionManager, instantiator) { _floorTiles = floorTiles; _outerWallTiles = outerWallTiles; }
// SPAWN TILES () public void SpawnTile() { if (FloorTiles.Count == 0 || TunnelTiles.Count == 0) { CreateTiles(10); // We need 10 tiles of both to make sure that the player thinks it's an endless path. } int randomIndex = Random.Range(0, 2); // Random Index if (randomIndex == 0 && currentTile != null) { GameObject temp = FloorTiles.Pop(); // Pop it out of the stack, into the Game World. temp.SetActive(true); // Make visible temp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(0).position; // Set position equal to the last tiles' first child: "AttachPoint" currentTile = temp; // set current tile equal to our new object } else if (randomIndex == 1 && currentTile != null) { GameObject temp = TunnelTiles.Pop(); temp.SetActive(true); temp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(0).position; currentTile = temp; } else // STARTING TILE { currentTile = tilePrefabs[1]; // Set tunnel as start tile. GameObject temp = TunnelTiles.Pop(); temp.SetActive(true); temp.transform.position = startPosition; // Set the position equal to pathspawners position currentTile = temp; } }
public void SelectTile(FloorTiles tile) { if (selectedTile == tile) { DeselectTile(); return; } selectedTile = tile; unitToCreate = null; }
// CREATE TILES () public void CreateTiles(int num) // Instantiate tiles in the stack.. { for (int i = 0; i < num; i++) { FloorTiles.Push(Instantiate(tilePrefabs[0])); TunnelTiles.Push(Instantiate(tilePrefabs[1])); // Using Peek to talk with the last added tile in the stack and set it inactive.. (non-visible) FloorTiles.Peek().SetActive(false); TunnelTiles.Peek().SetActive(false); } }
public void AddRoom(IFloorRoom room, Location origin) { var placedRoom = room.Shift(origin); FloorRooms.Add(placedRoom); foreach (var tile in placedRoom.FloorTiles) { if (tile.X < Width && tile.Y < Height) { var oldTile = GetFloorTile(tile.X, tile.Y); if (oldTile != null) { FloorTiles.Remove(oldTile); } FloorTiles.Add(tile); } } }
// Generates the level from a multi-dimensional array public void CreateBoard(char[,] map) { MAX_ROW = map.GetLength(0); MAX_COL = map.GetLength(1); Node.Walls = new HashSet <Location>(); Node.Pits = new HashSet <Location>(); for (int i = 0; i < MAX_ROW; i++) { for (int j = 0; j < MAX_COL; j++) { Location loc = new Location(i, j); char symbol = map[i, j]; GameObject tile; tile = Instantiate(tilePrefab, loc.ToVector(), Quaternion.identity); tile.transform.SetParent(TileHolder.transform); TileProperties tileProperties = tile.GetComponent <TileProperties>(); if (symbol == '+') { Node.Walls.Add(loc); tileProperties.Type = Item.Wall; } else if (symbol == '-') { Node.Pits.Add(loc); tileProperties.Type = Item.Pit; } else { tileProperties.Type = Item.Floor; FloorTiles.Add(loc, tile); } if (char.ToLower(symbol) >= 'a' && char.ToLower(symbol) <= 'z') { char lwrSymbol = char.ToLower(symbol); if (!Rooms.ContainsKey(lwrSymbol)) { Rooms.Add(lwrSymbol, new Room(lwrSymbol)); } Rooms[lwrSymbol].UnexploredTiles.Add(loc); Util.SetColor(FloorTiles[loc], Color.gray); } else if (symbol == '0') { Cat = new CatAgent(symbol, loc); } else if (symbol >= '1' && symbol <= '9') { Children.Add(symbol, new ChildAgent(symbol, loc)); } else if (symbol == '&') { Obstacles[loc] = new Obstacle(loc); GameObject prefab = objectPrefabs[0]; GameObject go; go = Instantiate(prefab, loc.ToVector(), Quaternion.identity); go.transform.SetParent(ObjectHolder.transform); ObjectPieces.Add(loc, go); } if (symbol >= 'A' && symbol <= 'Z') { Foods[loc] = new Food(loc); GameObject go; go = Instantiate(foodPrefab, loc.ToVector(), Quaternion.identity); go.transform.SetParent(ObjectHolder.transform); ObjectPieces.Add(loc, go); } } } foreach (Room r in Rooms.Values) { foreach (Location loc in r.UnexploredTiles) { HashSet <Location> neighbors = new HashSet <Location>() { new Location(loc.Row + 1, loc.Col), new Location(loc.Row - 1, loc.Col), new Location(loc.Row, loc.Col + 1), new Location(loc.Row, loc.Col - 1) }; foreach (Location neighbor in neighbors) { if (!Node.Walls.Contains(neighbor) && !Obstacles.ContainsKey(neighbor) && !r.UnexploredTiles.Contains(neighbor)) { r.Entrances.Add(loc); } } } } }
private void Start() { floor = FindObjectOfType <FloorTiles>(); dancers = FindObjectOfType <Dancers>(); dancers.Add(this); }
public GameBoardViewResolver(IViewHandler viewHandler, FloorTiles floorTiles, OuterWallTiles wallTiles) : base(viewHandler) { _floorTiles = floorTiles; _outerWallTiles = wallTiles; }
public ITile GetFloorTile(int x, int y) { return(FloorTiles.SingleOrDefault(t => x >= 0 && y >= 0 && t.X == x && t.Y == y)); }
public void DeselectTile() { selectedTile = null; }