private IEnumerator StartAttack(EnemyStartAttackParams parameters)
        {
            while (playerDead == false)
            {
                yield return(new WaitForSeconds(parameters.AttackTime)); // 공격 텀

                parameters.Attack(parameters);
                /// 코루틴 delegate를 받아서 enemyattackkinds의 fire함수들을 corutine 형태로 만들어서 attacktime을 넘겨주기.
            } // 플레이어가 리스폰했을때 다시 공격하도록 수정
        }
Beispiel #2
0
        private IEnumerator BoomBullet()
        {
            yield return(new WaitForSeconds(1.0f)); // 1 초후 폭발.

            EnemyAttackTypeDelegate attack = EnemyAttackKinds.FireConeType;

            parameters = new EnemyStartAttackParams(transformCache, 2.0f, EnemyAttackKinds.AttackType.RedAttack, attack);
            attack(parameters);
            Destroy(gameObject);
        }
        public IEnumerator FireBoomType(EnemyStartAttackParams parameters)     // 무작위 발사후 ConFireType 형태로 발사.
        {
            while (true)
            {
                int oneshot = 5;

                while (oneshot > 0)
                {
                    var angle = Random.Range(0.0f, 360.0f);

                    var targetDirection = RotateBullet(angle, parameters.SpawnTransform);
                    CreateMoveBullet(targetDirection, parameters.SpawnTransform, parameters.AttackType, 0, 1, parameters.BulletSpeed);

                    oneshot--;
                }
                yield return(new WaitForSeconds(parameters.AttackTime));
            }
        }
        public IEnumerator FireConeType(EnemyStartAttackParams parameters)
        {
            while (true)
            {
                var oneshot   = 5;
                var angle     = 60.0f;
                var anglePlus = angle / (oneshot - 1);
                angle *= 0.5f;

                while (oneshot > 0)
                {
                    var targetDirection = RotateBullet(angle, parameters.SpawnTransform);
                    CreateMoveBullet(targetDirection, parameters.SpawnTransform, parameters.AttackType, 0, 1, parameters.BulletSpeed);

                    oneshot--;
                    angle -= anglePlus;
                }
                yield return(new WaitForSeconds(parameters.AttackTime));
            }
        }
        private void AttackPlayer()
        {
            EnemyAttackTypeDelegate attackDelegate;

            float attackTime;
            float bulletSpeed;

            EnemyAttackKinds.AttackType attackType;

            if (EnemyTypeCheck == EnemyType.SmallEnemy1)
            {
                attackDelegate = EnemyAttackKinds.FireConeType;
                bulletSpeed    = 2.0f;
                attackTime     = 2.0f;
                attackType     = EnemyAttackKinds.AttackType.RedAttack;
            }
            else if (EnemyTypeCheck == EnemyType.SmallEnemy2)
            {
                attackDelegate = EnemyAttackKinds.FireBoomType;
                bulletSpeed    = 2.0f;
                attackTime     = Random.Range(1.0f, 2.0f);
                attackType     = EnemyAttackKinds.AttackType.BlueAttack;
            }
            else //if (EnemyTypeCheck == EnemyType.SmallEnemy3)
            {
                attackDelegate = EnemyAttackKinds.FireSinType;

                bulletSpeed = 4.0f;
                attackTime  = 2.0f;
                attackType  = EnemyAttackKinds.AttackType.PurpleCircle;
                parameters  = new EnemyStartAttackParams(transformCache, 4.0f, EnemyAttackKinds.AttackType.PurpleCircle, attackDelegate);
                StartCoroutine(attackDelegate(parameters));
            }

            parameters = new EnemyStartAttackParams(transformCache, bulletSpeed, attackTime, attackType, attackDelegate);
            if (objectCreator.LivePlayerController != null)
            {
                StartCoroutine(attackDelegate(parameters));
            }
        }
        public IEnumerator FireSinType(EnemyStartAttackParams parameters) // 6방향 sin형태의 탄 6발씩 발사 후 20도 꺾어서 6발발사. x6
        {
            var angle     = 0.0f;
            var oneShot   = 6.0f;
            var anglePlus = 0.0f;

            var direction = new Vector2(1, 0);

            while (true)
            {
                for (var i = 0; i < oneShot; i++)
                {
                    for (var z = 0; z < oneShot; z++)
                    {
                        CreateMoveBullet(direction, parameters.SpawnTransform, parameters.AttackType, angle, 0.5f, parameters.BulletSpeed);
                        angle += 60.0f;
                    }
                    yield return(new WaitForSeconds(0.2f));
                }
                anglePlus += 20.0f;
                angle      = anglePlus;
                yield return(new WaitForSeconds(0.2f));
            }
        }