Exemplo n.º 1
0
        }         //end OnGUI()

        private void GUIMovementPads()
        {
            int width      = 32;
            int height     = 32;
            int gridXShift = -8;
            int gridYShift = -8;

            //Button color
            GUI.backgroundColor = Color.red;
            if (m_currTravelDist > 0)
            {
                //left
                if (GUI.Button(new Rect((Screen.width - (3 * width) + gridXShift), (Screen.height - (2 * height) + gridYShift), width, height), "<"))
                {
                    m_displacementVector = m_MovementScript.MoveLeft(m_PlayerEntity.transform.position); //uncomment this and comment above when Brents Movement class is ready
                    m_playerCharacterScript.Face(GSP.Char.Character.FacingDirection.WEST);               // Face the character to the west which is to the left.
                    MovePlayer();
                    Highlight.ClearHightlight();                                                         // Clear the highlight objects.
                    Highlight.GenerateHighlight(m_PlayerEntity.transform.position, m_currTravelDist);    // Recreate the highlights with the new values.
                    audioSrc.audio.PlayOneShot(GSP.AudioReference.sfxWalking);                           //Play walking sound
                }
                //right
                if (GUI.Button(new Rect((Screen.width - (1 * width) + gridXShift), (Screen.height - (2 * height) + gridYShift), width, height), ">"))
                {
                    m_displacementVector = m_MovementScript.MoveRight(m_PlayerEntity.transform.position); //uncomment this and comment above when Brents Movement class is ready
                    m_playerCharacterScript.Face(GSP.Char.Character.FacingDirection.EAST);                // Face the character to the east which is to the right.
                    MovePlayer();
                    Highlight.ClearHightlight();                                                          // Clear the highlight objects.
                    Highlight.GenerateHighlight(m_PlayerEntity.transform.position, m_currTravelDist);     // Recreate the highlights with the new values.
                    audioSrc.audio.PlayOneShot(GSP.AudioReference.sfxWalking);                            //Play walking sound
                }
                //cancel
                if (GUI.Button(new Rect((Screen.width - (2 * width) + gridXShift), (Screen.height - (2 * height) + gridYShift), width, height), "X"))
                {
                    m_playerCharacterScript.Face(GSP.Char.Character.FacingDirection.SOUTH);                       // Face the character to the south which is to the left. This is the default facing.
                    //MOVE BACK TO ORIG POSITION
                    CancelMove();
                    Highlight.ClearHightlight();                                         // Clear the highlight objects.
                    Highlight.GenerateHighlight(m_origPlayerPosition, m_currTravelDist); // Recreate the highlights with the new values.
                    audioSrc.audio.PlayOneShot(GSP.AudioReference.sfxWalking);           //Play walking sound
                }
                //up
                if (GUI.Button(new Rect((Screen.width - (2 * width) + gridXShift), (Screen.height - (3 * height) + gridYShift), width, height), "^"))
                {
                    m_displacementVector = m_MovementScript.MoveUp(m_PlayerEntity.transform.position); //uncomment this and comment above when Brents Movement class is ready
                    m_playerCharacterScript.Face(GSP.Char.Character.FacingDirection.NORTH);            // Face the character to the north which is up.
                    MovePlayer();
                    Highlight.ClearHightlight();                                                       // Clear the highlight objects.
                    Highlight.GenerateHighlight(m_PlayerEntity.transform.position, m_currTravelDist);  // Recreate the highlights with the new values.
                    audioSrc.audio.PlayOneShot(GSP.AudioReference.sfxWalking);                         //Play walking sound
                }
                //down
                if (GUI.Button(new Rect((Screen.width - (2 * width) + gridXShift), (Screen.height - (1 * height) + gridYShift), width, height), "v"))
                {
                    m_displacementVector = m_MovementScript.MoveDown(m_PlayerEntity.transform.position); //uncomment this and comment above when Brents Movement class is ready
                    m_playerCharacterScript.Face(GSP.Char.Character.FacingDirection.SOUTH);              // Face the character to the south which is down.
                    MovePlayer();
                    Highlight.ClearHightlight();                                                         // Clear the highlight objects.
                    Highlight.GenerateHighlight(m_PlayerEntity.transform.position, m_currTravelDist);    // Recreate the highlights with the new values.
                    audioSrc.audio.PlayOneShot(GSP.AudioReference.sfxWalking);                           //Play walking sound
                }
            }                                                                                            //end if( m_currDistTravel > 0 )
            else
            {
                if (GUI.Button(new Rect((Screen.width - (2 * width) + gridXShift), (Screen.height - (2 * height) + gridYShift), width, height), "X"))
                {
                    m_playerCharacterScript.Face(GSP.Char.Character.FacingDirection.SOUTH);                       // Face the character to the south which is to the left. This is the default facing.
                    //TODO: CANCEL MOVE, MOVE BACK TO ORIG POSITION
                    CancelMove();
                    Highlight.ClearHightlight();                                         // Clear the highlight objects.
                    Highlight.GenerateHighlight(m_origPlayerPosition, m_currTravelDist); // Recreate the highlights with the new values.
                }
                //display travel distance is 0
                GUI.Box(new Rect((Screen.width - (3 * width) + gridXShift), (Screen.height - (3 * height) + gridYShift), 3 * width, height), "Out of Distance.");
            }
        }               //private void GUIMovementPads()
