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
463aa24f
Commit
463aa24f
authored
Feb 23, 2017
by
Tanner Grehawick
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master' into breakable
parents
32692b5c
1a6a7e32
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
648 additions
and
34 deletions
+648
-34
.vscode/settings.json
.vscode/settings.json
+56
-0
Assets/Prefabs/UI.meta
Assets/Prefabs/UI.meta
+9
-0
Assets/Prefabs/UI/DashMeterBG.prefab
Assets/Prefabs/UI/DashMeterBG.prefab
+0
-0
Assets/Prefabs/UI/DashMeterBG.prefab.meta
Assets/Prefabs/UI/DashMeterBG.prefab.meta
+8
-0
Assets/Scenes/CharacterTest.unity
Assets/Scenes/CharacterTest.unity
+0
-0
Assets/Scripts/Birb.meta
Assets/Scripts/Birb.meta
+3
-3
Assets/Scripts/Birb/Dash.cs
Assets/Scripts/Birb/Dash.cs
+52
-23
Assets/Scripts/Birb/GameManager.cs
Assets/Scripts/Birb/GameManager.cs
+46
-0
Assets/Scripts/Birb/GameManager.cs.meta
Assets/Scripts/Birb/GameManager.cs.meta
+12
-0
Assets/Scripts/Enemy/ToggleEnemy.cs
Assets/Scripts/Enemy/ToggleEnemy.cs
+30
-0
Assets/Scripts/MapEditor/MapEditor.cs
Assets/Scripts/MapEditor/MapEditor.cs
+4
-0
Assets/Scripts/MapEditor/World.cs
Assets/Scripts/MapEditor/World.cs
+6
-1
Assets/Scripts/Player/Birb.cs
Assets/Scripts/Player/Birb.cs
+138
-0
Assets/Scripts/Player/Birb.cs.meta
Assets/Scripts/Player/Birb.cs.meta
+12
-0
Assets/Scripts/Player/CameraFollow.cs
Assets/Scripts/Player/CameraFollow.cs
+66
-0
Assets/Scripts/Player/InputState.cs
Assets/Scripts/Player/InputState.cs
+3
-1
Assets/Scripts/Player/WallSliding.cs
Assets/Scripts/Player/WallSliding.cs
+55
-0
Assets/Scripts/Player/WallSliding.cs.meta
Assets/Scripts/Player/WallSliding.cs.meta
+12
-0
Assets/Scripts/Util/Borders.cs
Assets/Scripts/Util/Borders.cs
+124
-0
Assets/Scripts/Util/Borders.cs.meta
Assets/Scripts/Util/Borders.cs.meta
+12
-0
Assets/Scripts/Util/Hazard.cs.meta
Assets/Scripts/Util/Hazard.cs.meta
+0
-2
Assets/Scripts/Util/WinTrigger.cs.meta
Assets/Scripts/Util/WinTrigger.cs.meta
+0
-2
ProjectSettings/ProjectVersion.txt
ProjectSettings/ProjectVersion.txt
+0
-2
ProjectSettings/TagManager.asset
ProjectSettings/TagManager.asset
+0
-0
No files found.
.vscode/settings.json
0 → 100644
View file @
463aa24f
{
"files.exclude"
:
{
"**/.DS_Store"
:
true
,
"**/.git"
:
true
,
"**/.gitignore"
:
true
,
"**/.gitmodules"
:
true
,
"**/*.booproj"
:
true
,
"**/*.pidb"
:
true
,
"**/*.suo"
:
true
,
"**/*.user"
:
true
,
"**/*.userprefs"
:
true
,
"**/*.unityproj"
:
true
,
"**/*.dll"
:
true
,
"**/*.exe"
:
true
,
"**/*.pdf"
:
true
,
"**/*.mid"
:
true
,
"**/*.midi"
:
true
,
"**/*.wav"
:
true
,
"**/*.gif"
:
true
,
"**/*.ico"
:
true
,
"**/*.jpg"
:
true
,
"**/*.jpeg"
:
true
,
"**/*.png"
:
true
,
"**/*.psd"
:
true
,
"**/*.tga"
:
true
,
"**/*.tif"
:
true
,
"**/*.tiff"
:
true
,
"**/*.3ds"
:
true
,
"**/*.3DS"
:
true
,
"**/*.fbx"
:
true
,
"**/*.FBX"
:
true
,
"**/*.lxo"
:
true
,
"**/*.LXO"
:
true
,
"**/*.ma"
:
true
,
"**/*.MA"
:
true
,
"**/*.obj"
:
true
,
"**/*.OBJ"
:
true
,
"**/*.asset"
:
true
,
"**/*.cubemap"
:
true
,
"**/*.flare"
:
true
,
"**/*.mat"
:
true
,
"**/*.meta"
:
true
,
"**/*.prefab"
:
true
,
"**/*.unity"
:
true
,
"build/"
:
true
,
"Build/"
:
true
,
"Library/"
:
true
,
"library/"
:
true
,
"obj/"
:
true
,
"Obj/"
:
true
,
"ProjectSettings/"
:
true
,
"temp/"
:
true
,
"Temp/"
:
true
}
}
\ No newline at end of file
Assets/Prefabs/UI.meta
0 → 100644
View file @
463aa24f
fileFormatVersion: 2
guid: a58ae0e00797d794297ccb4228d903bf
folderAsset: yes
timeCreated: 1487292663
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
Assets/Prefabs/UI/DashMeterBG.prefab
0 → 100644
View file @
463aa24f
File added
Assets/Prefabs/UI/DashMeterBG.prefab.meta
0 → 100644
View file @
463aa24f
fileFormatVersion: 2
guid: fa60ffd6264804b43bc03430e8dd86b1
timeCreated: 1487292666
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
Assets/Scenes/CharacterTest.unity
View file @
463aa24f
No preview for this file type
Assets/Scripts/Birb.meta
View file @
463aa24f
fileFormatVersion: 2
guid:
2057902e730664aacbc88367b9c3b892
guid:
d31ebdd80916bea45bd33409fe585333
folderAsset: yes
timeCreated: 148668
723
7
timeCreated: 148668
681
7
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
assetBundleVariant:
\ No newline at end of file
Assets/Scripts/Birb/Dash.cs
View file @
463aa24f
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
// Sets dash velocity and smoothly decelerates to a minimum velocity
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
;
// Should be called every frame
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
// Sets dash velocity and smoothly decelerates to a minimum velocity
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
;
private
bool
_isDashing
=
false
;
private
Transform
dashMeter
;
// Call to check if currently dashing
public
bool
isDashing
{
get
{
return
_isDashing
;
}
private
set
{
_isDashing
=
value
;
}
}
void
Start
()
{
dashMeter
=
GameObject
.
FindGameObjectWithTag
(
"DashMeter"
).
transform
;
}
// Should be called every frame
public
void
DashCheck
()
{
// Button pressed, not in cooldown, and not on wall
if
(
inputState
.
GetButtonValue
(
inputButtons
[
0
])
&&
Time
.
time
>
lastDash
&&
!
collisionState
.
onWall
)
{
StartCoroutine
(
DoDash
());
}
}
// Dash
UpdateUI
();
}
void
UpdateUI
()
{
float
progress
=
1
-
((
lastDash
-
Time
.
time
)/
coolDown
);
dashMeter
.
localScale
=
new
Vector2
(
Mathf
.
Clamp01
(
progress
),
dashMeter
.
localScale
.
y
);
}
// Dash
IEnumerator
DoDash
()
{
// Cooldown
lastDash
=
Time
.
time
+
coolDown
;
// Is dashing
isDashing
=
true
;
// Set initial velocity
body
.
velocity
=
transform
.
right
*
dashforce
;
// Disable gravity
...
...
@@ -39,7 +63,6 @@ public class Dash : AbstractBehavior {
if
(
body
.
velocity
.
magnitude
<
minVelocity
||
collisionState
.
onWall
)
{
// Velocity is low enough or collision with wall
Debug
.
Log
(
"Stopped"
);
break
;
}
...
...
@@ -51,5 +74,11 @@ public class Dash : AbstractBehavior {
// Restore gravity
body
.
gravityScale
=
initialGrav
;
}
}
// Is not dashing
isDashing
=
false
;
}
public
void
DashIgnoringCooldown
()
{
StartCoroutine
(
DoDash
());
}
}
Assets/Scripts/Birb/GameManager.cs
0 → 100644
View file @
463aa24f
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
GameManager
:
SingletonBehaviour
<
GameManager
>
{
private
bool
_isPaused
;
//Manages game state. Pause, death, win, and changing levels.
public
bool
isPaused
{
get
{
return
_isPaused
;
}
set
{
_isPaused
=
value
;
if
(
isPaused
)
{
//set timescale back to normal
isPaused
=
false
;
Debug
.
Log
(
"Game is unpaused"
);
}
else
{
//set timescale to zero
isPaused
=
true
;
Debug
.
Log
(
"Game is paused"
);
}
}
}
public
void
Fail
()
{
Debug
.
Log
(
"You have died"
);
}
public
void
Win
()
{
Debug
.
Log
(
"You won!"
);
}
public
void
ChangeLevel
()
{
Debug
.
Log
(
"Changing level state"
);
}
}
Assets/Scripts/Birb/GameManager.cs.meta
0 → 100644
View file @
463aa24f
fileFormatVersion: 2
guid: cad3061263b98c140a9a3a49d70204c9
timeCreated: 1486686808
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Enemy/ToggleEnemy.cs
0 → 100644
View file @
463aa24f
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
ToggleEnemy
:
MonoBehaviour
{
Camera
cam
;
public
List
<
Collider2D
>
enemies
;
List
<
BaseEnemy
>
disabledEnemies
;
// Use this for initialization
void
Start
()
{
cam
=
Camera
.
main
;
}
// Update is called once per frame
void
Update
()
{
//get frustum of camera
Plane
[]
camPlanes
=
GeometryUtility
.
CalculateFrustumPlanes
(
cam
);
for
(
int
i
=
0
;
i
<
enemies
.
Count
;
i
++)
{
//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
.
Remove
(
enemies
[
i
]);
}
}
}
}
Assets/Scripts/MapEditor/MapEditor.cs
View file @
463aa24f
...
...
@@ -146,5 +146,9 @@ public class MapEditorEditor : Editor
// Toggle on field
MapEditor
.
On
=
GUILayout
.
Toggle
(
MapEditor
.
On
,
"ON"
);
// Initialize Borders
if
(
GUILayout
.
Button
(
"Initialize Borders"
))
Borders
.
initializeAll
();
}
}
Assets/Scripts/MapEditor/World.cs
View file @
463aa24f
...
...
@@ -37,6 +37,11 @@ public static class World
setupWithGOs
();
}
public
static
void
setup
()
{
setup
(
50
,
50
,
3
);
}
private
static
void
instantiateMap
()
{
map
=
new
GameObject
[
width
][][];
...
...
@@ -113,7 +118,7 @@ public static class World
{
if
(
x
<
0
||
y
<
0
||
z
<
0
||
x
>=
width
||
y
>=
height
||
z
>=
depth
)
{
Debug
.
LogWarning
(
"Pos out of bounds!"
);
//
Debug.LogWarning("Pos out of bounds!");
return
false
;
}
return
true
;
...
...
Assets/Scripts/Player/Birb.cs
0 → 100644
View file @
463aa24f
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine.SceneManagement
;
public
class
Birb
:
AbstractBehavior
{
//Add the name of the animations to be played.
private
string
idleAnim
=
""
;
private
string
walkAnim
=
""
;
private
string
jumpAnim
=
""
;
private
string
fallAnim
=
""
;
private
string
wallAnim
=
""
;
private
string
dashAnim
=
""
;
private
string
hurtAnim
=
""
;
public
enum
AnimState
{
Idle
,
Walking
,
Jumping
,
Falling
,
OnWall
,
Dashing
,
Hurt
//Add the necessary animation states.
}
AnimState
state
;
bool
enemyHit
;
void
Start
()
{
}
void
Update
()
{
ContinueState
();
}
public
void
Die
()
{
animator
.
Play
(
hurtAnim
);
GameManager
.
instance
.
Fail
();
}
//Determines if the animation state must change.
void
SetOrKeepState
(
AnimState
state
)
{
if
(
this
.
state
==
state
)
return
;
EnterState
(
state
);
}
//Plays the corresponding animation to each state.
void
EnterState
(
AnimState
state
)
{
ExitState
();
switch
(
state
)
{
case
AnimState
.
Idle
:
animator
.
Play
(
idleAnim
);
break
;
case
AnimState
.
Walking
:
animator
.
Play
(
walkAnim
);
break
;
case
AnimState
.
Jumping
:
animator
.
Play
(
jumpAnim
);
break
;
case
AnimState
.
Falling
:
animator
.
Play
(
fallAnim
);
break
;
case
AnimState
.
OnWall
:
animator
.
Play
(
wallAnim
);
break
;
case
AnimState
.
Dashing
:
animator
.
Play
(
dashAnim
);
break
;
}
this
.
state
=
state
;
}
//Determines
void
ContinueState
()
{
switch
(
state
)
{
case
AnimState
.
Idle
:
StateSwitch
();
break
;
case
AnimState
.
Walking
:
if
(!
StateSwitch
())
EnterState
(
AnimState
.
Idle
);
break
;
case
AnimState
.
Dashing
:
if
(
body
.
gravityScale
!=
0
)
StateSwitch
();
break
;
case
AnimState
.
Hurt
:
if
(!
enemyHit
)
//Check if enemy hit.
StateSwitch
();
break
;
case
AnimState
.
OnWall
:
if
(!
collisionState
.
onWall
)
StateSwitch
();
break
;
}
}
void
ExitState
()
{
}
bool
StateSwitch
()
{
if
(
inputState
.
GetButtonPressed
(
Buttons
.
A
)
&&
collisionState
.
onGround
)
SetOrKeepState
(
AnimState
.
Jumping
);
else
if
((
inputState
.
GetButtonPressed
(
Buttons
.
Right
)
||
inputState
.
GetButtonPressed
(
Buttons
.
Left
))
&&
collisionState
.
onGround
)
SetOrKeepState
(
AnimState
.
Walking
);
else
if
((
inputState
.
GetButtonPressed
(
Buttons
.
X
))
&&
body
.
gravityScale
==
0
)
//Add a way of knowing if the dash is off CD.
SetOrKeepState
(
AnimState
.
Dashing
);
else
if
((
body
.
velocity
.
y
<
0
))
SetOrKeepState
(
AnimState
.
Falling
);
else
if
(
enemyHit
)
SetOrKeepState
(
AnimState
.
Hurt
);
else
if
(
collisionState
.
onWall
)
SetOrKeepState
(
AnimState
.
OnWall
);
else
return
false
;
return
true
;
}
}
Assets/Scripts/Player/Birb.cs.meta
0 → 100644
View file @
463aa24f
fileFormatVersion: 2
guid: de3aa9fc98a1afc4ea1040f7e728697b
timeCreated: 1486687809
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Player/CameraFollow.cs
0 → 100644
View file @
463aa24f
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
CameraFollow
:
SingletonBehaviour
<
CameraFollow
>
{
Camera
cameraObj
;
public
float
smoothSpeed
;
private
float
MaxHeight
;
private
float
MaxWidth
;
private
float
MinHeight
;
private
float
MinWidth
;
private
float
OZ
;
// Use this for initialization
void
Start
()
{
cameraObj
=
Camera
.
main
;
float
camHeight
=
cameraObj
.
orthographicSize
*
2
;
float
camWidth
=
cameraObj
.
aspect
*
camHeight
;
MaxHeight
=
World
.
Height
-
camHeight
/
2
;
MaxWidth
=
World
.
Width
-
camWidth
/
2
;
MinHeight
=
World
.
Height
+
camHeight
/
2
;
MinWidth
=
World
.
Width
+
camHeight
/
2
;
OZ
=
cameraObj
.
transform
.
position
.
z
;
}
// Update is called once per frame
void
Update
()
{
Vector3
targetPOS
=
Vector3
.
Lerp
(
cameraObj
.
transform
.
position
,
transform
.
position
,
smoothSpeed
*
Time
.
deltaTime
);
/*
//camera dimensions and center
float camHeight = cameraObj.orthographicSize * 2;
float camWidth = cameraObj.aspect * camHeight;
if(targetPOS.y + camHeight > World.Height) //if camera is above bounds
{
targetPOS.y = (MaxHeight);
}
if(targetPOS.y - camHeight < World.Height) // if below bounds
{
targetPOS.y = (MinHeight);
}
if(targetPOS.x + camWidth > World.Width) //if right of bounds
{
targetPOS.x = (MaxWidth);
}
if(targetPOS.x - camWidth < World.Width) // if left of bounds
{
targetPOS.x = (MinWidth);
}*/
cameraObj
.
transform
.
position
=
new
Vector3
(
targetPOS
.
x
,
targetPOS
.
y
,
OZ
);
}
}
Assets/Scripts/Player/InputState.cs
View file @
463aa24f
...
...
@@ -67,7 +67,9 @@ public class InputState : MonoBehaviour {
public
float
GetButtonHoldTime
(
Buttons
key
){
if
(
buttonStates
.
ContainsKey
(
key
)){
return
buttonStates
[
key
].
holdTime
;
}
else
{
}
else
{
return
0
;
}
}
...
...
Assets/Scripts/Player/WallSliding.cs
0 → 100644
View file @
463aa24f
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
WallSliding
:
AbstractBehavior
{
[
SerializeField
]
private
float
speed
;
[
SerializeField
]
private
float
delay
;
[
SerializeField
]
private
float
wallJumpForce
;
[
SerializeField
]
private
int
leftButtonID
;
[
SerializeField
]
private
int
rightButtonID
;
[
SerializeField
]
private
int
jumpButtonID
;
private
float
previousGravity
;
private
bool
_isSliding
;
private
bool
isEnding
;
private
bool
isJumping
;
public
void
Activate
()
{
ToggleScripts
(
false
);
previousGravity
=
body
.
gravityScale
;
body
.
velocity
.
Set
(
body
.
velocity
.
x
,
speed
);
body
.
gravityScale
=
0
;
_isSliding
=
true
;
isEnding
=
false
;
isJumping
=
false
;
StartCoroutine
(
CheckForEnd
());
}
private
IEnumerator
CheckForEnd
()
{
while
(
_isSliding
)
{
if
(
ButtonCheck
(
leftButtonID
)
||
ButtonCheck
(
rightButtonID
))
{
if
(!
isEnding
)
StartCoroutine
(
EndWithDelay
());
}
if
(
ButtonCheck
(
jumpButtonID
))
{
if
(!
isJumping
)
JumpOffWall
();
if
(!
isEnding
)
EndSliding
();
}
yield
return
new
WaitForFixedUpdate
();
}
}
private
bool
ButtonCheck
(
int
button
)
{
return
inputState
.
GetButtonValue
(
inputButtons
[
button
]);
}
private
void
JumpOffWall
()
{
isJumping
=
true
;
body
.
AddForce
(
new
Vector2
((
int
)
inputState
.
direction
,
0
)
*
wallJumpForce
);
}
private
IEnumerator
EndWithDelay
()
{
isEnding
=
true
;
yield
return
new
WaitForSeconds
(
delay
);
EndSliding
();
}
private
void
EndSliding
()
{
body
.
gravityScale
=
previousGravity
;
_isSliding
=
false
;
isJumping
=
false
;
ToggleScripts
(
true
);
}
}
Assets/Scripts/Player/WallSliding.cs.meta
0 → 100644
View file @
463aa24f
fileFormatVersion: 2
guid: 604ce289803c4154f97ae0b77cd158b7
timeCreated: 1486689234
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Util/Borders.cs
0 → 100644
View file @
463aa24f
using
UnityEngine
;
using
UnityEditor
;