Commit b1e3f2ec authored by Andrew Van Buren's avatar Andrew Van Buren

Merge branch 'master' of git.gmu.edu:gadig/birb into designmerge

parents bae6a988 4c528b44
......@@ -256,7 +256,7 @@ AnimationClip:
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
......
......@@ -13,43 +13,49 @@ AnimatorController:
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: walk state
m_Type: 1
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: on ground
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: on wall
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: is wall sliding
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: is dashing
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: is dead
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: jump failed
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
......@@ -295,6 +301,30 @@ AnimatorStateTransition:
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &1101284597369093138
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: jump failed
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102617517530729818}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 0.013712956
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &1101321834524063170
AnimatorStateTransition:
m_ObjectHideFlags: 1
......@@ -556,6 +586,27 @@ AnimatorStateTransition:
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &1101807632871170194
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102586274863957820}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.1
m_TransitionOffset: 0
m_ExitTime: 0.375
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &1101807685430122190
AnimatorStateTransition:
m_ObjectHideFlags: 1
......@@ -925,6 +976,7 @@ AnimatorState:
m_Transitions:
- {fileID: 1101744012158545528}
- {fileID: 1101951043015843990}
- {fileID: 1101284597369093138}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
......@@ -947,7 +999,8 @@ AnimatorState:
m_Name: Failed Jump
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_Transitions:
- {fileID: 1101807632871170194}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
......@@ -1043,13 +1096,13 @@ AnimatorStateMachine:
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 1102129416387156292}
m_Position: {x: 0, y: 96, z: 0}
m_Position: {x: 12, y: 96, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102841603111430702}
m_Position: {x: 240, y: 12, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102617517530729818}
m_Position: {x: 0, y: 288, z: 0}
m_Position: {x: 240, y: 180, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102221100325450442}
m_Position: {x: 0, y: 336, z: 0}
......
......@@ -128,7 +128,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 4045396142737594, guid: db5e8a1e71fe955478cf51c1f332836a, type: 2}
propertyPath: m_RootOrder
value: 3
value: 2
objectReference: {fileID: 0}
- target: {fileID: 114188013725194092, guid: db5e8a1e71fe955478cf51c1f332836a,
type: 2}
......@@ -523,6 +523,10 @@ Prefab:
propertyPath: m_SortingLayerID
value: 1402309851
objectReference: {fileID: 0}
- target: {fileID: 4854154196249452, guid: 06c0373dffdb8dd41acff4ae0187b9ce, type: 2}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 06c0373dffdb8dd41acff4ae0187b9ce, type: 2}
m_IsPrefabParent: 0
......@@ -710,7 +714,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 4340557329068104, guid: 294123b456fc7644cb0e5b11c0d5a750, type: 2}
propertyPath: m_RootOrder
value: 9
value: 6
objectReference: {fileID: 0}
- target: {fileID: 1139495411747536, guid: 294123b456fc7644cb0e5b11c0d5a750, type: 2}
propertyPath: m_Name
......@@ -958,7 +962,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 7
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &599106627 stripped
Transform:
......@@ -1304,7 +1308,7 @@ ParticleSystem:
m_GameObject: {fileID: 920148520}
serializedVersion: 5
lengthInSec: 0.1
speed: 1
simulationSpeed: 1
looping: 1
prewarm: 0
playOnAwake: 1
......@@ -4343,6 +4347,7 @@ GameObject:
- component: {fileID: 1118525861}
- component: {fileID: 1118525860}
- component: {fileID: 1118525859}
- component: {fileID: 1118525863}
m_Layer: 5
m_Name: UI
m_TagString: Untagged
......@@ -4425,6 +4430,19 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!114 &1118525863
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1118525858}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 44c3e6c59af00de45b780a24a2fee2f3, type: 3}
m_Name:
m_EditorClassIdentifier:
inputButtons:
disableScripts: []
--- !u!1 &1149247900
GameObject:
m_ObjectHideFlags: 1
......@@ -4474,7 +4492,7 @@ Transform:
- {fileID: 2100709142}
- {fileID: 920148521}
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &1165012031 stripped
Transform:
......@@ -4507,7 +4525,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &1183635617 stripped
Transform:
......@@ -4540,6 +4558,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1288981517}
- {fileID: 47748003}
- {fileID: 1328617950}
- {fileID: 216344514}
- {fileID: 407241375}
......@@ -4589,11 +4608,10 @@ Transform:
- {fileID: 1727240399}
- {fileID: 992313189}
- {fileID: 182365961}
- {fileID: 47748003}
- {fileID: 242534398}
- {fileID: 762486095}
m_Father: {fileID: 0}
m_RootOrder: 8
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &1212815706 stripped
Transform:
......@@ -4679,7 +4697,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 4319832483873770, guid: 09bfee321e702c547b2cfc7221e70cd0, type: 2}
propertyPath: m_RootOrder
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 212386094942055944, guid: 09bfee321e702c547b2cfc7221e70cd0,
type: 2}
......@@ -5046,7 +5064,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a707327fed739e346b5480ab597dbb23, type: 3}
m_Name:
m_EditorClassIdentifier:
smoothSpeed: 1
--- !u!1001 &1398096626
Prefab:
m_ObjectHideFlags: 0
......@@ -5983,7 +6000,7 @@ ParticleSystem:
m_GameObject: {fileID: 2100709141}
serializedVersion: 5
lengthInSec: 0.1
speed: 1
simulationSpeed: 1
looping: 0
prewarm: 0
playOnAwake: 1
......
using UnityEngine;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
......@@ -26,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;
......@@ -35,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;
......@@ -43,7 +46,7 @@ public class Jump : AbstractBehavior {
}
void FixedUpdate() {
if (jumpRequested) {
if (jumpRequested) {
Activate();
jumpRequested = false;
}
......@@ -83,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
......@@ -13,8 +13,10 @@ public class Birb : AbstractBehavior {
private string jumpAnim = "";
private string fallAnim = "";
private string wallAnim = "";
private string dashAnim = "";
private string hurtAnim = "";
private string grndDashAnim = "";
private string airDashAnim= "";
private string hurtAnim = "Hurt.anim";
private string jumpBlockAnim="Failed Jump.anim";
public enum AnimState
{
......@@ -23,13 +25,17 @@ public class Birb : AbstractBehavior {
Jumping,
Falling,
OnWall,
Dashing,
Hurt
GrndDashing,
AirDashing,
Hurt,
OnGround,
JumpBlocked
//Add the necessary animation states.
}
AnimState state;
public AnimState state;
bool enemyHit;
bool canJump; //Replace with the "jumpblock" boolean in player manager.
void Start()
{
......@@ -37,7 +43,7 @@ public class Birb : AbstractBehavior {
void Update()
{
ContinueState ();
//ContinueState ();
}
public void Die()
......@@ -50,95 +56,128 @@ public class Birb : AbstractBehavior {
GameManager.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;
}
// //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.GrndDashing:
// animator.Play (grndDashAnim);
// break;
//
// case AnimState.AirDashing:
// animator.Play (airDashAnim);
// break;
//
// case AnimState.JumpBlocked:
// animator.Play (jumpBlockAnim);
// break;
// }
// this.state = state;
// }
// //Determines if the player must keep its current animation state.
// void ContinueState()
// {
// switch (state)
// {
// case AnimState.Idle:
// StateSwitch ();
// break;
// case AnimState.Walking:
// if (!StateSwitch ())
// EnterState (AnimState.Idle);
// break;
//
// case AnimState.GrndDashing:
// if (!((body.gravityScale==0)&&(collisionState.onGround)))
// StateSwitch ();
// break;
//
// case AnimState.AirDashing:
// if (!((body.gravityScale == 0) && (!collisionState.onGround)))
// StateSwitch ();
// break;
//
// case AnimState.Hurt:
// if (!enemyHit) //Check if enemy hit.
// StateSwitch ();
// break;
//
// case AnimState.OnWall:
// if (!collisionState.onWall)
// StateSwitch ();
// break;
//
// case AnimState.Jumping:
// if (!(body.velocity.y > 0))
// StateSwitch ();
// break;
//
// case AnimState.Falling:
// if (!(body.velocity.y < 0))
// StateSwitch ();
// break;
//
// }
// }
//
// void ExitState()
// {
// }
// //Determines the animation state the player must switch to.
// bool StateSwitch()
// {
// if ((inputState.GetButtonPressed (Buttons.A) && collisionState.onGround) || (body.velocity.y > 0)) //If the player is jumping or is in the air with a positive y velocity.
// SetOrKeepState (AnimState.Jumping);
// else if ((inputState.GetButtonPressed (Buttons.A) && collisionState.onGround) && (!canJump)) //Replace canJump with the "jumpBlocked" boolean in player manager.
// SetOrKeepState (AnimState.JumpBlocked);
// 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.
// {
// if (collisionState.onGround)
// SetOrKeepState (AnimState.GrndDashing);
// else
// SetOrKeepState (AnimState.AirDashing);
// }
//
// 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;
// }
}
......@@ -8,7 +8,10 @@ public class Hazard : MonoBehaviour {
{
if (other.CompareTag("Player"))
{
other.GetComponent<Birb>().Die ();
other.gameObject.SendMessage("Die", SendMessageOptions.DontRequireReceiver);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HazardSlow : AbstractBehavior {
//Remember to give prefabs that have this script a "slowHazard" tag.
float slowfactor;
float jumpHeightHold; //Holds the jumpHeight current value.
float wallJumpHeightHold; //Holds the wallJumpHeight current value.
static bool valuesHeld;
static int slowHazardCount;
void Awake()
{
slowfactor = 2.0f;
valuesHeld = false;
slowHazardCount = 0;
}
void OnTriggerEnter2D(Collider2D other){
if(other.tag=="Player"){
if (slowHazardCount == 0)
{
other.GetComponent<Walk> ().speed /= slowfactor;
//other.GetComponent<Jump> ().enabled = false;
if (!valuesHeld) {
jumpHeightHold = other.GetComponent<Jump> ().jumpHeight;
wallJumpHeightHold = other.GetComponent<Jump> ().wallJumpHeight;
valuesHeld = true;