Ejemplo n.º 1
0
    private void updateClock()
    {
        float minus;

        if (currentImage == 1)
        {
            playerTime = PoolGameManager.Instance.playerTime;
            if (PoolGameManager.Instance.offlineMode)
            {
                playerTime = PoolGameManager.Instance.playerTime + PoolGameManager.Instance.cueTime;
            }
            minus = 1.0f / playerTime * Time.deltaTime;

            imageClock1.fillAmount -= minus;

            if (imageClock1.fillAmount < 0.25f && !timeSoundsStarted)
            {
                audioSources[0].Play();
                timeSoundsStarted = true;
            }

            if (imageClock1.fillAmount == 0)
            {
                //				imageClock1.fillAmount = 1;
                //				currentImage = 2;
                //				showMessage (GameManager.Instance.nameOpponent + " turn");
                audioSources[0].Stop();
                PoolGameManager.Instance.stopTimer = true;
                shotPowerScript.resetCue();
                if (!PoolGameManager.Instance.offlineMode)
                {
                    PhotonNetwork.RaiseEvent(9, cueControllerScript.cue.transform.position, true, null);
                }
                else
                {
                    PoolGameManager.Instance.wasFault = true;
                    PoolGameManager.Instance.cueController.setTurnOffline(true);
                }


                PoolGameManager.Instance.cueController.ShotPowerIndicator.deactivate();
                PoolGameManager.Instance.cueController.ShotPowerIndicator.resetCue();

                PoolGameManager.Instance.cueController.cueSpinObject.GetComponent <SpinController>().hideController();

                PoolGameManager.Instance.cueController.whiteBallLimits.SetActive(false);
                PoolGameManager.Instance.ballHand.SetActive(false);

                showMessage("You " + PoolStaticStrings.runOutOfTime);

                if (!PoolGameManager.Instance.offlineMode)
                {
                    cueControllerScript.setOpponentTurn();
                }
            }
        }
        else
        {
            Debug.Log(PoolGameManager.Instance.opponentCueTime);
            playerTime = PoolGameManager.Instance.playerTime;
            if (PoolGameManager.Instance.offlineMode)
            {
                playerTime = PoolGameManager.Instance.playerTime + PoolGameManager.Instance.opponentCueTime;
            }
            minus = 1.0f / playerTime * Time.deltaTime;
            imageClock2.fillAmount -= minus;

            if (PoolGameManager.Instance.offlineMode && imageClock2.fillAmount < 0.25f && !timeSoundsStarted)
            {
                audioSources[0].Play();
                timeSoundsStarted = true;
            }

            if (imageClock2.fillAmount == 0)
            {
                PoolGameManager.Instance.stopTimer = true;

                if (PoolGameManager.Instance.offlineMode)
                {
                    showMessage("You " + PoolStaticStrings.runOutOfTime);
                }
                else
                {
                    showMessage(PoolGameManager.Instance.nameOpponent + " " + PoolStaticStrings.runOutOfTime);
                }

                //				imageClock2.fillAmount = 1;
                //				currentImage = 1;
                //				showMessage ("Your turn");

                if (PoolGameManager.Instance.offlineMode)
                {
                    PoolGameManager.Instance.wasFault = true;
                    PoolGameManager.Instance.cueController.setTurnOffline(true);
                }
            }
        }
    }