Ejemplo n.º 1
0
    private IEnumerator SpawnEnemiesDeffered(AlienStageWaveSettings alienStageSettings, Action <AlienEnemy> onAlienCreatedAction, float spawnStartDelay)
    {
        int firstRowIndex = FormationGrid.CurrentRowIndex;

        FormationGrid.ReserveRows(alienStageSettings.FormationSettings.RowsCount);

        yield return(new WaitForSeconds(spawnStartDelay));

        Vector3 spawnPosition = GetSpawnPosition();

        for (int i = 0; i < alienStageSettings.AlienCount; i++)
        {
            Vector3 formationPosition    = FormationGrid.EstimatePosition(i, firstRowIndex, alienStageSettings.FormationSettings.RowsCount);
            Vector3 currentSpawnPosition = ShouldInverseSpawnPosition(i) == true?spawnPosition.InverseX() : spawnPosition;

            AlienEnemy newAlien = CreateAlienEnemy(alienStageSettings.AlienEnemy, currentSpawnPosition);

            newAlien.SetFormationPosition(formationPosition);
            newAlien.SetAlienState(AlienEnemy.AlienStates.Appear);

            onAlienCreatedAction(newAlien);
            if (i % 2 != 0)
            {
                yield return(new WaitForSeconds(alienStageSettings.AlienSpawnDelay));
            }
        }
    }
Ejemplo n.º 2
0
        private void Start()
        {
            //Get the waypoint transforms
            var waypoints = this.GetComponentsInChildren <Transform>().Skip(1).ToArray();

            //Create the orange group. In this example we just create an empty grouping and add members to it
            var grpOrange = GroupingManager.CreateGrouping <IUnitFacade>();

            for (int i = 0; i < 20; i++)
            {
                var agent = Spawn(this.orangeMold, waypoints[0].position);
                grpOrange.Add(agent);
            }

            IFormation formation = new FormationGrid(1.5f);

            grpOrange.SetFormation(formation);

            for (int i = 1; i < 10; i++)
            {
                grpOrange.MoveTo(waypoints[i % waypoints.Length].position, true);
            }

            //Create the green group.
            var grpGreen = GroupingManager.CreateGroup <IUnitFacade>(9);

            for (int i = 0; i < 9; i++)
            {
                var agent = Spawn(this.greenMold, waypoints[3].position);
                grpGreen.Add(agent);
            }

            formation = new FormationEllipsoid(1.5f);
            grpGreen.SetFormation(formation);

            for (int i = 2; i > -10; i--)
            {
                var idx = Math.Abs((i + waypoints.Length) % waypoints.Length);
                grpGreen.MoveTo(waypoints[idx].position, true);
            }

            //Spawn a solo unit
            var solo = Spawn(this.blueMold, waypoints[4].position);

            for (int i = 0; i < 17; i++)
            {
                solo.MoveTo(waypoints[i % waypoints.Length].position, true);
            }
        }
Ejemplo n.º 3
0
 public void ResetFormationGrid()
 {
     FormationGrid.ResetFormationGrid();
 }