Example #1
0
 public static RunePathInfo RunePathData_to_RunePathInfo(RunePathData runePathData, bool isPri)
 {
     return(new RunePathInfo
     {
         isPrimary = isPri,
         pathName = runePathData.pathName,
         keystone = runePathData.keyStone,
         runeStones = runePathData.runeStones
     });
 }
Example #2
0
    private void DisplayRunePath(RunePathData primaryRunePathData, RunePathData secondaryRunePathData, bool isEmpty = true)
    {
        if (isEmpty)
        {
            RunePathInfo rpInfo = RunePathInfo.RunePathData_to_RunePathInfo(primaryRunePathData, true); //for debug usee
            Debug.Log("Displaying RunePath: \n" + rpInfo.ToString());                                   //for debug use

            primaryRunePath.Initialize(RunePathInfo.RunePathData_to_RunePathInfo(primaryRunePathData, true));
            secondaryRunePath.Initialize(RunePathInfo.RunePathData_to_RunePathInfo(secondaryRunePathData, false));
        }
    }
Example #3
0
    private RunePathData LoadRunePathData(string pathName, bool isPrimary)//for generating an empty runePage
    {
        TextAsset dataAsJson;
        string    jsonPath = "RunePathInfo_" + pathName + "_Json";

        dataAsJson = Resources.Load <TextAsset>(jsonPath);

        RunePathData runePathData = new RunePathData();

        runePathData = JsonUtility.FromJson <RunePathData>(dataAsJson.text);
        return(runePathData);
    }
Example #4
0
 public void ChangePath(string selectedPath, bool isPrimary)
 {
     if (isPrimary)
     {
         secPS.GetComponent <RunePathSelector>().RegenearteSecondaryPathSelections(selectedPath);
         primaryRunePath.Clear();
         secondaryRunePath.Clear();
         RunePathData primaryPathData   = LoadRunePathData(selectedPath, true);
         RunePathData secondaryPathData = primaryPathData;
         primaryRunePath.Initialize(RunePathInfo.RunePathData_to_RunePathInfo(primaryPathData, true));
         secondaryRunePath.Initialize(RunePathInfo.RunePathData_to_RunePathInfo(secondaryPathData, false));
         secondaryRunePath.Clear();
     }
     else
     {
         secondaryRunePath.Clear();
         RunePathData secondaryPathData = LoadRunePathData(selectedPath, false);
         secondaryRunePath.Initialize(RunePathInfo.RunePathData_to_RunePathInfo(secondaryPathData, false));
     }
 }
Example #5
0
    private RunePathData LoadRunePathData(bool isPrimary)//for saved data
    {
        string path = "Assets/StreamingAssets/SavedRunePages/"
                      + userName + "/" + (isPrimary ? "Primary" : "Secondary") + "Path" + runePageSeletor.value + ".json";

        if (File.Exists(path))
        {
            string dataAsJson;
            dataAsJson = File.ReadAllText(path);
            RunePathData runePathData = new RunePathData();
            runePathData = JsonUtility.FromJson <RunePathData>(dataAsJson);
            Debug.Log("Found Saved RunePage at " + path);
            Debug.Log(RunePathInfo.RunePathData_to_RunePathInfo(runePathData, isPrimary).ToString());
            return(runePathData);
        }
        else
        {
            Debug.Log("Did not Find Save RunePage at " + path);
            return(LoadRunePathData((isPrimary ? "Domination" : "Inspiration"), isPrimary));
        }
    }
    public RuneInfo LoadRuneInfo(string heroName)
    {
        RuneInfo runeInfo = new RuneInfo();

        string        priP       = "";
        string        secP       = "";
        string        keyStone   = "";
        List <string> runeStones = new List <string>();

        string path_pri;
        string path_sec;

#if UNITY_EDITOR || UNITY_STANDALONE_WIN
        path_pri = Application.streamingAssetsPath + "/SavedRunePages/" + heroName + "/PrimaryPath0.json";
        if (File.Exists(path_pri))
        {
            string dataAsJson;
            dataAsJson = File.ReadAllText(path_pri);
            RunePathData runePathData = new RunePathData();
            runePathData = JsonUtility.FromJson <RunePathData>(dataAsJson);
            Debug.Log("Found Saved RunePage at " + path_pri);
            GameDebugUtility.AddDebugMsg("Found Saved RunePage at " + path_pri);
            priP     = runePathData.pathName;
            keyStone = runePathData.keyStone.stoneChoiced;
            foreach (RuneStone rs in runePathData.runeStones)
            {
                runeStones.Add(rs.stoneChoiced);
            }
        }
        else
        {
            Debug.LogError("No saved RunePage");
        }
        path_sec = Application.streamingAssetsPath + "/SavedRunePages/" + heroName + "/SecondaryPath0.json";
        if (File.Exists(path_sec))
        {
            string dataAsJson;
            dataAsJson = File.ReadAllText(path_sec);
            RunePathData runePathData = new RunePathData();
            runePathData = JsonUtility.FromJson <RunePathData>(dataAsJson);
            Debug.Log("Found Saved RunePage at " + path_sec);
            GameDebugUtility.AddDebugMsg("Found Saved RunePage at " + path_sec);
            secP = runePathData.pathName;
            foreach (RuneStone rs in runePathData.runeStones)
            {
                runeStones.Add(rs.stoneChoiced);
            }
        }
        else
        {
            Debug.LogError("No saved RunePage");
        }
#endif

#if UNITY_ANDROID
        if (Application.platform == RuntimePlatform.Android)//Unknown bug in reading the files
        {
            string dataAsJson;
            path_pri = Path.Combine(Application.streamingAssetsPath + "/", heroName + "/PrimaryPath0.json");
            Debug.Assert(File.Exists(path_pri));
            WWW reader = new WWW(path_pri);
            while (!reader.isDone)
            {
            }
            dataAsJson = reader.text;
            RunePathData runePathData = new RunePathData();
            runePathData = JsonUtility.FromJson <RunePathData>(dataAsJson);
            Debug.Log("Found Saved RunePage at " + path_pri);

            priP     = runePathData.pathName;
            keyStone = runePathData.keyStone.stoneChoiced;
            foreach (RuneStone rs in runePathData.runeStones)
            {
                runeStones.Add(rs.stoneChoiced);
            }


            path_sec = Path.Combine(Application.streamingAssetsPath + "/", heroName + "/SecondaryPath0.json");
            reader   = new WWW(path_sec);
            while (!reader.isDone)
            {
            }
            dataAsJson   = reader.text;
            runePathData = new RunePathData();
            runePathData = JsonUtility.FromJson <RunePathData>(dataAsJson);
            Debug.Log("Found Saved RunePage at " + path_sec);

            secP = runePathData.pathName;
            foreach (RuneStone rs in runePathData.runeStones)
            {
                runeStones.Add(rs.stoneChoiced);
            }
        }
#endif
        runeInfo.Initialize(priP, secP);
        runeInfo.AddRuneStone(keyStone);
        foreach (string s in runeStones)
        {
            runeInfo.AddRuneStone(s);
        }

        return(runeInfo);
    }