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
6babb726
Commit
6babb726
authored
Mar 30, 2019
by
Christopher Benes
Browse files
Merge branch 'master' of gitlab.fsi.hochschule-trier.de:GameDevWeek/ws-18_19/unity/suck-it
parents
407c0dfe
9b6a1b80
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Assets/_Game/Scenes/Max-Level.unity
View file @
6babb726
This diff is collapsed.
Click to expand it.
Assets/_Game/Scenes/Max-Level.unity.meta
View file @
6babb726
fileFormatVersion: 2
guid:
77558aed3f259254e968ce9592e600c9
guid:
32561bea78ffe5941b1379159c0b43b2
DefaultImporter:
externalObjects: {}
userData:
...
...
Assets/_Game/Scripts/Player/PlayerAnimation.cs
View file @
6babb726
...
...
@@ -8,14 +8,20 @@ using _Game.Scripts.Scriptable_Object;
public
class
PlayerAnimation
:
MonoBehaviour
{
[
Header
(
"Scaling"
)]
public
AnimationCurve
m_AirScale
;
public
bool
m_ScalingActive
=
true
;
public
float
m_Time
=
10f
;
public
float
m_SizePerCharge
=
0.2f
;
private
Vector3
m_OriginScale
;
private
int
m_PreviousAirCharges
=
0
;
private
int
m_CurrentAirCharges
=
0
;
[
Header
(
"Rotation"
)]
public
float
m_Speed
=
3f
;
public
bool
m_RotationActive
=
false
;
public
float
m_Radius
=
1f
;
public
float
m_RadiusSinDifference
=
0.3f
;
public
float
m_MaxScale
=
0.3f
;
public
GameObject
m_ElementPrefab
;
public
Transform
m_ElementOrbParent
;
public
Transform
m_RotationOrigin
;
public
Vector2
m_RotationOriginOffset
;
public
Sprite
m_AirSprite
;
...
...
@@ -36,11 +42,7 @@ public class PlayerAnimation : MonoBehaviour
private
bool
m_isAnimating
=
false
;
private
bool
m_isScaled
=
false
;
private
bool
m_isRotating
=
false
;
private
int
m_PreviousCharges
=
0
;
private
Vector3
m_OriginSize
;
private
Vector2
m_OriginOffset
;
private
float
m_OriginCheckDistance
;
// Start is called before the first frame update
...
...
@@ -49,9 +51,7 @@ public class PlayerAnimation : MonoBehaviour
r_Controller
=
GetComponent
<
MovementController
>();
r_Collider2D
=
GetComponent
<
CapsuleCollider2D
>();
m_OriginSize
=
transform
.
localScale
;
m_OriginOffset
=
r_Controller
.
GroundCheckOffset
;
m_OriginCheckDistance
=
r_Controller
.
GroundCheckDistance
;
m_OriginScale
=
transform
.
localScale
;
m_ElementOrbTransforms
=
new
List
<
GameObject
>();
m_ElementOrbRenderer
=
new
List
<
SpriteRenderer
>();
...
...
@@ -75,48 +75,71 @@ public class PlayerAnimation : MonoBehaviour
switch
(
r_State
.
GetCurrentElement
())
{
case
InfusedElement
.
None
:
m_isRotating
=
false
;
SetRotationOrbsActive
(
false
,
5
);
ScalePlayer
();
break
;
case
InfusedElement
.
Air
:
ScalePlayer
();
SetRotationOrbsActive
(
true
,
r_State
.
GetCharges
());
SetRotationOrbSprite
(
m_AirSprite
);
if
(!
m_isRotating
)
if
(
m_ScalingActive
)
ScalePlayer
();
if
(
m_RotationActive
)
{
m_isRotating
=
tru
e
;
S
tartCorou
ti
n
e
(
RotatingElements
()
);
m_isRotating
=
fals
e
;
S
etRotationOrbsAc
ti
v
e
(
false
,
5
);
}
break
;
case
InfusedElement
.
Air
:
m_CurrentAirCharges
=
r_State
.
GetCharges
();
if
(
m_ScalingActive
)
ScalePlayer
();
/*if(m_isRotating) {
SetRotationOrbsActive(true, r_State.GetCharges());
SetRotationOrbSprite(m_AirSprite);
if (!m_isRotating)
{
m_isRotating = true;
StartCoroutine(RotatingElements());
}
}*/
break
;
case
InfusedElement
.
Fire
:
SetRotationOrbs
Active
(
tr
ue
,
r_State
.
GetCharges
())
;
SetRotationOrbSprite
(
m_FireSprite
);
if
(
!
m_isRotating
)
if
(
m_Scaling
Active
)
tr
ansform
.
localScale
=
m_OriginScale
;
if
(
m_isRotating
)
{
m_isRotating
=
true
;
StartCoroutine
(
RotatingElements
());
SetRotationOrbsActive
(
true
,
r_State
.
GetCharges
());
SetRotationOrbSprite
(
m_FireSprite
);
if
(!
m_isRotating
)
{
m_isRotating
=
true
;
StartCoroutine
(
RotatingElements
());
}
}
break
;
case
InfusedElement
.
Earth
:
SetRotationOrbs
Active
(
tr
ue
,
r_State
.
GetCharges
())
;
SetRotationOrbSprite
(
m_EarthSprite
);
if
(
!
m_isRotating
)
if
(
m_Scaling
Active
)
tr
ansform
.
localScale
=
m_OriginScale
;
if
(
m_isRotating
)
{
m_isRotating
=
true
;
StartCoroutine
(
RotatingElements
());
SetRotationOrbsActive
(
true
,
r_State
.
GetCharges
());
SetRotationOrbSprite
(
m_EarthSprite
);
if
(!
m_isRotating
)
{
m_isRotating
=
true
;
StartCoroutine
(
RotatingElements
());
}
}
break
;
case
InfusedElement
.
Water
:
SetRotationOrbs
Active
(
tr
ue
,
r_State
.
GetCharges
())
;
SetRotationOrbSprite
(
m_WaterSprite
);
if
(
!
m_isRotating
)
if
(
m_Scaling
Active
)
tr
ansform
.
localScale
=
m_OriginScale
;
if
(
m_isRotating
)
{
m_isRotating
=
true
;
StartCoroutine
(
RotatingElements
());
SetRotationOrbsActive
(
true
,
r_State
.
GetCharges
());
SetRotationOrbSprite
(
m_WaterSprite
);
if
(!
m_isRotating
)
{
m_isRotating
=
true
;
StartCoroutine
(
RotatingElements
());
}
}
break
;
...
...
@@ -126,24 +149,24 @@ public class PlayerAnimation : MonoBehaviour
public
void
ScalePlayer
()
{
int
currentCharges
=
r_State
.
GetCharges
();
int
diff
=
currentCharges
-
m_PreviousCharges
;
int
diff
=
currentCharges
-
m_Previous
Air
Charges
;
//Debug.Log("current: " + currentCharges + " previous: " + m_PreviousCharges + " difference: " + diff);
if
(!
m_isAnimating
||
m_isAnimating
)
{
if
(
diff
>
0
)
{
StartCoroutine
(
ScaleUp
(
diff
));
StartCoroutine
(
ScaleUp
(
m_PreviousAirCharges
,
currentCharges
));
}
else
{
StartCoroutine
(
ScaleDown
(
diff
));
StartCoroutine
(
ScaleDown
(
m_PreviousAirCharges
,
currentCharges
));
}
}
m_PreviousCharges
=
currentCharges
;
m_Previous
Air
Charges
=
currentCharges
;
}
private
IEnumerator
ScaleUp
(
int
amount
)
private
IEnumerator
ScaleUp
(
int
from
,
int
to
)
{
m_isAnimating
=
true
;
m_isScaled
=
true
;
...
...
@@ -151,20 +174,21 @@ public class PlayerAnimation : MonoBehaviour
float
step
=
1
/
m_Time
;
float
timer
=
0.0f
;
float
x
=
0f
;
float
diff
=
to
-
from
;
while
(
timer
<=
m_Time
)
{
x
=
m_SizePerCharge
*
Mathf
.
Abs
(
amount
);
transform
.
localScale
=
Vector3
.
LerpUnclamped
(
s
,
s
+
new
Vector3
(
x
*
Mathf
.
Sign
(
s
.
x
),
x
,
x
),
x
=
m_SizePerCharge
*
Mathf
.
Abs
(
diff
);
transform
.
localScale
=
Vector3
.
LerpUnclamped
(
s
,
s
+
new
Vector3
(
x
*
Mathf
.
Sign
(
transform
.
localScale
.
x
),
x
,
x
),
m_AirScale
.
Evaluate
(
timer
/
m_Time
));
timer
+=
Time
.
deltaTime
;
yield
return
null
;
}
transform
.
localScale
=
s
+
new
Vector3
(
x
*
Mathf
.
Sign
(
s
.
x
),
x
,
x
);
transform
.
localScale
=
s
+
new
Vector3
(
x
*
Mathf
.
Sign
(
transform
.
localScale
.
x
),
x
,
x
);
m_isAnimating
=
false
;
}
private
IEnumerator
ScaleDown
(
int
amount
)
private
IEnumerator
ScaleDown
(
int
from
,
int
to
)
{
m_isAnimating
=
true
;
m_isScaled
=
false
;
...
...
@@ -172,10 +196,11 @@ public class PlayerAnimation : MonoBehaviour
float
step
=
1
/
m_Time
;
float
timer
=
0.0f
;
float
x
=
0
;
float
diff
=
to
-
from
;
while
(
timer
<=
m_Time
)
{
x
=
m_SizePerCharge
*
Mathf
.
Abs
(
amount
);
transform
.
localScale
=
Vector3
.
LerpUnclamped
(
s
,
s
-
new
Vector3
(
x
*
Mathf
.
Sign
(
s
.
x
),
x
,
x
),
x
=
m_SizePerCharge
*
Mathf
.
Abs
(
diff
);
transform
.
localScale
=
Vector3
.
LerpUnclamped
(
s
,
s
-
new
Vector3
(
x
*
Mathf
.
Sign
(
transform
.
localScale
.
x
),
x
,
x
),
m_AirScale
.
Evaluate
(
timer
/
m_Time
));
timer
+=
Time
.
deltaTime
;
yield
return
null
;
...
...
@@ -183,11 +208,11 @@ public class PlayerAnimation : MonoBehaviour
if
(
r_State
.
GetCharges
()
>
0
)
{
transform
.
localScale
=
s
-
new
Vector3
(
x
*
Mathf
.
Sign
(
s
.
x
),
x
,
x
);
transform
.
localScale
=
s
-
new
Vector3
(
x
*
Mathf
.
Sign
(
transform
.
localScale
.
x
),
x
,
x
);
}
else
{
transform
.
localScale
=
m_OriginS
iz
e
;
transform
.
localScale
=
m_OriginS
cal
e
;
}
m_isAnimating
=
false
;
...
...
@@ -202,15 +227,16 @@ public class PlayerAnimation : MonoBehaviour
for
(
int
i
=
0
;
i
<
m_ElementOrbTransforms
.
Count
;
i
++)
{
pos
=
m_TimeCounter
;
if
(
r_State
.
GetCharges
()
>
0
)
pos
=
m_TimeCounter
+
i
*
Mathf
.
Deg2Rad
*
(
360
/
r_State
.
GetCharges
());
if
(
r_State
.
GetCharges
()
>
0
)
pos
=
m_TimeCounter
+
i
*
Mathf
.
Deg2Rad
*
(
360
/
r_State
.
GetCharges
());
float
r
=
(
m_Radius
-
m_RadiusSinDifference
)
+
(
m_RadiusSinDifference
*
Mathf
.
Sin
(
m_TimeCounter
));
float
x
=
Mathf
.
Cos
(
pos
)
*
r
;
float
y
=
Mathf
.
Sin
(
pos
)
*
r
;
Vector3
offset
=
m_RotationOriginOffset
;
//Transform elem = m_ElementOrbTransforms[i].transform;
m_ElementOrbTransforms
[
i
].
transform
.
position
=
m_RotationOrigin
.
position
+
offset
+
new
Vector3
(
x
,
y
,
0f
);
m_ElementOrbTransforms
[
i
].
transform
.
position
=
m_RotationOrigin
.
position
+
offset
+
new
Vector3
(
x
,
y
,
0f
);
yield
return
new
WaitForFixedUpdate
();
}
}
...
...
@@ -236,7 +262,6 @@ public class PlayerAnimation : MonoBehaviour
for
(
int
i
=
0
;
i
<
m_ElementOrbRenderer
.
Count
;
i
++)
{
m_ElementOrbRenderer
[
i
].
sprite
=
s
;
}
}
}
Write
Preview
Supports
Markdown
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