Example #1
0
    public static void LoadData()
    {
        PlayerSerializableData data = PlayerStaticDataHandler.LoadData();

        if (data != null)
        {
            playerTruckData.truckType     = (GameEnums.Truck)data.truckType;
            playerTruckData.firePointType = (GameEnums.FirePointType)data.firePointType;

            for (int i = 0; i < playerTruckData.firePointData.gunsConfigurations.Length; i++)
            {
                var config = playerTruckData.firePointData.gunsConfigurations[i];
                config.gunType       = (GameEnums.Gun)data.gunTypes[i];
                config.battleType    = (GameEnums.BattleType)data.battleTypes[i];
                config.locationPath  = (GameEnums.GunLocation)data.locationPaths[i];
                config.trackingGroup = (GameEnums.TrackingGroup)data.trackingGroups[i];
                config.gunDataType   = (GameEnums.GunDataType)data.gunDataTypes[i];
            }

            maxTraveledDistancePerSession = data.maxTraveledDistancePerSession;
            totalTraveledDistance         = data.totalTraveledDistance;
            maxDefeatedEnemiesPerSession  = data.maxDefeatedEnemiesPerSession;
            totalDefeatedEnemies          = data.totalDefeatedEnemies;

            totalTraveledTime            = data.totalTraveledTime;
            maxTraveledTimePerSession    = data.maxTraveledTimePerSession;
            maxTraveledDistance_1Minute  = data.maxTraveledDistance_1Minute;
            maxTraveledDistance_3Minutes = data.maxTraveledDistance_3Minutes;
            maxTraveledDistance_5Minutes = data.maxTraveledDistance_5Minutes;

            coins      = data.coins;
            experience = data.experience;
        }
    }
    private void Awake()
    {
        PlayerStaticRunTimeData.playerTruckData        = playerTruckData;
        PlayerStaticRunTimeData.customizationTruckData = customizationTruckData;
        customizationTruckData.RewriteData(playerTruckData);
        customizationTruckData.firePointData.RewriteData(playerTruckData.firePointData);
        if (PlayerStaticDataHandler.LoadData() == null)
        {
            PlayerStaticRunTimeData.coins = startCoins;
            PlayerStaticRunTimeData.playerTruckData.ResetData();
            PlayerStaticRunTimeData.customizationTruckData.ResetData();
            PlayerStaticDataHandler.SaveData(PlayerStaticRunTimeData.playerTruckData, new PlayerSessionData(0, 0, 0));
        }
        else
        {
            PlayerStaticRunTimeData.LoadData();
        }

        UnityEngine.SceneManagement.SceneManager.LoadScene("MainMenuWithCustomization");
    }