Пример #1
0
    public IEnumerator GetAndHandleBulletFamilySpawner()
    {
        timeSincePreviousBFSSpawn = 0;
        List <BulletFamilySpawner> _bfsList = new List <BulletFamilySpawner>();

        for (int i = 0; i < spawnerPatternCount; i++)
        {
            _bfsList.Add(GameManager.GetBulletFamilySpawner());
            AssignBFSStartValues(_bfsList[i]);
            _bfsList[i].SetupRuntimeValues();
            _bfsList[i].transform.parent        = this.transform;
            _bfsList[i].transform.localPosition = spawnerPatternPos[i] + AlterVector(bulletFamilySpawnerMovementKeyPointsPos[0], spawnerPatternRot[i]);
        }
        float   _timeSinceHandleStart    = 0;
        float   _progress                = 0;
        Vector3 _bfsBaseLocalPos         = bulletFamilySpawnerMovementKeyPointsPos[0];
        Vector3 _previousBFSBaseLocalLot = bulletFamilySpawnerMovementKeyPointsPos[0];
        //float _bfsBaseRot = Vector3.SignedAngle(Vector3.up, AlterVector(bulletFamilySpawnMovementKeyPointsPos[0], spawnerPatternRot[0]),Vector3.forward);
        float _bfsInfluencedRot = 0;//Rot influnced by bezier path

        while (_progress <= 1)
        {
            _timeSinceHandleStart += Time.deltaTime * GameManager.timeScale;
            _progress              = _timeSinceHandleStart / bulletFamilySpawnerMovementCyclePeriod;
            _bfsBaseLocalPos       = GetBezierCurvePoint(bulletFamilySpawnerMovementKeyPointsPos, _progress);
            _bfsInfluencedRot      = Vector3.SignedAngle(/*AlterVector(Vector3.up,_bfsBaseRot)*/ Vector3.up, (_bfsBaseLocalPos - _previousBFSBaseLocalLot), Vector3.forward);
            for (int i = 0; i < spawnerPatternCount; i++)
            {
                _bfsList[i].transform.localPosition        = AlterVector(spawnerPatternPos[i], curSpawnerMasterPatternRot) + AlterVector(_bfsBaseLocalPos, spawnerPatternRot[i] + curSpawnerIndividualPatternRot + curSpawnerMasterPatternRot);
                _bfsList[i].transform.rotation             = Quaternion.Euler(Vector3.forward * (_bfsInfluencedRot + spawnerPatternRot[i] + curSpawnerMasterPatternRot));
                _bfsList[i].timeSincePreviousBulletFamily += Time.deltaTime * GameManager.timeScale;
                if (_bfsList[i].timeSincePreviousBulletFamily > bulletFamilySpawnInterval)
                {
                    _bfsList[i].timeSincePreviousBulletFamily = 0;            //
                    BulletFamily _bf = _bfsList[i].GetAndSetupBulletFamily(); //- bulletFamilyActiveSideCount * bulletFamilySideSkipInterval * bulletFamilySideCount * 0.001388f));
                    _bf.bulletFamilyCompoundRotationReadjustment = _bfsInfluencedRot + spawnerPatternRot[i] + curSpawnerMasterPatternRot;
                    bulletFamilies.Add(_bf);
                }
            }
            _previousBFSBaseLocalLot = _bfsList[0].transform.localPosition;
            yield return(new WaitForEndOfFrame());
        }
        for (int i = 0; i < spawnerPatternCount; i++)
        {
            _bfsList[i].gameObject.SetActive(false);
            GameManager.availableBulletFamilySpawners.Add(_bfsList[i]);
        }
    }
Пример #2
0
    public BulletFamily GetAndSetupBulletFamily()
    {
        BulletFamily _bulletFamily = GameManager.GetBulletFamily();

        _bulletFamily.transform.position                 = this.transform.position;
        _bulletFamily.transform.rotation                 = this.transform.rotation;
        _bulletFamily.timeSinceCompoundStart             = -Mathf.PI;
        _bulletFamily.timeSincebfBulletMoveIntervalStart = -Mathf.PI;
        for (int i = 0; i < bulletSpawnPos.Count; i++)
        {
            Transform _bullet = GameManager.GetBullet();
            _bullet.parent        = _bulletFamily.transform;
            _bullet.localPosition = bulletSpawnPos[i];
            _bullet.localRotation = Quaternion.Euler(Vector3.forward * bulletSpawnRot[i]);
            _bulletFamily.bullets.Add(_bullet);
        }

        return(_bulletFamily);
    }