Commit e6747f5f authored by Eby Komenan's avatar Eby Komenan

add Birb

parent 724f20d8
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 ();
}
IEnumerator ExecuteAfterTime(float time)
{
yield return new WaitForSeconds(time);
animator.Play (hurtAnim);
Die ();
}
public void Die()
{
GameManager.Instance.fail ();
//SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
//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;
/*
case AnimState.Hurt:
animator.Play (hurtAnim);
StartCoroutine (ExecuteAfterTime (3.0f));
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;
}
public
}
fileFormatVersion: 2
guid: de3aa9fc98a1afc4ea1040f7e728697b
timeCreated: 1486687809
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -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;
}
}
......
<<<<<<< Updated upstream
m_EditorVersion: 5.5.0f3
\ No newline at end of file
m_EditorVersion: 5.5.0f3
=======
m_EditorVersion: 5.5.1f1
>>>>>>> Stashed changes
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment