Beispiel #1
0
    // Use this for initialization
    void Awake()
    {
        game = this;
        ResetStatics();
        ResearchMenu.InitializeAllStatics();
        darkOverlayActive = true;
        InitializeBasics();

        ModuleMod.currentMenu = new GameObject[ModuleMod.MAX_DEPTH];

        if (currentScene == Scene.Play)
        {
            assemblyContextMenu.Initialize();

            for (int i = 0; i < purchaseMenu.all.Count; i++)
            {
                Module mod = purchaseMenu.all[i].GetComponent <Module> ();
                if (mod.moduleType == Module.Type.Weapon)
                {
                    GenerateDefaultAssembly(mod);
                }
            }
        }

        ModuleAssemblyLoader.ConvertLegacyAssemblyFiles();
        HideGUI();

        UpdateMusicVolume();
    }
Beispiel #2
0
 public void Initialize()
 {
     cur    = this;
     isOpen = true;
     InitializeResearchMenu();
     startPos = transform.localPosition;
     ToggleResearchMenu();
     UpdateButtons();
 }
 // Use this for initialization
 void Awake()
 {
     cur = this;
     ResearchMenu.InitializeAllStatics();
     Game.currentScene     = Scene.AssemblyBuilder;
     Game.credits          = int.MaxValue;
     purchaseMenu.standard = Resources.LoadAll <GameObject> ("Modules").ToList();
     purchaseMenu.Initialize();
     newAssemblies = new List <Assembly> ();
     Game.UpdateDarkOverlay();
 }
    void OnGUI()
    {
        GUI.SetNextControlName("DUMMY");
        GUI.Label(new Rect(-100, -100, 1, 1), "DUMMY");

        if (research && research.research != null)
        {
            for (int i = 0; i < research.research.Count; i++)
            {
                research.research[i].index = i;
            }
        }

        if (!research)
        {
            GameObject r = GameObject.Find("ResearchMenu");
            if (r)
            {
                research = r.GetComponent <ResearchMenu>();
            }
        }
        else
        {
            if (state == WindowState.All)
            {
                if (action != Action.MovingResearch)
                {
                    offset.y = GUI.VerticalSlider(new Rect(position.width - 15, 5, 10, position.height - 10), offset.y, position.height, 0);
                    if (GUI.Button(new Rect(position.width / 3, position.height - 50, position.width / 3, 20), "Suggest All Names"))
                    {
                        for (int i = 0; i < research.research.Count; i++)
                        {
                            string n;
                            string d;

                            SuggestTitle(research.research[i], out n, out d);
                            research.research[i].name = n;
                            research.research[i].desc = d;
                        }
                    }

                    if (GUI.Button(new Rect(position.width / 3, position.height - 25, position.width / 3, 20), "Add Research"))
                    {
                        research.research.Add(new Research());
                        SelectResearch(research.research[research.research.Count - 1]);
                        research.research[research.research.Count - 1].index        = research.research.Count - 1;
                        research.research[research.research.Count - 1].prerequisite = -1;
                        state  = WindowState.All;
                        action = Action.MovingResearch;
                    }

                    for (int i = 0; i < research.research.Count; i++)
                    {
                        Research u   = research.research[i];
                        Vector3  pos = research.GetPos(u);

                        DrawResearchButton(pos, u);
                    }

                    for (int i = (int)(offset.y / 30); i < (int)(position.height / 30) + (int)(offset.y / 30); i++)
                    {
                        GUI.Label(new Rect(10, i * 30 + 10 - offset.y, 20, 20), i.ToString());
                    }
                }

                if (action == Action.MovingResearch || action == Action.CloningResearch)
                {
                    // Dis part gunna be heavy and hacky.
                    // I'm truely sorry you have to see this.

                    // Create and populate unfound research.
                    List <Research> unfound = new List <Research>();
                    foreach (Research r in research.research)
                    {
                        unfound.Add(r);
                    }

                    // Foreach loops are major simple to work with, yay! :D

                    for (int y = (int)(offset.y / 30); y < (int)(position.height / 30) + (int)(offset.y / 30); y++)
                    {
                        for (int x = (int)((offset.x - position.width / 2) / 30); x < (int)((position.width / 2) / 30); x++)
                        {
                            // Figure out if there is research at current position, search in unfound.
                            Research atPos = null;
                            foreach (Research r in unfound)
                            {
                                if (r.x == x && r.y == y)
                                {
                                    atPos = r;
                                }
                            }

                            if (atPos != null)
                            {
                                DrawResearchButton(new Vector3(x, y), atPos);
                                unfound.Remove(atPos);
                            }
                            else
                            {
                                DrawResearchButton(new Vector3(x, y), null);
                            }
                        }
                    }
                }
            }

            if (state == WindowState.Research)
            {
                if (focusResearch == null)
                {
                    state  = WindowState.All;
                    action = Action.Default;
                }
                focusResearch.name   = EditorGUILayout.TextField("Name: ", focusResearch.name);
                focusResearch.desc   = EditorGUILayout.TextArea(focusResearch.desc);
                focusResearch.func   = EditorGUILayout.TextField("Function: ", focusResearch.func);
                focusResearch.meta   = EditorGUILayout.TextField("Meta: ", focusResearch.meta);
                focusResearch.sprite = (Sprite)EditorGUILayout.ObjectField("Sprite: ", focusResearch.sprite, typeof(Sprite), false);
                focusResearch.colour = (Colour)EditorGUILayout.EnumPopup("Colour: ", focusResearch.colour);
                if (focusResearch.prerequisite != -1)
                {
                    if (GUILayout.Button("Remove Prerequisite: " + focusResearch.GetPrerequisite().name))
                    {
                        Debug.Log("Removing Prerequisitite");
                        focusResearch.prerequisite = -1;
                    }
                }
                else
                {
                    if (GUILayout.Button("Add Prerequisite"))
                    {
                        state  = WindowState.All;
                        action = Action.ChoosingPrerequisite;
                    }
                }

                if (GUILayout.Button("Move"))
                {
                    state  = WindowState.All;
                    action = Action.MovingResearch;
                }

                if (GUILayout.Button("Clone"))
                {
                    state  = WindowState.All;
                    action = Action.CloningResearch;
                }

                if (GUILayout.Button("Delete"))
                {
                    research.research.Remove(focusResearch);
                    state         = WindowState.All;
                    action        = Action.Default;
                    focusResearch = null;
                }

                if (GUILayout.Button("Suggest Name"))
                {
                    string n;
                    string d;

                    SuggestTitle(focusResearch, out n, out d);
                    focusResearch.name = n;
                    focusResearch.desc = d;
                }

                if (GUILayout.Button("Return"))
                {
                    state         = WindowState.All;
                    action        = Action.Default;
                    focusResearch = null;
                }
            }
        }
    }