Beispiel #1
0
    void Spawn()
    {
        WeaponPrefabPool pool = WeaponPrefabPool.GetPool(spawnWeaponeType);

        if (spawnLimit > -1 && pool.AliveObjects.Count >= spawnLimit)
        {
            return;
        }

        if (spawnType == SpawnType.OneByOne)
        {
            spawningPosIndex++;
            if (spawningPosIndex >= spawningPos.Length)
            {
                spawningPosIndex = 0;
            }

            float   angle;
            Vector3 axis;
            spawningPos[spawningPosIndex].rotation.ToAngleAxis(out angle, out axis);
            angle += 90 + Random.Range(-2f, 2f);

            Weapon bullet = pool.GetFromPool();

            bullet.Setup(spawningPos[spawningPosIndex].position, MiltiplyVector2(DegreeToVector2(angle), vecMultiplier), rotateType == RotateType.None? Quaternion.identity : transform.rotation);
        }
        else
        {
            for (spawningPosIndex = 0; spawningPosIndex < spawningPos.Length; spawningPosIndex++)
            {
                float   angle;
                Vector3 axis;
                spawningPos[spawningPosIndex].rotation.ToAngleAxis(out angle, out axis);

                Weapon bullet = pool.GetFromPool();
                angle += 90 + Random.Range(-2f, 2f);

                bullet.Setup(spawningPos[spawningPosIndex].position, MiltiplyVector2(DegreeToVector2(angle), vecMultiplier), rotateType == RotateType.None ? Quaternion.identity : transform.rotation);
            }
        }
    }
Beispiel #2
0
    public void ShootMissle()
    {
        if (stuning)
        {
            return;
        }

        if (missleCount > 0)
        {
            WeaponPrefabPool misslePool = WeaponPrefabPool.GetPool(WeaponType.PlayerMissle);
            if (misslePool.AliveObjects.Count == 0)
            {
                missleCount--;
                misslePool.GetFromPool().Setup(transform.position, Vector2.up * missleSpeed);
            }
        }
    }
Beispiel #3
0
    void Update()
    {
        if (stuning)
        {
            return;
        }

        if (fireRateTimer.UpdateEnd)
        {
            fireRateTimer.Reset();
            for (int i = 0; i < burstPosition.Length; i++)
            {
                Weapon weapon = WeaponPrefabPool.GetFromPool(WeaponType.PlayerBullet);
                weapon.Setup(burstPosition[i].position, Vector2.up * bulletSpeed);
                AudioManager.ins.PlayerSound(AudioEnum.BulletShoot);
            }
        }
    }