void Awake()
 {
     ImprovementManager improvementManager = (ImprovementManager)target;
     tileManager = improvementManager.GetComponent<TileManager>();
     if (improvementManager.improvements != null)
     {
         foldoutOpen = new bool[improvementManager.improvements.Count];
         extraInfoFoldout = new bool[improvementManager.improvements.Count];
     }
 }
Пример #2
0
 void Awake()
 {
     resourceManager = (ResourceManager)target;
     tileManager = resourceManager.GetComponent<TileManager>();
     if (resourceManager.resources != null)
     {
         foldoutOpen = new bool[resourceManager.resources.Count];
         extraInfoFoldout = new bool[resourceManager.resources.Count];
     }
 }
Пример #3
0
 public int[] ValidateData(TileManager tileManager)
 {
     List<int> tiles = possibleTiles.ToList();
     foreach(int t in tiles)
     {
         if (tileManager.tiles[t] == null)
         {
             tiles.Remove(t);
         }
     }
     return tiles.ToArray();
 }
Пример #4
0
        /// <summary>
        /// Sets up the improvement manager.
        /// Caches all needed values.
        /// </summary>
        public void SetUp()
        {
            //insert default "None" improvement into the improvement array
            improvements.Insert(0, new Improvement("None", null, null, false, null));

            //set internal array
            internalImprovements = improvements.ToArray();

            //cache managers
            resourceManager = GetComponent <ResourceManager>();
            tileManager     = GetComponent <TileManager>();

            //instatiate the improvement name array
            if (improvementNames == null)
            {
                UpdateImprovementNames();
            }
        }
Пример #5
0
        /// <summary>
        /// Sets up the resource manager.
        /// Caches all needed values.
        /// </summary>
        internal void SetUp()
        {
            //insert default "None" resource into the resource array
            resources.Insert(0, new Resource("None", 0, 0, null, null, false, null));

            //set internal array
            internalResources = resources.ToArray();

            //cache managers
            tileManager  = GetComponent <TileManager>();
            worldManager = GetComponent <WorldManager>();

            //instatiate the improvement name array
            if (resourceNames == null)
            {
                UpdateResourceNames();
            }
        }
Пример #6
0
        /// <summary>
        /// Sets up the improvement manager.
        /// Caches all needed values.
        /// </summary>
        public void SetUp()
        {
            //insert default "None" improvement into the improvement array
            improvements.Insert(0, new Improvement("None", null, null, false, null));

            //set internal array
            internalImprovements = improvements.ToArray();

            //cache managers
            resourceManager = GetComponent<ResourceManager>();
            tileManager = GetComponent<TileManager>();

            //instatiate the improvement name array
            if (improvementNames == null)
            {
                UpdateImprovementNames();
            }
        }
Пример #7
0
        /// <summary>
        /// Sets up the resource manager.
        /// Caches all needed values.
        /// </summary>
        internal void SetUp()
        {
            //insert default "None" resource into the resource array
            resources.Insert(0, new Resource("None", 0, 0, null, null, false, null));

            //set internal array
            internalResources = resources.ToArray();

            //cache managers
            tileManager = GetComponent<TileManager>();
            worldManager = GetComponent<WorldManager>();

            //instatiate the improvement name array
            if (resourceNames == null)
            {
                UpdateResourceNames();
            }
        }
Пример #8
0
 /// <summary>
 /// Checks all rules in the rule list.
 /// </summary>
 /// <param name="hex">Hex to compare the rules upon</param>
 /// <param name="rule">Rules to check</param>
 /// <param name="tileManager">The scene tile manager</param>
 /// <returns>If the hex passed the tests</returns>
 public static bool Test(Hex hex, HexRule rule, TileManager tileManager)
 {
     //check tile rules
     for (int i = 0; i < rule.possibleTiles.Length; i++)
     {
         //if the hex's tile type is in the list of possible tiles, break out of the loop and check features
         if (TestRule(hex, tileManager.tiles[rule.possibleTiles[i]]) == true) { break; }
         //the hex's tile type was not in the list of possible tiles, return false 
         if (i == (rule.possibleTiles.Length - 1)) { return false; }
     }
     //check feature rules
     for (int i = 0; i < rule.possibleFeatures.Length; i++)
     {
         //if hex's feature type is in the list of possible features, return true since both rules have been passed
         if (TestRule(hex, rule.possibleFeatures[i]) == true) { return true; }
         //the hex's feature type was not in the list of possible features, return false 
         if (i == (rule.possibleFeatures.Length - 1)) { return false; }
     }
     //unreachable mandatory code because c# is funky
     return false;
 }
Пример #9
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; }
        }
Пример #10
0
        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();
            }
        }
Пример #11
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;
        }
Пример #12
0
 public void OnEnable()
 {
     tileManager = GameObject.FindObjectOfType<TileManager>();
 }
Пример #13
0
 void OnEnable()
 {
     resourceManager = GameObject.FindObjectOfType<ResourceManager>();
     tileManager = GameObject.FindObjectOfType<TileManager>();
 }
Пример #14
0
 void OnEnable()
 {
     improvementManager = GameObject.FindObjectOfType<ImprovementManager>();
     tileManager = GameObject.FindObjectOfType<TileManager>();
 }