Пример #1
0
    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);
    }