void Start() { //script references hPatchesRandomizerCS = (PatchesRandomizerCS)this.GetComponent(typeof(PatchesRandomizerCS)); //hMissionsControllerCS = (MissionsControllerCS)this.GetComponent(typeof(MissionsControllerCS)); //hGlobalAchievementControllerCS = (GlobalAchievementControllerCS)this.GetComponent(typeof(GlobalAchievementControllerCS)); hPlayerSidesColliderScriptCS = (PlayerSidesColliderScriptCS)GameObject.Find("PlayerSidesCollider").GetComponent(typeof(PlayerSidesColliderScriptCS)); hPlayerFrontColliderScriptCS = (PlayerFrontColliderScriptCS)GameObject.Find("PlayerFrontCollider").GetComponent(typeof(PlayerFrontColliderScriptCS)); hSoundManagerCS = (SoundManagerCS)GameObject.Find("SoundManager").GetComponent(typeof(SoundManagerCS)); hInGameScriptCS = (InGameScriptCS)this.GetComponent(typeof(InGameScriptCS)); hPitsMainControllerCS = (PitsMainControllerCS)this.GetComponent(typeof(PitsMainControllerCS)); hCheckPointsMainCS = (CheckPointsMainCS)this.GetComponent(typeof(CheckPointsMainCS)); hPowerupScriptCS = (PowerupsMainControllerCS)this.GetComponent(typeof(PowerupsMainControllerCS)); //hEnemyControllerCS = (EnemyControllerCS)GameObject.Find("Enemy").GetComponent(typeof(EnemyControllerCS)); hPowerupScriptCS = (PowerupsMainControllerCS)this.GetComponent(typeof(PowerupsMainControllerCS)); hCameraControllerCS = (CameraControllerCS)GameObject.Find("Main Camera").GetComponent(typeof(CameraControllerCS)); swipeLogic = (SwipeControlsCS)transform.GetComponent(typeof(SwipeControlsCS)); //tPlayerMesh = (Transform)GameObject.Find("fatguy_").GetComponent(typeof(Transform)); //check which type of menu (Custom or NGUI) to work with if (hInGameScriptCS.isCustomMenuEnabled()) { //hMenuScriptCS = (MenuScriptCS)GameObject.Find("MenuGroup").GetComponent(typeof(MenuScriptCS)); HUDCamera = GameObject.Find("HUDCamera").GetComponent<Camera>(); tHUDGroup = GameObject.Find("HUDMainGroup/HUDGroup").transform; tPauseButton = GameObject.Find("HUDMainGroup/HUDGroup/HUDPause").transform; } tPlayer = transform; tPlayerRotation = transform.Find("PlayerRotation"); //get the animation component of the player character if (this.transform.Find("PlayerRotation/PlayerMesh/Prisoner")) { mecanimEnabled = false; aPlayer = (Animation)this.transform.Find("PlayerRotation/PlayerMesh/Prisoner").GetComponent(typeof(Animation)); StartCoroutine("playIdleAnimations");//start playing idle animations } else if (this.transform.Find("PlayerRotation/PlayerMesh/Prisoner(MecAnim)"))//check for mecanim animated character { mecanimEnabled = true; aPlayerMecAnim = (Animator)this.transform.Find("PlayerRotation/PlayerMesh/Prisoner(MecAnim)").GetComponent(typeof(Animator)); v3DefaultPlayerAnimPosition = aPlayerMecAnim.transform.localPosition;//get the default player position v3DefaultPlayerAnimRotation = aPlayerMecAnim.transform.localEulerAngles;//get the default player rotation } tBlobShadowPlane = transform.Find("BlobShadowPlane");//get the shadow tPlayerSidesCollider = GameObject.Find("PlayerSidesCollider").transform;//get the sides collider to detect stumbles tFrontCollider = GameObject.Find("PlayerFrontCollider").transform;//get the front collider to detect collisions 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; fDeathAnimStartTime = 0; bGroundhit = false; bJumpFlag = false; bInJump = false; fCurrentUpwardVelocity = 0; fCurrentHeight = 0; bDirectionQueueFlag = false; directionQueue = SwipeControlsCS.SwipeDirection.Null; iLanePosition = 0; //set current lane to mid fCurrentWalkSpeed = fStartingWalkSpeed; //get the type of controls (swipe or gyro) set by user if (PlayerPrefs.HasKey("ControlsType")) swipeControlsEnabled = PlayerPrefs.GetInt("ControlsType") == 1 ? true : false; else PlayerPrefs.SetInt("ControlsType", (swipeControlsEnabled == true ? 1 : 0)); //stop footsteps sound if playing hSoundManagerCS.stopSound(SoundManagerCS.CharacterSounds.Footsteps); stumbledXtimes = 0; }//end of Start()
void Start() { //script references hPatchesRandomizerCS = (PatchesRandomizerCS)this.GetComponent(typeof(PatchesRandomizerCS)); hMissionsControllerCS = (MissionsControllerCS)this.GetComponent(typeof(MissionsControllerCS)); hGlobalAchievementControllerCS = (GlobalAchievementControllerCS)this.GetComponent(typeof(GlobalAchievementControllerCS)); hPlayerSidesColliderScriptCS = (PlayerSidesColliderScriptCS)GameObject.Find("PlayerSidesCollider").GetComponent(typeof(PlayerSidesColliderScriptCS)); hPlayerFrontColliderScriptCS = (PlayerFrontColliderScriptCS)GameObject.Find("PlayerFrontCollider").GetComponent(typeof(PlayerFrontColliderScriptCS)); hSoundManagerCS = (SoundManagerCS)GameObject.Find("SoundManager").GetComponent(typeof(SoundManagerCS)); hInGameScriptCS = (InGameScriptCS)this.GetComponent(typeof(InGameScriptCS)); hPitsMainControllerCS = (PitsMainControllerCS)this.GetComponent(typeof(PitsMainControllerCS)); hCheckPointsMainCS = (CheckPointsMainCS)this.GetComponent(typeof(CheckPointsMainCS)); hPowerupScriptCS = (PowerupsMainControllerCS)this.GetComponent(typeof(PowerupsMainControllerCS)); hEnemyControllerCS = (EnemyControllerCS)GameObject.Find("Enemy").GetComponent(typeof(EnemyControllerCS)); hPowerupScriptCS = (PowerupsMainControllerCS)this.GetComponent(typeof(PowerupsMainControllerCS)); hCameraControllerCS = (CameraControllerCS)GameObject.Find("Main Camera").GetComponent(typeof(CameraControllerCS)); swipeLogic = (SwipeControlsCS)transform.GetComponent(typeof(SwipeControlsCS)); //check which type of menu (Custom or NGUI) to work with if (hInGameScriptCS.isCustomMenuEnabled()) { hMenuScriptCS = (MenuScriptCS)GameObject.Find("MenuGroup").GetComponent(typeof(MenuScriptCS)); HUDCamera = GameObject.Find("HUDCamera").GetComponent <Camera>(); tHUDGroup = GameObject.Find("HUDMainGroup/HUDGroup").transform; tPauseButton = GameObject.Find("HUDMainGroup/HUDGroup/HUDPause").transform; } tPlayer = transform; tPlayerRotation = transform.Find("PlayerRotation"); //get the animation component of the player character if (this.transform.Find("PlayerRotation/PlayerMesh/Prisoner")) { mecanimEnabled = false; aPlayer = (Animation)this.transform.Find("PlayerRotation/PlayerMesh/Prisoner").GetComponent(typeof(Animation)); StartCoroutine("playIdleAnimations"); //start playing idle animations } else if (this.transform.Find("PlayerRotation/PlayerMesh/Prisoner(MecAnim)")) //check for mecanim animated character { mecanimEnabled = true; aPlayerMecAnim = (Animator)this.transform.Find("PlayerRotation/PlayerMesh/Prisoner(MecAnim)").GetComponent(typeof(Animator)); v3DefaultPlayerAnimPosition = aPlayerMecAnim.transform.localPosition; //get the default player position v3DefaultPlayerAnimRotation = aPlayerMecAnim.transform.localEulerAngles; //get the default player rotation } tBlobShadowPlane = transform.Find("BlobShadowPlane"); //get the shadow tPlayerSidesCollider = GameObject.Find("PlayerSidesCollider").transform; //get the sides collider to detect stumbles tFrontCollider = GameObject.Find("PlayerFrontCollider").transform; //get the front collider to detect collisions 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; fDeathAnimStartTime = 0; bGroundhit = false; bJumpFlag = false; bInJump = false; fCurrentUpwardVelocity = 0; fCurrentHeight = 0; bDirectionQueueFlag = false; directionQueue = SwipeControlsCS.SwipeDirection.Null; iLanePosition = 0; //set current lane to mid fCurrentWalkSpeed = fStartingWalkSpeed; //get the type of controls (swipe or gyro) set by user if (PlayerPrefs.HasKey("ControlsType")) { swipeControlsEnabled = PlayerPrefs.GetInt("ControlsType") == 1 ? true : false; } else { PlayerPrefs.SetInt("ControlsType", (swipeControlsEnabled == true ? 1 : 0)); } //stop footsteps sound if playing hSoundManagerCS.stopSound(SoundManagerCS.CharacterSounds.Footsteps); } //end of Start()