protected override void basicAttack1() { colliderList = Physics.OverlapSphere(transform.position, m_rangeToTakeBullet); FlingableRock bullet = null; if (colliderList.Length > 0) { bullet = findBullet(); if (!bullet) { spawnAndFlingBullet(m_launcher, m_attack1ForceUp, m_attack1ForceForward); } else { // GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); // sphere.transform.position = transform.position; // sphere.transform.localScale = new Vector3(1, 1, 1) * m_rangeToTakeBullet; // sphere.GetComponent<SphereCollider>().enabled = false; // UnityEditor.EditorApplication.isPaused = true; bullet.setUser(gameObject); bullet.fling(m_launcher, m_attack1ForceUp, m_attack1ForceForward, false); } } else { spawnAndFlingBullet(m_launcher, m_attack1ForceUp, m_attack1ForceForward); } m_executingAtk1 = true; m_Animator.Play("Attack 01"); m_Animator.CrossFade("Grounded", 1f); }
private void basicAttack1() { AttackLauncher atkLauncher = GetComponent <AttackLauncher>(); Ray ray = atkLauncher.getAimRay(); RaycastHit hit; bool collided = Physics.Raycast(ray, out hit, 5000); BreakableRock breakableRock = null; if (hit.collider) { breakableRock = hit.collider.GetComponentInParent <BreakableRock>(); } if (Physics.Raycast(ray, out hit, 5000)) { if (collided && breakableRock != null) { breakableRock.breakRock(gameObject, GetComponent <AttackLauncher>(), m_attack1ForceUp, m_attack1ForceForward); } else { Collider[] colliders = Physics.OverlapSphere(transform.position, m_rangeToTakeBullet); FlingableRock bullet = null; if (colliders.Length > 0) { bullet = findBullet(colliders); if (!bullet) { spawnAndFlingBullet(GetComponent <AttackLauncher>(), m_attack1ForceUp, m_attack1ForceForward); } else { // GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); // sphere.transform.position = transform.position; // sphere.transform.localScale = new Vector3(1, 1, 1) * m_rangeToTakeBullet; // sphere.GetComponent<SphereCollider>().enabled = false // UnityEditor.EditorApplication.isPaused = true; bullet.setUser(gameObject); myCurrentBullet = bullet; bullet.fling(GetComponent <AttackLauncher>(), m_attack1ForceUp, m_attack1ForceForward, false); } } else { spawnAndFlingBullet(GetComponent <AttackLauncher>(), m_attack1ForceUp, m_attack1ForceForward); } } } GetComponent <BasicMovement>().m_Animator.Play("Attack 01"); GetComponent <BasicMovement>().m_Animator.CrossFade("Grounded", 1f); }
public void breakRock(GameObject _user, AttackLauncher _launcher, float _forceUp, float _forceForward) { if (transform.childCount <= 1) { return; } Transform child = transform.GetChild(0); if (!child.name.Contains("Part")) { return; } MeshRenderer childMeshRenderer = child.GetComponent <MeshRenderer>(); float centerRatio = childMeshRenderer.bounds.size.y / (2 * m_size.y); m_boxCollider.center -= new Vector3(0, centerRatio, 0); float sizeRatio = 1 - childMeshRenderer.bounds.size.y / m_size.y; m_boxCollider.size = new Vector3(m_boxCollider.size.x, sizeRatio, m_boxCollider.size.z); m_size -= childMeshRenderer.bounds.size; if (m_pieceList.Count == 0) { return; } Object obj = Instantiate(m_pieceList[0], child.position + Vector3.up * 0.1f, child.rotation); m_pieceList.RemoveAt(0); GameObject gameObject = (GameObject)obj; scaleIt(gameObject); FlingableRock flingableRock = gameObject.GetComponent <FlingableRock>(); Destroy(child.gameObject); flingableRock.setUser(_user); flingableRock.fling(_launcher, _forceUp, _forceForward, true); }