Skip to content
Snippets Groups Projects
Commit 1dab4fb6 authored by MaZiFAU's avatar MaZiFAU
Browse files

Fixed Merge; Squashed Bugs;

Please use estqblished code(conventions)
parent 3ebf8bca
Branches
No related tags found
No related merge requests found
......@@ -167,9 +167,6 @@ public static bool sendAdd(string path, string body, out string uri)
[JsonSubtypes.KnownSubType(typeof(TestFact), "TestFact")]
[JsonSubtypes.KnownSubType(typeof(EqualCirclesFact), "EqualCirclesFact")]
[JsonSubtypes.KnownSubType(typeof(UnEqualCirclesFact), "UnEqualCirclesFact")]
public abstract class Fact
{
/// <summary>
......@@ -1411,13 +1408,224 @@ protected override bool EquivalentWrapped(AngleFact f1, AngleFact f2)
}
}
/// <summary>
/// A RightAngleFact defined by 3 <see cref="PointFact">Pointfact</see>
/// </summary>
public class RightAngleFact : FactWrappedCRTP<RightAngleFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "RightAngleFact";
/// <summary> three <see cref="PointFact">Pointfacts</see> defining the right angle </summary>
public string Pid1, Pid2, Pid3;
/// <summary> \copydoc Fact.Fact </summary>
public RightAngleFact() : base()
{
this.Pid1 = null;
this.Pid2 = null;
this.Pid3 = null;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public RightAngleFact(RightAngleFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Pid1], old_to_new[fact.Pid2], old_to_new[fact.Pid3]);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="pid1">sets <see cref="Pid1"/></param>
/// <param name="pid2">sets <see cref="Pid2"/></param>
/// <param name="pid3">sets <see cref="Pid3"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public RightAngleFact(string pid1, string pid2, string pid3, FactOrganizer organizer) : base(organizer)
{
init(pid1, pid2, pid3);
}
/// <summary>
/// Initiates <see cref="Pid1"/>, <see cref="Pid2"/>, <see cref="Pid3"/>, <see cref="is_right_angle"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
/// </summary>
/// <param name="pid1">sets <see cref="Pid1"/></param>
/// <param name="pid2">sets <see cref="Pid2"/></param>
/// <param name="pid3">sets <see cref="Pid3"/></param>
private void init(string pid1, string pid2, string pid3)
{
this.Pid1 = pid1;
this.Pid2 = pid2;
this.Pid3 = pid3;
PointFact pf1 = _Facts[pid1] as PointFact;
PointFact pf2 = _Facts[pid2] as PointFact;
PointFact pf3 = _Facts[pid3] as PointFact;
MMTDeclaration mmtDecl;
string p1URI = pf1.Id;
string p2URI = pf2.Id;
string p3URI = pf3.Id;
mmtDecl = generateMMTDeclaration(p1URI, p2URI, p3URI);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="Pid1">sets <see cref="Pid1"/></param>
/// <param name="Pid2">sets <see cref="Pid2"/></param>
/// <param name="Pid3">sets <see cref="Pid3"/></param>
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public RightAngleFact(string Pid1, string Pid2, string Pid3, string backendURI, FactOrganizer organizer) : base(organizer)
{
this.Pid1 = Pid1;
this.Pid2 = Pid2;
this.Pid3 = Pid3;
this._URI = backendURI;
_ = this.Label;
}
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static RightAngleFact parseFact(Scroll.ScrollFact fact)
{
OMA tp = (OMA)((Scroll.ScrollSymbolFact)fact).tp;
if (tp == null)
return null;
string Point1Uri = "";
string Point2Uri = "";
string Point3Uri = "";
string uri = fact.@ref.uri;
OMA proof_OMA = (OMA)((Scroll.ScrollSymbolFact)fact).tp; // proof DED
OMA rightAngleOMA = (OMA)proof_OMA.arguments[0]; // rightAngle OMA
if (rightAngleOMA.arguments[0] is OMS)
{
Point1Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri;
Point2Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri;
Point3Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[2]).uri;
}
if (StageStatic.stage.factState.ContainsKey(Point1Uri)
&& StageStatic.stage.factState.ContainsKey(Point2Uri)
&& StageStatic.stage.factState.ContainsKey(Point3Uri))
return new RightAngleFact(Point1Uri, Point2Uri, Point3Uri, uri, StageStatic.stage.factState);
else //If dependent facts do not exist return null
return null;
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return _Facts[Pid1].Label + _Facts[Pid2].Label + _Facts[Pid3].Label + "⊥";
}
/// <summary>
/// Constructs struct for not-right-angled MMT %Fact <see cref="AddFactResponse"/>
/// </summary>
/// <param name="p1URI"> Uri for <see cref="Pid1"/></param>
/// <param name="p2URI"> Uri for <see cref="Pid2"/></param>
/// <param name="p3URI"> Uri for <see cref="Pid3"/></param>
/// <returns>struct for <see cref="AddFactResponse"/></returns>
private MMTDeclaration generateMMTDeclaration(string p1URI, string p2URI, string p3URI)
{
List<MMTTerm> innerArguments = new List<MMTTerm>
{
new OMS(p1URI),
new OMS(p2URI),
new OMS(p3URI)
};
List<MMTTerm> outerArguments = new List<MMTTerm>
{
new OMA(new OMS(MMTURIs.RightAngle), innerArguments)
};
MMTTerm tp = new OMA(new OMS(MMTURIs.Ded), outerArguments);
MMTTerm df = null;
return new MMTSymbolDeclaration(this.Label, tp, df);
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
{
return new string[] { Pid1, Pid2, Pid3 };
}
/// \copydoc Fact.instantiateDisplay(GameObject, 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 = _Facts[this.Pid1].Label;
obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Pid2].Label;
obj.transform.GetChild(2).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Pid3].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
/// uhhh is this a problem?
public override int GetHashCode()
{
return this.Pid1.GetHashCode() ^ this.Pid2.GetHashCode() ^ this.Pid3.GetHashCode();
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(RightAngleFact f1, RightAngleFact f2)
{
if (f1.Pid1 == f2.Pid1 && f1.Pid2 == f2.Pid2 && f1.Pid3 == f2.Pid3)
return true;
PointFact p1f1 = (PointFact)_Facts[f1.Pid1];
PointFact p2f1 = (PointFact)_Facts[f1.Pid2];
PointFact p3f1 = (PointFact)_Facts[f1.Pid3];
PointFact p1f2 = (PointFact)_Facts[f2.Pid1];
PointFact p2f2 = (PointFact)_Facts[f2.Pid2];
PointFact p3f2 = (PointFact)_Facts[f2.Pid3];
return (p1f1.Equivalent(p1f2) && p2f1.Equivalent(p2f2) && p3f1.Equivalent(p3f2));
}
}
/// <summary>
/// Two parallel Lines comprised of two <see cref="LineFact">LineFacts</see>
/// </summary>
public class ParallelLineFact : FactWrappedCRTP<ParallelLineFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "ParallelLineFact";
/// @{ <summary>
/// One <see cref="Fact.Id">Id</see> of thwo <see cref="LineFact">PointFacts</see> defining Angle [<see cref="Lid1"/>, <see cref="Lid2"/>].
/// </summary>
......@@ -1619,17 +1827,14 @@ protected override bool EquivalentWrapped(ParallelLineFact f1, ParallelLineFact
}
}
/// <summary>
/// A Circle that is made out of a middle point, a plane and a radius
/// </summary>
public class CircleFact : FactWrappedCRTP<CircleFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "CircleFact";
/// <summary> defining the middle point of the circle </summary>
public string Pid1;
......@@ -1922,12 +2127,15 @@ protected override bool EquivalentWrapped(CircleFact f1, CircleFact f2)
}
}
/// <summary>
/// A <see cref="PointFact"/> on a <see cref="CircleFact"/>
/// </summary>
public class OnCircleFact : FactWrappedCRTP<OnCircleFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "OnCircleFact";
/// <summary> the point on the circle </summary>
public string Pid;
/// <summary> the circle, which the point is on </summary>
......@@ -2082,13 +2290,15 @@ protected override bool EquivalentWrapped(OnCircleFact c1, OnCircleFact c2)
}
}
/// <summary>
/// Angle comprised of a line and a circle
/// </summary>
public class AngleCircleLineFact : FactWrappedCRTP<AngleCircleLineFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "AngleCircleLineFact";
/// @{ <summary>
/// One <see cref="Fact.Id">Id</see> of a <see cref="RayFact">RayFact</see> and a <see cref="CircleFact">CircleFact</see> defining Angle [<see cref="Cid1"/>, <see cref="Rid2"/>].
/// </summary>
......@@ -2279,12 +2489,15 @@ protected override bool EquivalentWrapped(AngleCircleLineFact f1, AngleCircleLin
}
}
/// <summary>
/// A RadiusFact that corresponds to a <see cref="CircleFact">PointFacts</see> and has a float value (the actual radius).
/// </summary>
public class RadiusFact : FactWrappedCRTP<RadiusFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "RadiusFact";
/// <summary> The circle corresponding to the radius </summary>
public string Cid1;
/// <summary> The radius as a float </summary>
......@@ -2439,12 +2652,15 @@ protected override bool EquivalentWrapped(RadiusFact f1, RadiusFact f2)
}
}
/// <summary>
/// Area of a <see cref="CircleFact">CircleFact</see>
/// </summary>
public class AreaCircleFact : FactWrappedCRTP<AreaCircleFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "AreaCircleFact";
/// <summary> the circle <see cref="CircleFact">CircleFact</see> </summary>
public string Cid1;
/// <summary> the area which is contained by the circle </summary>
......@@ -2598,12 +2814,15 @@ protected override bool EquivalentWrapped(AreaCircleFact f1, AreaCircleFact f2)
}
}
/// <summary>
/// The volume of a cone A defined by a base area <see cref="CircleFact">CircleFact</see>, an apex <see cref="PointFact">PointFact</see> and the volume as float
/// </summary>
public class ConeVolumeFact : FactWrappedCRTP<ConeVolumeFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "ConeVolumeFact";
/// <summary> a <see cref="CircleFact">CircleFact</see> describing the base area </summary>
public string Cid1;
/// <summary> a <see cref="PointFact">PointFact</see> describing the apex point </summary>
......@@ -2790,12 +3009,15 @@ protected override bool EquivalentWrapped(ConeVolumeFact f1, ConeVolumeFact f2)
}
}
/// <summary>
/// The fact that the plane of a <see cref="CircleFact">CircleFact</see> and the line <see cref="RayFact>RayFact</see> are orthogonal
/// </summary>
public class OrthogonalCircleLineFact : FactWrappedCRTP<OrthogonalCircleLineFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "OrthogonalCircleLineFact";
/// <summary> a <see cref="CircleFact">CircleFact</see> describing the base area </summary>
public string Cid1;
/// <summary> a <see cref="RayFact">Rayfact</see> describing the line </summary>
......@@ -2975,6 +3197,10 @@ protected override bool EquivalentWrapped(OrthogonalCircleLineFact f1, Orthogona
/// </summary>
public class TruncatedConeVolumeFact : FactWrappedCRTP<TruncatedConeVolumeFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "TruncatedConeVolumeFact";
/// <summary> a <see cref="CircleFact">CircleFact</see> describing the base area </summary>
public string Cid1;
/// <summary> a <see cref="CircleFact">CircleFact</see> describing the top area </summary>
......@@ -3174,222 +3400,15 @@ protected override bool EquivalentWrapped(TruncatedConeVolumeFact f1, TruncatedC
}
}
/// <summary>
/// A RightAngleFact defined by 3 <see cref="PointFact">Pointfact</see>
/// </summary>
public class RightAngleFact : FactWrappedCRTP<RightAngleFact>
{
/// <summary> three <see cref="PointFact">Pointfacts</see> defining the right angle </summary>
public string Pid1, Pid2, Pid3;
/// <summary> \copydoc Fact.Fact </summary>
public RightAngleFact() : base()
{
this.Pid1 = null;
this.Pid2 = null;
this.Pid3 = null;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public RightAngleFact(RightAngleFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Pid1], old_to_new[fact.Pid2],old_to_new[fact.Pid3]);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="pid1">sets <see cref="Pid1"/></param>
/// <param name="pid2">sets <see cref="Pid2"/></param>
/// <param name="pid3">sets <see cref="Pid3"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public RightAngleFact(string pid1, string pid2, string pid3, FactOrganizer organizer) : base(organizer)
{
init(pid1, pid2, pid3);
}
/// <summary>
/// Initiates <see cref="Pid1"/>, <see cref="Pid2"/>, <see cref="Pid3"/>, <see cref="is_right_angle"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
/// </summary>
/// <param name="pid1">sets <see cref="Pid1"/></param>
/// <param name="pid2">sets <see cref="Pid2"/></param>
/// <param name="pid3">sets <see cref="Pid3"/></param>
private void init(string pid1, string pid2, string pid3)
{
this.Pid1 = pid1;
this.Pid2 = pid2;
this.Pid3 = pid3;
PointFact pf1 = _Facts[pid1] as PointFact;
PointFact pf2 = _Facts[pid2] as PointFact;
PointFact pf3 = _Facts[pid3] as PointFact;
MMTDeclaration mmtDecl;
string p1URI = pf1.Id;
string p2URI = pf2.Id;
string p3URI = pf3.Id;
mmtDecl = generateMMTDeclaration(p1URI, p2URI, p3URI);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="Pid1">sets <see cref="Pid1"/></param>
/// <param name="Pid2">sets <see cref="Pid2"/></param>
/// <param name="Pid3">sets <see cref="Pid3"/></param>
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public RightAngleFact(string Pid1, string Pid2, string Pid3, string backendURI, FactOrganizer organizer) : base(organizer)
{
this.Pid1 = Pid1;
this.Pid2 = Pid2;
this.Pid3 = Pid3;
this._URI = backendURI;
_ = this.Label;
}
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static RightAngleFact parseFact(Scroll.ScrollFact fact)
{
OMA tp = (OMA)((Scroll.ScrollSymbolFact)fact).tp;
if (tp == null)
return null;
string Point1Uri = "";
string Point2Uri = "";
string Point3Uri = "";
string uri = fact.@ref.uri;
OMA proof_OMA = (OMA)((Scroll.ScrollSymbolFact)fact).tp; // proof DED
OMA rightAngleOMA = (OMA)proof_OMA.arguments[0]; // rightAngle OMA
if (rightAngleOMA.arguments[0] is OMS)
{
Point1Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri;
Point2Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri;
Point3Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[2]).uri;
}
if (StageStatic.stage.factState.ContainsKey(Point1Uri)
&& StageStatic.stage.factState.ContainsKey(Point2Uri)
&& StageStatic.stage.factState.ContainsKey(Point3Uri))
return new RightAngleFact(Point1Uri, Point2Uri, Point3Uri, uri, StageStatic.stage.factState);
else //If dependent facts do not exist return null
return null;
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return _Facts[Pid1].Label + _Facts[Pid2].Label + _Facts[Pid3].Label + "⊥";
}
/// <summary>
/// Constructs struct for not-right-angled MMT %Fact <see cref="AddFactResponse"/>
/// </summary>
/// <param name="p1URI"> Uri for <see cref="Pid1"/></param>
/// <param name="p2URI"> Uri for <see cref="Pid2"/></param>
/// <param name="p3URI"> Uri for <see cref="Pid3"/></param>
/// <returns>struct for <see cref="AddFactResponse"/></returns>
private MMTDeclaration generateMMTDeclaration(string p1URI, string p2URI, string p3URI)
{
List<MMTTerm> innerArguments = new List<MMTTerm>
{
new OMS(p1URI),
new OMS(p2URI),
new OMS(p3URI)
};
List<MMTTerm> outerArguments = new List<MMTTerm>
{
new OMA(new OMS(MMTURIs.RightAngle), innerArguments)
};
MMTTerm tp = new OMA(new OMS(MMTURIs.Ded), outerArguments);
MMTTerm df = null;
return new MMTSymbolDeclaration(this.Label, tp, df);
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
{
return new string[] { Pid1, Pid2, Pid3 };
}
/// \copydoc Fact.instantiateDisplay(GameObject, 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 = _Facts[this.Pid1].Label;
obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Pid2].Label;
obj.transform.GetChild(2).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Pid3].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
/// uhhh is this a problem?
public override int GetHashCode()
{
return this.Pid1.GetHashCode() ^ this.Pid2.GetHashCode() ^ this.Pid3.GetHashCode();
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(RightAngleFact f1, RightAngleFact f2)
{
if (f1.Pid1 == f2.Pid1 && f1.Pid2 == f2.Pid2 && f1.Pid3 == f2.Pid3)
return true;
PointFact p1f1 = (PointFact)_Facts[f1.Pid1];
PointFact p2f1 = (PointFact)_Facts[f1.Pid2];
PointFact p3f1 = (PointFact)_Facts[f1.Pid3];
PointFact p1f2 = (PointFact)_Facts[f2.Pid1];
PointFact p2f2 = (PointFact)_Facts[f2.Pid2];
PointFact p3f2 = (PointFact)_Facts[f2.Pid3];
return (p1f1.Equivalent(p1f2) && p2f1.Equivalent(p2f2) && p3f1.Equivalent(p3f2) );
}
}
/// <summary>
/// The volume of a cylinder defined by a base area <see cref="CircleFact">CircleFact</see>, a top area <see cref="CircleFact">CircleFact</see> and the volume as float
/// </summary>
public class CylinderVolumeFact : FactWrappedCRTP<CylinderVolumeFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "CylinderVolumeFact";
/// <summary> a <see cref="CircleFact">CircleFact</see> describing the base area </summary>
public string Cid1;
/// <summary> a <see cref="CircleFact">CircleFact</see> describing the top area </summary>
......@@ -3591,14 +3610,15 @@ protected override bool EquivalentWrapped(CylinderVolumeFact f1, CylinderVolumeF
}
}
/// <summary>
/// A fact that describes, that two circles have the same size and is comprised of two <see cref="CircleFact">CircleFacts</see>
/// </summary>
public class EqualCirclesFact : FactWrappedCRTP<EqualCirclesFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "EqualCirclesFact";
/// @{ <summary>
/// two circles that are meant to be equal in area
/// </summary>
......@@ -3792,12 +3812,15 @@ protected override bool EquivalentWrapped(EqualCirclesFact f1, EqualCirclesFact
}
}
/// <summary>
/// A fact that describes, that two circles have not the same size and is comprised of two <see cref="CircleFact">CircleFacts</see>
/// </summary>
public class UnEqualCirclesFact : FactWrappedCRTP<UnEqualCirclesFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "UnEqualCirclesFact";
/// @{ <summary>
/// two circles that are meant to be unequal in area
/// </summary>
......@@ -3993,10 +4016,6 @@ protected override bool EquivalentWrapped(UnEqualCirclesFact f1, UnEqualCirclesF
}
/// TEST FACT
/// use this if you need to test certain implementations of facts.
......@@ -4005,6 +4024,10 @@ protected override bool EquivalentWrapped(UnEqualCirclesFact f1, UnEqualCirclesF
/// </summary>
public class TestFact : FactWrappedCRTP<TestFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "TestFact";
......
......@@ -31,6 +31,7 @@ public Fact SpawnFactRepresentation(Fact fact)
{
PointFact => SpawnPoint,
LineFact => SpawnLine,
RightAngleFact => SpawnAngle, //needed for Hint System
AngleFact => SpawnAngle,
RayFact => SpawnRay,
CircleFact => SpawnRingAndCircle,
......@@ -141,11 +142,24 @@ public Fact SpawnRay(Fact fact)
//Spawn an angle: point with id = angleFact.Pid2 is the point where the angle gets applied
public Fact SpawnAngle(Fact fact)
{
AngleFact angleFact = (AngleFact)fact;
Vector3 point1, point2, point3;
// TODO: just use simple inheritence or similar!!
if (fact is RightAngleFact rightangleFact)
{
point1 = (StageStatic.stage.factState[rightangleFact.Pid1] as PointFact).Point;
point2 = (StageStatic.stage.factState[rightangleFact.Pid2] as PointFact).Point;
point3 = (StageStatic.stage.factState[rightangleFact.Pid3] as PointFact).Point;
}
else if (fact is AngleFact angleFact)
{
point1 = (StageStatic.stage.factState[angleFact.Pid1] as PointFact).Point;
point2 = (StageStatic.stage.factState[angleFact.Pid2] as PointFact).Point;
point3 = (StageStatic.stage.factState[angleFact.Pid3] as PointFact).Point;
}
else
throw new Exception("Invalid Type:" + fact.GetType().ToString());
Vector3 point1 = (StageStatic.stage.factState[angleFact.Pid1] as PointFact).Point;
Vector3 point2 = (StageStatic.stage.factState[angleFact.Pid2] as PointFact).Point;
Vector3 point3 = (StageStatic.stage.factState[angleFact.Pid3] as PointFact).Point;
//Length of the Angle relative to the Length of the shortest of the two lines (point2->point1) and (point2->point3)
float lengthFactor = 0.3f;
......@@ -193,9 +207,9 @@ public Fact SpawnAngle(Fact fact)
foreach (CircleSegmentGenerator c in segments)
c.setAngle(angleValue);
angle.GetComponentInChildren<FactObject>().URI = angleFact.Id;
angleFact.Representation = angle;
return angleFact;
angle.GetComponentInChildren<FactObject>().URI = fact.Id;
fact.Representation = angle;
return fact;
}
public Fact SpawnRingAndCircle(Fact fact)
......
......@@ -70,7 +70,7 @@ public override void _Hit(RaycastHit[] hit)
}
private void ResetGadget()
protected override void _ResetGadget()
{
this.FirstCircleSelected= false;
this.FirstCircle = null;
......
......@@ -22,7 +22,7 @@ public class GadgetBehaviour : MonoBehaviour, ISerializationCallbackReceiver
public static GameObject ParentMe;
public static Material[] Materials;
public static Sprite[] ButtonSprites;
public static String[] ButtonNames;
//public static String[] ButtonNames;
public static Dictionary<Gadget.GadgetIDs, DataContainerGadgetInit> DataContainerGadgetDict;
......@@ -60,7 +60,7 @@ public void OnAfterDeserialize()
#pragma warning disable UNT0008 // Null propagation on Unity objects
Materials = _DataContainerGadgetDict?.Materials ?? new Material[0];
ButtonSprites = _DataContainerGadgetDict?.ButtonSprites ?? new Sprite[0];
ButtonNames = _DataContainerGadgetDict?.GadgetNames ?? new string[0];
//ButtonNames = _DataContainerGadgetDict?.GadgetNames ?? new string[0];
DataContainerGadgetDict = _DataContainerGadgetDict?.DataContainerGadgetDict ?? new();
#pragma warning restore UNT0008 // Null propagation on Unity objects
}
......@@ -181,7 +181,7 @@ public static void ActivateGadget(int gid)
ActiveGadgetInd = gid;
//buttons[gid].animator.StartPlayback();
buttons[gid].transform.localScale *= ActiveGadgetScaleFactor;
GadgetName.GetComponent<TMP_Text>().text = ButtonNames[gadgets[gid].ButtonIndx];
GadgetName.GetComponent<TMP_Text>().text = gadgets[gid].UiName;
gadgets[gid].Enable();
OnHit = gadgets[gid].Hit;
......
......@@ -30,7 +30,8 @@ private void Awake()
{
CommunicationEvents.PushoutFactEvent.AddListener(HighlightFact);
CommunicationEvents.PushoutFactFailEvent.AddListener(LetItRain);
CommunicationEvents.AnimateExistingFactEvent.AddListener(HighlightWithFireworks);
CommunicationEvents.AnimateExistingFactEvent.AddListener(HighlightFact);
CommunicationEvents.AnimateExistingAsSolutionEvent.AddListener(HighlightWithFireworks);
rain = rain_wait = IEnumeratorExtensions.yield_break;
}
......@@ -95,12 +96,12 @@ public static void HighlightFact(Fact startFact, FactObject.FactMaterials tmp_ma
);
}
public void HighlightWithFireworks(Fact fact)
public void HighlightWithFireworks(Fact fact, FactObject.FactMaterials mat)
{
rain_wait = IEnumeratorExtensions.yield_break; //stop rain
StartCoroutine(BlossomAndDie());
HighlightFact(fact, FactObject.FactMaterials.Solution);
HighlightFact(fact, mat);
IEnumerator BlossomAndDie()
{
......@@ -125,7 +126,7 @@ IEnumerator BlossomAndDie()
}
}
public void LetItRain(Fact startFact)
public void LetItRain(Fact startFact, Scroll.ScrollApplicationInfo _)
{
// check if couroutine is waiting
if (!rain_wait.MoveNext()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment