Commit f33d110f authored by Andrew R Van Buren's avatar Andrew R Van Buren

Merge branch 'character' into 'master'

Character

See merge request !38
parents d93cc77b 64d16f00
......@@ -8,6 +8,7 @@ public class Actions : MonoBehaviour {
public GameObject currentAbility = null; // Which ability is currently active
private int abilitiesCounter = 0; // A counter which lets you cycle through the abilities
private Image abilitiesImage; // Picture which shows which ability it active
private GameObject myShield;
public int health;
......@@ -21,6 +22,9 @@ public class Actions : MonoBehaviour {
public float waterShieldCooldown = 5.0f;
public float fireballCooldown = 0.5f;
private AudioSource audio;
public AudioClip fireball;
private Vector3 LastInput = new Vector2(0, -1);
void Start () {
......@@ -31,6 +35,8 @@ public class Actions : MonoBehaviour {
abilityUnusable = new Color(255.0f,255.0f,255.0f,0.5f);
abilityUsable = new Color(255.0f,255.0f,255.0f,1.0f);
audio = GetComponent<AudioSource>();
}
......@@ -94,6 +100,9 @@ public class Actions : MonoBehaviour {
case "Ability - Fireball":
if (waterShieldUsable == true) {
StartCoroutine(move());
audio.PlayOneShot (fireball, 0.5f);
GameObject clone = Instantiate (currentAbility, this.transform.position, Quaternion.identity) as GameObject;
clone.GetComponent<FireballProjectile> ().move = LastInput;
clone.GetComponent<FireballProjectile> ().speed = fireballSpeed;
......@@ -105,7 +114,7 @@ public class Actions : MonoBehaviour {
case "Ability - Water Shield":
if(waterShieldUsable == true) {
GameObject myShield = (GameObject)Instantiate(currentAbility, transform.position, Quaternion.identity);
myShield = (GameObject)Instantiate(currentAbility, transform.position, Quaternion.identity);
WaterShield waterShield = myShield.GetComponent<WaterShield>();
waterShieldTimer = waterShieldCooldown;
......@@ -141,6 +150,14 @@ public class Actions : MonoBehaviour {
}
void GetHit(int d){
health -= d;
if(myShield == null)
health -= d;
}
IEnumerator move(){
this.GetComponent<HeroMobility> ().canMove = false;
yield return new WaitForSeconds (0.2f);
this.GetComponent<HeroMobility> ().canMove = true;
}
}
......@@ -20,7 +20,6 @@ public class FireballProjectile : MonoBehaviour {
void OnCollisionEnter2D(Collision2D c){
if(c.transform.CompareTag("Enemy")){
Debug.Log ("hit");
c.transform.SendMessage ("GetHit", damage);
}
......
......@@ -20,6 +20,8 @@ public class HeroMobility : MonoBehaviour {
public AudioClip[] grassFootsteps;
public AudioClip[] waterFootsteps;
public bool canMove = true;
void Start () {
playerRB = GetComponent<Rigidbody2D> ();
anim = GetComponent<Animator> ();
......@@ -33,14 +35,15 @@ public class HeroMobility : MonoBehaviour {
playerMove (input);
if(deltaPos.magnitude > 0.001f && Time.time > lastFootstep) {
lastFootstep += footStepDelay;
lastFootstep = Time.time + footStepDelay;
Footstep();
}
}
void playerMove (Vector2 input){
//Controls hero movement in all 8 directions
playerRB.MovePosition((Vector2)transform.position + input.normalized*playerSpeed);
if(canMove)
playerRB.MovePosition((Vector2)transform.position + input.normalized*playerSpeed);
deltaPos = playerRB.position - lastPos;
lastPos = playerRB.position;
......@@ -57,3 +60,4 @@ public class HeroMobility : MonoBehaviour {
}
}
}
......@@ -12,8 +12,15 @@ public class WaterShield : MonoBehaviour {
[HideInInspector]
public Vector2 playerDirection;
public AudioSource audio;
public AudioClip start;
public AudioClip end;
void Start() {
player = GameObject.FindGameObjectWithTag("Player");
audio = GetComponent<AudioSource>();
audio.PlayOneShot (start, 0.5f);
}
void Update () {
......@@ -24,6 +31,7 @@ public class WaterShield : MonoBehaviour {
if(timerOfShield >= durationOfShield) {
Explode();
player.GetComponent<AudioSource>().PlayOneShot (end, 0.5f);
Destroy(this.gameObject);
}
}
......@@ -51,3 +59,4 @@ public class WaterShield : MonoBehaviour {
return v;
}
}
......@@ -20,7 +20,6 @@ public class WaterShieldProjectile : MonoBehaviour {
void OnCollisionEnter2D(Collision2D c){
if(c.transform.CompareTag("Enemy")){
Debug.Log ("hit");
c.transform.SendMessage ("GetHit", damage);
}
......
......@@ -31,9 +31,9 @@ public class TurtleActions : MonoBehaviour {
StartCoroutine (dead ());
}
//attack
if (DistanceToPlayer ().magnitude < 5 && canShoot == true) {
timer = 0;
Debug.Log ("1");
StartCoroutine (attack ());
canShoot = false;
}
......@@ -91,31 +91,30 @@ public class TurtleActions : MonoBehaviour {
//Animation Control
void AminateMovement() {
if (timer < 0.5) {
animator.SetBool ("isAttacking", true);
} else {
animator.SetFloat("X", Mathf.Abs(DirectionToPlayer().x));
animator.SetFloat("Y", DirectionToPlayer().y);
animator.SetBool ("isAttacking", false);
Vector2 scale = new Vector2(1, 1);
if(DirectionToPlayer().x != 0)
scale.x = DirectionToPlayer().x;
transform.localScale = scale;
}
}
IEnumerator attack(){
animator.SetBool ("isAttacking", true);
Vector2 dir = DirectionToPlayer ();
yield return new WaitForSeconds (0.3f);
if (animator.GetBool ("isDead") == false) {
Debug.Log ("2");
GameObject clone = Instantiate (projectile, this.transform.position, Quaternion.identity) as GameObject;
clone.GetComponent<TurtleProjectile> ().move = dir;
clone.GetComponent<TurtleProjectile> ().move = DirectionToPlayer ();
clone.GetComponent<TurtleProjectile> ().speed = speed;
}
yield return new WaitForSeconds (0.25f);
animator.SetBool ("isAttacking", false);
}
IEnumerator dead(){
......
......@@ -20,7 +20,6 @@ public class TurtleProjectile : MonoBehaviour {
void OnCollisionEnter2D(Collision2D c){
if(c.transform.CompareTag("Player")){
Debug.Log ("hit");
c.transform.SendMessage ("GetHit", damage);
}
......
fileFormatVersion: 2
guid: d82b991eb2507f84bb413aed23f404c7
folderAsset: yes
timeCreated: 1475761198
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: ad4bf73242f185d489361f9c27f4f371
timeCreated: 1479606563
licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 6d2bd061f22ed2a4889cf39e38212518
timeCreated: 1479604851
licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 5d70fb513d8ad3f419f18f41110e52bd
timeCreated: 1479604850
licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 77a6f925311437f438471393208c0ea0
timeCreated: 1479604851
licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
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