void R() { ClearRange(); selected = 'R'; ShowRange(RRANGE); GLOBAL.DrawLine(transform.position + offset, RF.Mouse.transform.position, Color.red, .1f, RRANGE); if (GLOBAL.LeftClickHit()) { RaycastHit h = GLOBAL.MousePosRay(); Character c = h.collider.GetComponent <Character>(); if (GLOBAL.CheckCharacter(character, c)) { target = h.transform; CharacterPlayerNav.MoveTo(c.transform.position); chasing = true; } else { target = null; chasing = false; } } if (target != null && GLOBAL.HasReached(transform.position, target.position, BrandAbilities.RRANGE)) { Shoot(selected); } }
void BasicAttack() { #region ignore //Ray ray = new Ray(transform.position, Camera.main.ScreenToWorldPoint(Input.mousePosition)); //if (Physics.Raycast(ray, out RaycastHit hit, range, 9)) //{ // Transform t = hit.collider.gameObject.transform; // Character c = hit.collider.GetComponent<Character>(); // if (c != null && c.range >= Vector3.Distance(transform.position, t.position)) // { // } //} #endregion if (GLOBAL.RightClick()) { if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit)) { Character c = hit.collider.GetComponent <Character>(); // If a character is hit and is not yourself. if (GLOBAL.CheckCharacter(this, c)) { // Set the target to the clicked character. target = c.transform; // In range. if (GLOBAL.HasReached(transform.position, target.position, AutoRange)) { AutoAttack(); } // Chase this character. chasing = true; } else { // Do nothing and move there. target = null; chasing = false; } } } // Chase target. if (chasing) { // In range. if (GLOBAL.HasReached(transform.position, target.position, AutoRange)) { AutoAttack(); } else { // Out of range. Invoke(nameof(MaintainDistance), .5f); } } }