Exemplo n.º 1
0
        /// <summary>
        /// Spawns all the cells needed for the build area.
        /// </summary>
        public void SpawnAllBuildAreas(LevelDetails levelDetails)
        {
            ClearAllChildren();

            for (var i = 0; i < levelDetails.rowOfPlots.Count; i++)
            {
                List <Plot> plotSection = levelDetails.rowOfPlots[i].plotsInRow;

                GameObject newParent = Instantiate(new GameObject());
                newParent.transform.SetParent(transform);
                newParent.transform.localPosition = new Vector3(0, 0, 0);
                newParent.name = "Row" + (i + 1);

                foreach (Plot plot in plotSection)
                {
                    int pathCount = levelDetails.pathwayPlots.Count;

                    if (plot.xPos == levelDetails.pathwayPlots[0].xPos && plot.zPos == levelDetails.pathwayPlots[0].zPos)
                    {
                        plot.typeOfPlot = Plot.TypeOfPlot.entrance;
                        SpanwBuildAreaCell(plot, entrancePrefab, newParent.transform);
                    }
                    else if (plot.xPos == levelDetails.pathwayPlots[pathCount - 1].xPos && plot.zPos == levelDetails.pathwayPlots[pathCount - 1].zPos)
                    {
                        plot.typeOfPlot = Plot.TypeOfPlot.exit;
                        SpanwBuildAreaCell(plot, exitPrefab, newParent.transform);
                    }
                    else
                    {
                        SpanwBuildAreaCell(plot, plotCellPrefab, newParent.transform);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Displays to the player level navigation for the current campaign
        /// </summary>
        private void ShowLevelSelectionOptions()
        {
            GUILayout.TextArea("Select what level to edit or add a new one.");
            GUILayout.TextArea("LEVEL " + (levelToLookAt + 1) + "/" + currentCampaign.allLevelDetails.Count + " SELECTED TO EDIT.");

            if (GUILayout.Button("Edit Next Level", GUILayout.Width(200), GUILayout.Height(50)))
            {
                ToggleThroughLevels();
            }

            GUILayout.BeginHorizontal("box");

            GUILayout.BeginHorizontal("box");

            xNumber = EditorGUILayout.IntField("Number of rows", xNumber);
            zNumber = EditorGUILayout.IntField("Number of plots in a row:", zNumber);

            GUILayout.EndHorizontal();

            if (GUILayout.Button("Add another Level", GUILayout.Width(200), GUILayout.Height(50)))
            {
                LevelDetails newLevel = levelDataBuilder.GenerateNewLevelDetails(xNumber, zNumber);
                newLevel.levelTitle = "Level " + (currentCampaign.allLevelDetails.Count + 1);

                currentCampaign.allLevelDetails.Add(newLevel);

                levelToLookAt = (currentCampaign.allLevelDetails.Count - 1);
            }

            GUILayout.EndHorizontal();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Displays the enemies about a level to the user.
        /// </summary>
        /// <param name="levelDetails">The level to display</param>
        private void DisplayEnemyInfo(LevelDetails levelDetails)
        {
            GUILayout.TextArea("Info about the enemies in this level.");
            GUILayout.BeginHorizontal("box");

            GUILayout.TextArea("This level has " + levelDetails.enimiesAmount + " enemies.", GUILayout.Width(100), GUILayout.Height(50));

            if (GUILayout.Button("+", GUILayout.Width(50), GUILayout.Height(50)))
            {
                levelDetails.enimiesAmount += 1;
            }
            if (GUILayout.Button("-", GUILayout.Width(50), GUILayout.Height(50)))
            {
                if (levelDetails.enimiesAmount > 1)
                {
                    levelDetails.enimiesAmount -= 1;
                }
            }

            GUILayout.TextArea("The enemies spawn every " + levelDetails.spawnRate + " seconds.", GUILayout.Width(100), GUILayout.Height(50));

            if (GUILayout.Button("+", GUILayout.Width(50), GUILayout.Height(50)))
            {
                levelDetails.spawnRate += 0.1f;
            }
            if (GUILayout.Button("-", GUILayout.Width(50), GUILayout.Height(50)))
            {
                if (levelDetails.spawnRate > 0.1f)
                {
                    levelDetails.spawnRate -= 0.1f;
                }
            }

            GUILayout.EndHorizontal();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Generates a new level with a set number of rows and plots in rows
        /// </summary>
        /// <param name="xRow">Rows</param>
        /// <param name="zLine">Plots in row</param>
        /// <returns>New LevelDetails</returns>
        public LevelDetails GenerateNewLevelDetails(int xRow, int zLine)
        {
            LevelDetails newLevel = new LevelDetails();

            newLevel.levelTitle    = "New Level";
            newLevel.enimiesAmount = 10;
            newLevel.spawnRate     = 2;

            for (var x = 0; x < xRow; x++)
            {
                List <Plot> newRow = new List <Plot>();
                for (var z = 0; z < zLine; z++)
                {
                    newRow.Add(new Plot(x, z, Plot.TypeOfPlot.tower));
                }

                RowOfPlots rowOfPlots = new RowOfPlots();
                rowOfPlots.titleOfRow = "Row " + (x + 1);
                newLevel.rowOfPlots.Add(rowOfPlots);

                newLevel.rowOfPlots[x].plotsInRow = newRow;
            }

            return(newLevel);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Builds the base of data you can structure more levels off of. Saves it to Application.persistentDataPath
        /// </summary>
        public void BuildBaseData()
        {
            Campaign newCampaign = new Campaign();

            newCampaign.titleOfLevelDetails = "testing";
            newCampaign.lastLevelPlayed     = 0;

            LevelDetails newLevel = GenerateNewLevelDetails(6, 6);

            newLevel.levelTitle = "PreMade 1";
            LevelDetails newLevel2 = GenerateNewLevelDetails(6, 7);

            newLevel2.levelTitle = "PreMade 2";
            LevelDetails newLevel3 = GenerateNewLevelDetails(9, 8);

            newLevel3.levelTitle = "PreMade 3";

            newCampaign.allLevelDetails.Add(newLevel);
            newCampaign.allLevelDetails.Add(newLevel2);
            newCampaign.allLevelDetails.Add(newLevel3);

            SaveCampaign(newCampaign);
        }
 public void SpawnPlots(LevelDetails levelDetails)
 {
     buildAreaGenerator.SpawnAllBuildAreas(levelDetails);
 }