Exemplo n.º 2
0
        private void StateMachine()
        //---------------------------------------------------------------------
        // +StateMachine in charge of displaying GUI that describes
        //	 what stage the gamePlay is in
        // +Uses a switch() statement for handling states
        //
        //---------------------------------------------------------------------
        {
            var state = GameObject.FindGameObjectWithTag("GUITextTag").GetComponent <GUIText>();

            switch (m_gamePlayState)
            {
            case GamePlayState.BEGINTURN:
                //Get All the Players values
                GetPlayerValues();
                m_GUIBottomBarScript.RefreshBottomBarGUI(m_playerList[m_GUIPlayerTurn]);

                //tell the player to roll the dice
                m_gamePlayState = GamePlayState.ROLLDICE;
                break;

            case GamePlayState.ROLLDICE:
                //list start at 0 but I need GUI to start Display with player "1"
                int tmpPlayerTurn = m_GUIPlayerTurn + 1;

                state.text = "Player " + tmpPlayerTurn.ToString() + " roll dice";

                //create a roll dice button
                m_GUIActionString = "Action\nRoll Dice";

                //highlight button
                m_colorActionButtonDefault = false;

                //if button is clicked, destroy button
                if (m_GUIActionPressed)
                {
                    //stop animation
                    m_colorActionButtonDefault = true;

                    m_GUIDiceDistVal = m_DieScript.Dice.Roll(1, 8);

                    //Play die roll sound
                    audioSrc.audio.PlayOneShot(GSP.AudioReference.sfxDice);                       //Play die roll sound

                    //nextState()
                    m_gamePlayState = GamePlayState.CALCDISTANCE;
                }
                break;

//
            case GamePlayState.CALCDISTANCE:
                state.text = "Calculate Distance";

                //get dice value /calculate m_allowedTravelDistance
                m_GUIDiceDistVal = m_GUIDiceDistVal * (m_GUIMaxWeight - m_GUIWeight) / m_GUIMaxWeight;

                //nextState()
                m_GUIActionPressed = false;
                m_gamePlayState    = GamePlayState.DISPLAYDISTANCE;
                break;

            case GamePlayState.DISPLAYDISTANCE:
                state.text = "DisplayDistance";

                //TODO: Add function to display tiles

                //nextState()
                m_gamePlayState = GamePlayState.SELECTPATHTOTAKE;
                //display arrows
                m_GUIMovementScript.InitThis(m_playerList[m_GUIPlayerTurn], m_GUIDiceDistVal);
                break;

            case GamePlayState.SELECTPATHTOTAKE:
                state.text        = "Select Path To Take\nPress Action butotn to End Turn\nor X to start over.";
                m_GUIActionString = "End Turn";

                //update new value of DiceDist if player pressed a move button
                m_GUIDiceDistVal = m_GUIMovementScript.GetTravelDistanceLeft();

                //if ( Input.GetKeyDown( KeyCode.Alpha1 ) )
                if (m_GUIActionPressed)
                {
                    //find out what mapEvent Occured

                    m_gamePlayState = GamePlayState.DOACTION;

                    //TODO: REMOVE below line if test works.
                    //m_NEWGUIMapEventScript.InitThis( m_playerList[m_GUIPlayerTurn] );

                    //update gui by getting new values
                    //GetPlayerValues();

                    //TODO: after testing, delete command above and use this one below
                    m_MapEventString       = m_MapEventScript.DetermineEvent(m_playerList[m_GUIPlayerTurn]);
                    m_MapEventResultString = m_MapEventScript.GetResultString();
                    m_GUIMapEventsScript.InitThis(m_playerList[m_GUIPlayerTurn], m_MapEventString, m_MapEventResultString);
                    //m_GUIMapEventsScript.InitThis( m_playerList[m_GUIPlayerTurn], "ENEMY", null );
                }

                break;

            case GamePlayState.DOACTION:
                //state.text = "Do Action/MapEvent";
                state.text = "";

                GetPlayerValues();

                //map events
                if (m_GUIMapEventsScript.isActionRunning() == false)
                //TODO: remove bottome line if above line works
                //if( m_NEWGUIMapEventScript.GetIsActionRunning() == false )
                {
                    //TODO: After Testing, uncomment the following
                    m_MapEventString       = "NOTHING";
                    m_MapEventResultString = null;

                    //NextState()
                    m_gamePlayState    = GamePlayState.ENDTURN;
                    m_GUIActionPressed = false;
                }

                break;

            case GamePlayState.ENDTURN:
                state.text = "End Turn";

                // Clear the board of any highlight tiles.
                Highlight.ClearHightlight();

                //next players turn
                m_GUIPlayerTurn = m_GUIPlayerTurn + 1;

                //if exceeds the number of player playing, start back at player 1
                if (m_GUIPlayerTurn >= m_GUINumOfPlayers)
                {
                    m_GUIPlayerTurn = 0;
                }

                //new player gets new turn
                m_gamePlayState = GamePlayState.BEGINTURN;

                break;

            case GamePlayState.ENDGAME:
                state.text = "Universe Ending";

                if (m_runEndStuff)
                {
                    #region Selling Character resource stuff

                    // Set it to not run this again.
                    m_runEndStuff = false;

                    // Get the number of players.
                    int numPlayers = m_playerList.Count;

                    // Loop through and sell the character's resources and their ally's resources.
                    for (int playerSellIndex = 0; playerSellIndex < numPlayers; playerSellIndex++)
                    {
                        // We need to access the character script at the given index and sell the resources.
                        m_playerScriptList[playerSellIndex].SellResource();
                    }                     // end for loop

                    #endregion

                    #region End Scene Quit Adding Stuff

                    // Get the end scene data object's script.
                    EndSceneData endSceneScript = m_endSceneCharData.GetComponent <EndSceneData>();

                    // Add the player stuff.
                    for (int endSceneIndex = 0; endSceneIndex < numPlayers; endSceneIndex++)
                    {
                        // Add the current player to the end scene data object.
                        // Note: Be sure to add 1 to index to get the player number correct.
                        int playerNum = endSceneIndex + 1;

                        // Check if the key doesn't exist. Only proceed if it doesn't.
                        if (!endSceneScript.KeyExists(playerNum))
                        {
                            // NOTE: Uncomment the below line for testing. Recomment it for the real game.
                            //m_playerScriptList[endSceneIndex].Currency += m_DieScript.Dice.Roll(1, 100);
                            endSceneScript.AddData(playerNum, m_playerList[endSceneIndex]);
                        }                 // end if statement
                    }                     // end for loop

                    #endregion

                    // Next load the end scene
                    Application.LoadLevel("EndScene");
                }
                break;

            default:
                //stage transition
                break;
            }     //end switch (m_gamePlayState)
        }         //end private void StateMachine()