Exemple #1
0
    public void OnTriggerEnter(Collider other) {
		if (other.tag.Equals ("oil"))
			top_speed -= 30;
		else if (other.gameObject.CompareTag ("Pick Up") && powerUp == Avail_PowerUps.None) {
			int i = UnityEngine.Random.Range (1, 4);
			powerUp = (Avail_PowerUps)Enum.GetValues (typeof(Avail_PowerUps)).GetValue (i);
		}
    }
Exemple #2
0
 public void OnTriggerEnter(Collider other)
 {
     if (other.tag.Equals ("oil"))
         top_speed -= 30;
     else if (other.gameObject.CompareTag ("Pick Up") && powerUp == Avail_PowerUps.None) {
         int i = UnityEngine.Random.Range (1, 4);
         powerUp = (Avail_PowerUps)Enum.GetValues (typeof(Avail_PowerUps)).GetValue (i);
     }
 }
Exemple #3
0
	// Update is called once per frame
	void FixedUpdate () {
		if (lap_count < 2 && winpage == false) {
			velocity = deltaVelocity (velocity);
			float next_position;
			if (lane_change_pause < 15)
				lane_change_pause++;
			if (u + 1 >= bspline.Length)
				next_position = u + 1 - bspline.Length;
			else
				next_position = (float)Math.Truncate (u) + 1f;
			float point_smooth = 1 / (bspline.Evaluate (next_position) - bspline.Evaluate ((float)Math.Truncate (u))).magnitude;
			u += Time.fixedDeltaTime * velocity / 5 * point_smooth;
			if (CrossPlatformInputManager.GetAxis ("Horizontal") != 0 && lane_change_pause == 15)
				changeLanes ();
			if (u >= bspline.Length) {
				u -= bspline.Length;
				lap_count += 1;
			}
			Vector3 next_pos = bspline.Evaluate (u);
			UI_Update ();
			ghost.transform.LookAt (next_pos);
			ghost.transform.position = next_pos;
			if (whatTrack == -1)
				next_pos = ghost.transform.position - ghost.transform.right * shift;
			else if (whatTrack == 1)
				next_pos = ghost.transform.position + ghost.transform.right * shift;
			if (lane_change != 1) {
				if (lane_change + 0.01 > 1f)
					lane_change = 1;
				else
					lane_change += 0.01f;
			}
			if (u < 76 || u > 87)
				next_pos.y = gameTerrain.SampleHeight (next_pos) + 0.3f;
			transform.localRotation = ghost.transform.localRotation;
			transform.position = transform.position * (1 - lane_change) + next_pos * lane_change;
			if (Input.GetKeyDown ("space") && powerUp != Avail_PowerUps.None) {
				//Debug.Log (powerUp);
				power_up.enabled = false;
				spawnPoint.UsePowerUp (powerUp);
				powerUp = Avail_PowerUps.None;
				//            Debug.Log(powerUp);
			}
		}
			else if (winpage == false){
				print ("You WIN!!!!!");
				winpage = true;
			}
	}
Exemple #4
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (lap_count < 2 && winpage == false) {
         velocity = deltaVelocity (velocity);
         float next_position;
         if (lane_change_pause < 15)
             lane_change_pause++;
         if (u + 1 >= bspline.Length)
             next_position = u + 1 - bspline.Length;
         else
             next_position = (float)Math.Truncate (u) + 1f;
         float point_smooth = 1 / (bspline.Evaluate (next_position) - bspline.Evaluate ((float)Math.Truncate (u))).magnitude;
         u += Time.fixedDeltaTime * velocity / 5 * point_smooth;
         if (CrossPlatformInputManager.GetAxis ("Horizontal") != 0 && lane_change_pause == 15)
             changeLanes ();
         if (u >= bspline.Length) {
             u -= bspline.Length;
             lap_count += 1;
         }
         Vector3 next_pos = bspline.Evaluate (u);
         UI_Update ();
         ghost.transform.LookAt (next_pos);
         ghost.transform.position = next_pos;
         if (whatTrack == -1)
             next_pos = ghost.transform.position - ghost.transform.right * shift;
         else if (whatTrack == 1)
             next_pos = ghost.transform.position + ghost.transform.right * shift;
         if (lane_change != 1) {
             if (lane_change + 0.01 > 1f)
                 lane_change = 1;
             else
                 lane_change += 0.01f;
         }
         if (u < 76 || u > 87)
             next_pos.y = gameTerrain.SampleHeight (next_pos) + 0.3f;
         transform.localRotation = ghost.transform.localRotation;
         transform.position = transform.position * (1 - lane_change) + next_pos * lane_change;
         if (Input.GetKeyDown ("space") && powerUp != Avail_PowerUps.None) {
             //Debug.Log (powerUp);
             power_up.enabled = false;
             spawnPoint.UsePowerUp (powerUp);
             powerUp = Avail_PowerUps.None;
             //            Debug.Log(powerUp);
         }
     }
         else if (winpage == false){
             print ("You WIN!!!!!");
             winpage = true;
         }
 }