Example #1
0
    void Update()
    {
        if (_NextSceneID != SceneID.NULL && _AsyncObject == null)
        {
            //加载场景
            AsyncLoadScene(_NextSceneID);
            Debug.Log("START LOAD SCENE" + _NextSceneID.ToString());
        }
        //异步加载场景OK
        if (_AsyncObject != null && _AsyncObject.isDone && LoadedReady)
        {
            SceneTransitionData sd = GetSceneData(_NextSceneID);

            if (sd.CurrentSceneID == _LoadedSceneID)
            {
                Debug.Log("Scene " + sd.SceneName + " AsyncLoaded.");
                _NextSceneID   = SceneID.NULL;
                _LoadedSceneID = SceneID.NULL;
                _CurrSceneID   = sd.CurrentSceneID;
                _AsyncObject   = null;
            }
            else
            {
                Debug.Log("Scene Loading AsyncLoaded. Load Next Scene");
                AsyncLoadScene(_NextSceneID);
            }
        }
    }
Example #2
0
 void Update()
 {
     if (ClientProgram.clientId > -1 || ClientProgram.clientInst == null)
     {
         SceneTransitionData.Initialise();
     }
 }
    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);
    }
Example #4
0
    // Use this for initialization
    public void Initialize()
    {
        sceneTransData = GameManager.instance.GetSceneTransitionData();
        dataManager    = GameManager.instance.GetUserDataManager();

        GameManager.instance.StartCoroutine(StartCheckPointDetection());

        SpawnPlayer();
    }
Example #5
0
    static void OnDeath()
    {
        for (int i = 0; i < stats.Length; i++)
        {
            stats[i].OnChanged -= OnStatChanged;
            stats[i].OnZero    -= OnStatZero;
        }

        newGame = true;

        SceneTransitionData.Reset();
        SceneManager.LoadScene("Menu");
    }
    // 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");
        }
    }
Example #7
0
    public override void Move(Vector2 direction)
    {
        Tile nt = base.GetTileFromDirection(direction);

        if (nt.type == TileType.Door)
        {
            //spara senaste seed
            SceneTransitionData.SetLastRoomSeed(GameManager.room.seed);
            //sätt vilket håll vi gick ut åt
            SceneTransitionData.SetEntranceDirection(GameManager.room.GetEntranceDirection(nt));
            SceneManager.LoadScene("Map");
        }
        //spelaren flyttar till denna nya tile
        else
        {
            base.Move(direction);
            //markarerar att spelaren står på denna nya tile
            nt.SetType(TileType.Player);
            base.EndTurn();
        }
    }
Example #8
0
    private void AsyncLoadScene(SceneID id)
    {
        SceneTransitionData sd = GetSceneData(id);

        if (sd == null)
        {
            return;
        }

        //卸载当前场景内容
        SceneBase sceneBase = (SceneBase)FindObjectOfType(typeof(SceneBase));

        if (sceneBase != null)
        {
            sceneBase.Unload();
            Resources.UnloadUnusedAssets();             //去除不用的资源
        }

        //如果有LoadingScene则先加载LoadingScene
        if (sd.LoadingScene != SceneID.NULL && _LoadedSceneID != sd.LoadingScene)
        {
            //加载loadingScene
            AsyncLoadScene(sd.LoadingScene);
        }
        else
        {
            Debug.Log("Begin Load Scene " + sd.SceneName);
            //直接加载nextScene
            if (sd.IsAdditive)
            {
                _AsyncObject = SceneManager.LoadSceneAsync(sd.SceneName, LoadSceneMode.Additive);
            }
            else
            {
                _AsyncObject = SceneManager.LoadSceneAsync(sd.SceneName);
            }

            _LoadedSceneID = sd.CurrentSceneID;
        }
    }
    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));
    }
Example #10
0
 void Start()
 {
     lm = GameManager.instance.GetSceneTransitionData();
 }
Example #11
0
 // Use this for initialization
 void Start()
 {
     dataManager = GameManager.instance.GetUserDataManager();
     sceneTrans  = GameManager.instance.GetSceneTransitionData();
     RefreshPlayerList();
 }
Example #12
0
 void Start()
 {
     //get components
     lm = GameManager.instance.GetSceneTransitionData();
 }