public void selectButtonClick()
    {
        //Tile selectedTile = this.GetComponentInParent<Tile>();

        //find all game objects tagged as 'DirectionChoice' and destroy them
        var directionChoiceGameObjects = GameObject.FindGameObjectsWithTag("DirectionChoice");

        foreach (var item in directionChoiceGameObjects)
        {
            Destroy(item);
        }

        var playerToken = PlayerToken.FindActivePlayerToken();

        playerToken.MoveToken(SelectedTile);
    }
示例#2
0
    public IEnumerator RollDiceAnimator(float animationTime, int finalResult)
    {
        int iterationsToAnimate = (int)(20 * animationTime);

        for (int i = 0; i <= iterationsToAnimate; i++)
        {
            var randomDiceNumber = Random.Range(0, 5);
            this.transform.GetChild(0).GetComponent <Image>().sprite = diceImages[randomDiceNumber];
            yield return(new WaitForSeconds(0.05f));
        }
        //after animation of random images, update to final result from rule controller
        Debug.Log($"You rolled a {finalResult}.");
        textField.text = "Moves Left: " + finalResult.ToString();
        Debug.Log($"User moved by {finalResult}. Location updated.");

        this.transform.GetChild(0).GetComponent <Image>().sprite = diceImages[finalResult - 1];

        var playerToken = PlayerToken.FindActivePlayerToken();

        playerToken.SetSpacesRemainingInMove(finalResult);
        playerToken.ChooseDirectionToMove();
    }
示例#3
0
    //When the rule controller determines that cake should be awarded to a player,
    //This method can be called to update the state of the player's cake
    public void UpdateCakeState(string cakeColor)
    {
        if (cakeColor.ToUpper() == "RED")
        {
            hasRedCake = true;
        }
        if (cakeColor.ToUpper() == "BLUE")
        {
            hasBlueCake = true;
        }
        if (cakeColor.ToUpper() == "GREEN")
        {
            hasGreenCake = true;
        }
        if (cakeColor.ToUpper() == "WHITE")
        {
            hasWhiteCake = true;
        }


        var activePlayerToken = PlayerToken.FindActivePlayerToken();

        activePlayerToken.SetSpriteBasedOnCakeStatus(hasRedCake, hasBlueCake, hasGreenCake, hasWhiteCake);
    }