Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
GameDevWeek
Wintersemester 2018-2019
Unity
Suck It
Commits
4af38694
Commit
4af38694
authored
Mar 25, 2019
by
Sebastian Frey
Browse files
Code Cleanup
parent
504bf5ed
Changes
11
Hide whitespace changes
Inline
Side-by-side
Assets/_Game/Scripts/
MonoBehavior
.meta
→
Assets/_Game/Scripts/
Elements
.meta
View file @
4af38694
File moved
Assets/_Game/Scripts/Elements/InteractionObject.cs
0 → 100644
View file @
4af38694
using
UnityEngine
;
namespace
_Game.Scripts.Elements
{
public
class
InteractionObject
:
MonoBehaviour
{
public
void
DoInteraction
()
{
this
.
GetComponent
<
SpriteRenderer
>().
color
=
Color
.
green
;
}
}
}
Assets/_Game/Scripts/
MonoBehavior/Interaction
/InteractionObject.cs.meta
→
Assets/_Game/Scripts/
Elements
/InteractionObject.cs.meta
View file @
4af38694
File moved
Assets/_Game/Scripts/Interaction.meta
0 → 100644
View file @
4af38694
fileFormatVersion: 2
guid: 5782222d4c9b9424ea96676650e643a8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Assets/_Game/Scripts/MonoBehavior/Interaction/InteractionObject.cs
deleted
100644 → 0
View file @
504bf5ed
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
InteractionObject
:
MonoBehaviour
{
public
void
DoInteraction
()
{
this
.
GetComponent
<
SpriteRenderer
>().
color
=
Color
.
green
;
}
}
Assets/_Game/Scripts/MonoBehavior/Interaction/PlayerInteract.cs
deleted
100644 → 0
View file @
504bf5ed
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
PlayerInteract
:
MonoBehaviour
{
private
GameObject
currentObject
;
private
InteractionObject
targetScript
;
private
void
Update
()
{
if
(
Input
.
GetButtonDown
(
"Interact"
)
&&
currentObject
)
{
targetScript
.
DoInteraction
();
}
}
private
void
OnTriggerEnter2D
(
Collider2D
other
)
{
if
(
other
.
CompareTag
(
"Element"
))
{
Debug
.
Log
(
"Entered Collider of "
+
other
.
name
);
currentObject
=
other
.
gameObject
;
targetScript
=
currentObject
.
GetComponent
<
InteractionObject
>();
}
}
private
void
OnTriggerExit2D
(
Collider2D
other
)
{
if
(
other
.
CompareTag
(
"Element"
))
{
if
(
other
.
gameObject
==
currentObject
)
{
Debug
.
Log
(
"Exited Collider of "
+
other
.
name
);
currentObject
=
null
;
targetScript
=
null
;
}
}
}
}
Assets/_Game/Scripts/Player/Movement.cs
View file @
4af38694
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine
;
public
class
Movement
:
MonoBehaviour
{
namespace
_Game.Scripts.Player
{
public
class
Movement
:
MonoBehaviour
{
public
float
speed
=
1.0f
;
public
float
G
roundDist
=
0.5f
;
public
int
layer
;
public
float
speed
=
1.0f
;
public
float
g
roundDist
=
0.5f
;
public
int
layer
;
private
Transform
player
;
private
Rigidbody2D
r2
d
;
private
float
xAxis
;
private
Transform
_
player
;
private
Rigidbody2D
_
r2
D
;
private
float
_
xAxis
;
// Start is called before the first frame update
void
Start
()
{
player
=
GetComponent
<
Transform
>();
}
// Start is called before the first frame update
private
void
Start
()
{
_
player
=
GetComponent
<
Transform
>();
}
// Update is called once per frame
void
Update
()
{
Move
();
}
// Update is called once per frame
private
void
Update
()
{
Move
();
}
void
Move
()
{
xAxis
=
Input
.
GetAxis
(
"Horizontal"
);
player
.
position
+=
new
Vector3
(
xAxis
,
0
,
0
).
normalized
*
speed
*
Time
.
deltaTime
;
}
private
void
Move
()
{
_
xAxis
=
Input
.
GetAxis
(
"Horizontal"
);
_
player
.
position
+=
new
Vector3
(
_
xAxis
,
0
,
0
).
normalized
*
speed
*
Time
.
deltaTime
;
}
bool
Grounded
(){
return
Physics2D
.
Raycast
(
new
Vector2
(
player
.
position
.
x
,
player
.
position
.
y
)
+
(
Vector2
.
up
*
0.5f
),
Vector2
.
down
,
GroundDist
,
layer
);
}
private
bool
Grounded
()
{
var
position
=
_player
.
position
;
return
Physics2D
.
Raycast
(
new
Vector2
(
position
.
x
,
position
.
y
)
+
(
Vector2
.
up
*
0.5f
),
Vector2
.
down
,
groundDist
,
layer
);
}
}
}
\ No newline at end of file
Assets/_Game/Scripts/Player/PlayerInteract.cs
0 → 100644
View file @
4af38694
using
UnityEngine
;
using
_Game.Scripts.Elements
;
namespace
_Game.Scripts.Player
{
public
class
PlayerInteract
:
MonoBehaviour
{
private
GameObject
_currentObject
;
private
InteractionObject
_targetScript
;
private
void
Update
()
{
if
(
Input
.
GetButtonDown
(
"Interact"
)
&&
_currentObject
)
{
_targetScript
.
DoInteraction
();
}
}
private
void
OnTriggerEnter2D
(
Collider2D
other
)
{
if
(!
other
.
CompareTag
(
"Element"
))
return
;
Debug
.
Log
(
"Entered Collider of "
+
other
.
name
);
_currentObject
=
other
.
gameObject
;
_targetScript
=
_currentObject
.
GetComponent
<
InteractionObject
>();
}
private
void
OnTriggerExit2D
(
Collider2D
other
)
{
if
(!
other
.
CompareTag
(
"Element"
))
return
;
if
(
other
.
gameObject
!=
_currentObject
)
return
;
Debug
.
Log
(
"Exited Collider of "
+
other
.
name
);
_currentObject
=
null
;
_targetScript
=
null
;
}
}
}
Assets/_Game/Scripts/
MonoBehavior/Interaction
/PlayerInteract.cs.meta
→
Assets/_Game/Scripts/
Player
/PlayerInteract.cs.meta
View file @
4af38694
File moved
Assets/_Game/Scripts/Scriptable Object.meta
View file @
4af38694
fileFormatVersion: 2
guid:
efba442f6715bfe40b18801f66985717
guid:
284bf9e64b1631a4897eb66683d31ab8
folderAsset: yes
DefaultImporter:
externalObjects: {}
...
...
Assets/_Game/Scripts/Scriptable Object/PlayerState.cs
View file @
4af38694
...
...
@@ -2,17 +2,20 @@
using
System.Collections.Generic
;
using
UnityEngine
;
[
CreateAssetMenu
(
menuName
=
"PlayerState"
)]
public
class
PlayerState
:
ScriptableObject
namespace
_Game.Scripts.Scriptable_Object
{
public
InfusedElement
currentElement
;
}
[
CreateAssetMenu
(
fileName
=
"New Player State"
,
menuName
=
"PlayerState"
,
order
=
51
)]
public
class
PlayerState
:
ScriptableObject
{
public
InfusedElement
currentElement
;
}
public
enum
InfusedElement
{
None
,
Fire
,
Water
,
Earth
,
Air
}
public
enum
InfusedElement
{
None
,
Fire
,
Water
,
Earth
,
Air
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment