Пример #1
0
        private IEnumerator <YieldInstruction> LoadCreatures()
        {
            ConfigNode[] creatures = GameDatabase.Instance.GetConfigNodes("CREATURE");
            totalCreatures = creatures.Length;

            foreach (var node in creatures)
            {
                try
                {
                    if (node.HasValue("name"))
                    {
                        var name = node.GetValue("name");

                        var creatureLogger = new KopernicusExpansionLogger(name + ".Creature");
                        creatureLogger.SetAsActive();

                        var creature = Creature.Load(node);
                        currentCreatureName = creature.name;
                        LoadedCreatures.Add(creature);

                        //log it
                        Logger.Active.Log("Creature " + creature.name + " loaded");

                        creatureLogger.Flush();
                        creatureLogger.Close();
                    }
                }
                catch (Exception e)
                {
                    Utils.LogError("Error loading creature:");
                    Debug.LogException(e);
                }
                creatureLoadCounter++;

                //wait for next frame
                yield return(null);
            }

            creatureLoadCounter = totalCreatures;
            isDone = true;

            Utils.Log("CreatureLoader done!");
        }
        private IEnumerator<YieldInstruction> LoadCreatures()
        {
            ConfigNode[] creatures = GameDatabase.Instance.GetConfigNodes ("CREATURE");
            totalCreatures = creatures.Length;

            foreach (var node in creatures)
            {
                try
                {
                    if(node.HasValue("name"))
                    {
                        var name = node.GetValue ("name");

                        var creatureLogger = new KopernicusExpansionLogger (name + ".Creature");
                        creatureLogger.SetAsActive ();

                        var creature = Creature.Load (node);
                        currentCreatureName = creature.name;
                        LoadedCreatures.Add (creature);

                        //log it
                        Logger.Active.Log ("Creature " + creature.name + " loaded");

                        creatureLogger.Flush ();
                        creatureLogger.Close ();
                    }
                }
                catch(Exception e)
                {
                    Utils.LogError ("Error loading creature:");
                    Debug.LogException (e);
                }
                creatureLoadCounter++;

                //wait for next frame
                yield return null;
            }

            creatureLoadCounter = totalCreatures;
            isDone = true;

            Utils.Log ("CreatureLoader done!");
        }
Пример #3
0
        private void TextureViewerWindow(int id)
        {
            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical(GUILayout.Width(500f));
            textureViewScroll = GUILayout.BeginScrollView(textureViewScroll);
            if (selectedTexture != null)
            {
                GUILayout.Label("<b>" + selectedTexture.name + "</b>");
                GUILayout.Label(selectedTexture, GUILayout.Width(textureDefaultWidth * textureZoom), GUILayout.Height(textureDefaultWidth * textureZoom));
            }
            else
            {
                GUILayout.Space(100f);
                GUILayout.Label("<b><color=#aaaaaa>select a texture</color></b>", GUILayout.Height(textureDefaultWidth));
            }
            GUILayout.EndScrollView();
            textureZoom = DrawManipulationSlider("textureZoom", "Zoom", textureZoom, 0f, 10f, false);
            GUILayout.EndVertical();

            GUILayout.BeginVertical(GUILayout.Width(400f));
            //draw pages of textures
            textureListScroll = GUILayout.BeginScrollView(textureListScroll, false, true);
            foreach (var texture in thisTexturePage)
            {
                if (texture == null)
                {
                    continue;
                }
                var textureName = string.IsNullOrEmpty(texture.name) ? "<color=orange><unnamed></color>" : texture.name;
                if (texture == selectedTexture)
                {
                    GUILayout.Toggle(true, textureName, smallButton);
                }
                else
                {
                    if (GUILayout.Button(textureName, smallButton))
                    {
                        selectedTexture = texture;
                    }
                }
            }
            GUILayout.EndScrollView();

            GUILayout.BeginHorizontal();
            bool hasNextPage     = thisPageNumber < Mathf.FloorToInt((float)numberOfTextures / (float)pageLength);
            bool hasPreviousPage = thisPageNumber > 0;

            if (hasPreviousPage)
            {
                if (GUILayout.Button("<<", GUILayout.Width(80f)))
                {
                    GetPageOfTextures(thisPageNumber - 1);
                }
            }
            else
            {
                GUILayout.Toggle(true, "<<", skin.button, GUILayout.Width(80f));
            }
            GUILayout.Label("<color=white>Page " + (thisPageNumber + 1) + " of " + (Mathf.FloorToInt((float)numberOfTextures / (float)pageLength) + 1) + "</color>", GUILayout.ExpandWidth(true));
            if (hasNextPage)
            {
                if (GUILayout.Button(">>", GUILayout.Width(80f)))
                {
                    GetPageOfTextures(thisPageNumber + 1);
                }
            }
            else
            {
                GUILayout.Toggle(true, ">>", skin.button, GUILayout.Width(80f));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUI.color          = textBoxTextureNameColor;
            textBoxTextureName = GUILayout.TextField(textBoxTextureName, GUILayout.ExpandWidth(true));
            GUI.color          = Color.white;
            if (GUILayout.Button("Select", GUILayout.Width(120f)))
            {
                var allTextures = UnityEngine.Resources.FindObjectsOfTypeAll <Texture2D> ();
                if (allTextures.Any(t => t.name == textBoxTextureName))
                {
                    var texture = allTextures.First(t => t.name == textBoxTextureName);
                    if (texture == null)
                    {
                        textBoxTextureNameColor = Color.red;
                    }
                    else
                    {
                        selectedTexture         = texture;
                        textBoxTextureNameColor = Color.white;
                    }
                }
                else
                {
                    textBoxTextureNameColor = Color.red;
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUI.color      = pageJumpStringColor;
            pageJumpString = GUILayout.TextField(pageJumpString, GUILayout.ExpandWidth(true));
            GUI.color      = Color.white;
            if (GUILayout.Button("Jump to page", GUILayout.Width(120f)))
            {
                int pageToJumpTo = 0;
                if (int.TryParse(pageJumpString, out pageToJumpTo))
                {
                    pageToJumpTo -= 1;
                    bool isValidPage = pageToJumpTo >= 0 && pageToJumpTo <= Mathf.FloorToInt((float)numberOfTextures / (float)pageLength);
                    if (isValidPage)
                    {
                        GetPageOfTextures(pageToJumpTo);
                        pageJumpStringColor = Color.white;
                    }
                    else
                    {
                        pageJumpStringColor = Color.red;
                    }
                }
                else
                {
                    pageJumpStringColor = Color.red;
                }
            }
            GUILayout.EndHorizontal();

            if (GUILayout.Button("Print list of texture names", smallButton))
            {
                KopernicusExpansionLogger logger = new KopernicusExpansionLogger("TextureList");
                var allTextures = UnityEngine.Resources.FindObjectsOfTypeAll <Texture2D> ();
                logger.Log("Number of textures: " + numberOfTextures);
                logger.Log("");
                foreach (var texture in allTextures)
                {
                    logger.Log("Texture: " + texture.name);
                }
                logger.Flush();
                logger.Close();
            }
            GUILayout.Label("<color=white>Outputs a list of all texture names to <color=orange>Logs/KopernicusExpansion/TextureList.log</color></color>");

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            GUI.DragWindow();
        }