server post wip
This commit is contained in:
1 parent
ef95f63d14
commit
d6445332be
13 files changed
+239
-30
No files matched your search
@@ -0,0 +1,54 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e627c538dce2b838d8702905b032ac82
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: a57477913897c46af95d590f580878bd, type: 3}
|
||||
svgType: 0
|
||||
texturedSpriteMeshType: 0
|
||||
svgPixelsPerUnit: 100
|
||||
gradientResolution: 64
|
||||
alignment: 0
|
||||
customPivot: {x: 0, y: 0}
|
||||
generatePhysicsShape: 0
|
||||
viewportOptions: 0
|
||||
preserveViewport: 0
|
||||
advancedMode: 0
|
||||
predefinedResolutionIndex: 1
|
||||
targetResolution: 1080
|
||||
resolutionMultiplier: 1
|
||||
stepDistance: 10
|
||||
samplingStepDistance: 100
|
||||
maxCordDeviationEnabled: 0
|
||||
maxCordDeviation: 1
|
||||
maxTangentAngleEnabled: 0
|
||||
maxTangentAngle: 5
|
||||
keepTextureAspectRatio: 1
|
||||
textureSize: 256
|
||||
textureWidth: 256
|
||||
textureHeight: 256
|
||||
wrapMode: 0
|
||||
filterMode: 1
|
||||
sampleCount: 4
|
||||
preserveSVGImageAspect: 0
|
||||
useSVGPixelsPerUnit: 0
|
||||
spriteData:
|
||||
TessellationDetail: 0
|
||||
SpriteRect:
|
||||
name:
|
||||
originalName:
|
||||
pivot: {x: 0, y: 0}
|
||||
alignment: 0
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 0
|
||||
height: 0
|
||||
spriteID: 974c0935effe6880abbfb6994005227d
|
||||
PhysicsOutlines: []
|
||||
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
[Serializable]
|
||||
public class SectorTime {
|
||||
public int Sector;
|
||||
public double Seconds;
|
||||
public override string ToString() => $"{Seconds:0.000}";
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class Lap {
|
||||
public string Map;
|
||||
public List<SectorTime> Sectors;
|
||||
|
||||
// 0:1:39
|
||||
public override string ToString() {
|
||||
return $"{TimeSpan.FromSeconds(TotalTime):m\\:ss\\.fff}";
|
||||
}
|
||||
|
||||
public double TotalTime => Sectors.Sum(s => s.Seconds);
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class PlayerData {
|
||||
public Guid Id;
|
||||
}
|
||||
|
||||
public class LapStorage {
|
||||
public string Map = "unset";
|
||||
public List<Lap> Laps = new();
|
||||
public int Completions = 0;
|
||||
public int Position = 0;
|
||||
}
|
||||
|
||||
static class LapStorageService {
|
||||
static string playerDataPath = Path.Combine(Application.persistentDataPath, "playerData.json");
|
||||
PlayerData player;
|
||||
|
||||
LapStorage lapStorage;
|
||||
|
||||
static LapStorageService() {
|
||||
try {
|
||||
string json = File.ReadAllText(playerDataPath);
|
||||
JsonUtility.FromJsonOverwrite(json, player);
|
||||
} catch {
|
||||
Debug.Log("No existing playerData.json");
|
||||
CreatePlayerData();
|
||||
}
|
||||
}
|
||||
|
||||
public static LapJSON GetPlayerLaps(string mapName) {
|
||||
// get
|
||||
return new Lap;
|
||||
}
|
||||
|
||||
// laps.count
|
||||
public static int NumberOfCompletions() { return 0; }
|
||||
|
||||
// finds your PB in all completions
|
||||
public static int Position() { return 1; }
|
||||
|
||||
public static void PersistLap(Lap lap) {
|
||||
Debug.Log(JsonUtility.ToJson(lap));
|
||||
}
|
||||
|
||||
PlayerData CreatePlayerData() {
|
||||
player = new PlayerData { Id = Guid.NewGuid() }
|
||||
File.WriteAllText(playerDataPath, JsonUtility.ToJson(data));
|
||||
return player;
|
||||
}
|
||||
|
||||
public static Lap PB(string mapName) {
|
||||
return lapsByMap[mapName].Laps
|
||||
.MinBy(l => l.TotalTime);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -131,7 +131,7 @@ static class LapStorageService {
|
||||
public static int NumberOfCompletions() { return 0; }
|
||||
|
||||
// finds your PB in all completions
|
||||
public static int Rank() { return 1; }
|
||||
public static int Position() { return 1; }
|
||||
|
||||
public static void PersistLap(Lap lap) {
|
||||
LapJSON lapJson = GetPlayerLaps(lap.Map);
|
||||
|
||||
Reference in new issue
Block a user