Exemplo n.º 1
0
        public IEnumerator Shot(Mover mover)
        {
            Bullet b = GameSystem._Instance.CreateBullet <Bullet>();

            b.Init(BulletName.red, mover._X, mover._Y, GetPlayerAngle(mover._X, mover._Y), speed);
            yield return(null);
        }
Exemplo n.º 2
0
        /// <param name="dir">Direction. 0:Up, 1:Down, 2:Left, 3:Right</param>
        public void OneShot(int dir)
        {
            float x, y, angle;

            if (dir == 0)
            {
                x     = GameSystem._Instance.player._X;
                y     = GameSystem._Instance._MaxY;
                angle = 0.75f;
            }
            else if (dir == 1)
            {
                x     = GameSystem._Instance.player._X;
                y     = GameSystem._Instance._MinY;
                angle = 0.25f;
            }
            else if (dir == 2)
            {
                x     = GameSystem._Instance._MinX;
                y     = GameSystem._Instance.player._Y;
                angle = 0.0f;
            }
            else
            {
                x     = GameSystem._Instance._MaxX;
                y     = GameSystem._Instance.player._Y;
                angle = 0.50f;
            }

            Bullet b = GameSystem._Instance.CreateBullet <Bullet>();

            b.Init(BulletName.blue, x, y, angle, speed);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 양회전 소용돌이탄
        /// </summary>
        public IEnumerator BiDirectionalSpiralBullets(Mover mover, string shape
                                                      , float angle, float angleRate1, float angleRate2
                                                      , float speed, int count, int interval, int duration)
        {
            const int directionCount = 2;   // 회전방향의 수

            float[] shotAngle = new float[directionCount] {
                angle, angle
            };
            float[] shotAngleRate = new float[directionCount] {
                angleRate1, angleRate2
            };

            for (int frame = 0; frame < duration; ++frame)
            {
                if ((frame % interval) == 0)
                {
                    // 회전이 다른 2종류의 소용돌이탄 발사
                    for (int j = 0; j < directionCount; ++j)
                    {
                        // 지정된 발사 수 만큼 발사
                        for (int i = 0; i < count; ++i)
                        {
                            Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                            b.Init(shape, mover._X, mover._Y, shotAngle[j] + ((float)i / count)
                                   , 0.0f, speed, 0.0f);
                        }

                        shotAngle[j] += shotAngleRate[j];
                        shotAngle[j] -= Mathf.Floor(shotAngle[j]);
                    }
                }
                yield return(null);
            }
        }
Exemplo n.º 4
0
        public IEnumerator Shot(Mover mover)
        {
            const int directionCount = 2;

            float[] shotAngle     = { angle, angle };
            float[] shotAngleRate = { angleRate1, angleRate2 };

            for (int frame = 0; frame < duration; ++frame)
            {
                if ((frame % interval) == 0)
                {
                    for (int j = 0; j < directionCount; ++j)
                    {
                        for (int i = 0; i < count; ++i)
                        {
                            Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                            b.Init(BulletName.blue, mover._X, mover._Y, shotAngle[j] + ((float)i / count), speed);
                        }

                        shotAngle[j] += shotAngleRate[j];
                        shotAngle[j] -= Mathf.Floor(shotAngle[j]);
                    }
                }
                yield return(null);
            }
        }
Exemplo n.º 5
0
        public IEnumerator Pattern_02(Mover mover)
        {
            // 1
            float angle = 0.875f;

            NWayBullet(mover, BulletName.blue, angle, 0.25f, 0.02f, 6);
            yield return(new WaitForFrames(75));

            // 2
            NWayBullet(mover, BulletName.blue, angle, 0.25f, 0.02f, 6);
            yield return(new WaitForFrames(75));

            // 4 Way
            {
                float x = 1.0f;
                angle = 0.5f;
                for (int i = 0; i < 4; ++i)
                {
                    Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                    b.Init(BulletName.red, x, 0.5f - 1.5f / 3.0f * i, angle, 0.01f);
                    yield return(new WaitForFrames(25));
                }
            }
            // 연타
            CircleBullet(mover, BulletName.blue, 0.0f, 0.02f, 12, false);
            yield return(new WaitForFrames(26));

            CircleBullet(mover, BulletName.blue, 0.0f, 0.02f, 12, true);
        }
Exemplo n.º 6
0
 void NWayBullet(Mover mover, string shape, float angle, float angleRange, float speed, int count)
 {
     for (int i = 0; i < count; ++i)
     {
         Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
         b.Init(shape, mover._X, mover._Y, angle + angleRange * ((float)i / (count - 1) - 0.5f), speed);
     }
 }
Exemplo n.º 7
0
        void CircleBullet(Mover mover, float angle, float speed, int count, bool halfAngleOffset)
        {
            float angleStart = angle + ((halfAngleOffset) ? (1.0f / count / 2.0f) : 0.0f);

            for (int i = 0; i < count; ++i)
            {
                Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                b.Init(BulletName.red, mover._X, mover._Y, angleStart + (1.0f / count * i), speed);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 선회가속 원형탄
        /// </summary>
        public void BentCircleBullet(Mover mover, string shape, float angle, float speed, int count, float bulletAngleRate, float bulletSpeedRate, bool halfAngleOffset)
        {
            float angleStart = angle + ((halfAngleOffset) ? (1.0f / count / 2.0f) : 0.0f);

            for (int i = 0; i < count; ++i)
            {
                Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                b.Init(shape, mover._X, mover._Y, angleStart + (1.0f / count * i), bulletAngleRate, speed, bulletSpeedRate);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 원형탄
        /// </summary>
        public void CircleBullet(float x, float y, string shape, float angle, float speed, float speedRate, int count, bool halfAngleOffset)
        {
            float angleStart = angle + ((halfAngleOffset) ? (1.0f / count / 2.0f) : 0.0f);

            for (int i = 0; i < count; ++i)
            {
                Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                b.Init(shape, x, y, angleStart + (1.0f / count * i), 0.0f, speed, speedRate);
            }
        }
Exemplo n.º 10
0
 public IEnumerator Shot(Mover mover)
 {
     for (int i = 0; i < count; ++i)
     {
         Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
         b.Init(BulletName.blue, mover._X, mover._Y,
                angle + angleRange * ((float)i / (count - 1) - 0.5f), speed);
     }
     yield return(null);
 }
Exemplo n.º 11
0
        public IEnumerator Shot(Mover mover)
        {
            float angleStart = angle + ((halfAngleOffset) ? (1.0f / count / 2.0f) : 0.0f);

            for (int i = 0; i < count; ++i)
            {
                Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                b.Init(BulletName.blue, mover._X, mover._Y, angleStart + (1.0f / count * i), speed);
            }
            yield return(null);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 직선탄
        /// </summary>
        public IEnumerator LineBullets(Vector2 pos, string shape, float angle, float speed, int interval, int repeatCount)
        {
            for (int i = 0; i < repeatCount; ++i)
            {
                Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                b.Init(shape, pos.x, pos.y, angle, 0.0f, speed, 0.0f);

                if (i < repeatCount - 1)
                {
                    yield return(new WaitForFrames(interval));
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Rotate spiral
        /// </summary>
        void SpiralBullet(Mover mover, string shape, float angle, float angleRate, float speed, int interval, int duration)
        {
            for (int frame = 0; frame < duration; ++frame)
            {
                if ((frame % interval) == 0)
                {
                    Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                    b.Init(shape, mover._X, mover._Y, angle, speed);

                    angle += angleRate;
                    angle -= Mathf.Floor(angle);
                }
            }
        }
Exemplo n.º 14
0
        public IEnumerator Shot(Mover mover)
        {
            float angle = GetPlayerAngle(mover._X, mover._Y);

            for (int i = 0; i < count; ++i)
            {
                // 탄 별로 각도와 속도를 랜덤으로 설정
                float  bulletAngle = angle + angleRange * (GameSystem._Instance.GetRandom01() - 0.5f);
                float  bulletSpeed = speed + speedRange * GameSystem._Instance.GetRandom01();
                Bullet b           = GameSystem._Instance.CreateBullet <Bullet>();
                b.Init(BulletName.red, mover._X, mover._Y, bulletAngle, bulletSpeed);
            }
            yield return(null);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 소용돌이탄
        /// </summary>
        public IEnumerator SpiralBullets(Mover mover, string shape, float angle, float angleRate, float speed, int interval, int duration)
        {
            for (int frame = 0; frame < duration; ++frame)
            {
                if ((frame % interval) == 0)
                {
                    Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                    b.Init(shape, mover._X, mover._Y, angle, 0.0f, speed, 0.0f);

                    angle += angleRate;
                    angle -= Mathf.Floor(angle);
                }
                yield return(null);
            }
        }
Exemplo n.º 16
0
 // 랜덤 원형탄
 public IEnumerator RandomCircleBullets(Mover mover, string shape, float speed, int count, int interval, int duration)
 {
     for (int frame = 0; frame < duration; ++frame)
     {
         if ((frame % interval) == 0)
         {
             for (int i = 0; i < count; ++i)
             {
                 Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                 b.Init(shape, mover._X, mover._Y, GameSystem._Instance.GetRandom01(), speed);
             }
         }
         yield return(null);
     }
 }
Exemplo n.º 17
0
 public IEnumerator Shot(Mover mover)
 {
     for (int frame = 0; frame < duration; ++frame)
     {
         if ((frame % interval) == 0)
         {
             for (int i = 0; i < count; ++i)
             {
                 Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                 b.Init(BulletName.blue, mover._X, mover._Y, GameSystem._Instance.GetRandom01(), speed);
             }
         }
         yield return(null);
     }
 }
Exemplo n.º 18
0
        public IEnumerator Shot(Mover mover)
        {
            float angle = GetPlayerAngle(mover._X, mover._Y);

            for (int i = 0; i < repeatCount; ++i)
            {
                Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                b.Init(BulletName.blue, mover._X, mover._Y, angle, speed);

                if (i < repeatCount - 1)
                {
                    yield return(new WaitForFrames(interval));
                }
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// 랜덤 확산탄
        /// </summary>
        public void RandomSpreadBullet(Mover mover, string shape
                                       , float angleRange, float speed, float speedRange, int count)
        {
            // 한 번에 뿌리지만 속도가 달라 여러번 나눠서 뿌리는 것 같은 효과
            float angle = GetPlayerAngle(mover);

            for (int i = 0; i < count; ++i)
            {
                // 탄 별로 각도와 속도를 랜덤으로 설정
                float  bulletAngle = angle + angleRange * (GameSystem._Instance.GetRandom01() - 0.5f);
                float  bulletSpeed = speed + speedRange * GameSystem._Instance.GetRandom01();
                Bullet b           = GameSystem._Instance.CreateBullet <Bullet>();
                b.Init(shape, mover._X, mover._Y, bulletAngle, 0.0f, bulletSpeed, 0.0f);
            }
        }
Exemplo n.º 20
0
        public IEnumerator Pattern_01(Mover mover)
        {
            string shape    = BulletName.blue;
            float  angle    = 0.75f;
            float  speed    = 0.02f;
            int    interval = 10;

            byte[] pattern  = _patternNote;
            int    col      = _patternNoteCol;
            int    row      = _patternNoteRow;
            float  colSpace = 0.08f;

            // 한줄씩 발사
            float rad       = angle * Mathf.PI * 2.0f;
            float sin       = Mathf.Sin(rad);
            float cos       = Mathf.Cos(rad);
            float centerCol = ((float)col - 1.0f) / 2.0f;   // 가운데 칸의 인덱스 (예: 2칸 -> [0] "[0.5]" [1])

            // 아랫줄 부터 출력
            for (int r = row - 1; r >= 0; --r)
            {
                // 이번 줄 첫번째 인덱스
                int startIndex = col * r;

                // 왼쪽 탄을 위에 보이도록 하기 위해 오른쪽부터 읽음
                for (int i = col - 1; i >= 0; --i)
                {
                    // 0 외의 부분에 탄 발사
                    int index = startIndex + i;
                    if (pattern[index] != 0)
                    {
                        // 화면 아래로 향할 때(0.75, 270도) 패턴 그대로 출력
                        // 즉, 0도일 떄는 colOffset이 Y축으로 작동
                        float  xOffset = 0.0f;
                        float  yOffset = ((float)i - centerCol) * colSpace;                  // 가운데 칸으로부터 얼마나 떨어졌는가?
                        float  x       = mover._X + (cos * xOffset + -1.0f * sin * yOffset); // 벡터 회전공식 참고. http://en.wikipedia.org/wiki/Rotation_(mathematics)
                        float  y       = mover._Y + (sin * xOffset + cos * yOffset);
                        Bullet b       = GameSystem._Instance.CreateBullet <Bullet>();
                        b.Init(shape, x, y, angle, speed);
                    }
                }

                if (r > 0)
                {
                    yield return(new WaitForFrames(interval));
                }
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// 조준 직선탄
        /// </summary>
        public IEnumerator AimingLineBullets(Mover mover, string shape, float speed, int interval, int repeatCount)
        {
            // 발사 시작 시 플레이어와의 각도 계산
            float angle = GetPlayerAngle(mover);

            for (int i = 0; i < repeatCount; ++i)
            {
                Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                b.Init(shape, mover._X, mover._Y, angle, 0.0f, speed, 0.0f);

                if (i < repeatCount - 1)
                {
                    yield return(new WaitForFrames(interval));
                }
            }
        }
Exemplo n.º 22
0
 /// <summary>
 /// N-Way 탄
 /// </summary>
 public void NWayBullet(Mover mover, string shape, float angle, float angleRange, float speed, int count)
 {
     if (count > 1)
     {
         for (int i = 0; i < count; ++i)
         {
             // (angle - angleRange / 2) ~ (angle + angleRange / 2) 범위에서 count 만큼 생성
             Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
             b.Init(shape, mover._X, mover._Y, angle + angleRange * ((float)i / (count - 1) - 0.5f), 0.0f, speed, 0.0f);
         }
     }
     else if (count == 1)
     {
         // 탄 수가 하나일 때는 발사 각도로 1개 발사
         Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
         b.Init(shape, mover._X, mover._Y, angle, 0.0f, speed, 0.0f);
     }
 }
Exemplo n.º 23
0
        public override void Move()
        {
            // 탄도 상의 각도와 반경으로 슈터 좌표 설정
            float rad = _orbitAngle * Mathf.PI * 2.0f;

            _X = Mathf.Cos(rad) * _orbitRadius;
            _Y = Mathf.Sin(rad) * _orbitRadius;

            // 탄도 상의 각도 갱신
            _orbitAngle += _orbitAngleRate;
            _orbitAngle -= Mathf.Floor(_orbitAngle);

            // 화면 바깥쪽을 향해서 방향탄 발사
            if (_time % 5 == 0)
            {
                Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                b.Init(_bulletShape, _X, _Y, _orbitAngle, 0.0f, _bulletSpeed * 1.5f, 0.0f);
            }

            // 설치탄 발사
            int   count    = _time / (_shotTime + _waitTime);             // 그룹 번호
            int   time     = _time % (_shotTime + _waitTime);             // 그룹 내 시간
            float baseTime = (_orbitRadius - _playerSize) / _bulletSpeed; // 탄이 화면 중앙에 도달할 때 까지의 시간

            // 지정돤 그룹 수만큼 반복
            if (count < _groupCount)
            {
                // 발사 시간만큼 정해진 간격으로 탄 발사
                if ((time < _shotTime) && (time % _interval == 0))
                {
                    // 설치탄 생성
                    // 나중에 쏜 탄일수록 화면 중앙에 가깝게 함
                    PlacedBullet b = GameSystem._Instance.CreateBullet <PlacedBullet>();
                    b.Init(_bulletShape, _X, _Y, _orbitAngle + 0.5f, _bulletSpeed
                           , (int)(baseTime * count / _groupCount)
                           , (int)(baseTime + (_shotTime + _waitTime) * (_groupCount - count)));
                }
            }

            // 타이머 갱신
            _time = (_time + 1) % _cycle;

            // 삭제는 외부에서 지정
        }
Exemplo n.º 24
0
        /// <summary>
        /// 다방향 소용돌이탄
        /// </summary>
        public IEnumerator SpiralBullets(Mover mover, string shape, float angle, float angleRate, float speed, int count, int interval, int duration)
        {
            float shotAngle = angle;

            for (int frame = 0; frame < duration; ++frame)
            {
                if ((frame % interval) == 0)
                {
                    for (int i = 0; i < count; ++i)
                    {
                        Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                        b.Init(shape, mover._X, mover._Y, shotAngle + ((float)i / count), speed);
                    }
                    shotAngle += angleRate;
                    shotAngle -= Mathf.Floor(shotAngle);
                }
                yield return(null);
            }
        }
Exemplo n.º 25
0
        public IEnumerator Shot(Mover mover)
        {
            float shotAngle = angle;

            for (int frame = 0; frame < duration; ++frame)
            {
                if ((frame % interval) == 0)
                {
                    // 지정된 발사 수 만큼 발사
                    for (int i = 0; i < count; ++i)
                    {
                        Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                        b.Init(BulletName.red, mover._X, mover._Y, shotAngle + ((float)i / count), speed);
                    }

                    shotAngle += angleRate;
                    shotAngle -= Mathf.Floor(shotAngle);
                }
                yield return(null);
            }
        }
Exemplo n.º 26
0
        public IEnumerator Shot(Mover mover)
        {
            for (int i = 0; i < roundCount; ++i)
            {
                // 0: 우상, 1: 좌상, 2: 좌하, 3: 우하
                for (int dir = 0; dir < 4; ++dir)
                {
                    float x, y;
                    if (dir == 0)
                    {
                        x = GameSystem._Instance._MaxX;
                        y = GameSystem._Instance._MaxY;
                    }
                    else if (dir == 1)
                    {
                        x = GameSystem._Instance._MinX;
                        y = GameSystem._Instance._MaxY;
                    }
                    else if (dir == 2)
                    {
                        x = GameSystem._Instance._MinX;
                        y = GameSystem._Instance._MinY;
                    }
                    else
                    {
                        x = GameSystem._Instance._MaxX;
                        y = GameSystem._Instance._MinY;
                    }

                    float  angle = GetPlayerAngle(x, y);
                    Bullet b     = GameSystem._Instance.CreateBullet <Bullet>();
                    b.Init(BulletName.red, x, y, angle, speed);

                    if (!((i == (roundCount - 1) && (dir == (4 - 1)))))
                    {
                        yield return(new WaitForFrames(interval));
                    }
                }
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Shot form
        /// </summary>
        /// <param name="dir">Direction. 0:Up, 1:Down, 2:Left, 3:Right</param>
        public IEnumerator ShotFormBorder(int dir, float speed, int interval, int count)
        {
            for (int i = 0; i < count; ++i)
            {
                float x, y, angle;
                if (dir == 0)
                {
                    x     = GameSystem._Instance.player._X;
                    y     = GameSystem._Instance._MaxY;
                    angle = 0.75f;
                }
                else if (dir == 1)
                {
                    x     = GameSystem._Instance.player._X;
                    y     = GameSystem._Instance._MinY;
                    angle = 0.25f;
                }
                else if (dir == 2)
                {
                    x     = GameSystem._Instance._MinX;
                    y     = GameSystem._Instance.player._Y;
                    angle = 0.0f;
                }
                else
                {
                    x     = GameSystem._Instance._MaxX;
                    y     = GameSystem._Instance.player._Y;
                    angle = 0.50f;
                }

                Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                b.Init(BulletName.blue, x, y, angle, speed);

                if (i < count - 1)
                {
                    yield return(new WaitForFrames(interval));
                }
            }
        }
Exemplo n.º 28
0
        public IEnumerator Shot(Mover mover)
        {
            float angle = GetPlayerAngle(mover._X, mover._Y) + 0.25f;    // 시작 각도는 플레이어 방향과 직각

            for (int repeat = 0; repeat < repeatCount; ++repeat)
            {
                for (int i = 0; i < count; ++i)
                {
                    // 발사 위치
                    float spawnAngleRadian = (2.0f * Mathf.PI) * (angle - (1.0f / count * i));  // 반시계방향
                    float spawnX           = mover._X + radius * Mathf.Cos(spawnAngleRadian);
                    float spawnY           = mover._Y + radius * Mathf.Sin(spawnAngleRadian);
                    // 발사위치로부터 플레이어 방향
                    float bulletAngle = GetPlayerAngle(spawnX, spawnY);

                    Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                    b.Init(BulletName.blue, spawnX, spawnY, bulletAngle, speed);

                    yield return(new WaitForFrames(interval));
                }
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// 회전하며 조준탄 뿌리기
        /// </summary>
        public IEnumerator RollingAimingBullets(Mover mover, string shape
                                                , float speed, int count, float radius, int interval, int repeatCount)
        {
            float angle = GetPlayerAngle(mover) + 0.25f;    // 시작 각도는 플레이어 방향과 직각

            for (int repeat = 0; repeat < repeatCount; ++repeat)
            {
                for (int i = 0; i < count; ++i)
                {
                    // 발사 위치
                    float spawnAngleRadian = (2.0f * Mathf.PI) * (angle - (1.0f / count * i));  // 반시계방향
                    float spawnX           = mover._X + radius * Mathf.Cos(spawnAngleRadian);
                    float spawnY           = mover._Y + radius * Mathf.Sin(spawnAngleRadian);
                    // 발사위치로부터 플레이어 방향
                    float bulletAngle = GetPlayerAngle(spawnX, spawnY);

                    Bullet b = GameSystem._Instance.CreateBullet <Bullet>();
                    b.Init(shape, spawnX, spawnY, bulletAngle, 0.0f, speed, 0.0f);

                    yield return(new WaitForFrames(interval));
                }
            }
        }
Exemplo n.º 30
0
        public void AimimgBullet(Mover mover, string shape, float speed)
        {
            Bullet b = GameSystem._Instance.CreateBullet <Bullet>();

            b.Init(shape, mover._X, mover._Y, GetPlayerAngle(mover), 0.0f, speed, 0.0f);
        }