コード例 #1
0
 /*TODO: Make lookup table to link MazeTiles enum with corresponding Prefabs*/
 private void InstantiatePooledTile(MazeTiles tileType, GameObject tile, Vector3 position, Quaternion rotation)
 {
     //check to see if we can use a tile with the right mesh from the
     for (int i = 0; i < mazeParent.transform.childCount; i++)
     {
         if (!mazeParent.transform.GetChild(i).gameObject.activeSelf &&
             mazeParent.transform.GetChild(i).GetComponent<GameTile>().MazeTile == tileType)
         {
             mazeParent.transform.GetChild(i).gameObject.SetActive(true);
             mazeParent.transform.GetChild(i).position = position;
             mazeParent.transform.GetChild(i).rotation = rotation;
             return;
         }
     }
     Transform T_newTile = (
         (GameObject)Instantiate(tile, position, rotation, mazeParent.transform)
         ).GetComponent<Transform>();
     T_newTile.GetComponent<GameTile>().MazeTile = tileType;
 }
コード例 #2
0
 private void InstantiateTile(MazeTiles newTile, int rotationMulti, int y, int x)
 {
     switch (newTile)
     {
         case MazeTiles.Deadend:
             InstantiatePooledTile(newTile, deadend, new Vector3(x, 0f, -y) * tileSize, Quaternion.Euler(0f, 90f * rotationMulti, 0f));
             //Instantiate(deadend, new Vector3(x, 0f, -y) * tileSize, Quaternion.Euler(0f, 90f * rotationMulti, 0f), mazeParent);
             break;
         case MazeTiles.Corner:
             InstantiatePooledTile(newTile, corner, new Vector3(x, 0f, -y) * tileSize, Quaternion.Euler(0f, 90f * rotationMulti, 0f));
             break;
         case MazeTiles.Hallway:
             InstantiatePooledTile(newTile, hallway, new Vector3(x, 0f, -y) * tileSize, Quaternion.Euler(0f, 90f * rotationMulti, 0f));
             break;
         case MazeTiles.Juntion:
             InstantiatePooledTile(newTile, junction, new Vector3(x, 0f, -y) * tileSize, Quaternion.Euler(0f, 90f * rotationMulti, 0f));
             break;
         case MazeTiles.Cross:
             InstantiatePooledTile(newTile, cross, new Vector3(x, 0f, -y) * tileSize, Quaternion.Euler(0f, 90f * rotationMulti, 0f));
             break;
         case MazeTiles.NULL:
         default:
             break;
     }
 }
コード例 #3
0
 private static void SetTileForCell(Maze maze, ref MazeTiles newTile, ref int rotationMulti, int y, int x)
 {
     switch (maze.Cells[x, y].Exits)
     {
         #region Deadends
         case Cell.Direction.North:
             newTile = MazeTiles.Deadend;
             rotationMulti = 0;
             break;
         case Cell.Direction.East:
             newTile = MazeTiles.Deadend;
             rotationMulti = 1;
             break;
         case Cell.Direction.South:
             newTile = MazeTiles.Deadend;
             rotationMulti = 2;
             break;
         case Cell.Direction.West:
             newTile = MazeTiles.Deadend;
             rotationMulti = 3;
             break;
         #endregion
         #region Corners
         case Cell.Direction.North | Cell.Direction.East:
             newTile = MazeTiles.Corner;
             rotationMulti = 0;
             break;
         case Cell.Direction.East | Cell.Direction.South:
             newTile = MazeTiles.Corner;
             rotationMulti = 1;
             break;
         case Cell.Direction.South | Cell.Direction.West:
             newTile = MazeTiles.Corner;
             rotationMulti = 2;
             break;
         case Cell.Direction.West | Cell.Direction.North:
             newTile = MazeTiles.Corner;
             rotationMulti = 3;
             break;
         #endregion
         #region Hallways
         case Cell.Direction.North | Cell.Direction.South:
             newTile = MazeTiles.Hallway;
             rotationMulti = 0;
             break;
         case Cell.Direction.East | Cell.Direction.West:
             newTile = MazeTiles.Hallway;
             rotationMulti = 1;
             break;
         #endregion
         #region Junctions
         case Cell.Direction.North | Cell.Direction.East | Cell.Direction.South:
             newTile = MazeTiles.Juntion;
             rotationMulti = 0;
             break;
         case Cell.Direction.East | Cell.Direction.South | Cell.Direction.West:
             newTile = MazeTiles.Juntion;
             rotationMulti = 1;
             break;
         case Cell.Direction.South | Cell.Direction.West | Cell.Direction.North:
             newTile = MazeTiles.Juntion;
             rotationMulti = 2;
             break;
         case Cell.Direction.West | Cell.Direction.North | Cell.Direction.East:
             newTile = MazeTiles.Juntion;
             rotationMulti = 3;
             break;
         #endregion
         #region Crossroads
         case Cell.Direction.ALL:
             newTile = MazeTiles.Cross;
             rotationMulti = 0;
             break;
         #endregion
         case Cell.Direction.NONE:
         default:
             break;
     }
 }