using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using com.deeperbeige.lib;

// Main app
namespace com.deeperbeige.whiteout
{
    public class App
    {
        // Singleton
        private static          App _inst = null;
        public  static          App inst { get { if (_inst == null) { _inst = new App(); _inst.initialise(); } return _inst; } }
        public  void            create() {}
		
		public  string          levelID         = "small";
		public  int             players         = 1;
		public  MeshParams      meshParams      = MeshParams.MEDIUM;

		private Transition      transition;

        // Initialiser
        private void initialise()
        {
			DevPanel.Log(Build.bundleID + " " + Build.version);
			DevPanel.Log("Built: " + Build.datetime);

			// Set up levels
			Levels.Init(1);

			Sounds.Register("countdown-1",    1);
			Sounds.Register("countdown-2",    1);
			Sounds.Register("countdown-3",    1);
			Sounds.Register("countdown-go",    1);
			Sounds.Register("difficulty-easy",    1);
			Sounds.Register("difficulty-hard",    1);
			Sounds.Register("finish",    1);
			Sounds.Register("players-1",    1);
			Sounds.Register("players-2",    1);
			Sounds.Register("players-4",    1);
			Sounds.Register("difficulty-medium",    1);
	        Sounds.Register("ball-rolling",    1);
	        Sounds.Register("splat1",    1);
	        Sounds.Register("splat2",    1);
	        Sounds.Register("splat3",    1);
	        Sounds.Register("splat4",    1);
			Sounds.Register ("menu-select", 1);
			Sounds.Register ("menu-music", 1);
			Sounds.Register ("pause-menu", 1);
			Sounds.Register ("score-ding", 1);
			Sounds.RegisterMusic("in-game",    0.5f, true);
			Sounds.ReportErrors();
			Sounds.AutoRegisterGroup("splat");
			Sounds.Play ("in-game");

			Events.Listen(Events.EVENT_SCENE_CHANGED, CleanUp, false);
		}

		private void CleanUp()
		{
			Resources.UnloadUnusedAssets();
		}
    }
}