private void SetUiFromGameVariables()
    {
        // Setting ui elements from game variables

        // Score
        foreach (var highScoreTextObj in _highScoreText)
        {
            highScoreTextObj.GetComponent <Text>().text = GameVariablesScript.ConvertScoreToString(GameVariablesScript.HighScore);
        }
        _lastScoreText.text = GameVariablesScript.ConvertScoreToString(GameVariablesScript.LastScore);

        // Options sliders
        _sensitivitySlider.value = GameVariablesScript.PaddleSensitivity * GameVariablesScript.PaddleSensitivityCoeff;
        _ballSpeedSlider.value   = GameVariablesScript.BallSpeed * GameVariablesScript.BallSpeedCoeff;

        // Control Scheme
        SetControlSchemeUiFromGameVariables();

        // Music  & Sound
        _muteMusicButtonImage.overrideSprite        = GameVariablesScript.MusicMuted ? MusicOffImage : MusicOnImage;
        _muteSoundEffectsButtonImage.overrideSprite = GameVariablesScript.SoundEffectsMuted ? SoundEffectsOffImage : SoundEffectsOnImage;

        // Social Network stuff
        if (SoomlaProfile.IsLoggedIn(Provider.FACEBOOK) || SoomlaProfile.IsLoggedIn(Provider.TWITTER) || SoomlaProfile.IsLoggedIn(Provider.GOOGLE))
        {
            SetUserLoggedIn(true);
        }
    }
示例#2
0
    // functions

    // Start is called before the first frame update
    void Start()
    {
        if (GameVariablesScriptInstance == null)
        {
            GameVariablesScriptInstance = this;
        }



        if (m_IsHealthRandom)
        {
            m_Health = m_Player.GetComponent <RandomizeHealth>().RandomizeHealthFloat();
            for (var i = 3; i >= m_Health; i--)
            {
                m_Hearts[i].SetActive(false);
            }
        }
    }
示例#3
0
        // Update is called once per frame
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                StopGame();
            }

            if (!IsStarted)
            {
                StartGame();
            }

            #region Editor stuff
#if UNITY_EDITOR
            if (Input.GetKeyUp(KeyCode.Return))
            {
                AddScore(100000);
            }

            if (Input.GetKeyUp(KeyCode.Escape) && !IsPaused)
            {
                TogglePause();
            }

            if (Input.GetKeyUp(KeyCode.Tab))
            {
                //var ring = _brickRings[0];

                //foreach (Transform brick in ring.Anchor.transform)
                //    brick.gameObject.SetActive(false);

                //CheckRings();

                _paddleManager.WidenPaddles();
            }
#endif
            #endregion

            //if (SystemInfo.deviceType == DeviceType.Handheld)
            //{
            //    // Invert the z and w of the gyro attitude
            //    var rotation = Input.gyro.attitude;
            //    Physics.gravity = rotation * new Vector3(0, 1, 0);
            //}

            switch (_currentState)
            {
            case -1:        // Switch to lost screen
                StopGame();
                break;

            case 1:         // Switch to won screen
                StopGame();
                break;
            }

            if (IsPaused)
            {
                return;
            }

            // Update score
            if (_actualPointScore != _textPointScore)
            {
                _textPointScore += Mathf.CeilToInt((_actualPointScore - _textPointScore) / 2f);
                _scoreText.text  = GameVariablesScript.ConvertScoreToString(_textPointScore);
                Debug("Hi");
            }

            // Update time
            if (TimerStarted)
            {
                #region Timer Text
                _timer += Time.smoothDeltaTime;
                var minutes = Mathf.Floor(_timer / 60);
                var seconds = (_timer % 60);
                _timeText.text = minutes.ToString("00") + ":" + seconds.ToString("00");
                #endregion

                #region Ball Speed Increase
                // Update the timer that increases ball speed
                _speedIncreaseTimer += Time.smoothDeltaTime;
                if (!_eventCreated && _speedIncreaseTimer > TimeForSpeedIncrease - TimeForSpeedIncreaseEvent)
                {
                    _eventManager.CreateEvent("+", TimeForSpeedIncreaseEvent, 1);
                    _eventCreated = true;
                }
                else if (_speedIncreaseTimer >= TimeForSpeedIncrease)
                {
                    IncreaseBallSpeed();
                    _speedIncreaseTimer = 0;
                    _eventCreated       = false;
                }
                #endregion
            }

            #region Camera Shake
            if (_isCameraShaking)
            {
                UpdateShake();
            }
            #endregion

            #region Combo
            if (_comboText.enabled)
            {
                _comboTimer += Time.smoothDeltaTime;
                _comboText.transform.localScale = Vector3.Lerp(ComboTextInitialScale, ComboTextFinalScale,
                                                               _comboTimer / TimeForComboTextShow * 2);

                if (_comboText.transform.localScale.x > 1)
                {
                    _comboText.transform.localScale = new Vector3(1, 1, 1);
                }

                if (_comboTimer > TimeForComboTextShow)
                {
                    _comboTimer        = 0;
                    _comboText.enabled = false;
                }
            }
            #endregion

            #region Background Colour Shift

            var colour = _backgroundImage.color;
            switch (_backgroundColourIndex)
            {
            case 0:
                colour.r += BackgroundColourChangeSpeed / 255f;
                if (colour.r >= 1)
                {
                    _backgroundColourIndex++;
                }
                break;

            case 1:
                colour.b -= BackgroundColourChangeSpeed / 255f;
                if (colour.b <= 0)
                {
                    _backgroundColourIndex++;
                }
                break;

            case 2:
                colour.g += BackgroundColourChangeSpeed / 255f;
                if (colour.g >= 1)
                {
                    _backgroundColourIndex++;
                }
                break;

            case 3:
                colour.r -= BackgroundColourChangeSpeed / 255f;
                if (colour.r <= 0)
                {
                    _backgroundColourIndex++;
                }
                break;

            case 4:
                colour.b += BackgroundColourChangeSpeed / 255f;
                if (colour.b >= 1)
                {
                    _backgroundColourIndex++;
                }
                break;

            case 5:
                colour.g -= BackgroundColourChangeSpeed / 255f;
                if (colour.g <= 0)
                {
                    _backgroundColourIndex = 0;
                }
                break;
            }
            _backgroundImage.color = colour;

            #endregion
        }
 public void Reset()
 {
     GameVariablesScript.ResetVariables();
     SetUiFromGameVariables();
     FileServices.SaveGame();
 }