// Update is called once per frame void Update() { if (actionCount > 0.0f) { switch (action) { case 1: //step forward transform.Translate(0.0f, 0.0f, 1.5f * Time.deltaTime); actionCount -= 1.5f * Time.deltaTime; break; case 2: //step backward transform.Translate(0.0f, 0.0f, -1.5f * Time.deltaTime); actionCount -= 1.5f * Time.deltaTime; break; case 3: //turn right transform.Rotate(0.0f, 100.0f * Time.deltaTime, 0.0f); actionCount -= 100.0f * Time.deltaTime; break; case 4: //turn left transform.Rotate(0.0f, -100.0f * Time.deltaTime, 0.0f); actionCount -= 100.0f * Time.deltaTime; break; case 5: //fall if (transform.position.y < -0.2f) { if (cubeManager.ObjectCollision(Bottom.position)) { transform.position = new Vector3( cubeManager.CollidedObj.position.x, cubeManager.CollidedObj.position.y + 0.832f, cubeManager.CollidedObj.position.z); } else { Camera.SetParent(null); transform.Translate(0.0f, -0.5f * Time.deltaTime, 0.0f); } } else { transform.Translate(0.0f, -2.0f * Time.deltaTime, 0.0f); actionCount -= 2.0f * Time.deltaTime; } break; case 6: //cross jump transform.Translate(0.0f, 0.0f, 3.0f * Time.deltaTime); actionCount -= 1.5f * Time.deltaTime; break; case 7: //pushing transform.Translate(0.0f, 0.0f, 1.0f * Time.deltaTime); if (Mathf.RoundToInt(transform.eulerAngles.y) == 0) { cubeManager.PushableObj.Translate(0.0f, 0.0f, 1.0f * Time.deltaTime); } else if (Mathf.RoundToInt(transform.eulerAngles.y) == 270) { cubeManager.PushableObj.Translate(-1.0f * Time.deltaTime, 0.0f, 0.0f); } else if (Mathf.RoundToInt(transform.eulerAngles.y) == 180) { cubeManager.PushableObj.Translate(0.0f, 0.0f, -1.0f * Time.deltaTime); } else if (Mathf.RoundToInt(transform.eulerAngles.y) == 90) { cubeManager.PushableObj.Translate(1.0f * Time.deltaTime, 0.0f, 0.0f); } actionCount -= 1.0f * Time.deltaTime; break; case 8: //jump transform.Translate(0.0f, 0.0f, 1.5f * Time.deltaTime); actionCount -= 1.5f * Time.deltaTime; if (jumpCount > 0.0f) //jump { transform.Translate(0.0f, 2.5f * Time.deltaTime, 0.0f); jumpCount -= 2.5f * Time.deltaTime; } break; case 9: //spring jump near transform.Translate(0.0f, 0.0f, 1.5f * Time.deltaTime); actionCount -= 1.5f * Time.deltaTime; if (jumpCount > 0.0f) //jump { transform.Translate(0.0f, 5.0f * Time.deltaTime, 0.0f); jumpCount -= 5.0f * Time.deltaTime; } break; case 10: //spring jump far transform.Translate(0.0f, 0.0f, 3.0f * Time.deltaTime); actionCount -= 1.5f * Time.deltaTime; if (jumpCount > 0.0f) //jump { transform.Translate(0.0f, 2.5f * Time.deltaTime, 0.0f); jumpCount -= 2.5f * Time.deltaTime; } break; } if (actionCount < 0.0f) { if (action == 3 || action == 4) { fixRotate(); } if ((action == 1 || action == 2 || action == 5 || action == 6 || action == 8 || action == 9)) { if (!cubeManager.ObjectCollision(Bottom.position)) { fall(); } else { fixPosition(); actionCount = 0.0f; action = 0; } } else { if (action == 7) { cubeManager.PushableObj.position = new Vector3( Mathf.Round(cubeManager.PushableObj.position.x), cubeManager.PushableObj.position.y, Mathf.Round(cubeManager.PushableObj.position.z)); if (!cubeManager.ObjectCollision(LowerFront.position)) { cubeManager.invokeCubeFall(cubeManager.PushableObj); } else { cubeManager.PushableObj.SetParent(cubeManager.CollidedObj); } } actionCount = 0.0f; action = 0; } foreach (var note in LevelManager.MusicalNotes) { if (Vector3.Distance(transform.position, note.position) < 0.4f) { LevelManager.MusicalNotes.Remove(note); Destroy(note.gameObject); break; } } } } cubeManager.FallAction(); }