Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (hasAuthority == false)
        {
            return;
        }

        if (cam == null)
        {
            cam = FindObjectOfType <CameraFollowPlayer>();
            cam.playerTransform = this.gameObject.transform;
            cam.global          = global;
        }

        if (global.playerTurn == this.playerId)
        {
            myTurn = true;
            if (!global.isMoving && !global.isBackward && !diceController.isShake)
            {
                diceController.TurnOnShakeButton();
            }
            else
            {
                diceController.TurnOffShakeButton();
            }
        }
        else
        {
            myTurn = false;
            diceController.TurnOffShakeButton();
        }

        if (global.isWin)
        {
            Debug.Log("Player turn : " + global.playerTurn + ",Player ID : " + this.playerId);
            if (global.playerTurn == this.playerId)
            {
                GetComponent <PlayerAnimationController>().Win();
                if (!global.isFinish)
                {
                    //Instantiate(winPanel);
                    GameObject go = GameObject.FindGameObjectWithTag("WinPanel");
                    for (int i = 0; i < go.transform.childCount; i++)
                    {
                        go.transform.GetChild(i).gameObject.SetActive(true);
                    }
                    global.isFinish = true;
                }
            }
            else
            {
                GetComponent <PlayerAnimationController>().Lose();
                if (!global.isFinish)
                {
                    //Instantiate(losePanel);
                    GameObject go = GameObject.FindGameObjectWithTag("LosePanel");
                    for (int i = 0; i < go.transform.childCount; i++)
                    {
                        go.transform.GetChild(i).gameObject.SetActive(true);
                    }
                    global.isFinish = true;
                }
            }

            TurnOff();
        }

        //movePlayer();
    }