void GenerateAbilityElement(string index)
    {
        SpawnerOutput abilityButton = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper));

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(abilityButton, "Text").text = abilityInfo[index].n;

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(abilityButton).onClick.AddListener(() => {
            selectedAbility = index;

            switch (currMode)
            {
            case AbilityButtonMode.CHANGE_PRIMARY_CHARACTER:
                if (!abilityManifest.ContainsKey((int)AbilityManifest.PRIMARY_CHARACTER))
                {
                    abilityManifest.Add((int)AbilityManifest.PRIMARY_CHARACTER, index);
                }
                else
                {
                    abilityManifest[(int)AbilityManifest.PRIMARY_CHARACTER] = index;
                }

                SaveAbilityManifest();
                break;

            case AbilityButtonMode.DEFAULT:
                SceneTransitionData.LoadScene("AbilityMaker");
                break;
            }

            ChangeButtonMode(AbilityButtonMode.DEFAULT);
        });

        //UIDrawer.ChangeUISize(abilityButton, new Vector2(200, 30));
        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <LinearLayout>(lL).Add(abilityButton.script.transform as RectTransform);
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        string text = "Datafiles: " + cDT.sentFiles.ToString() + "/" + cDT.expectedFiles.ToString() + "\n";

        text += "Art Assets: " + iDT.sentFiles.ToString() + "/" + iDT.expectedFiles.ToString() + "\n";
        text += "Manifest: " + mE.sentData.ToString() + "/" + mE.expectedDataCount.ToString() + "\n";

        text += LoadedData.GetCurrentTimestamp();
        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(progressOfFiles).text = text;

        if (cDT.sentFiles == cDT.expectedFiles && iDT.sentFiles == iDT.expectedFiles && startInitiated && mE.expectedDataCount == mE.sentData)
        {
            SceneTransitionData.LoadScene("Gameplay");
        }
    }
    void Start()
    {
        string cData = FileSaver.sFT[FileSaverTypes.PLAYER_GENERATED_DATA].GenericLoadTrigger(new string[] { AbilityPageScript.selectedAbility }, 0);
        string wData = FileSaver.sFT[FileSaverTypes.PLAYER_GENERATED_DATA].GenericLoadTrigger(new string[] { AbilityPageScript.selectedAbility }, 2);

        if (cData != "")
        {
            abilityData = new UIAbilityData(LoadedData.GetSingleton <JSONFileConvertor>().ConvertToData(JsonConvert.DeserializeObject <StandardJSONFileFormat[]>(cData)), JsonConvert.DeserializeObject <float[][]>(wData));
        }
        else
        {
            abilityData = new UIAbilityData();
        }


        abilityWindows = new AutoPopulationList <EditableWindow>();
        lineData       = new AutoPopulationList <LineData>();

        SpawnUIFromData();

        mainClassSelection = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(LinearLayout));

        SpawnerOutput name = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(InputFieldWrapper));

        name.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.5f, 0.9f));

        InputField castedName = LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <InputField>(name);

        string data = FileSaver.sFT[FileSaverTypes.PLAYER_GENERATED_DATA].GenericLoadTrigger(new string[] { AbilityPageScript.selectedAbility }, 1);

        abilityDescription = JsonConvert.DeserializeObject <AbilityInfo>(data);
        castedName.text    = abilityDescription.n;

        castedName.onValueChanged.AddListener((s) => {
            abilityDescription.n = s;
        });

        SpawnerOutput[] buttons = new SpawnerOutput[LoadedData.loadedNodeInstance.Count];


        foreach (KeyValuePair <Type, AbilityTreeNode> entry in LoadedData.loadedNodeInstance)
        {
            SpawnerOutput button = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper));

            Button butInst = LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(button);

            // Need another way to get elements within spawner output...
            LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(button, "Text").text = entry.Key.Name;

            butInst.onClick.AddListener(() => {
                selectedType = entry.Key;
                windowSpawner.script.gameObject.SetActive(true);
                mMode = MouseMode.CREATE_NODE;
            });

            (mainClassSelection.script as LinearLayout).Add(butInst.transform as RectTransform);
        }

        classSelectionScrollRect = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ScrollRectWrapper));
        (classSelectionScrollRect.script as ScrollRectWrapper).ChangeScrollRectSize(new Vector2(100, 600));


        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <UIMule>(classSelectionScrollRect, "Content").GetRectTransform().sizeDelta = (mainClassSelection.script.transform as RectTransform).sizeDelta;
        classSelectionScrollRect.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.1f, 0.6f));

        mainClassSelection.script.transform.SetParent(LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <UIMule>(classSelectionScrollRect, "Content").transform);
        mainClassSelection.script.transform.localPosition = new Vector2(-(mainClassSelection.script.transform as RectTransform).sizeDelta.x / 2, 0);


        windowSpawner = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(Image));
        windowSpawner.script.gameObject.SetActive(false);

        SpawnerOutput optLL = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(LinearLayout));

        SpawnerOutput normConnButt = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper));

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(normConnButt, "Text").text    = "Normal Conection";
        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Image>(normConnButt, "Image").color = Color.green;

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(normConnButt).onClick.AddListener(() => {
            mMode = MouseMode.EDIT_CONN;
            lMode = LinkMode.NORMAL;
        });

        SpawnerOutput sigConnButt = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper));

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(sigConnButt, "Text").text    = "Signal Conection";
        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Image>(sigConnButt, "Image").color = Color.red;

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(sigConnButt).onClick.AddListener(() => {
            mMode = MouseMode.EDIT_CONN;
            lMode = LinkMode.SIGNAL;
        });

        SpawnerOutput rmConnButt = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper));

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(rmConnButt,"Text").text = "Remove Conection";

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(rmConnButt).onClick.AddListener(() => {
            mMode = MouseMode.REMOVE_CONN;
        });

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <LinearLayout>(optLL).Add(normConnButt.script.transform as RectTransform);
        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <LinearLayout>(optLL).Add(sigConnButt.script.transform as RectTransform);
        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <LinearLayout>(optLL).Add(rmConnButt.script.transform as RectTransform);

        optLL.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.9f,0.9f));

        SpawnerOutput saveButton = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper));

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(saveButton).onClick.AddListener(() => {
            int[] aEle = abilityData.subclasses.ReturnActiveElementIndex();

            AbilityDataSubclass[] cAD = abilityData.RelinkSubclass();

            string[] imgDependencies = AbilityDataSubclass.GetImageDependencies(cAD);

            // Gets all window locations.
            float[][] windowLocations = new float[cAD.Length][];

            for (int i = 0; i < windowLocations.Length; i++)
            {
                windowLocations[i] = new float[2];

                windowLocations[i][0] = abilityWindows.l[aEle[i]].transform.position.x;
                windowLocations[i][1] = abilityWindows.l[aEle[i]].transform.position.y;
            }

            FileSaver.sFT[FileSaverTypes.PLAYER_GENERATED_DATA].GenericSaveTrigger(new string[] { AbilityPageScript.selectedAbility },0,JsonConvert.SerializeObject(LoadedData.GetSingleton <JSONFileConvertor>().ConvertToStandard(cAD)));
            FileSaver.sFT[FileSaverTypes.PLAYER_GENERATED_DATA].GenericSaveTrigger(new string[] { AbilityPageScript.selectedAbility }, 1, JsonConvert.SerializeObject(abilityDescription));
            FileSaver.sFT[FileSaverTypes.PLAYER_GENERATED_DATA].GenericSaveTrigger(new string[] { AbilityPageScript.selectedAbility }, 2, JsonConvert.SerializeObject(windowLocations));
            FileSaver.sFT[FileSaverTypes.PLAYER_GENERATED_DATA].GenericSaveTrigger(new string[] { AbilityPageScript.selectedAbility }, 3, JsonConvert.SerializeObject(imgDependencies));
        });

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(saveButton, "Text").text = "Save JSON";
        saveButton.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.5f, 0.1f));


        // Creates dropdown for input.
        kcDdL = new KeyCodeDropdownList(abilityDescription.kC);
        kcDdL.ReturnDropdownWrapper().transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.75f, 0.9f));

        kcDdL.ReturnDropdownWrapper().dropdown.onValueChanged.AddListener((v) => {
            abilityDescription.kC = KeyCodeDropdownList.inputValues[v];
        });

        // Creates dropdown for startnode.
        //DropdownWrapper sNDW = LoadedData.GetSingleton<UIDrawer>().CreateScriptedObject(typeof(DropdownWrapper)).script as DropdownWrapper;



        ButtonWrapper addOptionsButton = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)).script as ButtonWrapper;

        addOptionsButton.button.onClick.AddListener(() => CreateWindowForAdditionalOptions());

        addOptionsButton.text.text          = "Additional Options";
        addOptionsButton.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.1f, 0.2f));

        ButtonWrapper exitBlueprintMaker = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)).script as ButtonWrapper;

        exitBlueprintMaker.button.onClick.AddListener(() => SceneTransitionData.LoadScene("AbilityPage"));
        exitBlueprintMaker.text.text          = "Exit";
        exitBlueprintMaker.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.1f, 0.1f));
    }