Example #1
0
 private void CreateAttribute(IntPair position, Tile tile)
 {
     if (tile.HasAttribute(Type.ENGING_POINT))
     {
         CreateEndingAttribute(position);
     }
     if (tile.HasAttribute(Type.ENEMY_SPAWNING_POINT))
     {
         CreateEnemy(position);
     }
 }
Example #2
0
        private Tile CreateOrUpdateTileIn(IntPair position, Dictionary<IntPair, Tile> allTiles)
        {
            Tile tile;
            allTiles.TryGetValue(position, out tile);
            if (tile == null)
            {
                tile = new Tile();
                allTiles.Add(position, tile);
            }

            foreach (Direction direction in Utils.GetAllDirections())
            {
                IntPair neighbourPosition = position.Move(direction);
                Tile neighbour;
                allTiles.TryGetValue(neighbourPosition, out neighbour);
                if (neighbour != null)
                {
                    tile.BindNeighbours(neighbour, direction);
                }
            }
            return tile;
        }
Example #3
0
 private void CreateGameObject(GameObject what, IntPair where, float y)
 {
     Vector3 gameObjectPosition = new Vector3(where.x, y, where.y) + transform.position;
     GameObject gameObjectInstance = Instantiate(what, gameObjectPosition, Quaternion.identity) as GameObject;
     gameObjectInstance.transform.parent = boardHolder.transform;
 }
Example #4
0
 private void CreateFloor(IntPair position)
 {
     CreateGameObject(prefabHolder.floor, position, 0.0f);
 }
Example #5
0
 private void CreateEnemy(IntPair position)
 {
     CreateGameObject(prefabHolder.enemy, position, 0.0f);
 }
Example #6
0
 private void CreateEndingAttribute(IntPair position)
 {
     CreateGameObject(prefabHolder.endingPoint, position, 0.5f);
 }
Example #7
0
 private void CreateCeiling(IntPair position)
 {
     CreateGameObject(prefabHolder.ceiling, position, 2.0f);
 }
Example #8
0
 private void CreateWalls(IntPair position, Tile tile)
 {
     foreach (Direction direciton in Model.Utils.GetAllDirections())
     {
         if (tile.GetNeighbour(direciton) == null)
         {
             CreateWall(position.Move(direciton));
         }
     }
 }
Example #9
0
 private void CreateWall(IntPair position)
 {
     CreateGameObject(prefabHolder.wall, position, 1.0f);
 }
Example #10
0
 public bool Equals(IntPair other)
 {
     return this == other;
 }
Example #11
0
 public IntPair(IntPair other)
 {
     this.x = other.x;
     this.y = other.y;
 }
Example #12
0
 public Room(IntRange widthRange, IntRange heightRange)
 {
     this.size = new IntPair(widthRange.Random, heightRange.Random);
 }
Example #13
0
 // Assumes position is in top-left corner of room
 private IntPair MovePositionToBorderOfRoomInGivenDirection(IntPair position, Room room, Direction direction)
 {
     int offset;
     // TODO: Add some randomized factor so that rooms are not linked always from top-left corner
     switch (direction)
     {
         case Direction.EAST:
             offset = room.size.x - 1;
             break;
         case Direction.NORTH:
             offset = room.size.y - 1;
             break;
         default:
             offset = 0;
             break;
     }
     return position.Move(direction, offset);
 }
Example #14
0
        // Assumes positon is at the end of the corridor
        private IntPair MovePositionFromCorridorBeginningToBottomLeftEndRoom(IntPair position, Corridor corridor)
        {
            int offset;
            switch (corridor.direction)
            {
                case Direction.WEST:
                    offset = corridor.exitRoom.size.x;
                    break;
                case Direction.SOUTH:
                    offset = corridor.exitRoom.size.y;
                    break;
                default:
                    offset = 1;
                    break;
            }

            return position.Move(corridor.direction, offset);
        }
Example #15
0
        private void GenerateTilesForRoom(Room room, IntPair topLeftCorner, Dictionary<IntPair, Tile> allTiles)
        {
            // Start filling up tiles from top left corner using width/height
            int width = room.size.x;
            int height = room.size.y;
            Tile tile;

            for (int i = 0; i < width; ++i)
            {
                for (int j = 0; j < height; ++j)
                {
                    tile = CreateOrUpdateTileIn(new IntPair(i + topLeftCorner.x, j + topLeftCorner.y), allTiles);
                    if (UnityEngine.Random.Range(0.0f, 100.0f) <= enemyDensity)
                    {
                        tile.AddAttribute(new global::Map.Model.TileAttribute.EnemySpawningPoint());
                    }
                }
            }
        }
Example #16
0
 // Assumes position is at end of starting room
 // Returns the position where the corridor ends
 private IntPair GenerateTilesForCorridor(Corridor corridor, IntPair position, Dictionary<IntPair, Tile> allTiles)
 {
     for (int i = 0; i < corridor.length; ++i)
     {
         position = position.Move(corridor.direction);
         CreateOrUpdateTileIn(position, allTiles);
     }
     return position;
 }