Skip to content
GitLab
Menu
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
56b5f4a6
Commit
56b5f4a6
authored
Mar 29, 2019
by
Sebastian Frey
Browse files
Element kann gelöscht werden; GameEvents kommen jetzt vom PlayerState
parent
5e80266d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Assets/_Game/Data/Player Data/PlayerState.asset
View file @
56b5f4a6
...
...
@@ -12,15 +12,17 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
353b156b7c59b1c45a8767d7500b31fb
,
type
:
3
}
m_Name
:
PlayerState
m_EditorClassIdentifier
:
currentInfusedElement
:
0
currentInfusedElement
:
1
currentMoveState
:
jumpForce
:
1
0
jumpForce
:
1
5
smoothing
:
0.03
airControl
:
1
canSwim
:
1
moveSpeed
:
20
maxJumpCount
:
1
maxJumpCount
:
2
mass
:
1
gravity
:
3
movementStates
:
{
fileID
:
11400000
,
guid
:
c757aad6925b37a46b916f609fa9012b
,
type
:
2
}
charges
:
2
onElementInfused
:
{
fileID
:
11400000
,
guid
:
7e5b80a8353af1846a878c3a997bdb4a
,
type
:
2
}
onChargeChange
:
{
fileID
:
11400000
,
guid
:
6ec6544f645a9d1458383b111fcaf8b6
,
type
:
2
}
charges
:
0
Assets/_Game/Scenes/Pick_Up_Test_Scene.unity
View file @
56b5f4a6
...
...
@@ -956,6 +956,12 @@ PrefabInstance:
propertyPath
:
m_MaxJumpCount
value
:
2
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
52145075018362291
,
guid
:
2e3528907311e438dab0d393127aa332
,
type
:
3
}
propertyPath
:
r_State
value
:
objectReference
:
{
fileID
:
11400000
,
guid
:
c5777bcc7b64ce24c9bd65d2c4b7c639
,
type
:
2
}
-
target
:
{
fileID
:
6060985002925283250
,
guid
:
2e3528907311e438dab0d393127aa332
,
type
:
3
}
propertyPath
:
lowJumpMultiplier
...
...
@@ -1000,7 +1006,7 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
83eb4399ff535ee4cbc76de3b8a32e46
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
C
ooldown
:
0
c
ooldown
:
0
volleySize
:
10
launchPower
:
10
attackSpeed
:
0.1
...
...
@@ -1018,6 +1024,9 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
ad90db0185377664288543ce4696c6b8
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
cooldown
:
0
massIncrease
:
0
isStomping
:
0
---
!u!114
&1876157330
MonoBehaviour
:
m_ObjectHideFlags
:
0
...
...
@@ -1049,8 +1058,7 @@ MonoBehaviour:
m_Name
:
m_EditorClassIdentifier
:
state
:
{
fileID
:
11400000
,
guid
:
c5777bcc7b64ce24c9bd65d2c4b7c639
,
type
:
2
}
onElementInfused
:
{
fileID
:
11400000
,
guid
:
7e5b80a8353af1846a878c3a997bdb4a
,
type
:
2
}
onChargeChange
:
{
fileID
:
11400000
,
guid
:
6ec6544f645a9d1458383b111fcaf8b6
,
type
:
2
}
onElementChanged
:
{
fileID
:
0
}
---
!u!4
&1876157337
stripped
Transform
:
m_CorrespondingSourceObject
:
{
fileID
:
52145075018362285
,
guid
:
2e3528907311e438dab0d393127aa332
,
...
...
Assets/_Game/Scripts/Elements/InteractionObject.cs
View file @
56b5f4a6
using
UnityEngine
;
using
_Game.Scripts.Scriptable_Object
;
namespace
_Game.Scripts.Elements
{
public
class
InteractionObject
:
MonoBehaviour
{
[
SerializeField
]
private
InfusedElement
element
;
public
void
InfuseElement
()
{
//this.GetComponent<SpriteRenderer>().color = Color.green;
Debug
.
Log
(
"Infused "
+
this
.
gameObject
.
tag
);
}
public
InfusedElement
GetElement
()
{
return
element
;
}
}
}
Assets/_Game/Scripts/Player/PlayerInteract.cs
View file @
56b5f4a6
...
...
@@ -19,9 +19,7 @@ namespace _Game.Scripts.Player
[
SerializeField
]
private
PlayerState
state
;
[
SerializeField
]
private
ElementGameEvent
onElementInfused
;
[
SerializeField
]
private
ChargeGameEvent
onChargeChange
;
[
SerializeField
]
private
ElementGameEventListener
onElementChanged
;
private
PlayerAirAttack
_airAttack
;
private
PlayerEarthAttack
_earthAttack
;
...
...
@@ -44,7 +42,7 @@ namespace _Game.Scripts.Player
_earthAttack
.
enabled
=
false
;
_fireAttack
.
enabled
=
false
;
_waterAttack
.
enabled
=
false
;
_controller
.
SetMovementParameters
(
state
.
GetCurrentMovementState
());
//
_controller.SetMovementParameters(state.GetCurrentMovementState());
}
private
void
Update
()
...
...
@@ -64,78 +62,77 @@ namespace _Game.Scripts.Player
if
(
_earthAttack
.
Attack
())
{
state
.
ChangeCharges
(-
1
);
onChargeChange
.
Raise
();
}
break
;
case
InfusedElement
.
Fire
:
if
(
_fireAttack
.
Attack
())
{
state
.
ChangeCharges
(-
1
);
onChargeChange
.
Raise
();
}
break
;
case
InfusedElement
.
Water
:
print
(
"done"
);
if
(
_waterAttack
.
Attack
())
{
state
.
ChangeCharges
(-
1
);
onChargeChange
.
Raise
();
}
break
;
case
InfusedElement
.
None
:
break
;
case
InfusedElement
.
Air
:
break
;
default
:
throw
new
ArgumentOutOfRangeException
();
}
}
if
(!
Input
.
GetButtonDown
(
"Interact"
)
||
!
_currentObject
)
return
;
if
(
Input
.
GetButtonDown
(
"Interact"
)
&&
_currentObject
)
{
switch
(
_currentObject
.
tag
)
{
case
"Air"
:
state
.
UpdateElement
(
InfusedElement
.
Air
);
_airAttack
.
enabled
=
true
;
_earthAttack
.
enabled
=
false
;
_fireAttack
.
enabled
=
false
;
_waterAttack
.
enabled
=
false
;
break
;
case
"Earth"
:
state
.
UpdateElement
(
InfusedElement
.
Earth
);
_airAttack
.
enabled
=
false
;
_earthAttack
.
enabled
=
true
;
_fireAttack
.
enabled
=
false
;
_waterAttack
.
enabled
=
false
;
break
;
case
"Fire"
:
state
.
UpdateElement
(
InfusedElement
.
Fire
);
_airAttack
.
enabled
=
false
;
_earthAttack
.
enabled
=
false
;
_fireAttack
.
enabled
=
true
;
_waterAttack
.
enabled
=
false
;
break
;
case
"Water"
:
state
.
UpdateElement
(
InfusedElement
.
Water
);
_airAttack
.
enabled
=
false
;
_earthAttack
.
enabled
=
false
;
_fireAttack
.
enabled
=
false
;
_waterAttack
.
enabled
=
true
;
break
;
default
:
throw
new
ArgumentOutOfRangeException
();
}
_targetScript
.
InfuseElement
();
}
switch
(
_currentObject
.
tag
)
if
(
Input
.
GetButtonDown
(
"Cancel Element"
)
)
{
case
"Air"
:
state
.
UpdateElement
(
InfusedElement
.
Air
);
state
.
ChangeCharges
(
3
);
onElementInfused
.
Raise
(
InfusedElement
.
Air
);
onChargeChange
.
Raise
();
_airAttack
.
enabled
=
true
;
_earthAttack
.
enabled
=
false
;
_fireAttack
.
enabled
=
false
;
_waterAttack
.
enabled
=
false
;
break
;
case
"Earth"
:
state
.
UpdateElement
(
InfusedElement
.
Earth
);
state
.
ChangeCharges
(
3
);
onElementInfused
.
Raise
(
InfusedElement
.
Earth
);
onChargeChange
.
Raise
();
_airAttack
.
enabled
=
false
;
_earthAttack
.
enabled
=
true
;
_fireAttack
.
enabled
=
false
;
_waterAttack
.
enabled
=
false
;
break
;
case
"Fire"
:
state
.
UpdateElement
(
InfusedElement
.
Fire
);
state
.
ChangeCharges
(
3
);
onElementInfused
.
Raise
(
InfusedElement
.
Fire
);
onChargeChange
.
Raise
();
_airAttack
.
enabled
=
false
;
_earthAttack
.
enabled
=
false
;
_fireAttack
.
enabled
=
true
;
_waterAttack
.
enabled
=
false
;
break
;
case
"Water"
:
state
.
UpdateElement
(
InfusedElement
.
Water
);
state
.
ChangeCharges
(
3
);
onElementInfused
.
Raise
(
InfusedElement
.
Water
);
onChargeChange
.
Raise
();
_airAttack
.
enabled
=
false
;
_earthAttack
.
enabled
=
false
;
_fireAttack
.
enabled
=
false
;
_waterAttack
.
enabled
=
true
;
break
;
state
.
UpdateElement
(
InfusedElement
.
None
);
state
.
ChangeCharges
(-
5
);
_airAttack
.
enabled
=
false
;
_earthAttack
.
enabled
=
false
;
_fireAttack
.
enabled
=
false
;
_waterAttack
.
enabled
=
false
;
}
//_controller.SetMovementParameters(state.GetCurrentMovementState());
_targetScript
.
InfuseElement
();
}
...
...
Assets/_Game/Scripts/Scriptable Object/PlayerState.cs
View file @
56b5f4a6
...
...
@@ -17,6 +17,9 @@ namespace _Game.Scripts.Scriptable_Object
[
SerializeField
]
private
MovementStates
movementStates
;
[
SerializeField
]
private
ElementGameEvent
onElementInfused
;
[
SerializeField
]
private
ChargeGameEvent
onChargeChange
;
[
SerializeField
][
Range
(
0
,
5
)]
private
int
charges
;
// [SerializeField] private float currentJumpForce;
...
...
@@ -31,6 +34,11 @@ namespace _Game.Scripts.Scriptable_Object
{
currentInfusedElement
=
newElement
;
currentMoveState
=
movementStates
.
GetMovementState
(
newElement
);
onElementInfused
.
Raise
(
newElement
);
if
(
newElement
==
InfusedElement
.
None
)
return
;
ChangeCharges
(
5
);
onChargeChange
.
Raise
();
}
public
MovementState
GetCurrentMovementState
()
...
...
@@ -38,22 +46,19 @@ namespace _Game.Scripts.Scriptable_Object
return
currentMoveState
;
}
public
bool
ChangeCharges
(
int
amount
)
public
void
ChangeCharges
(
int
amount
)
{
if
((
charges
+
amount
)
>
5
)
{
charges
=
5
;
return
true
;
}
else
if
((
charges
+
amount
)
<=
0
)
{
charges
=
0
;
UpdateElement
(
InfusedElement
.
None
);
return
false
;
}
else
{
charges
+=
amount
;
return
true
;
}
}
...
...
ProjectSettings/InputManager.asset
View file @
56b5f4a6
...
...
@@ -54,13 +54,13 @@ InputManager:
axis
:
0
joyNum
:
0
-
serializedVersion
:
3
m_Name
:
Fire2
m_Name
:
Cancel Element
descriptiveName
:
descriptiveNegativeName
:
negativeButton
:
positiveButton
:
left alt
positiveButton
:
q
altNegativeButton
:
altPositiveButton
:
mouse
1
altPositiveButton
:
gravity
:
1000
dead
:
0.001
sensitivity
:
1000
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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