示例#1
0
        /// <summary>
        /// Sets up values for world generation.
        /// </summary>
        void Awake()
        {
			showGrid = ShowGrid;
            resourceManager = GetComponent<ResourceManager>();
            improvementManager = GetComponent<ImprovementManager>();
            tileManager = GetComponent<TileManager>();
            civGridCamera = GameObject.FindObjectOfType<CivGridCamera>();
            axialToHexDictionary = new Dictionary<Vector2, Hex>();

            if (generateNodeLocations)
            {
                nodeLocations = new Vector3[(int)mapSize.x, (int)mapSize.y];
            }

            if (generateOnStart == true)
            {
                //LoadAndGenerateMap("terrainTest");
                GenerateNewMap(true);
                //FileUtility.SaveTerrain("terrainTest");
            }
            else { civGridCamera.enabled = false; }
        }
示例#2
0
        void OnEnable()
        {
            this.title = "Terrain Manager";
            worldManager = GameObject.FindObjectOfType<WorldManager>();
            improvementManager = GameObject.FindObjectOfType<ImprovementManager>();
            resourceManager = GameObject.FindObjectOfType<ResourceManager>();
            tileManager = GameObject.FindObjectOfType<TileManager>();

            if (worldManager == null || improvementManager == null)
            {
                Debug.LogError("Need to have WorldManager and ImprovementManager in current scene");
            }

            int length = 0;

            foreach(Resource r in resourceManager.resources)
            {
                if (r.replaceGroundTexture == true) { length++; }
            }
            foreach(Improvement i in improvementManager.improvements)
            {
                if (i.replaceGroundTexture == true) { length++; }
            }
            length += tileManager.tileNames.Length;

            for (int i = 0; i < length; i++)
            {
                AddElement();
            }

                tileManager.UpdateTileNames();
            resourceManager.UpdateResourceNames();
            improvementManager.UpdateImprovementNames();

            start = true;
        }
        public override void OnInspectorGUI()
        {
            if (done == false)
            {
                Awake();

                done = true;
            }

            if (improvementManager == null) { improvementManager = (ImprovementManager)target; }
            if (worldManager == null) { worldManager = improvementManager.GetComponent<WorldManager>(); }
            if (tileManager == null) { tileManager = improvementManager.GetComponent<TileManager>(); }
            if (improvementManager.improvements != null && (foldoutOpen == null || foldoutOpen.Length != improvementManager.improvements.Count)) { foldoutOpen = new bool[improvementManager.improvements.Count]; }
            if (improvementManager.improvements != null && (extraInfoFoldout == null || extraInfoFoldout.Length != improvementManager.improvements.Count)) { extraInfoFoldout = new bool[improvementManager.improvements.Count]; }

            if (GUILayout.Button("Add New Improvement"))
            {
                ImprovementEditorWindow window = EditorWindow.CreateInstance<ImprovementEditorWindow>();
                EditorWindow.GetWindow<ImprovementEditorWindow>();
                window.editMode = false;
                window.improvementIndexToEdit = 0;
            }

            if (improvementManager.improvements != null && improvementManager.improvements.Count > 0)
            {
                for (int i = 0; i < improvementManager.improvements.Count; i++)
                {
                    Improvement improvement = improvementManager.improvements[i];

                    EditorGUILayout.BeginHorizontal();

                    foldoutOpen[i] = EditorGUILayout.Foldout(foldoutOpen[i], improvement.name);

                    if (GUILayout.Button("Edit"))
                    {
                        ImprovementEditorWindow window = EditorWindow.CreateInstance<ImprovementEditorWindow>();
                        EditorWindow.GetWindow<ImprovementEditorWindow>();
                        window.editMode = true;
                        window.improvementIndexToEdit = i;
                    }

                    if (GUILayout.Button("Remove"))
                    {
                        improvementManager.DeleteImprovement(improvement);
                    }

                    EditorGUILayout.EndHorizontal();

                    EditorGUI.indentLevel++;
                    if (foldoutOpen[i])
                    {
                        improvement.name = EditorGUILayout.TextField("Improvement Name:", improvement.name);
                        improvement.replaceGroundTexture = EditorGUILayout.Toggle("Replace Ground Texture:", improvement.replaceGroundTexture);

                        extraInfoFoldout[i] = EditorGUILayout.Foldout(extraInfoFoldout[i], "Rules:");

                        if (extraInfoFoldout[i])
                        {
                            EditorGUILayout.SelectableLabel("Possible Tiles:", EditorStyles.boldLabel, GUILayout.ExpandHeight(false), GUILayout.MaxHeight(15));
							EditorGUI.indentLevel++;
							if(improvement.rule.possibleTiles.Length == 0)
							{
								EditorGUILayout.SelectableLabel("No Possible Tiles");	
							}
							else
							{
								foreach (int t in improvement.rule.possibleTiles)
                            	{
                                	EditorGUI.indentLevel++;
                                	EditorGUILayout.SelectableLabel(tileManager.tiles[t].name, GUILayout.ExpandHeight(false), GUILayout.MaxHeight(18));
                                	EditorGUI.indentLevel--;
                            	}
							}
							EditorGUI.indentLevel--;
							
                            EditorGUILayout.SelectableLabel("Possible Features:", EditorStyles.boldLabel, GUILayout.ExpandHeight(false), GUILayout.MaxHeight(15));
							EditorGUI.indentLevel++;
							if(improvement.rule.possibleFeatures.Length == 0)
							{
								EditorGUILayout.SelectableLabel("No Possible Features");	
							}
							else
							{
								foreach (Feature f in improvement.rule.possibleFeatures)
                            	{
                                	EditorGUI.indentLevel++;
                                	EditorGUILayout.SelectableLabel(f.ToString(), GUILayout.ExpandHeight(false), GUILayout.MaxHeight(18));
                                	EditorGUI.indentLevel--;
                            	}
							}
							EditorGUI.indentLevel--;
							
							EditorGUILayout.Separator();
                        }
                        improvement.meshToSpawn = (Mesh)EditorGUILayout.ObjectField("Improvement Mesh", (Object)improvement.meshToSpawn, typeof(Mesh), false);
                        improvement.meshTexture = (Texture2D)EditorGUILayout.ObjectField("Improvement Mesh Texture:", (Object)improvement.meshTexture, typeof(Texture2D), false, GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));

                    }
                    EditorGUI.indentLevel--;
                }
            }
            else
            {
                GUILayout.Label("No Improvements Created; Please Add Some");
            }

            if (GUILayout.Button("Finalize"))
            {
                improvementManager.UpdateImprovementNames();
            }
        }
示例#4
0
 void OnEnable()
 {
     improvementManager = GameObject.FindObjectOfType<ImprovementManager>();
     tileManager = GameObject.FindObjectOfType<TileManager>();
 }