using Otter;
using PpbbffttMiningHa.entities;
using PpbbffttMiningHa.ui;
using PpbbffttMiningHa.Utility;

class Global
{
    public static Game GAME = null;
    public static Session PlayerSession;
    public static Session PausePersonSession;
    public static ControllerXbox360 xBoxController;
    public static ControllerXbox360 xBoxController2;
    public static ControllerXbox360 xBoxController3;
    public static ControllerXbox360 xBoxController4;
    public static Session LBD1;
    public static Player player = null;
    public static PausePerson pausePerson = null;

    public const int MW = 720;
    public const int MH = 2000;
    public const int GRID_WIDTH = 8;
    public const int GRID_HEIGHT = 8;

    public static Camera cam = new Camera(0, 0);
    public static bool PlayerOneHighScoreSet;
    public static bool PlayerOneHighScoreIsSet;
    public static string PlayerOneHighScoreName = "";
    public static string PlayerOneOldHighScoreName = "";
    #region player globals
    public static float PlayerX = 0.0f;
    public static float PlayerY = 0.0f;
    public static float PlayerSpeed = 1.0f;//was 3, seems good though.
    public static int PlayerLives = 0;//was 2
    public static int PlayerExtraLifeThreshold = 30000;//starts here. 
    public static int PlayerHealth = 300;
    public static string PlayerCurrentAnim = "";
    public static long Score = 0;
    #endregion
    public static bool IsPlayerOneAxisReset;
    public static Music music;
    public static bool IsGamePaused;

    public static bool IsScreenShake;
    public static int Done = 0;
    public static int CameraTimer = 3;
    public static int Drection = Rand.Int(1, 5);
    //private variables
    private static bool _isColor;
    private static int _colorChanger = 3;
    internal static float dirtSpeed = 3f;
    internal static float AlligatorSpeed = 4f;
    internal static float PrairieDogSpeed = 5f;
    internal static float GhostSpeed = 6f;
    internal static int AlligatorHealth = 10;
    internal static int PrairieDogHealth = 20;
    internal static int GhostHealth = 30;
    internal static int DirtInHand = 0;
    internal static int GemsInHand = 0;
    internal static bool HasKey = false;
    internal static int TotalGemsCollected = 0;
    internal static bool HasTreasure = false;

    public enum Type
    {
        PLAYER,
        SOLID,
        MENUBUBBLE,
        PAUSEMENUNUMBERS,
        PRESSKEYNUMBERS,
        NUMBERS,
        SMALLNUMBERS,
        BOMB,
        EXPLOSION,
        FLYINGDIRT,
        BOTTOMROCK,
        ALLIGATOR,
        DEADALLIGATOR,
        GEM,
        DOOR,
        DOORKEY,
        PLAYERHEALTH,
        DEADPRAIRIEDOG,
        PRAIRIEDOG,
        DEADGHOST,
        GHOST
    }

    //extra functions that are useful
    public static void ColorChanger(Entity _flash, Color _firstColor, Color _secondColor, int rateOfChange = 3)
    {
        if (_colorChanger <= 0)
        {
            if (_isColor)
                _isColor = false;
            else
                _isColor = true;
            _colorChanger = rateOfChange;
        }
        if (_isColor)
            _flash.Graphic.Color = _firstColor;
        else
            _flash.Graphic.Color = _secondColor;

        if (_colorChanger > 0)
            _colorChanger--;
    }
    public static void WriteWord(float x, float y, string word, Color color, float scale, int layer, Scene scene, int destructionTimer,
    int spacer = 15)
    {
        var a = 0;
        for (var i = 0; i < word.Length; i++)
        {
            scene.Add(new MovingNumbers(x + a, y, word[i].ToString(), color, scale, layer, destructionTimer));
            a += spacer;
        }
    }
    public static void WriteWordUI(float x, float y, string word, Color color, float scale, int layer, Scene scene, int destructionTimer, int spacer = 15)
    {
        var a = 0;
        for (var i = 0; i < word.Length; i++)
        {
            scene.Add(new NumbersUI(x + a, y, word[i].ToString(), color, scale, layer, destructionTimer));
            a += spacer;
        }
    }
}
