private void OnMouseDown()
 {
     if (GameManager.paused)
     {
         return;
     }
     // score
     if (TimeFreeze.isFreeze)
     {
         TimeFreeze.clickedWhileFreezed(this.gameObject);
     }
     else
     {
         this.clicked();
         this.remove();
     }
 }
        private void FixedUpdate()
        {
            float speed;

            GetInput(out speed);
            // always move along the camera forward as it is the direction that it being aimed at
            Vector3 desiredMove = transform.forward * m_Input.y + transform.right * m_Input.x;


            ///////////////////////////////////
            /// //////////////////////////////

            //Animations
            if (m_Input.magnitude != 0)
            {
                anim_hud.SetBool(move_hash, true);
                anim_left.SetBool(move_hash, true);
                anim_right.SetBool(move_hash, true);
                anim_up.SetBool(move_hash, true);
                anim_down.SetBool(move_hash, true);
                Debug.Log("Moving");
            }
            else
            {
                anim_hud.SetBool(move_hash, false);
                anim_left.SetBool(move_hash, false);
                anim_right.SetBool(move_hash, false);
                anim_up.SetBool(move_hash, false);
                anim_down.SetBool(move_hash, false);
            }

            //Time freeze
            if (desiredMove.magnitude != 0 && Time.timeScale != 1)
            {
                TimeFreeze.move();
            }
            else if (desiredMove.magnitude == 0 && Time.timeScale != 0)
            {
                TimeFreeze.stop();
            }


            //////////////////////////////////////
            //////////////////////////////////////

            // get a normal for the surface that is being touched to move along it
            RaycastHit hitInfo;

            Physics.SphereCast(transform.position, m_CharacterController.radius, Vector3.down, out hitInfo,
                               m_CharacterController.height / 2f, Physics.AllLayers, QueryTriggerInteraction.Ignore);
            desiredMove = Vector3.ProjectOnPlane(desiredMove, hitInfo.normal).normalized;

            m_MoveDir.x = desiredMove.x * speed;
            m_MoveDir.z = desiredMove.z * speed;


            if (m_CharacterController.isGrounded)
            {
                m_MoveDir.y = -m_StickToGroundForce;

                if (m_Jump)
                {
                    m_MoveDir.y = m_JumpSpeed;
                    PlayJumpSound();
                    m_Jump    = false;
                    m_Jumping = true;
                }
            }
            else
            {
                m_MoveDir += Physics.gravity * m_GravityMultiplier * Time.fixedDeltaTime;
            }
            m_CollisionFlags = m_CharacterController.Move(m_MoveDir * Time.fixedDeltaTime);

            ProgressStepCycle(speed);
            UpdateCameraPosition(speed);

            m_MouseLook.UpdateCursorLock();
        }
Exemple #3
0
    void Awake()
    {
        if (alPrScr == null)
        {
            alPrScr = FindObjectOfType <AllPrefsScript>();
        }
        if (univFunc == null)
        {
            univFunc = FindObjectOfType <UniversalFunctions>();
        }
        if (gM == null)
        {
            gM = FindObjectOfType <GameManager> ();
        }
        if (adMob == null)
        {
            adMob = FindObjectOfType <AndroidAdMob_0>();
        }
        if (buf == null)
        {
            buf = FindObjectOfType <Buffer>();
        }

        if (cntrL == null)
        {
            cntrL = FindObjectOfType <CountriesList>();
        }
        if (plL == null)
        {
            plL = FindObjectOfType <PlayersList>();
        }
        if (prMng == null)
        {
            prMng = FindObjectOfType <ProfileManager>();
        }

        switch (SceneManager.GetActiveScene().buildIndex)
        {
        case 1:
            if (upgr == null)
            {
                upgr = FindObjectOfType <Upgrades>();
            }
            if (allAw == null)
            {
                allAw = FindObjectOfType <AllAwardsScript>();
            }
            if (topPanMng == null)
            {
                topPanMng = FindObjectOfType <TopPanelManager>();
            }
            if (objM == null)
            {
                objM = FindObjectOfType <Objects_Menu>();
            }
            if (currPrPan == null)
            {
                currPrPan = FindObjectOfType <CurrentProfilePanel>();
            }
            if (everyDayReward == null)
            {
                everyDayReward = FindObjectOfType <EverydayReward>();
            }
            if (carMng == null)
            {
                carMng = FindObjectOfType <CareerManager>();
            }
            break;

        case 2:
            if (fwScr == null)
            {
                fwScr = FindObjectOfType <FireworkScript>();
            }
            if (molnia == null)
            {
                molnia = FindObjectOfType <LighteningScript>();
            }
            if (practScr == null)
            {
                practScr = FindObjectOfType <Practice>();
            }
            if (timFr == null)
            {
                timFr = FindObjectOfType <TimeFreeze>();
            }
            if (rainMan == null)
            {
                rainMan = FindObjectOfType <RainManager>();
            }
            if (bonObjMan == null)
            {
                bonObjMan = FindObjectOfType <BonusObjManager>();
            }
            if (enOrDis == null)
            {
                enOrDis = FindObjectOfType <EnableOrDisable>();
            }
            if (monWin == null)
            {
                monWin = FindObjectOfType <MoneyWinScript>();
            }
            if (camSize == null)
            {
                camSize = FindObjectOfType <CameraSize>();
            }
            if (colCorr == null)
            {
                colCorr = FindObjectOfType <ColorCorrectionControl>();
            }
            if (marks == null)
            {
                marks = FindObjectOfType <Markers>();
            }
            if (goalPanScr == null)
            {
                goalPanScr = FindObjectOfType <GoalPanelScript>();
            }
            if (objLev == null)
            {
                objLev = FindObjectOfType <Objects_Level>();
            }
            if (scoreScr == null)
            {
                scoreScr = FindObjectOfType <Score>();
            }
            if (pMov == null)
            {
                pMov = FindObjectOfType <PlayerMovement>();
            }
            if (tM == null)
            {
                tM = FindObjectOfType <TimeManager>();
            }
            if (ballScr == null)
            {
                ballScr = FindObjectOfType <BallScript>();
            }
            if (grTr == null)
            {
                grTr = FindObjectOfType <GroundTrigger1>();
            }
            if (congrPan == null)
            {
                congrPan = FindObjectOfType <CongradulationsPanel>();
            }
            if (levAudScr == null)
            {
                levAudScr = FindObjectOfType <LevelAudioScript>();
            }
            if (stChScr == null)
            {
                stChScr = FindObjectOfType <StadiumChooseScript>();
            }
            if (ballTScr == null)
            {
                ballTScr = FindObjectOfType <BallTouchScript>();
            }
            if (jScr == null)
            {
                jScr = FindObjectOfType <JumpScript>();
            }
            if (skyScr == null)
            {
                skyScr = FindObjectOfType <SkyScript>();
            }
            //if (enAlg == null) enAlg = FindObjectOfType<Enemy>();
            break;
        }
    }