void Update() { if (!isLocalPlayer) { return; } if (anim.GetCurrentAnimatorStateInfo(0).IsName("Attack")) { Debug.Log("not attacking"); StopAttacking(); } //codice per input management if (dead || downed) { return; } //cerchi con frecce che indicano player downed if (downedManager != null && downedManager.nekoAlive == 0 && !isNeko) { if (nekoMaid == null) { nekoMaid = FindObjectOfType <NekoMaidAttacks>().gameObject; } if (!nekoArrow.activeInHierarchy) { nekoDownedTimerSlider.maxValue = downedManager.nekoDownedTimer; } nekoArrow.SetActive(true); Vector3 nekoPos = nekoMaid.transform.position; Vector3 myPos = transform.position; Vector3 direction = (nekoPos - myPos).normalized; Quaternion resetRot = Quaternion.identity; resetRot.eulerAngles = new Vector3(0, 0, 0); nekoArrow.transform.rotation = resetRot; Quaternion rot = Quaternion.identity; rot.eulerAngles = direction; nekoArrow.transform.rotation = Quaternion.FromToRotation(nekoArrow.transform.up, new Vector3(direction.x, direction.y, 0)); nekoDownedTimerSlider.value = downedManager.nekoDownedTimer; } else { nekoArrow.SetActive(false); } if (downedManager != null && downedManager.octoAlive == 0 && !isOcto) { if (octoChef == null) { octoChef = FindObjectOfType <OctoChefAttacks>().gameObject; } if (!octoArrow.activeInHierarchy) { octoDownedTimerSlider.maxValue = downedManager.octoDownedTimer; } octoArrow.SetActive(true); Vector3 octoPos = octoChef.transform.position; Vector3 myPos = transform.position; Vector3 direction = (octoPos - myPos).normalized; Quaternion resetRot = Quaternion.identity; resetRot.eulerAngles = new Vector3(0, 0, 0); octoArrow.transform.rotation = resetRot; Quaternion rot = Quaternion.identity; rot.eulerAngles = direction; octoArrow.transform.rotation = Quaternion.FromToRotation(octoArrow.transform.up, new Vector3(direction.x, direction.y, 0)); octoDownedTimerSlider.value = downedManager.octoDownedTimer; } else { octoArrow.SetActive(false); } if (downedManager != null && downedManager.fishermanAlive == 0 && !isFisherman) { if (fisherman == null) { fisherman = FindObjectOfType <FishermanAttacks>().gameObject; } if (!fishermanArrow.activeInHierarchy) { fishermanDownedTimerSlider.maxValue = downedManager.fishermanDownedTimer; } fishermanArrow.SetActive(true); Vector3 fishPos = fisherman.transform.position; Vector3 myPos = transform.position; Vector3 direction = (fishPos - myPos).normalized; Quaternion resetRot = Quaternion.identity; resetRot.eulerAngles = new Vector3(0, 0, 0); fishermanArrow.transform.rotation = resetRot; Quaternion rot = Quaternion.identity; rot.eulerAngles = direction; fishermanArrow.transform.rotation = Quaternion.FromToRotation(fishermanArrow.transform.up, new Vector3(direction.x, direction.y, 0)); fishermanDownedTimerSlider.value = downedManager.fishermanDownedTimer; } else { fishermanArrow.SetActive(false); } //movimenti playerMoving = false; m_horizontal = Input.GetAxisRaw("Horizontal"); m_vertical = Input.GetAxisRaw("Vertical"); if (m_horizontal != 0 || m_vertical != 0) { playerMoving = true; lastMove = new Vector2(m_horizontal, m_vertical); } anim.SetFloat("MoveX", m_horizontal); anim.SetFloat("MoveY", m_vertical); anim.SetBool("Moving", playerMoving); anim.SetFloat("LastMoveX", lastMove.x); anim.SetFloat("LastMoveY", lastMove.y); //chiamate alle skill dei personaggi singoli if (usingUltimate) { characterAttacks.UltimateSkill(); return; } if (usingSkillOne) { characterAttacks.SkillOne(); return; } if (usingSkillTwo) { characterAttacks.SkillTwo(); return; } //per debug if (Input.GetKeyDown(KeyCode.L)) { StopAttacking(); } //blocco input mentre si attacca /*if (attacking) { * return; * }*/ //revive downed player if (Input.GetKeyDown(KeyCode.F)) { Collider2D[] nearPlayers = Physics2D.OverlapCircleAll(transform.position, 2); foreach (Collider2D coll in nearPlayers) { GameObject go = coll.gameObject; if (go.CompareTag(Tags.player) && go != gameObject) { PlayerController pl = go.GetComponent <PlayerController>(); if (pl.downed && !pl.dead) { CmdReviveDownedPlayer(go, ConstantsDictionary.MedicateHealthPercentage, ""); } } } } //skill one if (Input.GetKeyDown(KeyCode.Q) && !attacking && skillOneCanBeUsed) { attacking = true; playerMoving = false; anim.SetBool("Skill", true); anim.SetBool("Moving", playerMoving); rb.velocity = Vector2.zero; usingSkillOne = true; characterAttacks.SkillOne(); return; } //skill two if (Input.GetKeyDown(KeyCode.E) && !attacking && skillTwoCanBeUsed) { attacking = true; playerMoving = false; anim.SetBool("Skill", true); anim.SetBool("Moving", playerMoving); rb.velocity = Vector2.zero; usingSkillTwo = true; characterAttacks.SkillTwo(); return; } //ultimate if (Input.GetMouseButtonDown(1) && !attacking && ultimate_charge >= 100) { attacking = true; playerMoving = false; anim.SetBool("Skill", true); anim.SetBool("Moving", playerMoving); rb.velocity = Vector2.zero; usingUltimate = true; characterAttacks.UltimateSkill(); return; } //basic attack if (Input.GetMouseButtonDown(0) && !attacking && Time.time > nextFire) { nextFire = Time.time + fireRate; attacking = true; playerMoving = false; anim.SetBool("Attacking", true); anim.SetBool("Moving", playerMoving); rb.velocity = Vector2.zero; } //Skill Tree if (Input.GetKeyDown(KeyCode.Tab)) { ShowSkillTree(); } }