Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Birb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gadig
Birb
Commits
49af132d
Commit
49af132d
authored
Apr 13, 2017
by
Eby Komenan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified: Assets/Scripts/Birb/Jump.cs
modified: Assets/Scripts/Util/HazardSlow.cs
parent
95935f37
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
15 deletions
+28
-15
Assets/Scripts/Birb/Jump.cs
Assets/Scripts/Birb/Jump.cs
+11
-13
Assets/Scripts/Util/HazardSlow.cs
Assets/Scripts/Util/HazardSlow.cs
+17
-2
No files found.
Assets/Scripts/Birb/Jump.cs
View file @
49af132d
using
UnityEngine
;
using
UnityEngine
;
using
System.Collections
;
using
System.Collections.Generic
;
...
...
@@ -14,7 +15,6 @@ public class Jump : AbstractBehavior {
get
{
return
jumpRequested
;}
}
bool
jumpRequested
;
bool
jumpBlocked
;
int
airJumpsMade
=
0
;
Walk
walk
;
...
...
@@ -27,6 +27,8 @@ public class Jump : AbstractBehavior {
void
Update
()
{
if
(!
jumpRequested
&&
inputState
.
GetButtonPressed
(
inputButtons
[
0
]))
{
jumpRequested
=
true
;
if
(
jumpHeight
==
0
)
animator
.
SetTrigger
(
"jump failed"
);
}
float
jumpState
;
Vector2
vel
=
body
.
velocity
;
...
...
@@ -36,7 +38,7 @@ public class Jump : AbstractBehavior {
jumpState
=
0
;
}
jumpState
=
Mathf
.
Sqrt
(
jumpState
);
animator
.
SetFloat
(
"jump state"
,
jumpState
);
animator
.
SetFloat
(
"jump state"
,
jumpState
);
// reset air jumps when on ground
if
(
collisionState
.
onGround
)
{
airJumpsMade
=
0
;
...
...
@@ -44,7 +46,7 @@ public class Jump : AbstractBehavior {
}
void
FixedUpdate
()
{
if
(
jumpRequested
)
{
if
(
jumpRequested
)
{
Activate
();
jumpRequested
=
false
;
}
...
...
@@ -53,11 +55,6 @@ public class Jump : AbstractBehavior {
public
void
Activate
()
{
if
(
collisionState
.
onGround
)
{
// ground jump
<<<<<<<
HEAD
airJumpsMade
=
0
;
=======
>>>>>>>
d984067ea55e6a0191c6cb7033212e7268955de1
Vector2
vel
=
body
.
velocity
;
vel
.
y
=
GetJumpVelocity
(
jumpHeight
);
body
.
velocity
=
vel
;
...
...
@@ -89,8 +86,9 @@ public class Jump : AbstractBehavior {
return
Mathf
.
Sqrt
(-
2
*
gravity
*
height
);
}
void
OnCollisionEnter2D
(
Collision2D
other
)
{
airJumpsMade
=
0
;
}
}
void
OnCollisionEnter2D
(
Collision2D
other
)
{
airJumpsMade
=
0
;
}
}
\ No newline at end of file
Assets/Scripts/Util/HazardSlow.cs
View file @
49af132d
...
...
@@ -6,10 +6,15 @@ public class HazardSlow : AbstractBehavior {
//Remember to give prefabs that have this script a "slowHazard" tag.
float
slowfactor
;
public
float
slowedSpeed
;
float
jumpHeightHold
;
//Holds the jumpHeight current value.
float
wallJumpHeightHold
;
//Holds the wallJumpHeight current value.
bool
valuesHeld
;
void
Awake
()
{
slowfactor
=
2.0f
;
valuesHeld
=
false
;
}
void
OnTriggerEnter2D
(
Collider2D
other
){
...
...
@@ -17,7 +22,15 @@ public class HazardSlow : AbstractBehavior {
if
(
other
.
tag
==
"Player"
){
other
.
GetComponent
<
Walk
>().
speed
/=
slowfactor
;
other
.
GetComponent
<
Jump
>
().
enabled
=
false
;
//other.GetComponent<Jump> ().enabled = false;
if
(!
valuesHeld
)
{
jumpHeightHold
=
other
.
GetComponent
<
Jump
>
().
jumpHeight
;
wallJumpHeightHold
=
other
.
GetComponent
<
Jump
>
().
wallJumpHeight
;
valuesHeld
=
true
;
}
other
.
GetComponent
<
Jump
>
().
jumpHeight
=
0
;
other
.
GetComponent
<
Jump
>
().
wallJumpHeight
=
0
;
}
}
void
OnTriggerExit2D
(
Collider2D
other
){
...
...
@@ -25,7 +38,9 @@ public class HazardSlow : AbstractBehavior {
if
(
other
.
tag
==
"Player"
){
other
.
GetComponent
<
Walk
>().
speed
*=
slowfactor
;
other
.
GetComponent
<
Jump
>().
enabled
=
true
;
//other.GetComponent<Jump>().enabled = true;
other
.
GetComponent
<
Jump
>
().
jumpHeight
=
jumpHeightHold
;
other
.
GetComponent
<
Jump
>
().
wallJumpHeight
=
wallJumpHeightHold
;
}
}
...
...
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