diff --git a/Assets/Scripts/InteractionEngine/Fact.cs b/Assets/Scripts/InteractionEngine/Fact.cs index 13e47deead6f7ed1d32281ccb6373be8f7007b73..20e1dfdc71485330c4f279f5daf2446d34957d57 100644 --- a/Assets/Scripts/InteractionEngine/Fact.cs +++ b/Assets/Scripts/InteractionEngine/Fact.cs @@ -46,7 +46,7 @@ public string format(float t) 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); @@ -163,7 +163,7 @@ public override int[] getDependentFactIds() { 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); obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(this.Id); obj.GetComponent<FactWrapper>().fact = this; @@ -208,7 +208,7 @@ public LineFact(int i, int pid1, int pid2) //Label is currently set to Fact.setId //Set Label to StringConcatenation of Points - this.Label = "|" + pf1.Label + pf2.Label + "|"; + this.Label = pf1.Label + pf2.Label; string p1URI = pf1.backendURI; string p2URI = pf2.backendURI; @@ -269,7 +269,7 @@ public override int[] getDependentFactIds() 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); 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) string p1URI = pf1.backendURI; string p2URI = pf2.backendURI; - //Set Label to StringConcatenation of Points - this.Label = pf1.Label + pf2.Label; - List<MMTTerm> arguments = new List<MMTTerm> { new OMS(p1URI), @@ -380,7 +377,7 @@ public override int[] getDependentFactIds() 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); 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); @@ -425,7 +422,7 @@ public OnLineFact(int i, int pid, int rid) string rURI = rf.backendURI; //Set Label to StringConcatenation of Points - this.Label = pf.Label + " ∊ " + rf.Label; + this.Label = pf.Label + " ∈ " + rf.Label; List<MMTTerm> innerArguments = new List<MMTTerm> { @@ -486,7 +483,7 @@ public override int[] getDependentFactIds() 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); obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[this.Pid].Id); @@ -678,7 +675,7 @@ public override int[] getDependentFactIds() 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); 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); diff --git a/Assets/Scripts/InventoryStuff/DisplayFacts.cs b/Assets/Scripts/InventoryStuff/DisplayFacts.cs index 3fbc3814b13eddb14aef7b3a7bca93e98e4d5807..68c35a2b161b8da8126f006b8ee45a018d77e90d 100644 --- a/Assets/Scripts/InventoryStuff/DisplayFacts.cs +++ b/Assets/Scripts/InventoryStuff/DisplayFacts.cs @@ -6,6 +6,8 @@ public class DisplayFacts : MonoBehaviour { + public Dictionary<Type, GameObject> prefabDictionary; + public Dictionary<string, GameObject> displayedFacts = new Dictionary<string, GameObject>(); public GameObject prefab_Point; @@ -15,8 +17,6 @@ public class DisplayFacts : MonoBehaviour public GameObject prefab_OnLine; public GameObject prefab_Line; - public Dictionary<string, GameObject> prefabDictionary; - public int x_Start; public int y_Start; public int X_Pacece_Between_Items; @@ -26,6 +26,14 @@ public class DisplayFacts : MonoBehaviour //Start is called before the first frame update 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>(); x_Start = (int)(rect.rect.x + X_Pacece_Between_Items * .5f); y_Start = (int)(-rect.rect.y - y_Pacece_Between_Items * .5f);//); @@ -33,14 +41,6 @@ void Start() AddFactEvent.AddListener(AddFact); 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) { @@ -61,7 +61,7 @@ string getLetter(int Id) { 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)