Example #1
0
        internal void Generate(TracksInspector inspector, int _TrackIndex)
        {
            TrackIndex          = _TrackIndex;
            _newPlatformXZScale = app.model.BattleField.Base.Inspector.BaseXZSize / inspector.CellsResolutionWidth;

            int CountX = inspector.CellsResolutionWidth;
            int CountZ = inspector.CellsResolutionLength;

            //Spawner spawner = new Spawner();

            PlatformsWall   = new List <List <GameObject> >(CountZ);
            PlatformsGround = new List <List <GameObject> >(CountZ);

            Defenders = new List <GameObject>(CountX - 2);

            for (int z = 0; z < CountZ; ++z)
            {
                PlatformsWall.Add(new List <GameObject>(2));
                PlatformsGround.Add(new List <GameObject>(CountX - 2));

                for (int x = 0; x < CountX; ++x)
                {
                    if (x == 0 || x == CountX - 1)
                    {
                        PlatformsWall[z].Add(Spawner.SpawnAtPosition(
                                                 inspector.PlatformWallPrefab,
                                                 CalculateNextPlatformPosition(x, z, inspector.PlatformWallPrefab.transform.localScale.y),
                                                 transform, GenerateCurrentPlatformName("Wall", x, z)));
                    }
                    else
                    {
                        PlatformsGround[z].Add(Spawner.SpawnAtPosition(
                                                   inspector.PlatformGroundPrefab,
                                                   CalculateNextPlatformPosition(x, z, inspector.PlatformGroundPrefab.transform.localScale.y),
                                                   transform, GenerateCurrentPlatformName("Ground", x, z)));

                        if (z == 0)
                        {
                            GameObject Defender = Spawner.SpawnAtGameObject(
                                inspector.DefendersWallPrefab, PlatformsGround[z][x - 1].transform,
                                PlatformsGround[z][x - 1].transform, "Defender");
                            UnitModel um = Defender.GetComponent <UnitModel>();

                            Defender.GetComponent <UnitModel>().TrackIndex = this.TrackIndex;
                            Defenders.Add(Defender);
                        }
                    }
                }
            }
            FixPlatformScale(PlatformsWall);
            FixPlatformScale(PlatformsGround);
            FixDefendersScale(Defenders);
        }
Example #2
0
 internal TracksModel SetPreset(TracksInspector tracksInspector)
 {
     Inspector = tracksInspector;
     return(this);
 }