Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Failframeit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FrameIT
Failframeit
Commits
bfa9a3c4
Commit
bfa9a3c4
authored
4 years ago
by
John Schihada
Browse files
Options
Downloads
Patches
Plain Diff
Refactored DisplayFacts
parent
6ad5caa4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Assets/Scripts/InteractionEngine/Fact.cs
+50
-0
50 additions, 0 deletions
Assets/Scripts/InteractionEngine/Fact.cs
Assets/Scripts/InventoryStuff/DisplayFacts.cs
+11
-54
11 additions, 54 deletions
Assets/Scripts/InventoryStuff/DisplayFacts.cs
with
61 additions
and
54 deletions
Assets/Scripts/InteractionEngine/Fact.cs
+
50
−
0
View file @
bfa9a3c4
...
...
@@ -2,6 +2,7 @@
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine.Networking
;
using
TMPro
;
using
static
JSONManager
;
public
class
ParsingDictionary
{
...
...
@@ -45,9 +46,16 @@ public string format(float t)
public
abstract
int
[]
getDependentFactIds
();
public
abstract
GameObject
instantiateRepresentation
(
GameObject
prefab
,
Transform
transform
);
public
abstract
override
bool
Equals
(
System
.
Object
obj
);
public
abstract
override
int
GetHashCode
();
public
static
string
getLetter
(
int
Id
)
{
return
((
Char
)(
64
+
Id
+
1
)).
ToString
();
}
}
public
abstract
class
DirectedFact
:
Fact
...
...
@@ -155,6 +163,13 @@ public override int[] getDependentFactIds() {
return
null
;
}
public
override
GameObject
instantiateRepresentation
(
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
;
return
obj
;
}
public
override
bool
Equals
(
System
.
Object
obj
)
{
//Check for null and compare run-time types.
...
...
@@ -254,6 +269,15 @@ public override int[] getDependentFactIds()
return
new
int
[]
{
Pid1
,
Pid2
};
}
public
override
GameObject
instantiateRepresentation
(
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
);
obj
.
GetComponent
<
FactWrapper
>().
fact
=
this
;
return
obj
;
}
public
override
bool
Equals
(
System
.
Object
obj
)
{
//Check for null and compare run-time types.
...
...
@@ -356,6 +380,14 @@ public override int[] getDependentFactIds()
return
new
int
[]
{
Pid1
,
Pid2
};
}
public
override
GameObject
instantiateRepresentation
(
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);
obj
.
GetComponent
<
FactWrapper
>().
fact
=
this
;
return
obj
;
}
public
override
bool
Equals
(
System
.
Object
obj
)
{
//Check for null and compare run-time types.
...
...
@@ -454,6 +486,15 @@ public override int[] getDependentFactIds()
return
new
int
[]
{
Pid
,
Rid
};
}
public
override
GameObject
instantiateRepresentation
(
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
);
obj
.
transform
.
GetChild
(
1
).
gameObject
.
GetComponent
<
TextMeshProUGUI
>().
text
=
""
+
getLetter
(
CommunicationEvents
.
Facts
[
this
.
Rid
].
Id
);
obj
.
GetComponent
<
FactWrapper
>().
fact
=
this
;
return
obj
;
}
public
override
bool
Equals
(
System
.
Object
obj
)
{
//Check for null and compare run-time types.
...
...
@@ -637,6 +678,15 @@ public override int[] getDependentFactIds()
return
new
int
[]
{
Pid1
,
Pid2
,
Pid3
};
}
public
override
GameObject
instantiateRepresentation
(
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
);
obj
.
transform
.
GetChild
(
2
).
gameObject
.
GetComponent
<
TextMeshProUGUI
>().
text
=
""
+
getLetter
(
CommunicationEvents
.
Facts
[
this
.
Pid3
].
Id
);
obj
.
GetComponent
<
FactWrapper
>().
fact
=
this
;
return
obj
;
}
public
override
bool
Equals
(
System
.
Object
obj
)
{
//Check for null and compare run-time types.
...
...
This diff is collapsed.
Click to expand it.
Assets/Scripts/InventoryStuff/DisplayFacts.cs
+
11
−
54
View file @
bfa9a3c4
...
...
@@ -15,6 +15,8 @@ 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
;
...
...
@@ -31,6 +33,14 @@ 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
)
{
...
...
@@ -51,60 +61,7 @@ string getLetter(int Id) {
private
GameObject
CreateDisplay
(
Transform
transform
,
Fact
fact
)
{
switch
(
fact
)
{
case
LineFact
f
:
{
var
obj
=
Instantiate
(
prefab_Distance
,
Vector3
.
zero
,
Quaternion
.
identity
,
transform
);
obj
.
transform
.
GetChild
(
0
).
gameObject
.
GetComponent
<
TextMeshProUGUI
>().
text
=
""
+
getLetter
(
CommunicationEvents
.
Facts
[
f
.
Pid1
].
Id
);
obj
.
transform
.
GetChild
(
1
).
gameObject
.
GetComponent
<
TextMeshProUGUI
>().
text
=
""
+
getLetter
(
CommunicationEvents
.
Facts
[
f
.
Pid2
].
Id
);
obj
.
GetComponent
<
FactWrapper
>().
fact
=
f
;
return
obj
;
}
case
RayFact
f
:
{
var
obj
=
Instantiate
(
prefab_Line
,
Vector3
.
zero
,
Quaternion
.
identity
,
transform
);
obj
.
transform
.
GetChild
(
0
).
gameObject
.
GetComponent
<
TextMeshProUGUI
>().
text
=
""
+
getLetter
(
f
.
Id
);
//obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[f.Pid2].Id);
obj
.
GetComponent
<
FactWrapper
>().
fact
=
f
;
return
obj
;
}
case
AngleFact
f
:
{
var
obj
=
Instantiate
(
prefab_Angle
,
Vector3
.
zero
,
Quaternion
.
identity
,
transform
);
obj
.
transform
.
GetChild
(
0
).
gameObject
.
GetComponent
<
TextMeshProUGUI
>().
text
=
""
+
getLetter
(
CommunicationEvents
.
Facts
[
f
.
Pid1
].
Id
);
obj
.
transform
.
GetChild
(
1
).
gameObject
.
GetComponent
<
TextMeshProUGUI
>().
text
=
""
+
getLetter
(
CommunicationEvents
.
Facts
[
f
.
Pid2
].
Id
);
obj
.
transform
.
GetChild
(
2
).
gameObject
.
GetComponent
<
TextMeshProUGUI
>().
text
=
""
+
getLetter
(
CommunicationEvents
.
Facts
[
f
.
Pid3
].
Id
);
obj
.
GetComponent
<
FactWrapper
>().
fact
=
f
;
return
obj
;
}
case
PointFact
f
:
{
var
obj
=
Instantiate
(
prefab_Point
,
Vector3
.
zero
,
Quaternion
.
identity
,
transform
);
obj
.
transform
.
GetChild
(
0
).
gameObject
.
GetComponent
<
TextMeshProUGUI
>().
text
=
""
+
getLetter
(
f
.
Id
);
obj
.
GetComponent
<
FactWrapper
>().
fact
=
f
;
return
obj
;
}
case
OnLineFact
f
:
{
var
obj
=
Instantiate
(
prefab_OnLine
,
Vector3
.
zero
,
Quaternion
.
identity
,
transform
);
obj
.
transform
.
GetChild
(
0
).
gameObject
.
GetComponent
<
TextMeshProUGUI
>().
text
=
""
+
getLetter
(
CommunicationEvents
.
Facts
[
f
.
Pid
].
Id
);
obj
.
transform
.
GetChild
(
1
).
gameObject
.
GetComponent
<
TextMeshProUGUI
>().
text
=
""
+
getLetter
(
CommunicationEvents
.
Facts
[
f
.
Rid
].
Id
);
obj
.
GetComponent
<
FactWrapper
>().
fact
=
f
;
return
obj
;
}
default
:
{
var
obj
=
Instantiate
(
prefab_Default
,
Vector3
.
zero
,
Quaternion
.
identity
,
transform
);
return
obj
;
}
}
return
fact
.
instantiateRepresentation
(
prefabDictionary
[
fact
.
GetType
().
Name
],
transform
);
}
public
Vector3
GetPosition
(
int
i
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment