Esempio n. 1
0
 public void SetDimension(RectInt bounds)
 {
     if (!bounds.Equals(null))
     {
         dimensions = bounds;
     }
 }
        private void Update()
        {
            if (IsInitialized)
            {
                RectInt windowRect = ZApplicationWindow.Rect;

                // Update the viewport's position and size based on the
                // current position and size of the application window.
                Viewport.Rect = windowRect;

                // Get the current display based on the center position
                // of the application window.
                if (!windowRect.Equals(this._previousWindowRect))
                {
                    CurrentDisplay = Context.DisplayManager.GetDisplay(
                        (int)windowRect.center.x, (int)windowRect.center.y);
                }

                // Update the SDK's context.
                Context.Update();

                this._previousWindowRect = windowRect;
            }

            this.UpdateScreenMetrics();
        }
        // Method that returns the room at each leaf by traversing the binary tree recursively.
        RectInt GetRoom()
        {
            if (!room.Equals(new RectInt(0, 0, 0, 0)))
            {
                return(room);
            }
            else
            {
                RectInt room1 = new RectInt(0, 0, 0, 0);
                RectInt room2 = new RectInt(0, 0, 0, 0);
                if (this.child1 != null)
                {
                    room1 = child1.GetRoom();
                }

                if (this.child2 != null)
                {
                    room2 = child2.GetRoom();
                }

                if (!room1.Equals(new RectInt(0, 0, 0, 0)) || !room2.Equals(new RectInt(0, 0, 0, 0)))
                {
                    return(new RectInt(0, 0, 0, 0));
                }
                else if (!room2.Equals(new RectInt(0, 0, 0, 0)))
                {
                    return(room1);
                }
                else if (!room1.Equals(new RectInt(0, 0, 0, 0)))
                {
                    return(room2);
                }
                else
                {
                    if (Random.Range(0, 100) < 50)
                    {
                        return(room1);
                    }
                    else
                    {
                        return(room2);
                    }
                }
            }
        }
Esempio n. 4
0
    // Spikes have a chance on spawning in every room (except for the starting room)
    void SpawnSpikes()
    {
        // For each vertex/room
        foreach (Vertex vertex in vertices)
        {
            RectInt tempRoom = mapData.FindRoom(vertex);
            bool    bossRoom = tempRoom.Equals(mapData.FindRoom(mapData.end));

            // If not the starting room where the player spawns
            if (!tempRoom.Equals(mapData.FindRoom(mapData.start)))
            {
                // Double for loop to loop through each tile in a room
                for (int x = tempRoom.xMin + 1; x <= tempRoom.xMax - 1; x++)
                {
                    for (int y = tempRoom.yMin + 2; y <= tempRoom.yMax - 3; y++)
                    {
                        if (bossRoom)
                        {
                            // If inside a boss room, do not spawn spikes if it is too close to the center (where the boss will spawn)
                            if (!(x <= tempRoom.center.x + 2 && x >= tempRoom.center.x - 2 && y <= tempRoom.center.y + 2 && y >= tempRoom.center.y - 2))
                            {
                                // 3% chance of having a spike spawn on a tile
                                if (Random.Range(0, 100) < 3)
                                {
                                    spikeGrid.SetTile(new Vector3Int(x, y, 0), spike);
                                }
                            }
                        }
                        else
                        {
                            // 2% chance of having a spike spawn on a tile
                            if (Random.Range(0, 100) < 2)
                            {
                                spikeGrid.SetTile(new Vector3Int(x, y, 0), spike);
                            }
                        }
                    }
                }
            }
        }
    }
Esempio n. 5
0
 // Health/one heart has an increasing chance of spawning the closer we get to the boss room (the further away we get from the spawn/start room)
 void SpawnHealth()
 {
     // For each room
     for (int i = 0; i < distancesArr.Length; i++)
     {
         RectInt roomBounds = mapData.FindRoom(verticesArr[i]);
         // If the room is not a boss room, there is a chance to spawn a heart piece
         if (!roomBounds.Equals(mapData.FindRoom(mapData.end)))
         {
             if (Random.Range(0, 100) < 10)
             {
                 Instantiate(health, new Vector3(Random.Range(roomBounds.xMin + 2, roomBounds.xMax - 2) + 0.125f, Random.Range(roomBounds.yMin + 2, roomBounds.yMax - 4) + 0.1875f), Quaternion.identity);
             }
         }
     }
 }