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
bb345224
Commit
bb345224
authored
Mar 02, 2017
by
Tanner Grehawick
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dashrefactor'
parents
150022c1
9a5e7b4e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
60 additions
and
12 deletions
+60
-12
Assets/Scenes/CharacterTest.unity
Assets/Scenes/CharacterTest.unity
+0
-0
Assets/Scripts/Birb/Dash.cs
Assets/Scripts/Birb/Dash.cs
+21
-2
Assets/Scripts/Breakable.cs
Assets/Scripts/Breakable.cs
+19
-0
Assets/Scripts/Breakable.cs.meta
Assets/Scripts/Breakable.cs.meta
+2
-2
Assets/Scripts/Enemy/ToggleEnemy.cs
Assets/Scripts/Enemy/ToggleEnemy.cs
+3
-3
Assets/Scripts/Player/CameraFollow.cs.meta
Assets/Scripts/Player/CameraFollow.cs.meta
+12
-0
Assets/Scripts/Util/Hazard.cs
Assets/Scripts/Util/Hazard.cs
+1
-1
Assets/Scripts/Util/WinTrigger.cs
Assets/Scripts/Util/WinTrigger.cs
+2
-2
ProjectSettings/ProjectVersion.txt
ProjectSettings/ProjectVersion.txt
+0
-2
No files found.
Assets/Scenes/CharacterTest.unity
View file @
bb345224
No preview for this file type
Assets/Scripts/Birb/Dash.cs
View file @
bb345224
...
...
@@ -7,13 +7,15 @@ using UnityEngine;
public
class
Dash
:
AbstractBehavior
{
private
float
lastDash
;
public
float
coolDown
=
1f
;
public
float
dashforce
=
5
;
public
float
holdTime
=
0.4f
;
public
float
minVelocity
=
0.5f
;
public
float
minVelocity
=
0.5f
;
private
bool
_isDashing
=
false
;
private
Transform
dashMeter
;
private
float
lastDash
;
private
CircleCollider2D
collider
;
// Call to check if currently dashing
public
bool
isDashing
...
...
@@ -27,6 +29,7 @@ public class Dash : AbstractBehavior {
void
Start
()
{
dashMeter
=
GameObject
.
FindGameObjectWithTag
(
"DashMeter"
).
transform
;
collider
=
GetComponent
<
CircleCollider2D
>();
}
void
Update
()
{
...
...
@@ -60,6 +63,9 @@ public class Dash : AbstractBehavior {
float
initialGrav
=
body
.
gravityScale
;
body
.
gravityScale
=
0
;
// results for circle cast
RaycastHit2D
[]
results
=
new
RaycastHit2D
[
8
];
// Decelerate
for
(
float
i
=
0
;
i
<
holdTime
;
i
+=
Time
.
deltaTime
)
{
// Calculate velocity
...
...
@@ -72,6 +78,19 @@ public class Dash : AbstractBehavior {
// Apply velocity
body
.
velocity
=
targetVel
;
float
checkDistance
=
body
.
velocity
.
magnitude
*
Time
.
deltaTime
;
// check for breakable in front
int
resultCount
=
Physics2D
.
CircleCastNonAlloc
(
body
.
position
,
collider
.
radius
,
body
.
velocity
,
results
,
checkDistance
);
for
(
int
r
=
0
;
r
<
resultCount
;
r
++)
{
RaycastHit2D
result
=
results
[
r
];
Breakable
breakable
=
result
.
collider
.
GetComponent
<
Breakable
>();
if
(
breakable
!=
null
&&
breakable
.
breakOnPlayerDash
)
{
breakable
.
Break
();
}
}
// Wait
yield
return
new
WaitForEndOfFrame
();
}
...
...
Assets/Scripts/Breakable.cs
0 → 100644
View file @
bb345224
using
UnityEngine
;
using
UnityEngine.Events
;
using
System.Collections
;
using
System.Collections.Generic
;
// breakable object
public
class
Breakable
:
MonoBehaviour
{
public
bool
breakOnPlayerDash
=
false
;
public
UnityEvent
onBreak
;
public
void
Break
()
{
// handle animation and stuff here
onBreak
.
Invoke
();
Destroy
(
gameObject
);
}
}
Assets/Scripts/
Enemy/ToggleEnemy
.cs.meta
→
Assets/Scripts/
Breakable
.cs.meta
View file @
bb345224
fileFormatVersion: 2
guid:
c7ca022d5dbae2f43a9a23d5ca5ee019
timeCreated: 1487
785552
guid:
5e257b3931afd45bf902bc96e4c29208
timeCreated: 1487
900567
licenseType: Free
MonoImporter:
serializedVersion: 2
...
...
Assets/Scripts/Enemy/ToggleEnemy.cs
View file @
bb345224
...
...
@@ -6,13 +6,13 @@ public class ToggleEnemy : MonoBehaviour {
Camera
cam
;
public
List
<
Collider2D
>
enemies
;
//
List<BaseEnemy> disabledEnemies;
//
List<BaseEnemy> disabledEnemies;
// Use this for initialization
void
Start
()
{
cam
=
Camera
.
main
;
}
// Update is called once per frame
void
Update
()
{
//get frustum of camera
...
...
@@ -22,7 +22,7 @@ public class ToggleEnemy : MonoBehaviour {
//check if enemy is in view of camera and disable if not
if
(!
GeometryUtility
.
TestPlanesAABB
(
camPlanes
,
enemies
[
i
].
bounds
))
{
//
enemies[i].gameObject.GetComponent<BaseEnemy>().enabled = false;
//
enemies[i].gameObject.GetComponent<BaseEnemy>().enabled = false;
enemies
.
Remove
(
enemies
[
i
]);
}
}
...
...
Assets/Scripts/
Enemy
.meta
→
Assets/Scripts/
Player/CameraFollow.cs
.meta
View file @
bb345224
fileFormatVersion: 2
guid: f5015e51666ab3b4e9a750c868d6703b
folderAsset: yes
timeCreated: 1487785551
guid: 11ecc39894ce94f60a0a952e704c611f
timeCreated: 1487896949
licenseType: Free
DefaultImporter:
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Util/Hazard.cs
View file @
bb345224
...
...
@@ -8,7 +8,7 @@ public class Hazard : MonoBehaviour {
{
if
(
other
.
CompareTag
(
"Player"
))
{
other
.
GetComponent
<
Birb
>().
Die
();
//
other.GetComponent<Birb>().Die ();
}
}
}
Assets/Scripts/Util/WinTrigger.cs
View file @
bb345224
...
...
@@ -7,10 +7,10 @@ public class WinTrigger : MonoBehaviour {
//checks for incoming collision
public
void
OnTriggerEnter2D
(
Collider2D
other
)
{
if
(
other
.
gameObject
.
name
==
"Player"
)
//ensuring it's the player
if
(
other
.
gameObject
.
name
==
"Player"
)
//ensuring it's the player
{
//tell manager it has won
//GameEditor.Win();
//
GameEditor.Win();
//Debug.Log("Victory Achieved");
}
}
...
...
ProjectSettings/ProjectVersion.txt
deleted
100644 → 0
View file @
150022c1
m_EditorVersion: 5.3.5f1
m_StandardAssetsVersion: 0
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