Skip to content
Snippets Groups Projects
Commit f50302c5 authored by Marco Zimmer's avatar Marco Zimmer
Browse files

BugFixes, Refactoring, +CommunicationEvents: added Verbose Setting for Debug.Log()

parent 759ed469
Branches
No related tags found
No related merge requests found
Showing
with 62 additions and 50 deletions
...@@ -109,7 +109,7 @@ GameObject: ...@@ -109,7 +109,7 @@ GameObject:
- component: {fileID: 7455726115425455088} - component: {fileID: 7455726115425455088}
- component: {fileID: 933372636075482527} - component: {fileID: 933372636075482527}
- component: {fileID: 539717056228735193} - component: {fileID: 539717056228735193}
m_Layer: 0 m_Layer: 16
m_Name: TopSnapZone m_Name: TopSnapZone
m_TagString: SnapZone m_TagString: SnapZone
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
......
...@@ -3544,6 +3544,7 @@ MonoBehaviour: ...@@ -3544,6 +3544,7 @@ MonoBehaviour:
ignoreLayerMask: ignoreLayerMask:
serializedVersion: 2 serializedVersion: 2
m_Bits: 96768 m_Bits: 96768
maxHeight: 2.5
Cursor: {fileID: 1324548121420804703} Cursor: {fileID: 1324548121420804703}
lineRenderer: {fileID: 492903072} lineRenderer: {fileID: 492903072}
linePreviewMaterial: {fileID: 2100000, guid: a8a7bf60a30970f469a9c9d3ae2de6ef, type: 2} linePreviewMaterial: {fileID: 2100000, guid: a8a7bf60a30970f469a9c9d3ae2de6ef, type: 2}
...@@ -59786,6 +59787,11 @@ PrefabInstance: ...@@ -59786,6 +59787,11 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y propertyPath: m_AnchoredPosition.y
value: 75 value: 75
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 798194300259120277, guid: b996060e27da25c498842defc1996d84,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 798194300310305303, guid: b996060e27da25c498842defc1996d84, - target: {fileID: 798194300310305303, guid: b996060e27da25c498842defc1996d84,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x
...@@ -75,7 +75,7 @@ void Update() ...@@ -75,7 +75,7 @@ void Update()
if(taskCharacterAddressed && !LelvelVerifiedSolved && checkGameSolved()) if(taskCharacterAddressed && !LelvelVerifiedSolved && checkGameSolved())
{ {
startHappy(); startHappy();
//LelvelVerifiedSolved = true; LelvelVerifiedSolved = true;
} }
return; return;
......
...@@ -51,9 +51,12 @@ public class AnimationEventWithUris : UnityEvent<List<string>> { } ...@@ -51,9 +51,12 @@ public class AnimationEventWithUris : UnityEvent<List<string>> { }
// Global Level-List of Facts // Global Level-List of Facts
public static FactOrganizer LevelFacts = new FactOrganizer(true); public static FactOrganizer LevelFacts = new FactOrganizer(true);
public static FactOrganizer SolutionManager = new FactOrganizer(false); public static FactOrganizer SolutionManager = new FactOrganizer(false);
//TODO? List<[HashSet<string>, FactComparer]> //TODO? [SolutionManager, List<[HashSet<string>, FactComparer]>]
public static List<Fact> Solution = new List<Fact>(); public static List<Fact> Solution = new List<Fact>();
public static bool ServerRunning = true; public static bool ServerRunning = true;
public static string ServerAdress = "localhost:8085"; public static string ServerAdress = "localhost:8085";
// Configs
public static bool VerboseURI = false;
} }
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
using static JSONManager; using static JSONManager;
using static CommunicationEvents; using static CommunicationEvents;
public class ParsingDictionary { public class ParsingDictionary {
public static Dictionary<string, Func<Scroll.ScrollFact, Fact>> parseFactDictionary = new Dictionary<string, Func<Scroll.ScrollFact, Fact>>() { public static Dictionary<string, Func<Scroll.ScrollFact, Fact>> parseFactDictionary = new Dictionary<string, Func<Scroll.ScrollFact, Fact>>() {
...@@ -27,14 +28,24 @@ public class AddFactResponse ...@@ -27,14 +28,24 @@ public class AddFactResponse
// public string factValUri; // public string factValUri;
public string uri; public string uri;
public static AddFactResponse sendAdd(string path, string body) public static bool sendAdd(MMTDeclaration mmtDecl, out string uri)
{
string body = MMTSymbolDeclaration.ToJson(mmtDecl);
return sendAdd(CommunicationEvents.ServerAdress + "/fact/add", body, out uri);
}
public static bool sendAdd(string path, string body, out string uri)
{ {
if (!CommunicationEvents.ServerRunning) if (!CommunicationEvents.ServerRunning)
{ {
Debug.LogWarning("Server not running"); Debug.LogWarning("Server not running");
return new AddFactResponse(); uri = null;
return false;
} }
Debug.Log(body);
if(VerboseURI)
Debug.Log("Sending to Server:\n" + body);
//Put constructor parses stringbody to byteArray internally (goofy workaround) //Put constructor parses stringbody to byteArray internally (goofy workaround)
UnityWebRequest www = UnityWebRequest.Put(path, body); UnityWebRequest www = UnityWebRequest.Put(path, body);
www.method = UnityWebRequest.kHttpVerbPOST; www.method = UnityWebRequest.kHttpVerbPOST;
...@@ -49,12 +60,19 @@ public static AddFactResponse sendAdd(string path, string body) ...@@ -49,12 +60,19 @@ public static AddFactResponse sendAdd(string path, string body)
|| www.result == UnityWebRequest.Result.ProtocolError) || www.result == UnityWebRequest.Result.ProtocolError)
{ {
Debug.LogWarning(www.error); Debug.LogWarning(www.error);
return new AddFactResponse(); uri = null;
return false;
} }
else else
{ {
string answer = www.downloadHandler.text; string answer = www.downloadHandler.text;
return JsonUtility.FromJson<AddFactResponse>(answer); AddFactResponse res = JsonUtility.FromJson<AddFactResponse>(answer);
if (VerboseURI)
Debug.Log("Server added Fact:\n" + res.uri);
uri = res.uri;
return true;
} }
} }
} }
...@@ -92,6 +110,8 @@ public void rename(string newLabel) ...@@ -92,6 +110,8 @@ public void rename(string newLabel)
public virtual void delete() public virtual void delete()
{ {
//TODO: MMT: delete over there //TODO: MMT: delete over there
if (VerboseURI)
Debug.Log("Server removed Fact:\n" + this.URI);
} }
public abstract bool Equivalent(Fact f2); public abstract bool Equivalent(Fact f2);
...@@ -102,6 +122,7 @@ public virtual void delete() ...@@ -102,6 +122,7 @@ public virtual void delete()
protected abstract string generateLabel(); protected abstract string generateLabel();
// TODO: "ID"/ Letter Management
protected string generateLetter() protected string generateLetter()
{ {
return ((char)(64 + LabelId++ + 1)).ToString(); return ((char)(64 + LabelId++ + 1)).ToString();
...@@ -231,11 +252,7 @@ public PointFact(Vector3 P, Vector3 N, FactOrganizer organizer) : base(organizer ...@@ -231,11 +252,7 @@ public PointFact(Vector3 P, Vector3 N, FactOrganizer organizer) : base(organizer
//TODO: rework fact list + labeling //TODO: rework fact list + labeling
MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df); MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);
string body = MMTSymbolDeclaration.ToJson(mmtDecl); AddFactResponse.sendAdd(mmtDecl, out this._URI);
AddFactResponse res = AddFactResponse.sendAdd(CommunicationEvents.ServerAdress+"/fact/add", body);
this._URI = res.uri;
Debug.Log(this.URI);
} }
public PointFact(float a, float b, float c, string uri, FactOrganizer organizer) : base(organizer) public PointFact(float a, float b, float c, string uri, FactOrganizer organizer) : base(organizer)
...@@ -327,10 +344,7 @@ public LineFact(string pid1, string pid2, FactOrganizer organizer) : base(pid1, ...@@ -327,10 +344,7 @@ public LineFact(string pid1, string pid2, FactOrganizer organizer) : base(pid1,
//see point label //see point label
MMTValueDeclaration mmtDecl = new MMTValueDeclaration(this.Label, lhs, valueTp, value); MMTValueDeclaration mmtDecl = new MMTValueDeclaration(this.Label, lhs, valueTp, value);
string body = MMTDeclaration.ToJson(mmtDecl); AddFactResponse.sendAdd(mmtDecl, out this._URI);
AddFactResponse res = AddFactResponse.sendAdd(CommunicationEvents.ServerAdress + "/fact/add", body);
this._URI = res.uri;
Debug.Log(this.URI);
} }
public static LineFact parseFact(Scroll.ScrollFact fact) public static LineFact parseFact(Scroll.ScrollFact fact)
...@@ -407,11 +421,7 @@ public RayFact(string pid1, string pid2, FactOrganizer organizer) : base(pid1, p ...@@ -407,11 +421,7 @@ public RayFact(string pid1, string pid2, FactOrganizer organizer) : base(pid1, p
//TODO: rework fact list + labeling //TODO: rework fact list + labeling
MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df); MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);
string body = MMTSymbolDeclaration.ToJson(mmtDecl); AddFactResponse.sendAdd(mmtDecl, out this._URI);
AddFactResponse res = AddFactResponse.sendAdd(CommunicationEvents.ServerAdress + "/fact/add", body);
this._URI = res.uri;
Debug.Log(this.URI);
} }
public static RayFact parseFact(Scroll.ScrollFact fact) public static RayFact parseFact(Scroll.ScrollFact fact)
...@@ -491,11 +501,7 @@ public OnLineFact(string pid, string rid, FactOrganizer organizer) : base(organi ...@@ -491,11 +501,7 @@ public OnLineFact(string pid, string rid, FactOrganizer organizer) : base(organi
//TODO: rework fact list + labeling //TODO: rework fact list + labeling
MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df); MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);
string body = MMTSymbolDeclaration.ToJson(mmtDecl); AddFactResponse.sendAdd(mmtDecl, out this._URI);
AddFactResponse res = AddFactResponse.sendAdd(CommunicationEvents.ServerAdress + "/fact/add", body);
this._URI = res.uri;
Debug.Log(this.URI);
} }
public OnLineFact(string pid, string rid, string uri, FactOrganizer organizer) : base(organizer) public OnLineFact(string pid, string rid, string uri, FactOrganizer organizer) : base(organizer)
...@@ -591,14 +597,7 @@ public AngleFact(string pid1, string pid2, string pid3, FactOrganizer organizer) ...@@ -591,14 +597,7 @@ public AngleFact(string pid1, string pid2, string pid3, FactOrganizer organizer)
else else
mmtDecl = generateNot90DegreeAngleDeclaration(v, p1URI, p2URI, p3URI); mmtDecl = generateNot90DegreeAngleDeclaration(v, p1URI, p2URI, p3URI);
Debug.Log("angle: " + v); AddFactResponse.sendAdd(mmtDecl, out this._URI);
string body = MMTDeclaration.ToJson(mmtDecl);
Debug.Log(body);
AddFactResponse res = AddFactResponse.sendAdd(CommunicationEvents.ServerAdress+"/fact/add", body);
this._URI = res.uri;
Debug.Log(this.URI);
} }
public AngleFact(string Pid1, string Pid2, string Pid3, string backendURI, FactOrganizer organizer) : base(organizer) public AngleFact(string Pid1, string Pid2, string Pid3, string backendURI, FactOrganizer organizer) : base(organizer)
......
...@@ -44,7 +44,7 @@ protected override bool Compare (Fact search, Fact fact) ...@@ -44,7 +44,7 @@ protected override bool Compare (Fact search, Fact fact)
{ {
return fact is LineFact && search is LineFact return fact is LineFact && search is LineFact
&& Math3d.IsApproximatelyParallel(((LineFact) fact).Dir, ((LineFact) search).Dir) && Math3d.IsApproximatelyParallel(((LineFact) fact).Dir, ((LineFact) search).Dir)
&& ((LineFact) fact).Distance > ((LineFact) search).Distance + Math3d.vectorPrecission; && ((LineFact) fact).Distance + Math3d.vectorPrecission >= ((LineFact) search).Distance;
// && Mathf.Approximately(((LineFact) x).Distance, ((LineFact) y).Distance); // && Mathf.Approximately(((LineFact) x).Distance, ((LineFact) y).Distance);
} }
} }
...@@ -133,10 +133,10 @@ private void WorkflowAdd(stepnote note) ...@@ -133,10 +133,10 @@ private void WorkflowAdd(stepnote note)
private void PruneWorkflow() private void PruneWorkflow()
// set current (displayed) state in stone; resets un-redo parameters // set current (displayed) state in stone; resets un-redo parameters
{ {
if (soft_resetted) /*if (soft_resetted)
this.hardreset(false); this.hardreset(false); // musn't clear
else if (backlog > 0) else*/ if (backlog > 0)
{ {
worksteps -= backlog; worksteps -= backlog;
backlog = 0; backlog = 0;
...@@ -424,10 +424,10 @@ private void InvokeFactEvent(bool creation, string Id) ...@@ -424,10 +424,10 @@ private void InvokeFactEvent(bool creation, string Id)
CommunicationEvents.RemoveFactEvent.Invoke(this[Id]); CommunicationEvents.RemoveFactEvent.Invoke(this[Id]);
} }
public bool StaticlySovled(List<Fact> StaticSolution, out List<Fact> MissingElements) public bool StaticlySovled(List<Fact> StaticSolution, out List<Fact> MissingElements, out List<Fact> Solutions)
// QoL for simple Levels // QoL for simple Levels
{ {
return DynamiclySolved(StaticSolution, out MissingElements, out _, new FactEquivalentsComparer()); return DynamiclySolved(StaticSolution, out MissingElements, out Solutions, new FactEquivalentsComparer());
} }
//TODO: PERF: see CommunicationEvents.Solution //TODO: PERF: see CommunicationEvents.Solution
......
...@@ -122,7 +122,7 @@ public Fact SpawnRay(Fact fact) ...@@ -122,7 +122,7 @@ public Fact SpawnRay(Fact fact)
//Get the Line-GameObject as the first Child of the Line-Prefab -> That's the Collider //Get the Line-GameObject as the first Child of the Line-Prefab -> That's the Collider
var v3T = line.transform.GetChild(0).localScale; var v3T = line.transform.GetChild(0).localScale;
v3T.x = (point2 - point1).magnitude; v3T.x = (point2 - point1).magnitude;
Debug.Log(v3T.x);
//For every Coordinate x,y,z we have to devide it by the LocalScale of the Child, //For every Coordinate x,y,z we have to devide it by the LocalScale of the Child,
//because actually the Child should be of this length and not the parent, which is only the Collider //because actually the Child should be of this length and not the parent, which is only the Collider
v3T.x = v3T.x / line.transform.GetChild(0).GetChild(0).localScale.x; v3T.x = v3T.x / line.transform.GetChild(0).GetChild(0).localScale.x;
...@@ -197,7 +197,6 @@ public Fact SpawnAngle(Fact fact) ...@@ -197,7 +197,6 @@ public Fact SpawnAngle(Fact fact)
public void DeleteObject(Fact fact) public void DeleteObject(Fact fact)
{ {
Debug.Log("delete obj of "+ fact.URI);
GameObject factRepresentation = fact.Representation; GameObject factRepresentation = fact.Representation;
GameObject.Destroy(factRepresentation); GameObject.Destroy(factRepresentation);
} }
......
...@@ -13,7 +13,6 @@ void Start() ...@@ -13,7 +13,6 @@ void Start()
CommunicationEvents.ToolModeChangedEvent.AddListener(OnToolModeChanged); CommunicationEvents.ToolModeChangedEvent.AddListener(OnToolModeChanged);
gadgets = GetComponentsInChildren<Gadget>(); gadgets = GetComponentsInChildren<Gadget>();
Debug.Log(gadgets.Length);
for (int i = 0; i < gadgets.Length; i++) for (int i = 0; i < gadgets.Length; i++)
{ {
gadgets[i].id = i; gadgets[i].id = i;
......
...@@ -276,7 +276,7 @@ public void CheckPushoutHighlighting() { ...@@ -276,7 +276,7 @@ public void CheckPushoutHighlighting() {
StopHighlighting(); StopHighlighting();
} }
//After this.timerDuration: Slow Down Fireworks //After this.timerDuration: Slow Down Fireworks
else else if (this.extraHighlight != null)
{ {
ParticleSystem main1 = this.extraHighlight.transform.GetChild(0).GetComponent<ParticleSystem>(); ParticleSystem main1 = this.extraHighlight.transform.GetChild(0).GetComponent<ParticleSystem>();
ParticleSystem main2 = this.extraHighlight.transform.GetChild(1).GetComponent<ParticleSystem>(); ParticleSystem main2 = this.extraHighlight.transform.GetChild(1).GetComponent<ParticleSystem>();
......
...@@ -15,6 +15,7 @@ public class Level : MonoBehaviour ...@@ -15,6 +15,7 @@ public class Level : MonoBehaviour
void Start() void Start()
// Start is called before the first frame update // Start is called before the first frame update
{ {
// TODO: do not generate! -> load from somewhere
PointFact PointFact
buttom = new PointFact(Vector3.zero, Vector3.up, SolutionManager), buttom = new PointFact(Vector3.zero, Vector3.up, SolutionManager),
top = new PointFact(Vector3.zero + Vector3.up * minimalSolutionHight, Vector3.up, SolutionManager); top = new PointFact(Vector3.zero + Vector3.up * minimalSolutionHight, Vector3.up, SolutionManager);
......
...@@ -6,8 +6,13 @@ public class Restart : MonoBehaviour ...@@ -6,8 +6,13 @@ public class Restart : MonoBehaviour
public void LevelReset() public void LevelReset()
{ {
CommunicationEvents.LevelReset.Invoke(); // currently unused CommunicationEvents.LevelReset.Invoke(); // currently unused
Level.solved = false; // needed? Level.solved = false; // needed since static
CommunicationEvents.LevelFacts.hardreset(false); // delete Facts at Server
// delete Facts at Server
CommunicationEvents.LevelFacts.hardreset(false);
// only when generated! (in Level.cs)
CommunicationEvents.SolutionManager.hardreset(false);
SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex); SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex);
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"com.unity.analytics": "3.5.3", "com.unity.analytics": "3.5.3",
"com.unity.collab-proxy": "1.7.1", "com.unity.collab-proxy": "1.7.1",
"com.unity.ide.rider": "2.0.7", "com.unity.ide.rider": "2.0.7",
"com.unity.ide.visualstudio": "2.0.9", "com.unity.ide.visualstudio": "2.0.11",
"com.unity.ide.vscode": "1.2.3", "com.unity.ide.vscode": "1.2.3",
"com.unity.multiplayer-hlapi": "1.0.8", "com.unity.multiplayer-hlapi": "1.0.8",
"com.unity.nuget.newtonsoft-json": "2.0.0", "com.unity.nuget.newtonsoft-json": "2.0.0",
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
"url": "https://packages.unity.com" "url": "https://packages.unity.com"
}, },
"com.unity.ide.visualstudio": { "com.unity.ide.visualstudio": {
"version": "2.0.9", "version": "2.0.11",
"depth": 0, "depth": 0,
"source": "registry", "source": "registry",
"dependencies": { "dependencies": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment