IEnumerator CoroutineGenerateShape()
    {
        for (int i = 0; i < spellSettings.phasesArray.Length; i++)
        {
            GameObject phaseObj = Instantiate <GameObject>(phase);
            phaseObj.transform.parent = this.transform;
            PhaseGenerator phaseScript = phaseObj.GetComponent <PhaseGenerator>();
            phaseScript.phaseSettings = spellSettings.phasesArray[i];
            phaseScript.GenerateShapes(this.transform);
            phaseObj.transform.rotation = Quaternion.identity;

            yield return(new WaitForSeconds(spellSettings.phasesArray[i].phaseDuration));
        }
    }
        private IEnumerable <IMoveStrategy> PrepareMoveStrategies(Type type, int satCount, Func <int, IEnumerable <float> > orbitFunc)
        {
            // TODO:
            // need to be refactored
            var strategies = Enumerable.Range(0, satCount).Select(i => (IMoveStrategy)Activator.CreateInstance(type)).ToArray();

            var newPhases = PhaseGenerator.GetPhases((uint)_sateliteList.Count());
            var newOrbits = orbitFunc(_sateliteList.Count());

            for (var i = 0; i < strategies.Count(); i++)
            {
                strategies[i].PhaseChange = newPhases.ElementAt(i);
                strategies[i].Orbit       = newOrbits.ElementAt(i);
            }

            return(strategies);
        }
예제 #3
0
    private void ResetPhasesAndSpawnSatellites(uint newCount)
    {
        if (satellites.Count() >= newCount)
        {
            throw new Exception("satellites.Count() >= newCount");
        }
        var satellitesOrdered = satellites.OrderBy(i => i.GetComponent <SateliteMoveCircleScript>().phaseChange).ToArray();
        var newPhases         = PhaseGenerator.GetPhases(newCount);

        for (var i = 0; i < satellitesOrdered.Count(); i++)
        {
            satellitesOrdered[i].GetComponent <SateliteMoveCircleScript>().phaseChange = newPhases[i];
        }

        for (var i = satellitesOrdered.Count(); i < newCount; i++)
        {
            Camera.current.GetComponent <SatelliteGenerationScript>().Spawn(newPhases[i]);
        }
    }