예제 #1
0
    public IEnumerator RotateBullet()
    {
        while (true)
        {
            if (movingBullet.bulletMoveSpeed <= 0.0f)
            {
                movingBullet.bulletMoveSpeed             = 3.0f;
                movingBullet.bulletDecelerationMoveSpeed = 0.06f;
                if (initializeBullet.bulletNumber <= 2)
                {
                    movingBullet.ChangeRotateAngle(movingBullet.GetAngle() + 25.0f + 180.0f);
                }
                else
                {
                    movingBullet.ChangeRotateAngle(movingBullet.GetAngle() - 25.0f + 180.0f);
                }

                if (rotateCount >= 1)
                {
                    spriteRenderer.sprite         = enemyFire.spriteCollection[79];
                    movingBullet.bulletMoveSpeed  = 2.0f;
                    movingBullet.bulletSpeedState = BulletSpeedState.BULLETSPEEDSTATE_NORMAL;
                    break;
                }
                else
                {
                    spriteRenderer.sprite = enemyFire.spriteCollection[78];
                    rotateCount++;
                }
            }

            yield return(new WaitForEndOfFrame());
        }
    }
예제 #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        SpriteRenderer   spriteRenderer   = this.GetComponent <SpriteRenderer>();
        InitializeBullet initializeBullet = this.GetComponent <InitializeBullet>();
        MovingBullet     movingBullet     = this.GetComponent <MovingBullet>();

        if (!initializeBullet.bulletReflect.Equals(BulletReflect.BULLETREFLECT_NONE) && collision.tag.Equals("REFLECTZONE"))
        {
            if (this.gameObject.activeSelf.Equals(true) && reflectCount < reflectLimit)
            {
                reflectCount++;
                if (collision.gameObject.layer.Equals(LayerMask.NameToLayer("REFLECTZONE_LEFTRIGHT")))
                {
                    movingBullet.ChangeRotateAngle(movingBullet.GetAngle() * -1);
                }
                else if ((collision.gameObject.layer.Equals(LayerMask.NameToLayer("REFLECTZONE_TOP"))) ||
                         (collision.gameObject.layer.Equals(LayerMask.NameToLayer("REFLECTZONE_BOTTOM")) && initializeBullet.bulletReflect.Equals(BulletReflect.BULLETREFLECT_CONTAINBOTTOM)))
                {
                    if (movingBullet.GetAngle() >= 0.0f && movingBullet.GetAngle() <= 180.0f)
                    {
                        movingBullet.ChangeRotateAngle(180.0f - movingBullet.GetAngle());
                    }
                    else
                    {
                        movingBullet.ChangeRotateAngle(-180.0f - movingBullet.GetAngle());
                    }
                }

                if (!(collision.gameObject.layer.Equals(LayerMask.NameToLayer("REFLECTZONE_BOTTOM")) && !initializeBullet.bulletReflect.Equals(BulletReflect.BULLETREFLECT_CONTAINBOTTOM)))
                {
                    if (isSpriteChange.Equals(true))
                    {
                        spriteRenderer.sprite = enemyFire.spriteCollection[changeSpriteNumber];
                    }
                    if (isEffectOutput.Equals(true))
                    {
                        StartCoroutine(enemyFire.CreateBulletFireEffect(effectSpriteNumber, scaleDownSpeed, scaleDownTime, alphaUpSpeed, transform.position));
                    }
                }
            }
        }
    }
