Exemple #1
0
 public void RewriteData(FirePointData dataToCopy)
 {
     for (int i = 0; i < gunsConfigurations.Length; i++)
     {
         gunsConfigurations[i].battleType    = dataToCopy.gunsConfigurations[i].battleType;
         gunsConfigurations[i].gunDataType   = dataToCopy.gunsConfigurations[i].gunDataType;
         gunsConfigurations[i].gunType       = dataToCopy.gunsConfigurations[i].gunType;
         gunsConfigurations[i].locationPath  = dataToCopy.gunsConfigurations[i].locationPath;
         gunsConfigurations[i].trackingGroup = dataToCopy.gunsConfigurations[i].trackingGroup;
     }
 }
Exemple #2
0
    public static void SaveData(TruckData truckData, FirePointData firePointData, PlayerSessionData playerSessionData)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/player.data";

        FileStream stream = new FileStream(path, FileMode.Create);

        SerializablePlayerData data = new SerializablePlayerData();

        data.firePointType = (int)truckData.firePointType;
        data.truckType     = (int)truckData.truckType;

        data.gunTypes       = new int[12];
        data.locationPaths  = new int[12];
        data.trackingGroups = new int[12];
        data.gunDataTypes   = new int[12];

        for (int i = 0; i < firePointData.gunsConfigurations.Length; i++)
        {
            var config = firePointData.gunsConfigurations[i];
            data.gunTypes[i]       = (int)config.gunType;
            data.locationPaths[i]  = (int)config.locationPath;
            data.trackingGroups[i] = (int)config.trackingGroup;
            data.gunDataTypes[i]   = (int)config.gunDataType;
        }

        if (playerSessionData.traveledDistance > PlayerStaticRunTimeData.maxTraveledDistancePerSession)
        {
            data.maxTraveledDistancePerSession = playerSessionData.traveledDistance;
        }
        else
        {
            data.maxTraveledDistancePerSession = PlayerStaticRunTimeData.maxTraveledDistancePerSession;
        }
        data.traveledDistance = PlayerStaticRunTimeData.traveledDistance + playerSessionData.traveledDistance;
        if (playerSessionData.defeatedEnemies > PlayerStaticRunTimeData.maxDefeatedEnemiesPerSession)
        {
            data.maxDefeatedEnemiesPerSession = playerSessionData.defeatedEnemies;
        }
        else
        {
            data.maxDefeatedEnemiesPerSession = PlayerStaticRunTimeData.maxDefeatedEnemiesPerSession;
        }
        data.defeatedEnemies = PlayerStaticRunTimeData.defeatedEnemies + playerSessionData.defeatedEnemies;
        data.experience      = PlayerStaticRunTimeData.experience + playerSessionData.defeatedEnemies * 100 + playerSessionData.traveledDistance / 10;
        data.coins           = PlayerStaticRunTimeData.coins + playerSessionData.defeatedEnemies * 10 + +playerSessionData.traveledDistance / 10;

        formatter.Serialize(stream, data);
        stream.Close();
    }