예제 #1
0
        private void themeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (themeComboBox.SelectedIndex)
            {
            case 0:
            {
                roomTheme = RoomTheme.Industrial;
            }
            break;

            case 1:
            {
                roomTheme = RoomTheme.Medical;
            }
            break;

            case 2:
            {
                roomTheme = RoomTheme.Study;
            }
            break;

            case 3:
            {
                roomTheme = RoomTheme.General;
            }
            break;
            }
        }
    /// <summary>
    /// Request a RoomData object of the desired theme, type, and level of difficulty for use in generation
    /// </summary>
    /// <param name="theme">Room Theme (i.e. space, cave, etc)</param>
    /// <param name="type">Room Type (i.e. top open, bottom sealed, etc)</param>
    /// <param name="desiredDifficulty">Room Difficulty Level (currently not implemented)</param>
    /// <returns></returns>
    public RoomData GetRoomData(RoomTheme theme, RoomType type, float desiredDifficulty)
    {
        RoomData         roomData  = new RoomData();
        List <TextAsset> roomFiles = new List <TextAsset>();

        //Load all rooms of the desired theme from the Unity resources path (works at runtime even when serialised)
        TextAsset[] fileInfoArray = Resources.LoadAll <TextAsset>(GetPath() + theme.ToString());

        //Get a list of all rooms in this theme that match the desired type
        foreach (TextAsset file in fileInfoArray)
        {
            if (file.name.Contains(type.ToString()))
            {
                roomFiles.Add(file);
            }
        }

        //Choose a random room from the potential matches
        int randomRoomIndex = Random.Range(0, roomFiles.Count);

        roomData.tileData = ParseTileDataFromCSVFile(roomFiles[randomRoomIndex]);

        //Unload the resources from memory and return the chosen room
        Resources.UnloadUnusedAssets();
        return(roomData);
    }
예제 #3
0
        public void Load(ref ContentManager content, Vector2 roomDimensions,
                         RoomTheme theme, RoomType type, string backgroundFile)
        {
            //  The level dimensions of the level to work out the zoom and shell scale.
            this.roomDimensions = new Point((int)roomDimensions.X, (int)roomDimensions.Y);

            #region If Level Rotates
            //  If the level is rotating, we want to load a background to the level,
            //  the containing shell and scale it properly to the level.
            if (type == RoomType.Rotating)
            {
                this._levelBackground = content.Load <Texture2D>(backgroundFile);

                switch (theme)
                {
                case RoomTheme.General:
                    this._roomShell = content.Load <Texture2D>("Assets/Images/Textures/RoomSetup/RingWood");
                    break;

                case RoomTheme.Industrial:
                    this._roomShell = content.Load <Texture2D>("Assets/Images/Textures/RoomSetup/RingWood");
                    break;

                case RoomTheme.Medical:
                    this._roomShell = content.Load <Texture2D>("Assets/Images/Textures/RoomSetup/RingWood");
                    break;

                case RoomTheme.Study:
                    this._roomShell = content.Load <Texture2D>("Assets/Images/Textures/RoomSetup/RingWood");
                    break;
                }

                //  The width of the ring multiplied by 2 (one per side)
                float shellWidth    = 30 * 2;
                float levelDiameter = Camera.Instance.GetLevelDiameter();
                this._shellScale = levelDiameter / (_roomShell.Width - shellWidth);
            }
            #endregion
        }