예제 #3
0
    public IEnumerator RotateBullet()
    {
        while (true)
        {
            if (movingBullet.bulletMoveSpeed <= 0.0f)
            {
                movingBullet.bulletSpeedState = BulletSpeedState.BULLETSPEEDSTATE_NORMAL;
                movingBullet.bulletMoveSpeed  = 2.0f;
                if (initializeBullet.bulletNumber < 8)
                {
                    movingBullet.ChangeRotateAngle(-110.0f - (20.0f * initializeBullet.bulletNumber) + Random.Range(-2.0f, 2.0f));
                }
                else
                {
                    movingBullet.ChangeRotateAngle(110.0f + (20.0f * (initializeBullet.bulletNumber - 8) + Random.Range(-2.0f, 2.0f)));
                }
                break;
            }

            yield return(new WaitForEndOfFrame());
        }
    }
    public IEnumerator RotateBullet()
    {
        while (true)
        {
            if (movingBullet.bulletMoveSpeed <= 0.0f)
            {
                movingBullet.bulletMoveSpeed  = initializeBullet.bulletNumber.Equals(0) ? 5.0f : 6.0f;
                movingBullet.bulletSpeedState = BulletSpeedState.BULLETSPEEDSTATE_NORMAL;
                movingBullet.ChangeRotateAngle(movingBullet.GetAngle() + 180.0f + (initializeBullet.bulletNumber.Equals(0) ? -35.0f : 35.0f));
                break;
            }

            yield return(new WaitForEndOfFrame());
        }
    }
    public IEnumerator RotateBullet()
    {
        while (true)
        {
            if (movingBullet.bulletMoveSpeed <= 0.0f)
            {
                movingBullet.bulletRotateTime  = 0.0f;
                movingBullet.bulletSpeedState  = BulletSpeedState.BULLETSPEEDSTATE_NORMAL;
                movingBullet.bulletMoveSpeed   = 1.8f;
                movingBullet.bulletRotateState = BulletRotateState.BULLETROTATESTATE_LIMIT;
                movingBullet.ChangeRotateAngle(movingBullet.GetAngle() + ((initializeBullet.bulletNumber % 2).Equals(0) ? 90.0f : -90.0f));
                break;
            }

            yield return(new WaitForEndOfFrame());
        }
    }
예제 #6
0
    public IEnumerator SetBullet()
    {
        while (true)
        {
            if (movingBullet.bulletMoveSpeed <= 0.0f)
            {
                Vector2 targetPosition = playerObject.transform.position;
                movingBullet.bulletSpeedState  = BulletSpeedState.BULLETSPEEDSTATE_NORMAL;
                movingBullet.bulletMoveSpeed   = 7.0f;
                movingBullet.bulletDestination = initializeBullet.GetAimedBulletDestination(targetPosition);
                float angle = Mathf.Atan2(movingBullet.bulletDestination.y, movingBullet.bulletDestination.x) * Mathf.Rad2Deg;
                movingBullet.ChangeRotateAngle(angle - 90.0f);
                break;
            }

            yield return(new WaitForEndOfFrame());
        }
    }
예제 #7
0
    public IEnumerator Fragmentation()
    {
        while (true)
        {
            // 탄막 2 발사 (파란색 원탄) (랜덤탄)
            if (movingBullet.bulletMoveSpeed <= 0.0f)
            {
                Vector2 bulletFirePosition = transform.position;

                // 탄막 2 이펙트
                StartCoroutine(enemyFire.CreateBulletFireEffect(301, 1.0f, 12.0f, 0.4f, 0.1f, 0.35f, bulletFirePosition));

                if (bulletManager.bulletPool.Count > 0)
                {
                    for (int i = 0; i < 16; i++)
                    {
                        GameObject bullet = bulletManager.bulletPool.Dequeue();
                        bullet.SetActive(true);
                        EnemyFire.ClearChild(bullet);
                        bullet.transform.position = transform.position;
                        bullet.gameObject.tag     = "BULLET_ENEMY";
                        bullet.gameObject.layer   = LayerMask.NameToLayer("BULLET_ENEMY_DESTROYZONE_INNER1");
                        bullet.transform.SetParent(enemyBullet);
                        if (!bullet.GetComponent <SpriteRenderer>())
                        {
                            bullet.AddComponent <SpriteRenderer>();
                        }
                        if (!bullet.GetComponent <CircleCollider2D>())
                        {
                            bullet.AddComponent <CircleCollider2D>();
                        }
                        if (!bullet.GetComponent <InitializeBullet>())
                        {
                            bullet.AddComponent <InitializeBullet>();
                        }
                        if (!bullet.GetComponent <MovingBullet>())
                        {
                            bullet.AddComponent <MovingBullet>();
                        }
                        if (!bullet.GetComponent <EraseBullet>())
                        {
                            bullet.AddComponent <EraseBullet>();
                        }
                        SpriteRenderer   spriteRenderer   = bullet.GetComponent <SpriteRenderer>();
                        CircleCollider2D circleCollider2D = bullet.GetComponent <CircleCollider2D>();
                        InitializeBullet initializeBullet = bullet.GetComponent <InitializeBullet>();
                        MovingBullet     movingBullet     = bullet.GetComponent <MovingBullet>();
                        spriteRenderer.sprite          = enemyFire.spriteCollection[23];
                        spriteRenderer.sortingOrder    = 3;
                        circleCollider2D.isTrigger     = true;
                        circleCollider2D.radius        = 0.04f;
                        circleCollider2D.enabled       = false;
                        initializeBullet.bulletType    = BulletType.BULLETTYPE_NORMAL;
                        initializeBullet.bulletObject  = bullet.gameObject;
                        initializeBullet.targetObject  = playerObject;
                        initializeBullet.isGrazed      = false;
                        movingBullet.bulletMoveSpeed   = Random.Range(4.0f, 6.0f);
                        movingBullet.bulletSpeedState  = BulletSpeedState.BULLETSPEEDSTATE_NORMAL;
                        movingBullet.bulletRotateState = BulletRotateState.BULLETROTATESTATE_NONE;
                        movingBullet.bulletDestination = initializeBullet.GetRandomAimedBulletDestination();
                        float angle = Mathf.Atan2(movingBullet.bulletDestination.y, movingBullet.bulletDestination.x) * Mathf.Rad2Deg;
                        movingBullet.ChangeRotateAngle(angle - 90.0f);
                    }

                    bulletManager.bulletPool.Enqueue(gameObject);
                    transform.SetParent(enemyBullet);
                    eraseBullet.ClearBullet();
                    gameObject.SetActive(false);
                    break;
                }
                else
                {
                    enemyFire.AddBulletPool();
                    break;
                }
            }

            yield return(new WaitForEndOfFrame());
        }
    }
