public void LoadAll()
 {
     for (int i = 0; i < classes.Count; i++)
     {
         classes[i] = (SavedClass)ClassSaver.LoadClass(classes[0].GetType().ToString());
     }
 }
示例#2
0
    //
    // Used when moving between scenes, saves all required Infomation
    //
    public void SaveGameData()
    {
        //This is when Minigames Are Loaded, Each Attribute will be saved.
        ClassSaver classSaver = new ClassSaver();

        string JsonPath = Application.persistentDataPath + "/Test.json";
        //Save Array of Waypoints into List.
        WayPointChecker PointCheck;

        foreach (GameObject point in WayPoint)
        {
            PointCheck = point.GetComponent <WayPointChecker>();

            WayPoint WayToList = new WayPoint();

            WayToList.Owned       = PointCheck.Owned;
            WayToList.OwnedBy     = PointCheck.OwnedBy;
            WayToList.Ownable     = PointCheck.Ownable;
            WayToList.ChestActive = PointCheck.ChestActive;
            WayToList.ChestSpace  = PointCheck.ChestActive;

            classSaver.wayPointSaveList.Add(WayToList);
        }

        //Save Players Current Postition and Points/Crowns.
        PlayerSaver playersave = new PlayerSaver();

        playersave.P1Pos    = PlayerList[0].PlayerObject.GetComponent <PlayerMovement>().WayPointNumber;
        playersave.P1Points = PlayerList[0].Coins;
        playersave.P1Crowns = PlayerList[0].Crowns;

        playersave.P2Pos    = PlayerList[1].PlayerObject.GetComponent <PlayerMovement>().WayPointNumber;
        playersave.P2Points = PlayerList[1].Coins;
        playersave.P2Crowns = PlayerList[1].Crowns;

        //Debug.Log(PlayerList[0].PlayerObject.GetComponent<PlayerMovement>().WayPointNumber);

        if (PlayerAmount == 3 || PlayerAmount == 4)
        {
            playersave.P3Pos    = PlayerList[2].PlayerObject.GetComponent <PlayerMovement>().WayPointNumber;
            playersave.P3Points = PlayerList[2].Coins;
            playersave.P3Crowns = PlayerList[2].Crowns;
        }

        if (PlayerAmount == 4)
        {
            playersave.P4Pos    = PlayerList[3].PlayerObject.GetComponent <PlayerMovement>().WayPointNumber;
            playersave.P4Points = PlayerList[3].Coins;
            playersave.P4Crowns = PlayerList[3].Crowns;
        }

        classSaver.savePayerPos.Add(playersave);

        Debug.Log("SAVING");
        string JSONDATA = JsonUtility.ToJson(classSaver, true);

        File.WriteAllText(JsonPath, JSONDATA);
    }
    private IEnumerator UpdateAll()
    {
        for (int i = 0; i < classes.Count; i++)
        {
            CurrentStatsInfo.isDownloading = true;

            classes[i].UpdateClass();

            yield return(new WaitUntil(() => CurrentStatsInfo.isDownloading == false));

            ClassSaver.SaveClass(classes[i]);
        }
    }
示例#4
0
    public void LoadGameData()
    {
        Debug.Log("Loading Data");
        //This will be ran after a minigame has been played. It will sort everyone to their relevent location/stats/Waypoints info.
        CrossGameInfo = JsonUtility.FromJson <ClassSaver>(File.ReadAllText(Application.persistentDataPath + "/Test.json"));

        //Set Player Info to What it use to be.
        PlayerList[0].PlayerObject.GetComponent <PlayerMovement>().WayPointNumber = CrossGameInfo.savePayerPos[0].P1Pos;
        PlayerList[1].PlayerObject.GetComponent <PlayerMovement>().WayPointNumber = CrossGameInfo.savePayerPos[0].P2Pos;

        //Set Locations for players as otherwise they slowly move there. Checking to see if anyone is on start Stil also
        if (CrossGameInfo.savePayerPos[0].P1Pos != 0)
        {
            PlayerList[0].PlayerObject.transform.position = WayPoint[CrossGameInfo.savePayerPos[0].P1Pos - 1].transform.position;
        }

        if (CrossGameInfo.savePayerPos[0].P2Pos != 0)
        {
            PlayerList[1].PlayerObject.transform.position = WayPoint[CrossGameInfo.savePayerPos[0].P2Pos - 1].transform.position;
        }

        PlayerList[0].Crowns = CrossGameInfo.savePayerPos[0].P1Crowns;
        PlayerList[1].Crowns = CrossGameInfo.savePayerPos[0].P2Crowns;

        PlayerList[0].Coins = CrossGameInfo.savePayerPos[0].P1Points;
        PlayerList[1].Coins = CrossGameInfo.savePayerPos[0].P2Points;

        if (PlayerAmount == 3 || PlayerAmount == 4)
        {
            PlayerList[2].PlayerObject.GetComponent <PlayerMovement>().WayPointNumber = CrossGameInfo.savePayerPos[0].P3Pos;
            PlayerList[2].Crowns = CrossGameInfo.savePayerPos[0].P3Crowns;
            PlayerList[2].Coins  = CrossGameInfo.savePayerPos[0].P3Points;
            if (CrossGameInfo.savePayerPos[0].P3Pos != 0)
            {
                PlayerList[2].PlayerObject.transform.position = WayPoint[CrossGameInfo.savePayerPos[0].P3Pos - 1].transform.position;
            }
        }

        if (PlayerAmount == 4)
        {
            PlayerList[3].PlayerObject.GetComponent <PlayerMovement>().WayPointNumber = CrossGameInfo.savePayerPos[0].P4Pos;
            PlayerList[3].Crowns = CrossGameInfo.savePayerPos[0].P4Crowns;
            PlayerList[3].Coins  = CrossGameInfo.savePayerPos[0].P4Points;
            if (CrossGameInfo.savePayerPos[0].P4Pos != 0)
            {
                PlayerList[3].PlayerObject.transform.position = WayPoint[CrossGameInfo.savePayerPos[0].P4Pos - 1].transform.position;
            }
        }

        //Loading WayPoints Into Current Array.
        for (int i = 0; i < CrossGameInfo.wayPointSaveList.Count(); i++)
        {
            WayPoint[i].GetComponent <WayPointChecker>().Owned       = CrossGameInfo.wayPointSaveList[i].Owned;
            WayPoint[i].GetComponent <WayPointChecker>().OwnedBy     = CrossGameInfo.wayPointSaveList[i].OwnedBy;
            WayPoint[i].GetComponent <WayPointChecker>().Ownable     = CrossGameInfo.wayPointSaveList[i].Ownable;
            WayPoint[i].GetComponent <WayPointChecker>().ChestActive = CrossGameInfo.wayPointSaveList[i].ChestActive;
            WayPoint[i].GetComponent <WayPointChecker>().ChestSpace  = CrossGameInfo.wayPointSaveList[i].ChestSpace;

            if (WayPoint[i].GetComponent <WayPointChecker>().ChestActive == true)
            {
                WayPoint[i].GetComponent <WayPointChecker>().UpdateChestImage();
            }

            if (WayPoint[i].GetComponent <WayPointChecker>().Owned == true)
            {
                WayPoint[i].GetComponent <WayPointChecker>().UpdateColor();
            }
        }

        Debug.Log("Data Loading Complete");
    }