Exemplo n.º 1
0
        ///<summary>
        ///Close the menu
        ///</summary>
        public virtual void Close()
        {
            if (IsActive)
            {
                if (closeEffect != null)
                {
                    CachedSoundManager.Play(closeEffect);
                }

                CanvasGroup cg = root.GetComponent <CanvasGroup>();
                if (cg != null && useTransitionEffect)
                {
                    StopAllCoroutines();
                    StartCoroutine(FadeMenu(cg, 1f, 0f, true));
                }
                else
                {
                    isActive = false;
                    root.SetActive(false);
                    if (stopsMovement)
                    {
                        OnMenuClose();
                    }
                }
            }
        }
Exemplo n.º 2
0
        ///<summary>
        ///Process clicked button
        ///</summary>
        public virtual bool ClickButton()
        {
            if (clickButtonEffect != null)
            {
                CachedSoundManager.Play(clickButtonEffect);
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        public override void Open()
        {
            if (!IsActive)
            {
                if (openEffect != null)
                {
                    CachedSoundManager.Play(openEffect);
                }

                CanvasGroup cg = root.GetComponent <CanvasGroup>();
                if (cg != null)
                {
                    StopCoroutine("FadeMenu");
                    StartCoroutine(FadeMenu(cg, 0f, 1f));
                }

                isActive = true;
                root.SetActive(true);
            }
        }
Exemplo n.º 4
0
        public override void Close()
        {
            if (IsActive)
            {
                if (closeEffect != null)
                {
                    CachedSoundManager.Play(closeEffect);
                }

                CanvasGroup cg = root.GetComponent <CanvasGroup>();
                if (cg != null)
                {
                    StopCoroutine("FadeMenu");
                    StartCoroutine(FadeMenu(cg, 1f, 0f, true));
                }
                else
                {
                    isActive = false;
                    root.SetActive(false);
                }
            }
        }
Exemplo n.º 5
0
        ///<summary>
        ///Open the menu
        ///</summary>
        public virtual void Open()
        {
            if (!IsActive)
            {
                if (openEffect != null)
                {
                    CachedSoundManager.Play(openEffect);
                }

                CanvasGroup cg = root.GetComponent <CanvasGroup>();
                if (cg != null && useTransitionEffect)
                {
                    StopAllCoroutines();
                    StartCoroutine(FadeMenu(cg, 0f, 1f));
                }

                isActive = true;
                root.SetActive(true);
                if (stopsMovement && OnMenuClose != null)
                {
                    OnMenuOpen();
                }
            }
        }
Exemplo n.º 6
0
        private void FixedUpdate()
        {
            if (CachedPlayerStats.CurrentMovementSpeed > 0)
            {
                if (carController.MaxSpeed != playerStats.CurrentMovementSpeed)
                {
                    carController.MaxSpeed = playerStats.CurrentMovementSpeed;
                }

                float h         = 0;
                float v         = CrossPlatformInputManager.GetAxis("Vertical");
                float handbrake = CrossPlatformInputManager.GetAxis("Jump");

                if (v != 0)
                {
                    h = CrossPlatformInputManager.GetAxis("Horizontal");
                    if (cachedSoundSource == null)
                    {
                        cachedSoundSource = CachedSoundManager.Play(CurrentMovementClip);
                    }
                }
                else if (CrossPlatformInputManager.GetAxis("Horizontal") != 0)
                {
                    float rotationAngle = CachedPlayerStats.MovementSpeed * movementSpeedMultiplier * Time.deltaTime * CrossPlatformInputManager.GetAxis("Horizontal");
                    transform.Rotate(Vector3.up, rotationAngle);
                    if (cachedSoundSource == null)
                    {
                        cachedSoundSource = CachedSoundManager.Play(CurrentMovementClip);
                    }
                }
                else
                {
                    if (cachedSoundSource != null)
                    {
                        CachedSoundManager.Play(CurrentStopClip);
                        CachedSoundManager.Stop(cachedSoundSource);
                    }
                }

                if (mouseLook.rotationX != 0 && h == 0 && v != 0)
                {
                    //if the camera rotation is different than the chassi rotation and theres no horizontal input
                    //then we want to turn anyway
                    mouseLook.rotationX = Mathf.Lerp(mouseLook.rotationX, 0, Time.deltaTime);
                    h = (mouseLook.rotationX / mouseLook.maximumX) * mouseLook.sensitivityX;
                }

                wheelAnimator.SetFloat("speed", v);

                handbrake = (v == 0 && handbrake == 0) ? 1 : 0;

                carController.Move(h, v, v, handbrake);
            }
            else
            {
                carController.Move(0, 0, 0, 1);
                if (cachedSoundSource != null)
                {
                    CachedSoundManager.Stop(cachedSoundSource);
                }
            }
        }