예제 #8
0
    private IEnumerator CreateBullet()
    {
        yield return(new WaitForSeconds(0.075f));

        while (true)
        {
            // 탄막 2 생성
            if (bulletManager.bulletPool.Count > 0)
            {
                GameObject bullet = bulletManager.bulletPool.Dequeue();
                bullet.SetActive(true);
                EnemyFire.ClearChild(bullet);
                bullet.transform.position = transform.position;
                bullet.gameObject.tag     = "BULLET_ENEMY";
                bullet.gameObject.layer   = LayerMask.NameToLayer("BULLET_ENEMY_DESTROYZONE_INNER1");
                bullet.transform.SetParent(enemyBullet);
                if (!bullet.GetComponent <SpriteRenderer>())
                {
                    bullet.AddComponent <SpriteRenderer>();
                }
                if (!bullet.GetComponent <CircleCollider2D>())
                {
                    bullet.AddComponent <CircleCollider2D>();
                }
                if (!bullet.GetComponent <InitializeBullet>())
                {
                    bullet.AddComponent <InitializeBullet>();
                }
                if (!bullet.GetComponent <MovingBullet>())
                {
                    bullet.AddComponent <MovingBullet>();
                }
                if (!bullet.GetComponent <EraseBullet>())
                {
                    bullet.AddComponent <EraseBullet>();
                }
                SpriteRenderer   spriteRenderer   = bullet.GetComponent <SpriteRenderer>();
                CircleCollider2D circleCollider2D = bullet.GetComponent <CircleCollider2D>();
                InitializeBullet initializeBullet = bullet.GetComponent <InitializeBullet>();
                MovingBullet     movingBullet     = bullet.GetComponent <MovingBullet>();
                spriteRenderer.sprite          = enemyFire.spriteCollection[18];
                spriteRenderer.sortingOrder    = 3;
                circleCollider2D.isTrigger     = true;
                circleCollider2D.radius        = 0.04f;
                circleCollider2D.enabled       = false;
                initializeBullet.bulletType    = BulletType.BULLETTYPE_NORMAL;
                initializeBullet.bulletObject  = bullet.gameObject;
                initializeBullet.targetObject  = playerObject;
                initializeBullet.isGrazed      = false;
                movingBullet.bulletMoveSpeed   = 0.0f;
                movingBullet.bulletSpeedState  = BulletSpeedState.BULLETSPEEDSTATE_NORMAL;
                movingBullet.bulletRotateState = BulletRotateState.BULLETROTATESTATE_NONE;
                movingBullet.bulletDestination = initializeBullet.GetRandomAimedBulletDestination();
                float angle = Mathf.Atan2(movingBullet.bulletDestination.y, movingBullet.bulletDestination.x) * Mathf.Rad2Deg;
                movingBullet.ChangeRotateAngle(angle - 90.0f);
            }
            else
            {
                enemyFire.AddBulletPool();
            }

            yield return(new WaitForSeconds(0.15f));
        }
    }
