コード例 #1
0
ファイル: Slot.cs プロジェクト: brentspector/TheTraveler-sr
        // Use this for initialization
        void Start()
        {
            // Get the Inventory component reference
            inventory = GameObject.Find("Inventory").GetComponent<Inventory>();

            // Get the Image component reference
            itemIcon = gameObject.transform.GetChild(0).GetComponent<Image>();
        }
コード例 #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
        }
コード例 #3
0
        // 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;
        }