Ejemplo n.º 1
0
    /*
     * Configure UI elements for turns, get externalHandlers for characters,
     */
    public void SetUpTurns()
    {
        turnsLeft = initialTurns;
        //extraTurnsLeft = extraTurns;
        gameNotOver        = true;
        instructionControl = FindObjectOfType <InstructionControl>();
        timeKeeper         = FindObjectOfType <TimeKeeper>();


        var them = GameObject.FindGameObjectWithTag(character == "Human"?"Agent":"Human");

        if (them)
        {
            theirHandler = them.GetComponent <ExternalActionHandler>();
        }
        var me = GameObject.FindGameObjectWithTag(character);

        if (me)
        {
            myHandler = me.GetComponent <ExternalActionHandler>();
        }
        if (character == "Human")
        {
            movesRemaining   = leadersMovesPerTurn;
            myTurn           = true;
            moveDisplay.text = "Moves Left: " + leadersMovesPerTurn + " Moves Left in Turn";

            // Initially the end-turn button should be disabled so the leader must
            // put in a command during their turn.
            endTurnButton.interactable = false;
          #if UNITY_WEBGL
            if (!TutorialGuide.tutorialMode)
            {
                backgroundImage.material.SetColor("_Color", gameGreen);
                backgroundImage.material.SetColor("_Color2", gameGreen);
            }
          #endif
        }
        else //character=="Agent"
        {
            movesRemaining   = followersMovesPerTurn;
            myTurn           = false;
            moveDisplay.text = "Moves Left: Waiting for partner!";
            if (!TutorialGuide.tutorialMode)
            {
                backgroundImage.material.SetColor("_Color", gamePink);
                backgroundImage.material.SetColor("_Color2", gamePink);
            }
        }
        // (turnsLeft+1)/2 to show half the num turns left correctly w/ int division
        totalTurnsDisplay.text = "Turns Left: " + (turnsLeft + 1) / 2;
        if (TutorialGuide.tutorialMode)
        {
            theirHandler.GiveTurn(); GetTurn();
        }                                                                      // Fix movement for tutorial role.
    }
Ejemplo n.º 2
0
    public void GiveTurn(string method)
    {
        if (!TutorialGuide.tutorialMode)
        {
            Dictionary <string, string> strData = new Dictionary <string, string>()
            {
                { "character", character },
                { "method", method }
            };
            webSocketManager.Send("yourTurn", strData, null);
            movesRemaining   = character == "Human"?leadersMovesPerTurn : followersMovesPerTurn;
            moveDisplay.text = "Moves: Waiting for partner!";

            turnsLeft -= 1;
            totalTurnsDisplay.text  = "Turns Left: " + (turnsLeft + 1) / 2; // Shows each player's usable turns
            totalTurnsDisplay.color = Color.black;

            if (character == "Human")
            {
                instructionControl.TurnOff();
                endTurnButton.interactable = false;
            }
            else
            {
                // Make the finish command button non-interactable.
                finishCommandButton.interactable = false;
            }


            myTurn = false;
            myHandler.GiveTurn();
            backgroundImage.material.SetColor("_Color", gamePink);
            backgroundImage.material.SetColor("_Color2", gamePink);
            timeKeeper.ResetTime(character == "Human"?"Agent":"Human");
            if (isFirstTurn)
            {
                isFirstTurn = false;
            }
        }
        else
        {
            if (character == "Agent")
            {
                movesRemaining = followersMovesPerTurn;
                timeKeeper.ResetTime("Agent");
            }
            else
            {
                timeKeeper.ResetTime("Human");
            }
        }
    }