Skip to content
Snippets Groups Projects
Commit c2727815 authored by John Schihada's avatar John Schihada
Browse files

Refactoring

parent c4c72e06
Branches
No related tags found
No related merge requests found
...@@ -46,7 +46,7 @@ public string format(float t) ...@@ -46,7 +46,7 @@ public string format(float t)
public abstract int[] getDependentFactIds(); public abstract int[] getDependentFactIds();
public abstract GameObject instantiateRepresentation(GameObject prefab, Transform transform); public abstract GameObject instantiateDisplay(GameObject prefab, Transform transform);
public abstract override bool Equals(System.Object obj); public abstract override bool Equals(System.Object obj);
...@@ -163,7 +163,7 @@ public override int[] getDependentFactIds() { ...@@ -163,7 +163,7 @@ public override int[] getDependentFactIds() {
return null; return null;
} }
public override GameObject instantiateRepresentation(GameObject prefab, Transform transform) { public override GameObject instantiateDisplay(GameObject prefab, Transform transform) {
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform); var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(this.Id); obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(this.Id);
obj.GetComponent<FactWrapper>().fact = this; obj.GetComponent<FactWrapper>().fact = this;
...@@ -208,7 +208,7 @@ public LineFact(int i, int pid1, int pid2) ...@@ -208,7 +208,7 @@ public LineFact(int i, int pid1, int pid2)
//Label is currently set to Fact.setId //Label is currently set to Fact.setId
//Set Label to StringConcatenation of Points //Set Label to StringConcatenation of Points
this.Label = "|" + pf1.Label + pf2.Label + "|"; this.Label = pf1.Label + pf2.Label;
string p1URI = pf1.backendURI; string p1URI = pf1.backendURI;
string p2URI = pf2.backendURI; string p2URI = pf2.backendURI;
...@@ -269,7 +269,7 @@ public override int[] getDependentFactIds() ...@@ -269,7 +269,7 @@ public override int[] getDependentFactIds()
return new int[] { Pid1, Pid2 }; return new int[] { Pid1, Pid2 };
} }
public override GameObject instantiateRepresentation(GameObject prefab, Transform transform) public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{ {
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform); var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[this.Pid1].Id); obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[this.Pid1].Id);
...@@ -316,9 +316,6 @@ public RayFact(int i, int pid1, int pid2) ...@@ -316,9 +316,6 @@ public RayFact(int i, int pid1, int pid2)
string p1URI = pf1.backendURI; string p1URI = pf1.backendURI;
string p2URI = pf2.backendURI; string p2URI = pf2.backendURI;
//Set Label to StringConcatenation of Points
this.Label = pf1.Label + pf2.Label;
List<MMTTerm> arguments = new List<MMTTerm> List<MMTTerm> arguments = new List<MMTTerm>
{ {
new OMS(p1URI), new OMS(p1URI),
...@@ -380,7 +377,7 @@ public override int[] getDependentFactIds() ...@@ -380,7 +377,7 @@ public override int[] getDependentFactIds()
return new int[] { Pid1, Pid2 }; return new int[] { Pid1, Pid2 };
} }
public override GameObject instantiateRepresentation(GameObject prefab, Transform transform) { public override GameObject instantiateDisplay(GameObject prefab, Transform transform) {
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform); var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(this.Id); obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(this.Id);
//obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[f.Pid2].Id); //obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[f.Pid2].Id);
...@@ -425,7 +422,7 @@ public OnLineFact(int i, int pid, int rid) ...@@ -425,7 +422,7 @@ public OnLineFact(int i, int pid, int rid)
string rURI = rf.backendURI; string rURI = rf.backendURI;
//Set Label to StringConcatenation of Points //Set Label to StringConcatenation of Points
this.Label = pf.Label + " " + rf.Label; this.Label = pf.Label + " " + rf.Label;
List<MMTTerm> innerArguments = new List<MMTTerm> List<MMTTerm> innerArguments = new List<MMTTerm>
{ {
...@@ -486,7 +483,7 @@ public override int[] getDependentFactIds() ...@@ -486,7 +483,7 @@ public override int[] getDependentFactIds()
return new int[] { Pid, Rid }; return new int[] { Pid, Rid };
} }
public override GameObject instantiateRepresentation(GameObject prefab, Transform transform) public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{ {
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform); var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[this.Pid].Id); obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[this.Pid].Id);
...@@ -678,7 +675,7 @@ public override int[] getDependentFactIds() ...@@ -678,7 +675,7 @@ public override int[] getDependentFactIds()
return new int[] { Pid1, Pid2, Pid3 }; return new int[] { Pid1, Pid2, Pid3 };
} }
public override GameObject instantiateRepresentation(GameObject prefab, Transform transform) { public override GameObject instantiateDisplay(GameObject prefab, Transform transform) {
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform); var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[this.Pid1].Id); obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[this.Pid1].Id);
obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[this.Pid2].Id); obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[this.Pid2].Id);
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
public class DisplayFacts : MonoBehaviour public class DisplayFacts : MonoBehaviour
{ {
public Dictionary<Type, GameObject> prefabDictionary;
public Dictionary<string, GameObject> displayedFacts = new Dictionary<string, GameObject>(); public Dictionary<string, GameObject> displayedFacts = new Dictionary<string, GameObject>();
public GameObject prefab_Point; public GameObject prefab_Point;
...@@ -15,8 +17,6 @@ public class DisplayFacts : MonoBehaviour ...@@ -15,8 +17,6 @@ public class DisplayFacts : MonoBehaviour
public GameObject prefab_OnLine; public GameObject prefab_OnLine;
public GameObject prefab_Line; public GameObject prefab_Line;
public Dictionary<string, GameObject> prefabDictionary;
public int x_Start; public int x_Start;
public int y_Start; public int y_Start;
public int X_Pacece_Between_Items; public int X_Pacece_Between_Items;
...@@ -26,6 +26,14 @@ public class DisplayFacts : MonoBehaviour ...@@ -26,6 +26,14 @@ public class DisplayFacts : MonoBehaviour
//Start is called before the first frame update //Start is called before the first frame update
void Start() void Start()
{ {
prefabDictionary = new Dictionary<Type, GameObject>() {
{typeof(PointFact), prefab_Point},
{typeof(LineFact), prefab_Distance},
{typeof(RayFact), prefab_Line},
{typeof(AngleFact), prefab_Angle},
{typeof(OnLineFact), prefab_OnLine}
};
var rect = GetComponent<RectTransform>(); var rect = GetComponent<RectTransform>();
x_Start = (int)(rect.rect.x + X_Pacece_Between_Items * .5f); x_Start = (int)(rect.rect.x + X_Pacece_Between_Items * .5f);
y_Start = (int)(-rect.rect.y - y_Pacece_Between_Items * .5f);//); y_Start = (int)(-rect.rect.y - y_Pacece_Between_Items * .5f);//);
...@@ -33,14 +41,6 @@ void Start() ...@@ -33,14 +41,6 @@ void Start()
AddFactEvent.AddListener(AddFact); AddFactEvent.AddListener(AddFact);
AnimateExistingFactEvent.AddListener(AnimateFact); AnimateExistingFactEvent.AddListener(AnimateFact);
prefabDictionary = new Dictionary<string, GameObject>() {
{"PointFact", prefab_Point},
{"LineFact", prefab_Distance},
{"RayFact", prefab_Line},
{"AngleFact", prefab_Angle},
{"OnLineFact", prefab_OnLine}
};
} }
public void AddFact(Fact fact) { public void AddFact(Fact fact) {
...@@ -61,7 +61,7 @@ string getLetter(int Id) { ...@@ -61,7 +61,7 @@ string getLetter(int Id) {
private GameObject CreateDisplay(Transform transform, Fact fact) private GameObject CreateDisplay(Transform transform, Fact fact)
{ {
return fact.instantiateRepresentation(prefabDictionary[fact.GetType().Name], transform); return fact.instantiateDisplay(prefabDictionary[fact.GetType()], transform);
} }
public Vector3 GetPosition(int i) public Vector3 GetPosition(int i)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment