void Update() { RaycastHit hit; Ray forward = new Ray(transform.position, transform.forward); Ray backward = new Ray(transform.position, transform.forward * -1); if (Physics.Raycast(forward, out hit) || Physics.Raycast(backward, out hit)) { if (hit.transform.CompareTag("Enemy")) { direction *= -1; } else if (hit.transform.gameObject.CompareTag("Player") && !isCoolingDown) { isCoolingDown = true; FireComponent.numberOfCollectedParasites = 1; FireComponent.Fire(); Invoke("ResetCoolDown", 2 / difficultyMultipyer); } else if (hit.distance < 1.1f && Physics.Raycast(transform.position + Vector3.up * 0.2f, -transform.up, 0.25f)) { //JumpComponent.Jump(); } } MovmentComponent.Move(direction); RotationComponent.RotateTowards(target); MovmentComponent.thisUpdate(); }
public void tutorial() { switch (currentTutorialState) { case Tutorial_States.PRE_START: animator.SetTrigger("ZoomIn"); currentTutorialState = Tutorial_States.START; break; case Tutorial_States.START: controlls_Text.text = "Press RIGHT"; DebugLogging.CustomDebug("here"); playerController.enabled = true; movmentComponent.enabled = true; if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow)) { currentTutorialState = Tutorial_States.MOVE_RIGHT; } break; case Tutorial_States.MOVE_RIGHT: controlls_Text.text = "Press LEFT"; if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow)) { currentTutorialState = Tutorial_States.MOVE_LEFT; } break; case Tutorial_States.MOVE_LEFT: controlls_Text.text = "Press SPACE"; jumpComponent.enabled = true; if (Input.GetKeyDown(KeyCode.Space)) { currentTutorialState = Tutorial_States.JUMP; } break; case Tutorial_States.JUMP: controlls_Text.text = "RIGHT click to collect parasite in range"; collectComponent.enabled = true; parasite.SetActive(true); paraiteMove.Move(-1); if (Input.GetKeyDown(KeyCode.Mouse1) && collectComponent.numberOfCollectedParasites > 0) { currentTutorialState = Tutorial_States.COLLECT; parasite.SetActive(false); } break; case Tutorial_States.COLLECT: controlls_Text.text = "LEFT click fire parasite"; fireComponent.enabled = true; if (Input.GetKeyDown(KeyCode.Mouse0)) { currentTutorialState = Tutorial_States.FIRE; } break; case Tutorial_States.FIRE: controlls_Text.text = string.Empty; isTutorialRunning = false; animator.SetTrigger("ZoomOut"); PanelMain.SetActive(true); playerController.enabled = false; movmentComponent.enabled = false; jumpComponent.enabled = false; collectComponent.enabled = false; fireComponent.enabled = false; break; } }