Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (gameIsPlaying == false) {
- return;
- }
- if (isDead == true) {
- return;
- }
- if (isJumpingUp) {
- if (this.transform.position.x > JumpTargetLocation.x) {
- this.transform.position = new Vector3 (this.transform.position.x - (movingSpeed * Time.deltaTime), this.transform.position.y, this.transform.position.z);
- if (this.transform.position.x > midWayPointX) {
- this.transform.position = new Vector3 (this.transform.position.x, this.transform.position.y + jumpHeightIncrement * Time.deltaTime, this.transform.position.z);
- } else {
- this.transform.position = new Vector3 (this.transform.position.x, this.transform.position.y - jumpHeightIncrement * Time.deltaTime, this.transform.position.z);
- }
- } else {
- isJumpingUp = false;
- this.transform.position = new Vector3 (transform.position.x, initialPositionY, transform.position.z);
- }
- } else if (isJumpingDown) {
- if (this.transform.position.x < JumpTargetLocation.x) {
- this.transform.position = new Vector3 (this.transform.position.x + (movingSpeed * Time.deltaTime), this.transform.position.y, this.transform.position.z);
- if (this.transform.position.x < midWayPointX) {
- this.transform.position = new Vector3 (this.transform.position.x, this.transform.position.y + jumpHeightIncrement * Time.deltaTime, this.transform.position.z);
- } else {
- this.transform.position = new Vector3 (this.transform.position.x, this.transform.position.y - jumpHeightIncrement * Time.deltaTime, this.transform.position.z);
- }
- } else {
- isJumpingDown = false;
- this.transform.position = new Vector3 (transform.position.x, initialPositionY, transform.position.z);
- }
- } else if (isJumpingLeft) {
- if (this.transform.position.z > JumpTargetLocation.z) {
- this.transform.position = new Vector3 (this.transform.position.x, this.transform.position.y, this.transform.position.z - (movingSpeed * Time.deltaTime));
- if (this.transform.position.z > midWayPointX) {
- this.transform.position = new Vector3 (this.transform.position.x, this.transform.position.y + jumpHeightIncrement * Time.deltaTime, this.transform.position.z);
- } else {
- this.transform.position = new Vector3 (this.transform.position.x, this.transform.position.y - jumpHeightIncrement * Time.deltaTime, this.transform.position.z);
- }
- } else {
- isJumpingLeft = false;
- this.transform.position = new Vector3 (transform.position.x, initialPositionY, transform.position.z);
- }
- } else if (isJumpingRight) {
- if (this.transform.position.z < JumpTargetLocation.z) {
- this.transform.position = new Vector3 (this.transform.position.x, this.transform.position.y, this.transform.position.z + (movingSpeed * Time.deltaTime));
- if (this.transform.position.z < midWayPointX) {
- this.transform.position = new Vector3 (this.transform.position.x, this.transform.position.y + jumpHeightIncrement * Time.deltaTime, this.transform.position.z);
- } else {
- this.transform.position = new Vector3 (this.transform.position.x, this.transform.position.y - jumpHeightIncrement * Time.deltaTime, this.transform.position.z);
- }
- } else {
- isJumpingRight = false;
- this.transform.position = new Vector3 (transform.position.x, initialPositionY, transform.position.z);
- }
- }
- if (isPlayingDeathAnimation == true) {
- UpdateDeathAnimation();
- }
- }
- void SpawnNewStrip() {
- int stripsPrefabCount = poolOfStripsPrefabs.Length;
- int randomNumber = Random.Range (0, stripsPrefabCount);
- GameObject item = poolOfStripsPrefabs [randomNumber] as GameObject;
- Transform itemChildTransform = item.transform.GetChild(0) as Transform;
- Transform itemChildOfChildTranform = itemChildTransform.GetChild (0) as Transform;
- float itemWidth = itemChildOfChildTranform.gameObject.GetComponent<Renderer> ().bounds.size.x;
- GameObject lastStrip = strips [strips.Count - 1] as GameObject;
- GameObject newStrip = Instantiate (item, lastStrip.transform.position, lastStrip.transform.rotation) as GameObject;
- newStrip.transform.position = new Vector3 (newStrip.transform.position.x - itemWidth, newStrip.transform.position.y, newStrip.transform.position.z);
- strips.Add (newStrip);
- }
- void OnTriggerEnter(Collider other){
- if (other.gameObject.tag == "Mail") {
- Debug.Log ("player take Mail");
- Score += 25;
- scoreText.text = "score; " + Score.ToString ();
- Destroy (other.gameObject);
- this.GetComponent<AudioSource> ().PlayOneShot (mailClip);
- }
- if (other.gameObject.tag == "Enemy") {
- Debug.Log ("player are dead");
- DeathAnimation();
- }
- if (other.gameObject.tag == "obstacle") {
- Debug.Log ("player hit obstacle");
- float offsetUpDown = 0;
- float offsetLeftRight = 0;
- if(isJumpingUp){
- offsetUpDown = 2.5f;
- }
- else if(isJumpingDown){
- offsetUpDown = -2.5f;
- }
- else if(isJumpingLeft){
- offsetLeftRight = 2.5f;
- }
- else if(isJumpingRight){
- offsetLeftRight = -2.5f;
- }
- transform.position = new Vector3(transform.position.x + offsetUpDown, initialPositionY, transform.position.z + offsetLeftRight);
- isJumpingUp = isJumpingRight = isJumpingLeft = isJumpingDown = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement