using System;
using System.Collections.Generic;
using System.Text;
using DXGfxLib;

namespace Game
{
    /// <summary>
    /// We use this class to keep track of some global objects or list of objects ! Like entities sometime need to 
    /// query the world for information to take IA decision.
    /// </summary>
    public class World
    {
        private static World globalInstance = null;

        public World()
        {
            if (globalInstance == null)
            {
                globalInstance = this;
            }
            else
            {
                throw new InvalidOperationException("There shouldn't be more than one World per game !");
            }
        }

        public static World GetGlobalInstance()
        {
            if (globalInstance == null)
            {
                globalInstance = new World();
            }

            return globalInstance;
        }

        private OutDoorScene currentOutDoorScene = null;

        public void Attach(OutDoorScene outdoor)
        {
            if (currentOutDoorScene != null)
            {
                throw new InvalidOperationException("At the moment only one outdoorscene per world is supported");
            }

            currentOutDoorScene = outdoor;
        }

        public float TerrainHeigth(float x, float z)
        {
            float res = 0;

            if (currentOutDoorScene != null)
            {
                res = currentOutDoorScene.SceneTerrain.GetHeigth(currentOutDoorScene, x, z);
            }

            return res;
        }

        /// <summary>
        /// These are the public  market prices when you need to by a ressource because you don't exploit it.
        /// </summary>
        public float priceStone = 10.0f;
        public float priceWood = 10.0f;
        public float priceMetal = 10.0f;
    }
}
