using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public class GameSettings : MonoBehaviour
{
    public static GameSettings settings;

    public FadedRoom fadedRoomPrefab;

    /// <summary>
    /// How quickly the room rotates in response to moment- if it helps the player
    /// </summary>
    public float rotationSpeed = 0.5f;

    /// <summary>
    /// How quickly we disbalance
    /// </summary>
    public float disbalanceSpeed = 0.1f;

    public float difficultyRamp = 0.3f;
    
    /// <summary>
    /// How long to wait between the creation of rooms
    /// </summary>
    public float roomCreationPeriod = 20;

    /// <summary>
    /// How wide is a room?
    /// </summary>
    public float roomWidth = 3;

    public float roomWidthBuffer = 0.05f;

    public float roomHeightBuffer = 0.05f;

    public float roomFurnitureWidth = 2.5f;

    /// <summary>
    /// The percentage of room distance to offset each floor.
    /// </summary>
    public float roomPlacementOffset = 0.25f;

    public float previousLevelMultiplier = 0.5f;

    /// <summary>
    /// The level we win at when we reach
    /// </summary>
    public int winLevel = 5;

    /// <summary>
    /// If we have a single room, how much will we have to wait before the next appears?
    /// </summary>
    public float singleRoomTimeMultiplier = 0.5f;

    /// <summary>
    /// How high is a room?
    /// </summary>
    public float roomHeight = 2;

    /// <summary>
    /// If an item of special furniture is chosen (immovable or auto-moving), a check will be made to determine whether it is confirmed
    /// </summary>
    public int percentageCheckForSpecialFurniture = 10;

    public string backTag = "Back";

    /// <summary>
    /// Room blueprints
    /// </summary>
    public List<RoomBlueprint> blueprints;

    public RoomBlueprint GetRandomBlueprint(int level)
    {
        return blueprints.Where(s => s.levels.Any(l => l == level))
               .OrderBy(r => Random.Range(0, 100))
               .First();
    }

    public GameObject emptyRoomPrefab;

    private void Awake()
    {
        settings = this;
    }
}
