Ejemplo n.º 1
0
        // Initialise things sort of like a custom constructor
        public void InitThis(Player player, int travelDistance, bool isAI)
        {
            // Set whether the player is an AI
            isPlayerAI = isAI;

            // Make sure the player isn't AI before enabling the buttons
            if (!isAI)
            {
                // Make sure buttons are enabled
                EnableButtons();
            } // end if

            // Player script
            playerScript = player;

            // Store original position
            origPlayerPosition = player.transform.position;

            // How much can the player move
            initialTravelDist = travelDistance;
            currTravelDist = initialTravelDist;

            // Initialize displacement vector
            displacementVector = Vector3.zero;

            // Generate the initial set of highlight objects
            Highlight.GenerateHighlight(origPlayerPosition, currTravelDist);
        }
Ejemplo n.º 2
0
        //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
        }
Ejemplo n.º 3
0
        // Initialise things sort of like a custom constructor
        public void InitThis(Player player, int travelDistance)
        {
            // Make sure buttons are enabled
            EnableButtons ();

            // Player script
            playerScript = player;

            // Store original position
            origPlayerPosition = player.transform.position;

            // How much can the player move
            initialTravelDist = travelDistance;
            currTravelDist = initialTravelDist;

            // Initialize displacement vector
            displacementVector = Vector3.zero;

            // Generate the initial set of highlight objects
            Highlight.GenerateHighlight(origPlayerPosition, currTravelDist);
        }
Ejemplo n.º 4
0
        //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
        }