예제 #1
0
    void SineWaveShoot(Vector3 targetPos, bool isStartLeft)
    {
        Transform currBullet = null;

        if (ownerType == OwnerType.PLAYER)
        {
            currBullet = BulletManager.sSingleton.GetBulletTrans(BulletManager.GroupIndex.PLAYER_MAIN, mainBulletIndex);
        }
        else
        {
            currBullet = BulletManager.sSingleton.GetBulletTrans(BulletManager.GroupIndex.ENEMY, mainBulletIndex);
        }

        Vector3 temp = owner.position;

        temp.x += offsetPosition.x;
        temp.y += offsetPosition.y;
        currBullet.position = temp;
        currBullet.gameObject.SetActive(true);

        Vector2 dir = Vector2.zero;

        if (ownerType == OwnerType.PLAYER)
        {
            dir = bulletDirection;
        }
        else
        {
            if (isShootPlayer)
            {
                if (isFollowPlayer)
                {
                    dir = (Vector2)(targetPos - owner.transform.position).normalized;
                }
                else if (!isFollowPlayer)
                {
                    if (mSavedDir == Vector2.zero)
                    {
                        mSavedDir = (Vector2)(targetPos - owner.transform.position).normalized;
                    }
                    dir = mSavedDir;
                }
            }
            else
            {
                if (isDirectionFromOwner)
                {
                    Vector2 nextPos = (Vector2)owner.position + shootDirection;
                    dir = (nextPos - (Vector2)owner.position).normalized;
                }
                else
                {
                    dir = (Vector2)((Vector3)shootDirection - owner.position).normalized;
                }
            }
        }

        BulletMove bulletMove = currBullet.GetComponent <BulletMove>();

        SetProperties(ref bulletMove, dir);
        bulletMove.SetCurveAxis(GetCurveAxis(dir, isStartLeft));
    }