void Update() { if (timer > 0) { timer -= Time.deltaTime; } if (Input.GetKeyDown(KeyCode.Mouse1) && timer <= 0) { if (weaponName == "knife") { MeleeAttack(knifeDamage, knifeRange); } else if (weaponName == "spear") { MeleeAttack(spearDamage, spearRange); } else if (weaponName == "javelin") { ThrowJavelin(javelinDamage, javelinForce); } timer = 0.5f; } if (Input.GetKeyDown(KeyCode.I)) { inventory.gameObject.SetActive(!inventory.gameObject.activeInHierarchy); craftingPanel.SetActive(!craftingPanel.gameObject.activeInHierarchy); PauseButton.GetInstance().SwitchPause(); } Collider[] overlaps = Physics.OverlapSphere(transform.position, 0.15f); for (int i = 0; i < overlaps.Length; i++) { if (overlaps[i].tag == "KelpBank") { isOverKelp = true; break; } if (i == overlaps.Length - 1) { isOverKelp = false; break; } } if (isOverKelp && HasRaft()) { speed = raftSpeed / 2; } else if (isOverKelp && !HasRaft()) { speed = originalSpeed / 2; } else if (!isOverKelp) { SetSpeeds(); } }
void Update() //Se buggea (No se va de pantalla) el cartel de gather si apretaste F y despues te fuiste sin recolectar nada { if (!player) { player = GlobalRef.playerPos.gameObject.GetComponent <PlayerController>(); } if (canGather && !gathering) { RaycastHit hitInfo; if (Physics.Raycast(GlobalRef.cameraPos.position, GlobalRef.cameraPos.forward, out hitInfo) && hitInfo.collider == col) { GlobalRef.gNotice.gameObject.SetActive(true); GlobalRef.gNotice.text = "Press F to gather from " + resName + "."; if (Input.GetKeyDown(KeyCode.F)) { gathering = true; PauseButton.GetInstance().SwitchPause(); StartGather(); return; } } else { if (GlobalRef.gNotice.gameObject.activeInHierarchy) { GlobalRef.gNotice.gameObject.SetActive(false); } if (gathering) { StopGather(); Cursor.visible = false; } } } if (gathering) { GlobalRef.gNotice.text = "Press F to finish."; } if (gathering && Input.GetKeyDown(KeyCode.F)) { StopGather(); PauseButton.GetInstance().SwitchPause(); GlobalRef.gNotice.gameObject.SetActive(false); gathering = false; GlobalRef.gNotice.text = ""; } }