Exemple #1
0
    void Start()
    {
        bSidesColliderFlag = true;

        hInGameScript = GameObject.Find("Player").GetComponent <InGameScript>() as InGameScript;
        hPlayerFrontColliderScript = GameObject.Find("PlayerFrontCollider").GetComponent <PlayerFrontColliderScript>() as PlayerFrontColliderScript;
        hControllerScript          = GameObject.Find("Player").GetComponent <ControllerScript>() as ControllerScript;
    }
    void Start()
    {
        hMenuScript                = GameObject.Find("MenuGroup").GetComponent <MenuScript>() as MenuScript;
        hPatchesRandomizer         = this.GetComponent <PatchesRandomizer>() as PatchesRandomizer;
        hPlayerSidesColliderScript = GameObject.Find("PlayerSidesCollider").GetComponent <PlayerSidesColliderScript>() as PlayerSidesColliderScript;
        hPlayerFrontColliderScript = GameObject.Find("PlayerFrontCollider").GetComponent <PlayerFrontColliderScript>() as PlayerFrontColliderScript;
        hSoundManager              = GameObject.Find("SoundManager").GetComponent <SoundManager>() as SoundManager;
        hInGameScript              = this.GetComponent <InGameScript>() as InGameScript;
        hPitsMainController        = this.GetComponent <PitsMainController>() as PitsMainController;
        hCheckPointsMain           = this.GetComponent <CheckPointsMain>() as CheckPointsMain;
        hPowerupScript             = this.GetComponent <PowerupsMainController>() as PowerupsMainController;
        hEnemyController           = GameObject.Find("Enemy").GetComponent <EnemyController>() as EnemyController;
        hPowerupScript             = this.GetComponent <PowerupsMainController>() as PowerupsMainController;
        hCameraController          = Camera.main.gameObject.GetComponent <CameraController>() as CameraController;
        swipeLogic = transform.GetComponent <SwipeControls>() as SwipeControls;

        tPlayer         = transform;
        tPlayerRotation = transform.Find("PlayerRotation");
        playerRenderer  = GameObject.Find("rend").GetComponent <SkinnedMeshRenderer>();

        //get the animation component of the player character
        aPlayer          = this.transform.Find("PlayerRotation/PlayerMesh/Prisoner").GetComponent <Animation>() as Animation;
        tBlobShadowPlane = transform.Find("BlobShadowPlane");

        tPlayerSidesCollider = GameObject.Find("PlayerSidesCollider").transform;
        tFrontCollider       = GameObject.Find("PlayerFrontCollider").transform;
        if (!PersistentManagerScript.Instance.obstacles)
        {
            tFrontCollider.GetComponent <BoxCollider>().enabled       = false;
            tPlayerSidesCollider.GetComponent <BoxCollider>().enabled = false;
        }

        tHUDGroup    = GameObject.Find("HUDMainGroup/HUDGroup").transform;
        tPauseButton = GameObject.Find("HUDMainGroup/HUDGroup/HUDPause").transform;
        tQuitButton  = GameObject.Find("HUDMainGroup/HUDGroup/HUDQuit").transform;
        tQuitButton.gameObject.active = false;

        HUDCamera = GameObject.Find("HUDCamera").GetComponent <Camera>();

        v3BNCDefaultScale = tFrontCollider.localScale;
        v3BFCDefaultScale = tPlayerSidesCollider.localScale;

        bInAir = false;
        fCurrentDistanceOnPath = 50.0f;         //inital distance with respect to spline
        fCurrentDistance       = 0.0f;
        fCurrentMileage        = 0.0f;
        tCurrentAngle          = 0.0f;
        fPitFallLerpValue      = 0.0f;
        fPitFallForwardSpeed   = 0.0f;
        fPitPositionX          = 0.0f;
        iDeathAnimStartTime    = 0;
        bGroundhit             = false;
        bJumpFlag = false;
        bInJump   = false;
        fCurrentUpwardVelocity = 0;
        fCurrentHeight         = 0;

        bDirectionQueueFlag = false;
        directionQueue      = SwipeControls.SwipeDirection.Null;
        iLanePosition       = 0;        //set current lane to mid
        fCurrentWalkSpeed   = fStartingWalkSpeed;


        if (PlayerPrefs.HasKey("ControlsType"))
        {
            swipeControlsEnabled = PlayerPrefs.GetInt("ControlsType") == 1 ? true : false;
        }
        else
        {
            PlayerPrefs.SetInt("ControlsType", (swipeControlsEnabled == true ? 1 : 0));
        }

        hSoundManager.stopSound(SoundManager.CharacterSounds.Footsteps);
        StartCoroutine("playIdleAnimations");        //start playing idle animations
    }