// Update is called once per frame void Update() { arrowSpeed = gen.arrowSpeed; Vector3 tempPos = transform.position; tempPos.y -= arrowSpeed; transform.position = tempPos; if (Input.GetKeyDown(KeyCode.D) && dir == direction.a) { CheckLocation(); } if (Input.GetKeyDown(KeyCode.F) && dir == direction.b) { CheckLocation(); } if (Input.GetKeyDown(KeyCode.Space) && dir == direction.spc) { CheckLocation(); } if (Input.GetKeyDown(KeyCode.J) && dir == direction.c) { CheckLocation(); } if (Input.GetKeyDown(KeyCode.K) && dir == direction.d) { CheckLocation(); } //Missed if (transform.position.y < arrowBack.transform.position.y - strumOffset) { GetComponent <Renderer>().material.SetColor("_Color", new Color(0.5f, 0.0f, 0.0f)); StartCoroutine(DespawnArrow()); if (!scoreApplied) { scoreApplied = true; scoreHandler.SendMessage("LoseScore"); scoreHandler.SendMessage("LoseCombo"); heartbeatController.SendMessage("loseLife"); } } }
/// <summary> /// checks if the falling arrow was hit at the right place /// </summary> void CheckLocation() { if (transform.position.y >= arrowBack.transform.position.y - strumOffset && transform.position.y <= arrowBack.transform.position.y + strumOffset) { arrowBack.GetComponent <Animator>().SetBool("isLit", true); // color arrow scoreHandler.SendMessage("AddScore"); // update score Destroy(this.gameObject); // destroy arrow } }
// Update is called once per frame void Update() { Debug.Log("Arrow_Movement.Update()"); arrowSpeed = gen.arrowSpeed; Vector3 tempPos = transform.position; tempPos.y -= arrowSpeed; transform.position = tempPos; if (Input.GetKeyDown(KeyCode.LeftArrow) && dir == direction.left) { CheckLocation(); } if (Input.GetKeyDown(KeyCode.DownArrow) && dir == direction.down) { CheckLocation(); } if (Input.GetKeyDown(KeyCode.UpArrow) && dir == direction.up) { CheckLocation(); } if (Input.GetKeyDown(KeyCode.RightArrow) && dir == direction.right) { CheckLocation(); } //Missed if (transform.position.y < arrowBack.transform.position.y - strumOffset) { GetComponent <Renderer>().material.SetColor("_Color", new Color(0.5f, 0.0f, 0.0f)); StartCoroutine(DespawnArrow()); if (!scoreApplied) { scoreApplied = true; scoreHandler.SendMessage("LoseScore"); } } }