// Use this for initialization
        void Start()
        {
            // Init control
            playerTurn = true;
            playerNum = GameMaster.Instance.Turn;
            die = new Die ();
            die.Reseed (Environment.TickCount);
            damage = 0;

            // Init IDamageable objects
            // Create the enemy
            GameMaster.Instance.CreateEnemy(HostileType.Bandit, "Bandit");

            // Get the enemyID from the list of enemy IDs; since this a 1v1 fight there should only be a single ID
            enemyID = GameMaster.Instance.EnemyIdentifiers[0];

            // Get the enemy entity
            enemyEntity = (Bandit)EntityManager.Instance.GetEntity(enemyID);

            // Set the stats of the enemy
            enemyEntity.AttackPower = die.Roll(1, 9) + 5;
            enemyEntity.DefencePower = die.Roll(1, 9) + 5;

            // Set sprite of enemy
            if(enemyEntity.AttackPower > enemyEntity.DefencePower)
            {
                GameObject.Find ("Battler2Sprite").GetComponent<Image> ().sprite = Resources.Load<Sprite> ("Bandit1");
            } //end if
            else
            {
                GameObject.Find ("Battler2Sprite").GetComponent<Image> ().sprite = Resources.Load<Sprite> ("Bandit2");
            }

            // Set the enemy
            enemy = (IDamageable) enemyEntity;

            // Get the player's merchant
            GameMaster.Instance.LoadPlayers ();
            playerMerchant = (Merchant)GameMaster.Instance.GetPlayerScript(playerNum).Entity;
            playerAttack = playerMerchant.AttackPower;
            playerDefense = playerMerchant.DefencePower;
            GameObject.Find ("Battler1Sprite").GetComponent<Image> ().sprite = playerMerchant.GetSprite (2);

            // Set the player
            player = (IDamageable)playerMerchant;

            // Set background
            if(GameMaster.Instance.BattleMap == BattleMap.area01)
            {
                GameObject.Find("Background").GetComponent<Image>().sprite = Resources.Load<Sprite> ("BattleBackgrounds/Battle_Desert");
            } //end if
            else if(GameMaster.Instance.BattleMap == BattleMap.area02)
            {
                GameObject.Find("Background").GetComponent<Image>().sprite = Resources.Load<Sprite> ("BattleBackgrounds/Battle_Euro");
            } //end else if
            else if(GameMaster.Instance.BattleMap == BattleMap.area03)
            {
                GameObject.Find("Background").GetComponent<Image>().sprite = Resources.Load<Sprite> ("BattleBackgrounds/Battle_Metro");
            } //end if
            else
            {
                GameObject.Find("Background").GetComponent<Image>().sprite = Resources.Load<Sprite> ("BattleBackgrounds/Battle_Snow");
            } //end else

            // Init and set HUD objects
            GameObject.Find("Canvas").transform.Find("PlayerInventory").gameObject.SetActive(false);
            GameObject.Find("Canvas").transform.Find("AllyInventory").gameObject.SetActive(false);
            GameObject.Find("Canvas").transform.Find("Tooltip").gameObject.SetActive(false);
            playerName = GameObject.Find ("Battler1Name").GetComponent<Text> ();
            playerName.text = GameMaster.Instance.GetPlayerName (playerNum);
            enemyName = GameObject.Find ("Battler2Name").GetComponent<Text> ();
            GameObject.Find ("Battler1Attack").GetComponent<Text> ().text = playerMerchant.AttackPower.ToString ();
            GameObject.Find ("Battler2Attack").GetComponent<Text> ().text = enemyEntity.AttackPower.ToString ();
            GameObject.Find ("Battler1Defense").GetComponent<Text> ().text = playerMerchant.DefencePower.ToString ();
            GameObject.Find ("Battler2Defense").GetComponent<Text> ().text = enemyEntity.DefencePower.ToString ();
            playerHealth = GameObject.Find ("Battler1Health").GetComponent<Text> ();
            playerHealth.text = player.Health.ToString ();
            enemyHealth = GameObject.Find ("Battler2Health").GetComponent<Text> ();
            enemyHealth.text = enemy.Health.ToString ();
            playerBar = GameObject.Find ("Battler1HealthLeft").GetComponent<RectTransform> ();
            enemyBar = GameObject.Find ("Battler2HealthLeft").GetComponent<RectTransform> ();
            fightBoxText = GameObject.Find ("FightText").GetComponent<Text> ();

            // Init fight box and flavor
            fightBoxText.text = "The battlers square off!";
            linesOfText = 1;
            verbs = new List<string>();
            verbs.Add ("attacked");
            verbs.Add ("retaliated against");
            verbs.Add ("hammered");
            verbs.Add ("struck");
            verbs.Add ("lashed at");

            // Check if the player is an AI
            if (playerMerchant.GameObj.GetComponent<Player>().IsAI)
            {
                // Disable the fight buttons
                GameObject.Find("AttackButtons/HeadButton").GetComponent<Button>().interactable = false;
                GameObject.Find("AttackButtons/TorsoButton").GetComponent<Button>().interactable = false;
                GameObject.Find("AttackButtons/FeintButton").GetComponent<Button>().interactable = false;
            }
        }
        // Resolves an item when the item MapEvent spawns
        public string ResolveItem(Die die)
        {
            // String to return for display
            string result = string.Empty;

            // Determine what item was found
            int itemType = die.Roll(1, 3);

            // The item to add to the player's inventory
            Item item = null;

            // Switch ove the itemType
            switch (itemType)
            {
                // A weapon item
                case 1:
                    {
                        // Pick an item from the weapons enumeration
                        int itemNumber = die.Roll(1, (int)WeaponType.Size) - 1;

                        // Find the item in the database
                        item = ItemDatabase.Instance.Items.Find(tempItem => tempItem.Type == ((WeaponType)itemNumber).ToString());
                        break;
                    } // end case 1
                // Am armour item
                case 2:
                    {
                        // Pick an item from the armor enumeration
                        int itemNumber = die.Roll(1, (int)ArmorType.Size) - 1;

                        // Find the item in the database
                        item = ItemDatabase.Instance.Items.Find(tempItem => tempItem.Type == ((ArmorType)itemNumber).ToString());
                        break;
                    } // end case 2
                // A bonus item (inventory/weight
                case 3:
                    {
                        // Pick an item from the inventory enumeration
                        int itemNumber = die.Roll(1, (int)BonusType.Size) - 1;

                        // Find the item in the database
                        item = ItemDatabase.Instance.Items.Find(tempItem => tempItem.Type == ((BonusType)itemNumber).ToString());
                        break;
                    } // end case 3
                // An invalid item
                default:
                    {
                        result = "non-existant item. Nothing given.";
                        break;
                    } // end case default
            } // end switch itemType

            if (item != null)
            {
                // Return the resulting item's name
                result = item.Name;

                // Add the item to the player's inventory
                inventory.AddItem(GameMaster.Instance.Turn, item.Id);
            } // end if

            // Set and return the result
            guiResult = "You got \n" + result;
            return guiResult;
        }
        //Calls map event and returns string
        public string DetermineEvent(int playerNum, Die die)
        {
            // Set the player GameObject and its Player script
            player = GameMaster.Instance.GetPlayerObject(playerNum);
            playerScript = GameMaster.Instance.GetPlayerScript(playerNum);

            // Set the Merchant entity for convienience
            playerMerchant = (Merchant)playerScript.Entity;

            // Get the inventory script
            inventory = GameObject.Find("Canvas").transform.Find("Inventory").GetComponent<Inventory>();

            // Get the tile at the player's position
            Vector3 tmp = player.transform.localPosition;

            // Fix the z-axis; change by Damien to get the tiles to work again.
            tmp.z = -0.01f;
            Tile currentTile = TileDictionary.GetTile(TileManager.ToPixels(tmp));

            // Was a tile found?
            if(currentTile == null)
            {
                // No tile found so return "This is not a valid \ntile. No event occured.";
                guiResult = "This is not a valid \ntile. No event occured.";
                return "Nothing";
            } // end if
            // Otherwise, was the tile a non-resource?
            else if (currentTile.ResourceType == ResourceType.None)
            {
                // Roll a die to get a number from 1-100
                if (die == null)
                {
                    Debug.LogError("ME: die is null!");
                }
                int dieResult = die.Roll (1, 100);

                // Check for an enemy
                if(dieResult < enemyChance)
                {
                    return ResolveFight(die);
                } // end if
                // Check for an ally
                else if (dieResult < allyChance + enemyChance && dieResult >= enemyChance)
                {
                    return "Ally";
                } // end else if
                // Check for an item
                else if(dieResult < itemChance + allyChance + enemyChance && dieResult >= allyChance + enemyChance)
                {
                    return ResolveItem(die);
                } // end else if
                else
                {
                    // The MapEvent was nothing
                    guiResult = "No map event occured.";
                    return "Nothing";
                } // end else
            } //end if
            // Otherwise, the tile is a resource
            else
            {
                // Get the resource from the database
                Item temp = ItemDatabase.Instance.Items.Find(resource => resource.Type == currentTile.ResourceType.ToString());

                // Pick up the resource
                playerMerchant.PickupResource((Resource)temp, 1);

                // Declare what was landed on
                guiResult = "You got a resource:\n" + temp.Name;

                // Play found for what was landed on
                if(temp.Name == "Fish")
                {
                    // Play fish sound
                    AudioManager.Instance.PlayFish();
                } // end if
                else if(temp.Name == "Wood")
                {
                    // Play wood sound
                    AudioManager.Instance.PlayWood();
                } // end else if
                else if(temp.Name == "Wool")
                {
                    // Play wool sound
                    AudioManager.Instance.PlayShear();
                } // end else if
                else
                {
                    // Play ore sound
                    AudioManager.Instance.PlayMine();
                } // end else
                return guiResult;
            } // end else
        }
 // NOTE: Hard-coded for now to work with only 1 enemy type; it works for now. :P
 // Resolves a fight when the enemy MapEvent spawns
 public string ResolveFight(Die die)
 {
     GameMaster.Instance.SavePlayers ();
     GameMaster.Instance.SaveResources();
     GameMaster.Instance.LoadLevel ("BattleScene");
     return "Enemy fought";
 }
        // Runs when the object if first instantiated, because this object will occur once through the game,
        // these values are the beginning of game values
        // Note: Values should be updated at the EndTurn State
        void Start()
        {
            // Get the reference to the tile manager
            tileManager = GameObject.Find("TileManager").GetComponent<TileManager>();
            // Generate the map
            tileManager.GenerateMap();

            // Get HUD elements
            CurrentPlayer = GameObject.Find ("Canvas/CurrentPlayer");
            AllPlayers = GameObject.Find("Canvas/AllPlayers");
            BKG = GameObject.Find ("Canvas/Background");
            guiPlayerName = GameObject.Find("CurrentPlayer/PlayerNamePanel/PlayerName").GetComponent<Text>();
            guiTurnText = GameObject.Find("CurrentPlayer/TurnPhasePanel/TurnPhase").GetComponent<Text>();
            guiGold = GameObject.Find("CurrentPlayer/WeightGold/Gold").GetComponent<Text>();
            guiWeight = GameObject.Find("CurrentPlayer/WeightGold/Weight").GetComponent<Text>();
            actionButton = GameObject.Find("CurrentPlayer/ActionButton").GetComponent<Button>();
            actionButtonText = GameObject.Find("CurrentPlayer/ActionButton").GetComponentInChildren<Text>();
            acceptPanel = GameObject.Find("Accept");
            pauseMenu = GameObject.Find ("PauseMenu");
            instructionsSet = GameObject.Find ("Instructions");
            audioSet = GameObject.Find ("Options");
            imageParent = GameObject.Find("AllPlayers/ImageOrganizer");
            textParent = GameObject.Find("AllPlayers/TextOrganizer");
            inventory = GameObject.Find("PlayerInventory").GetComponent<PlayerInventory>();
            allyInventory = GameObject.Find("AllyInventory").GetComponent<AllyInventory>();
            recycleInventory = GameObject.Find("RecycleBin").GetComponent<RecycleBin>();
            allyTable = GameObject.Find("Allies").GetComponent<AllyTable>();
            GameObject.Find ("Canvas").transform.Find ("Instructions").gameObject.SetActive (false);
            HUDToggle = true;
            actionButtonActive = true;
            isPaused = false;
            instructionsProgress = 1;

            // Disable the other panels by default
            acceptPanel.SetActive(false);
            pauseMenu.SetActive (false);
            audioSet.SetActive (false);
            inventory.gameObject.SetActive(false);
            allyInventory.gameObject.SetActive(false);
            recycleInventory.gameObject.SetActive(false);
            allyTable.gameObject.SetActive(false);

            // Running the end stuff defaults to true
            canRunEndStuff = true;

            // The movement class is not initialised
            isMovementInitialized = false;

            // The ally window are closed by default
            isAlliesOpen = false;

            // Get the number of players
            guiNumOfPlayers = GameMaster.Instance.NumPlayers;

            // Set the turn
            guiPlayerTurn = GameMaster.Instance.Turn;

            // Set starting values
            guiDiceDistVal = 0;
            movementCooldown = 0.0f;

            // The player is not an AI by default
            isPlayerAI = false;

            // Create a die
            die = new Die();

            // Get movement and map event components
            guiMovement = GameObject.Find("Canvas").GetComponent<GUIMovement> ();
            guiMapEvent = GameObject.Find("Canvas").GetComponent<MapEvent> ();

            // There isn't a map event in the beginning
            mapEventResultString = string.Empty;

            // Initialise other things after Start() runs
            canInitAfterStart = true;

            // Set the state to the BeginTurn state
            gamePlayState = GamePlayState.BeginTurn;
        }
        //Calls map event and returns string
        public string DetermineEvent(int playerNum, Die die)
        {
            // Set the player GameObject and its Player script
            player = GameMaster.Instance.GetPlayerObject(playerNum);
            playerScript = GameMaster.Instance.GetPlayerScript(playerNum);

            // Set the Merchant entity for convienience
            playerMerchant = (Merchant)playerScript.Entity;

            // Get the inventory script
            inventory = GameObject.Find("Canvas").transform.Find("PlayerInventory").GetComponent<PlayerInventory>();

            // Get the player's position
            Vector3 tmp = player.transform.localPosition;

            // Get the tile manager's reference
            TileManager tileManager = GameObject.Find("TileManager").GetComponent<TileManager>();

            // Get the resource type of the tile
            ResourceType resourceTileType = tileManager.GetResourceType(tmp);
            // Get the market type of the tile
            MarketType marketTileType = tileManager.GetMarketType(tmp);

            // Was the tile type a non-resource and non-market?
            if (resourceTileType == ResourceType.None && marketTileType == MarketType.None)
            {
                // Roll a die to get a number from 1-100
                if (die == null)
                {
                    Debug.LogError("ME: die is null!");
                }
                int dieResult = die.Roll (1, 100);

                // Check for an enemy
                if(dieResult < enemyChance)
                {
                    return ResolveFight(die);
                } // end if
                // Check for an ally
                else if (dieResult < allyChance + enemyChance && dieResult >= enemyChance)
                {
                    return "Ally";
                } // end else if
                // Check for an item
                else if(dieResult < itemChance + allyChance + enemyChance && dieResult >= allyChance + enemyChance)
                {
                    return ResolveItem(die);
                } // end else if
                else
                {
                    // The MapEvent was nothing
                    guiResult = "No map event occured.";
                    return "Nothing";
                } // end else
            } //end if
            // Otherwise, the tile type is a resource or market
            else
            {
                // Check if the tile is not a market
                if (marketTileType == MarketType.None)
                {
                    // Get the resource from the database
                    Item temp = ItemDatabase.Instance.Items.Find(resource => resource.Type == resourceTileType.ToString());

                    // Attempt to pick up the resource
                    if (playerMerchant.PickupResource((Resource)temp, 1))
                    {
                        // Declare what was landed on
                        guiResult = "You got a resource:\n" + temp.Name;
                    } // end if
                    else
                    {
                        // Otherwise, there is no space for the resource or it's too heavy
                        guiResult = "Unable to pickup the \n" + temp.Name;
                    } // end else

                    // Play found for what was landed on
                    if (temp.Name == "Fish")
                    {
                        // Play fish sound
                        AudioManager.Instance.PlayFish();
                    } // end if
                    else if (temp.Name == "Wood")
                    {
                        // Play wood sound
                        AudioManager.Instance.PlayWood();
                    } // end else if
                    else if (temp.Name == "Wool")
                    {
                        // Play wool sound
                        AudioManager.Instance.PlayShear();
                    } // end else if
                    else
                    {
                        // Play ore sound
                        AudioManager.Instance.PlayMine();
                    } // end else

                    return guiResult;
                } // end if
                // Otherwise the tile is a market
                else
                {
                    // Check which type of market the player is one
                    if (marketTileType == MarketType.Market)
                    {
                        // The player landed on regular market
                        return "Market";
                    } // end if
                    else
                    {
                        // The player landed on the end game village
                        return "Village";
                    } // end else
                } // end else
            } // end else
        }
        // Runs when the object if first instantiated, because this object will occur once through the game,
        // these values are the beginning of game values
        // Note: Values should be updated at the EndTurn State
        void Start()
        {
            //TODO: Damien: Replace Tile stuff later
            // Clear the tile dictionary
            TileDictionary.Clean();
            // Set the dimensions and generate/add the tiles
            TileManager.SetDimensions(64, 20, 16);
            TileManager.GenerateAndAddTiles();

            // Get HUD elements
            guiPlayerName = GameObject.Find("CurrentPlayer/PlayerName").GetComponent<Text>();
            guiTurnText = GameObject.Find("CurrentPlayer/TurnPhase").GetComponent<Text>();
            guiGold = GameObject.Find("CurrentPlayer/WeightGold/Gold").GetComponent<Text>();
            guiWeight = GameObject.Find("CurrentPlayer/WeightGold/Weight").GetComponent<Text>();
            actionButton = GameObject.Find("CurrentPlayer/ActionButton").GetComponent<Button>();
            actionButtonText = GameObject.Find("CurrentPlayer/ActionButton").GetComponentInChildren<Text>();
            acceptPanel = GameObject.Find("Accept");
            pauseMenu = GameObject.Find ("PauseMenu");
            imageParent = GameObject.Find("AllPlayers/ImageOrganizer");
            textParent = GameObject.Find("AllPlayers/TextOrganizer");
            inventory = GameObject.Find("Inventory").GetComponent<Inventory>();
            allyTable = GameObject.Find("Allies").GetComponent<AllyTable>();
            GameObject.Find ("Canvas").transform.Find ("Instructions").gameObject.SetActive (false);
            actionButtonActive = true;
            isPaused = false;

            // Disable the accept panel by default
            acceptPanel.SetActive(false);

            // Disable the pause menu by default
            pauseMenu.SetActive (false);

            // Disable the inventory by default
            inventory.gameObject.SetActive(false);

            // Disable the ally window by default
            allyTable.gameObject.SetActive(false);

            // Running the end stuff defaults to true
            canRunEndStuff = true;

            // The inventory is closed by default
            isInventoryOpen = false;

            // The ally window is closed by default
            isAlliesOpen = false;

            // Get the number of players
            guiNumOfPlayers = GameMaster.Instance.NumPlayers;

            // Set the turn
            guiPlayerTurn = GameMaster.Instance.Turn;

            // Set starting values
            guiDiceDistVal = 0;

            // Create a die
            die = new Die();

            // Reseed the random number generator
            die.Reseed(Environment.TickCount);

            // Get movement and map event components
            guiMovement = GameObject.Find("Canvas").GetComponent<GUIMovement> ();
            guiMapEvent = GameObject.Find("Canvas").GetComponent<MapEvent> ();

            // There isn't a map event in the beginning
            mapEventResultString = string.Empty;

            // Initialise other things after Start() runs
            canInitAfterStart = true;

            // Set the state to the BeginTurn state
            gamePlayState = GamePlayState.BeginTurn;
        }
 // Use this for initialization
 void Start()
 {
     // Create a die object.
     m_dice = new Die();
 }