using GiraffeRoller;
using GiraffeRoller.entities;
using GiraffeRoller.ui;
using GiraffeRoller.Utility;
using Otter;

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 * 2;
    public const int MH = 480 * 2;
    public const int GRID_WIDTH = 16;
    public const int GRID_HEIGHT = 16;
    public const int AIRGRID_WIDTH = 16;
    public const int AIRGRID_HEIGHT = 16;

    public static Camera cam = new Camera(0, 0);
    //public static bool PlayerOneHighScoreSet;
    //public static bool PlayerOneHighScoreIsSet;
    //public static bool DoesPlayerHaveCart = true;//testing for now
    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 = 1000;//was 1000 testing!
    public static string PlayerCurrentAnim = "";
    public static long Score = 0;
    public static float PlayerFiredWaterSpeed = 6f;
    public static Speed PlayerFakeSpeed = new Speed(100);
    public static bool StopPlayerCharge = false;
    #endregion
    //Enemy Objects
    public static int BossHealth = 10;//was 10
    public static int WarehouseHealth = 9;//was 9
    public static int PowerHealth = 7;//was 7
    public static int WaterHealth = 6;//was 6
    //things
    public static bool StuckInLoop;

    //Boss
    public static int Boss = 5000;
    public static Speed BossSpeed = new Speed(.5f); //I have no idea what speed this should be...
    public static int NumberOfGiraffesCollected = 0;
    //events
    public static bool EventTwoCanKillPower = false;
    public static bool EventThreeCanKillWarehouse = false;
    public static bool EventFourCanKillBoss = false;
    public static bool TriggerEnd = false;
    //utitlity
    public static bool IsPlayerOneAxisReset;
    public static Music music = new Music(Assets.CRICKETAMBIENCE);
    public static bool IsGamePaused = false;
    //enemies
    public static float wildGiraffeSpeed = .1f;
    public static float troopSpeed = .1f;
    public static float enemyBulletSpeed = 3f;
    public static float rocketSpeed = 6f;

    public static bool IsScreenShake = false;
    public static int Done = 0;
    public static int CameraTimer = 3;
    public static int Drection = Rand.Int(1, 5);
    //private variables
    private static bool _isColor = false;
    private static int _colorChanger = 3;


    public enum Type
    {
        PLAYER,
        SOLID,
        NUMBERS,
        MENUBUBBLE,
        SMALLNUMBERS,
        PRESSKEYNUMBERS,
        PAUSEMENUNUMBERS,
        WILDGIRAFFE,
        RUNNINGWILDGIRAFFE,
        BOSS,
        CHARGINGCOLLIDER,
        POWER,
        WATERTOWER,
        WAREHOUSE,
        GIRAFFESSTOLEN,
        WATERDROP,
        PLAYERHEALTH,
        CONCRETEBLOCK,
        ROCKET
    }

    //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;
        }
    }
}
