void Start()
    {
        // Applies pending data that was recieved while loading.
        Debug.Log("Updating " + pendingData.Count + " messages while loading.");
        for (int i = 0; i < pendingData.Count; i++)
        {
            (NetworkMessageEncoder.encoders[(int)NetworkEncoderTypes.UPDATE_ABILITY_DATA] as UpdateAbilityDataEncoder).ParseMessage(pendingData[i]);
        }

        pendingData.Clear();
        playerLoadedInLobby = true;

        // Creates global variables for this player.
        aData[ClientProgram.clientId].abilties[""].InputCallback(0);

        // Creates player main character.
        string priCharacterId = aData[ClientProgram.clientId].abilityManifest[(int)AbilityManifest.PRIMARY_CHARACTER];

        aData[ClientProgram.clientId].abilties[priCharacterId].InputCallback(0);

        abilities = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(LinearLayout));
        (abilities.script as LinearLayout).o = LinearLayout.Orientation.X;
        abilities.script.transform.position  = UIDrawer.UINormalisedPosition(new Vector3(0.1f,0.1f));
        AssignInputKeys();
    }
    void GenerateMenuElements()
    {
        SpawnerOutput topText = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(TextWrapper));

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(topText).text  = "Abilities";
        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(topText).color = Color.white;

        topText.script.transform.position = UIDrawer.UINormalisedPosition(new Vector2(0.5f, 0.9f));

        commandText = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(TextWrapper));
        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(commandText).text  = "";
        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(commandText).color = Color.white;

        commandText.script.transform.position = UIDrawer.UINormalisedPosition(new Vector2(0.5f, 0.75f));

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

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(addAbility).onClick.AddListener(() => { CreateAbility(); });
        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(addAbility, "Text").text = "Create Ability";

        addAbility.script.transform.position = UIDrawer.UINormalisedPosition(new Vector2(0.15f, 0.1f));

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

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(setNewPrimary).onClick.AddListener(() => { ChangeButtonMode(AbilityButtonMode.CHANGE_PRIMARY_CHARACTER); });
        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(setNewPrimary, "Text").text = "Set new primary";

        setNewPrimary.script.transform.position = UIDrawer.UINormalisedPosition(new Vector2(0.9f, 0.8f));

        lL = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(LinearLayout));
        lL.script.transform.position = UIDrawer.UINormalisedPosition(new Vector2(0.1f, 0.75f));
    }
示例#3
0
    // Use this for initialization
    void Start()
    {
        AbilitiesManager.playerLoadedInLobby = false;

        lobbyInst = this;

        cDT = NetworkMessageEncoder.encoders[(int)NetworkEncoderTypes.CUSTOM_DATA_TRASMIT] as PlayerCustomDataTrasmitter;
        iDT = NetworkMessageEncoder.encoders[(int)NetworkEncoderTypes.IMAGE_DATA_TRANSMIT] as ImageDependenciesTransfer;
        mE  = NetworkMessageEncoder.encoders[(int)NetworkEncoderTypes.MANIFEST] as ManifestEncoder;

        ResetGameplayNetworkHelpers();

        lobbyText = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(TextWrapper));
        lobbyText.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.5f, 0.9f));

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(lobbyText).text = "Lobby";

        progressOfFiles = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(TextWrapper));
        progressOfFiles.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.5f, 0.5f));
        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(progressOfFiles).verticalOverflow = VerticalWrapMode.Overflow;

        startGame = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper));
        startGame.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.5f, 0.1f));

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(startGame, "Text").text = "Start Game";

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(startGame).onClick.AddListener(() => {
            ServerChannel sC = NetworkMessageEncoder.encoders[(int)NetworkEncoderTypes.SERVER_CHANNEL] as ServerChannel;
            sC.CommunicateServerSide(ServerSideMethods.START_GAME);
        });
    }
    public void ChangeWindowsContentSize(Vector2 size)
    {
        (windowsGraphic.transform as RectTransform).sizeDelta = new Vector2(size.x + contentOffset.z + contentOffset.w, size.y + contentOffset.x + contentOffset.y);

        deleteButton.transform.position = UIDrawer.UINormalisedPosition(windowsGraphic.transform as RectTransform, new Vector2(0.95f, 1f)) - new Vector3(0, contentOffset.x / 2);
        windowsText.transform.position  = UIDrawer.UINormalisedPosition(windowsGraphic.transform as RectTransform, new Vector2(0.5f, 1f)) - new Vector3(0, contentOffset.x / 2);
        (windowsText.transform as RectTransform).sizeDelta = new Vector2(size.x - contentOffset.z - contentOffset.w, contentOffset.x * 0.9f);
        content.transform.position = UIDrawer.UINormalisedPosition(windowsGraphic.transform as RectTransform, new Vector2(0f, 1f)) - new Vector3(-contentOffset.z, contentOffset.x);

        windowsSize = size;
    }
    void Start()
    {
        mPos          = new Vector2();
        rcs           = 16;
        dimensions    = 450;
        PNGDimensions = 1024;

        CalibrateEditor();

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

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(sO).onClick.AddListener(SavePNG);
        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(sO, "Text").text = "Save Art";

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

        LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <InputField>(nO).onValueChanged.AddListener((s) => {
            name = s;
        });

        sO.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.1f, 0.9f));
        nO.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.1f, 0.8f));

        GeneratePixels();
        pointer = CreatePixel();


        /*colors = new Color[1000];
         * for (int i = 0; i < colors.Length; i++)
         *  if (i < 500)
         *      colors[i] = Color.red;
         *  else
         *      colors[i] = Color.black;
         *
         * colorTest = new Texture2D(100, 10);
         * colorTest.SetPixels(colors);
         *
         * File.WriteAllBytes(Application.dataPath + "/../test6.png", colorTest.EncodeToPNG());*/
    }
    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));
    }