예제 #9
0
    public IEnumerator FragmentationAttack1(Vector2 bulletFirePosition)
    {
        int spriteIndex = 0;

        for (int i = 0; i < 3; i++)
        {
            spriteIndex++;

            // 충돌체 생성
            if (bulletManager.bulletPool.Count > 0)
            {
                GameObject bullet = bulletManager.bulletPool.Dequeue();
                bullet.SetActive(true);
                EnemyFire.ClearChild(bullet);
                bullet.transform.position = bulletFirePosition;
                bullet.gameObject.tag     = "BULLET_ENEMY";
                bullet.gameObject.layer   = LayerMask.NameToLayer("BULLET_ENEMY_DESTROYZONE_INNER2");
                bullet.transform.SetParent(enemyFire.enemyBulletTemp2);
                if (!bullet.GetComponent <CircleCollider2D>())
                {
                    bullet.AddComponent <CircleCollider2D>();
                }
                if (!bullet.GetComponent <InitializeBullet>())
                {
                    bullet.AddComponent <InitializeBullet>();
                }
                if (!bullet.GetComponent <MovingBullet>())
                {
                    bullet.AddComponent <MovingBullet>();
                }
                if (!bullet.GetComponent <EraseBullet>())
                {
                    bullet.AddComponent <EraseBullet>();
                }
                if (!bullet.GetComponent <SpriteRenderer>())
                {
                    bullet.AddComponent <SpriteRenderer>();
                }
                if (!bullet.GetComponent <ObjectRotate>())
                {
                    bullet.AddComponent <ObjectRotate>();
                }
                SpriteRenderer   spriteRenderer   = bullet.GetComponent <SpriteRenderer>();
                CircleCollider2D circleCollider2D = bullet.GetComponent <CircleCollider2D>();
                InitializeBullet initializeBullet = bullet.GetComponent <InitializeBullet>();
                MovingBullet     movingBullet     = bullet.GetComponent <MovingBullet>();
                ObjectRotate     objectRotate     = bullet.GetComponent <ObjectRotate>();
                Rigidbody2D      rigidbody2D      = bullet.GetComponent <Rigidbody2D>();
                spriteRenderer.sprite          = enemyFire.spriteCollection[203 + ((spriteIndex % 3) * 2)];
                spriteRenderer.sortingOrder    = 3;
                circleCollider2D.isTrigger     = true;
                circleCollider2D.radius        = 0.015f;
                circleCollider2D.enabled       = false;
                initializeBullet.bulletType    = BulletType.BULLETTYPE_NORMAL;
                initializeBullet.bulletObject  = bullet.gameObject;
                initializeBullet.targetObject  = playerObject;
                initializeBullet.isGrazed      = false;
                movingBullet.bulletMoveSpeed   = 0.0f;
                movingBullet.bulletSpeedState  = BulletSpeedState.BULLETSPEEDSTATE_NORMAL;
                movingBullet.bulletRotateState = BulletRotateState.BULLETROTATESTATE_NONE;
                movingBullet.bulletDestination = initializeBullet.GetRandomAimedBulletDestination();
                float angle = Mathf.Atan2(movingBullet.bulletDestination.y, movingBullet.bulletDestination.x) * Mathf.Rad2Deg;
                movingBullet.ChangeRotateAngle(angle - 90.0f + Random.Range(-40.0f, 40.0f));
                objectRotate.rotateSpeed = 120.0f;
                rigidbody2D.velocity     = movingBullet.bulletDestination.normalized * Random.Range(1.0f, 2.5f);
                rigidbody2D.gravityScale = 0.2f;
            }
            else
            {
                enemyFire.AddBulletPool();
            }
        }

        yield return(null);
    }