Beispiel #1
0
    void Start()
    {
        iObstacleCount = obstaclePrefabs.Length;
        iPowerupCount  = powerupPrefabs.Length;
        iTotalCount    = iObstacleCount + iPowerupCount + 1;     //obstacles + powerups + currency

        bGenerateElements = true;
        bPowerupPlaced    = true;     //do not place powerup on first patch
        System.DateTime dt = System.DateTime.Now;
        Random.seed = dt.Hour * dt.Minute * dt.Second;

        setPrefabHandlers();

        hPowerupsMainControllerCS = (PowerupsMainControllerCS)this.GetComponent(typeof(PowerupsMainControllerCS));
        hCheckPointsMainCS        = (CheckPointsMainCS)GameObject.Find("Player").GetComponent(typeof(CheckPointsMainCS));
        hPatchesRandomizerCS      = (PatchesRandomizerCS)this.GetComponent(typeof(PatchesRandomizerCS));

        //generate elements on first patch
        float i = 0.20f;

        while (i < 0.99f)
        {
            float incrementValue = generateElements(getRandomElement(), i, true); //get any type of element
            i += incrementValue;
        }                                                                         //end of while
    }                                                                             //end of Start()
	void Start()
	{
		iObstacleCount = obstaclePrefabs.Length;
		iPowerupCount = powerupPrefabs.Length;
		iTotalCount = iObstacleCount + iPowerupCount + 1;//obstacles + powerups + currency
		
		bGenerateElements = true;
		bPowerupPlaced = true;//do not place powerup on first patch
		System.DateTime dt = System.DateTime.Now;
		Random.seed = dt.Hour * dt.Minute * dt.Second;
		
		setPrefabHandlers();
		
		hPowerupsMainControllerCS = (PowerupsMainControllerCS)this.GetComponent(typeof(PowerupsMainControllerCS));
		hCheckPointsMainCS = (CheckPointsMainCS)GameObject.Find("Player").GetComponent(typeof(CheckPointsMainCS));
		hPatchesRandomizerCS = (PatchesRandomizerCS)this.GetComponent(typeof(PatchesRandomizerCS));
		
		//generate elements on first patch
		float i = 0.20f;
		while (i < 0.99f)
		{	
			float incrementValue = generateElements(getRandomElement(), i, true);//get any type of element
			i += incrementValue;
		}//end of while		
	}//end of Start()
    void Start()
    {
        hInGameScriptCS      = (InGameScriptCS)this.GetComponent(typeof(InGameScriptCS));
        hCheckPointsMainCS   = (CheckPointsMainCS)GetComponent(typeof(CheckPointsMainCS));
        hElementsGeneratorCS = (ElementsGeneratorCS)this.GetComponent(typeof(ElementsGeneratorCS));

        iCurrentPNum           = 1;
        fPreviousTotalDistance = 0.0f;
        fPatchDistance         = hCheckPointsMainCS.getDefaultPathLength();

        instantiateStartPatch();
        goPreviousPatch = goCurrentPatch;

        tPlayer = GameObject.Find("Player").transform;
        hCheckPointsMainCS.setChildGroups();

        hCheckPointsMainCS.SetCurrentPatchCPs();
        hCheckPointsMainCS.SetNextPatchCPs();
    }
	void Start()
	{
		hInGameScriptCS = (InGameScriptCS)this.GetComponent(typeof(InGameScriptCS));
		hCheckPointsMainCS = (CheckPointsMainCS)GetComponent(typeof(CheckPointsMainCS));
		hElementsGeneratorCS = (ElementsGeneratorCS)this.GetComponent(typeof(ElementsGeneratorCS));
		
		iCurrentPNum = 1;
		fPreviousTotalDistance = 0.0f;
		fPatchDistance = hCheckPointsMainCS.getDefaultPathLength();
		
		instantiateStartPatch();	
		goPreviousPatch = goCurrentPatch;	
		
		tPlayer = GameObject.Find("Player").transform;
		hCheckPointsMainCS.setChildGroups();
		
		hCheckPointsMainCS.SetCurrentPatchCPs();
		hCheckPointsMainCS.SetNextPatchCPs();
	}
Beispiel #5
0
    // Use this for initialization
    void Start()
    {
        bMoving = false;

        hCheckPointsMainCS   = (CheckPointsMainCS)GameObject.Find("Player").GetComponent(typeof(CheckPointsMainCS));
        hPatchesRandomizerCS = (PatchesRandomizerCS)GameObject.Find("Player").GetComponent(typeof(PatchesRandomizerCS));
        if (this.transform.parent.parent == null)
        {
            hPathLineDrawerCS = (PathLineDrawerCS)this.transform.parent.GetComponentInChildren(typeof(PathLineDrawerCS));
            patch             = this.transform.parent.gameObject;
        }
        else
        {
            hPathLineDrawerCS = (PathLineDrawerCS)this.transform.parent.parent.GetComponentInChildren(typeof(PathLineDrawerCS));
            patch             = this.transform.parent.parent.gameObject;
        }

        fSpeedPercent = fSpeed / hPathLineDrawerCS.fPathLength;

        isNext  = patch == hPatchesRandomizerCS.getNextPatch();
        isFirst = patch == hPatchesRandomizerCS.getCurrentPatch();
        Vector3 pos;

        if (isNext)
        {
            pos    = hCheckPointsMainCS.getNextWSPointBasedOnPercent(fPercent);
            fAngle = hPatchesRandomizerCS.getNextPatch().transform.eulerAngles.y;
        }
        else
        {
            pos    = hCheckPointsMainCS.getCurrentWSPointBasedOnPercent(fPercent);
            fAngle = hPatchesRandomizerCS.getCurrentPatch().transform.eulerAngles.y;
        }

        offset = this.transform.position - pos;
    }
Beispiel #6
0
    // Use this for initialization
    void Start()
    {
        fTime = fFrequence;

        hCheckPointsMainCS = (CheckPointsMainCS)GameObject.Find("Player").GetComponent(typeof(CheckPointsMainCS));
    }
	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()