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

Merge branch 'character' into 'master'

Character

Added more boss stuff and player sounds (missing attack sounds/melee)

See merge request !37
parents 17ee1245 008e8a97
fileFormatVersion: 2
guid: 3204d6a83813aa040b2ea1895f486060
folderAsset: yes
timeCreated: 1479432947
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2 fileFormatVersion: 2
guid: b641e451acdc12541acef94eaf7d4c8e guid: 0ba698c06397ec44e8ab14d4f7c8487a
timeCreated: 1478834377 timeCreated: 1479439371
licenseType: Free licenseType: Free
NativeFormatImporter: NativeFormatImporter:
userData: userData:
......
fileFormatVersion: 2
guid: 5841dd40cb838a648bbe46a681bc8748
timeCreated: 1479432922
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
...@@ -9,6 +9,8 @@ public class Actions : MonoBehaviour { ...@@ -9,6 +9,8 @@ public class Actions : MonoBehaviour {
private int abilitiesCounter = 0; // A counter which lets you cycle through the abilities private int abilitiesCounter = 0; // A counter which lets you cycle through the abilities
private Image abilitiesImage; // Picture which shows which ability it active private Image abilitiesImage; // Picture which shows which ability it active
public int health;
private Color abilityUnusable; private Color abilityUnusable;
private Color abilityUsable; private Color abilityUsable;
...@@ -17,6 +19,7 @@ public class Actions : MonoBehaviour { ...@@ -17,6 +19,7 @@ public class Actions : MonoBehaviour {
public bool waterShieldUsable = true; public bool waterShieldUsable = true;
private float waterShieldTimer = 0.0f; private float waterShieldTimer = 0.0f;
public float waterShieldCooldown = 5.0f; public float waterShieldCooldown = 5.0f;
public float fireballCooldown = 0.5f;
private Vector3 LastInput = new Vector2(0, -1); private Vector3 LastInput = new Vector2(0, -1);
...@@ -45,8 +48,8 @@ public class Actions : MonoBehaviour { ...@@ -45,8 +48,8 @@ public class Actions : MonoBehaviour {
} }
if(waterShieldUsable == false) { if(waterShieldUsable == false) {
waterShieldTimer += Time.deltaTime; waterShieldTimer -= Time.deltaTime;
if(waterShieldTimer > waterShieldCooldown) { if(waterShieldTimer <= 0) {
waterShieldUsable = true; waterShieldUsable = true;
waterShieldTimer = 0.0f; waterShieldTimer = 0.0f;
} }
...@@ -90,9 +93,14 @@ public class Actions : MonoBehaviour { ...@@ -90,9 +93,14 @@ public class Actions : MonoBehaviour {
switch(myCurrentAbility) { switch(myCurrentAbility) {
case "Ability - Fireball": case "Ability - Fireball":
GameObject clone = Instantiate (currentAbility, this.transform.position, Quaternion.identity) as GameObject; if (waterShieldUsable == true) {
clone.GetComponent<FireballProjectile>().move = LastInput; GameObject clone = Instantiate (currentAbility, this.transform.position, Quaternion.identity) as GameObject;
clone.GetComponent<FireballProjectile>().speed = fireballSpeed; clone.GetComponent<FireballProjectile> ().move = LastInput;
clone.GetComponent<FireballProjectile> ().speed = fireballSpeed;
waterShieldTimer = fireballCooldown;
waterShieldUsable = false;
}
break; break;
case "Ability - Water Shield": case "Ability - Water Shield":
...@@ -100,6 +108,7 @@ public class Actions : MonoBehaviour { ...@@ -100,6 +108,7 @@ public class Actions : MonoBehaviour {
GameObject myShield = (GameObject)Instantiate(currentAbility, transform.position, Quaternion.identity); GameObject myShield = (GameObject)Instantiate(currentAbility, transform.position, Quaternion.identity);
WaterShield waterShield = myShield.GetComponent<WaterShield>(); WaterShield waterShield = myShield.GetComponent<WaterShield>();
waterShieldTimer = waterShieldCooldown;
waterShieldUsable = false; waterShieldUsable = false;
} }
break; break;
...@@ -130,4 +139,8 @@ public class Actions : MonoBehaviour { ...@@ -130,4 +139,8 @@ public class Actions : MonoBehaviour {
return LastInput; return LastInput;
} }
void GetHit(int d){
health -= d;
}
} }
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
public class Boss : MonoBehaviour { public class Boss : MonoBehaviour {
private Rigidbody2D rb; private Rigidbody2D rb;
public float speed = 1f; public float speed = 75f;
public GameObject[] waypoints; public float dangerSpeedMultiplier = 2f;
private Transform currentWaypoint; public int dangerTheshold = 10;
public float distanceThreshold = 0.5f; public GameObject[] waypoints;
public GameObject projectile; private Transform currentWaypoint;
public float attackCooldown = 2.0f; public float distanceThreshold = 0.5f;
public float attackRandom = 1.0f; public GameObject projectile;
private float lastAttack = 0; public float attackCooldown = 2.0f;
public float projectileSpeed = 5; public float attackRandom = 1.0f;
public int health = 100; private float lastAttack = 0;
public GameObject diety; public float projectileSpeed = 5;
public AudioClip attackSound;
// Use this for initialization public int health = 100;
void Start () { public GameObject diety;
waypoints = GameObject.FindGameObjectsWithTag("Waypoint"); public Color damageColor;
rb = GetComponent<Rigidbody2D>(); public float damageColorSpeed = 8;
PickWaypoint(); public AudioClip damageSound;
} public Color dangerColor;
private SpriteRenderer sr;
// Update is called once per frame private Animator animator;
void Update () {
if (currentWaypoint) { public AudioClip bossMusic;
if (Vector2.Distance(transform.position, currentWaypoint.position) < distanceThreshold) { private AudioSource bgm;
PickWaypoint();
} else { private AudioSource audioSource;
Vector2 dir = currentWaypoint.position - transform.position;
Vector2 force = new Vector2(dir.x, dir.y) * speed; GameObject player;
rb.AddForce(Vector2.ClampMagnitude(force, speed));
} private bool triggered = false;
} public float triggerDist = 10f;
if(Time.time > lastAttack) { // Use this for initialization
lastAttack = Time.time + attackCooldown + Random.Range(0, attackRandom); void Start () {
waypoints = GameObject.FindGameObjectsWithTag("Waypoint");
Shoot(0); rb = GetComponent<Rigidbody2D>();
Shoot(90); sr = GetComponent<SpriteRenderer>();
Shoot(180); animator = GetComponent<Animator>();
Shoot(270); player = GameObject.FindGameObjectWithTag("Player");
} PickWaypoint();
} rb.isKinematic = true;
bgm = Camera.main.GetComponentInChildren<AudioSource>();
void PickWaypoint() { audioSource = GetComponent<AudioSource>();
currentWaypoint = waypoints[Random.Range(0, waypoints.Length)].transform; }
}
// Update is called once per frame
void Shoot(int angle) { void Update () {
float rad = (angle + 90) * Mathf.Deg2Rad; if (currentWaypoint && triggered) {
Vector2 vel = new Vector2(Mathf.Cos(rad), Mathf.Sin(rad)) * projectileSpeed; if (Vector2.Distance(transform.position, currentWaypoint.position) < distanceThreshold) {
PickWaypoint();
GameObject projectile_clone = Instantiate(projectile, transform.position, Quaternion.identity) as GameObject; } else {
projectile_clone.GetComponent<Rigidbody2D>().velocity = vel; Vector2 dir = currentWaypoint.position - transform.position;
projectile_clone.transform.eulerAngles = new Vector3(0, 0, angle); Vector2 force = new Vector2(dir.x, dir.y) * speed * (health < dangerTheshold ? dangerSpeedMultiplier : 1);
} rb.AddForce(Vector2.ClampMagnitude(force, speed * (health < dangerTheshold ? dangerSpeedMultiplier : 1)));
}
void GetHit(int amount) { }
health -= health;
if (health <= 0) { if(Time.time > lastAttack) {
Die(); lastAttack = Time.time + (attackCooldown + Random.Range(0, attackRandom)) / (health < dangerTheshold ? dangerSpeedMultiplier : 1);
} StartCoroutine(Attack());
} }
void Die() { // Set color
Instantiate(diety, transform.position, Quaternion.identity); sr.color = Color.Lerp(sr.color, (health < dangerTheshold ? dangerColor : Color.white), Time.deltaTime * damageColorSpeed);
Destroy(gameObject);
} if(Vector2.Distance(player.transform.position, transform.position) < triggerDist) {
} if (!triggered) {
bgm.clip = bossMusic;
bgm.Play();
}
triggered = true;
animator.SetBool("Moving", true);
rb.isKinematic = false;
}
}
void PickWaypoint() {
currentWaypoint = waypoints[Random.Range(0, waypoints.Length)].transform;
}
void Shoot(int angle) {
float rad = (angle + 90) * Mathf.Deg2Rad;
Vector2 vel = new Vector2(Mathf.Cos(rad), Mathf.Sin(rad)) * projectileSpeed;
GameObject projectile_clone = Instantiate(projectile, transform.position, Quaternion.identity) as GameObject;
projectile_clone.GetComponent<Rigidbody2D>().velocity = vel;
projectile_clone.transform.eulerAngles = new Vector3(0, 0, angle);
}
void GetHit(int amount) {
if (triggered) {
if (damageSound)
audioSource.PlayOneShot(damageSound);
health -= amount;
sr.color = damageColor;
if (health <= 0) {
Die();
}
}
}
void Die() {
bgm.Stop();
Instantiate(diety, transform.position, Quaternion.identity);
Destroy(gameObject);
}
IEnumerator Attack() {
if (triggered) {
animator.SetBool("Attacking", true);
if(attackSound)
audioSource.PlayOneShot(attackSound);
yield return new WaitForSeconds(0.3f);
Shoot(0);
Shoot(90);
Shoot(180);
Shoot(270);
yield return new WaitForSeconds(0.3f);
animator.SetBool("Attacking", false);
}
}
}
...@@ -5,6 +5,7 @@ public class FireballProjectile : MonoBehaviour { ...@@ -5,6 +5,7 @@ public class FireballProjectile : MonoBehaviour {
[HideInInspector] [HideInInspector]
public float speed; public float speed;
public int damage = 1;
private Rigidbody2D rb; private Rigidbody2D rb;
public Vector2 move; public Vector2 move;
...@@ -18,6 +19,11 @@ public class FireballProjectile : MonoBehaviour { ...@@ -18,6 +19,11 @@ public class FireballProjectile : MonoBehaviour {
void OnCollisionEnter2D(Collision2D c){ void OnCollisionEnter2D(Collision2D c){
if(c.transform.CompareTag("Enemy")){
Debug.Log ("hit");
c.transform.SendMessage ("GetHit", damage);
}
Destroy (this.gameObject); Destroy (this.gameObject);
} }
} }
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
public class HeroMobility : MonoBehaviour { public class HeroMobility : MonoBehaviour {
public float playerSpeed = 1f; public enum Footsteps {
private Rigidbody2D playerRB; GRASS,
Animator anim; WATER
private Vector2 lastPos; }
public Vector2 deltaPos;
public float playerSpeed = 1f;
void Start () { private Rigidbody2D playerRB;
playerRB = GetComponent<Rigidbody2D> (); Animator anim;
anim = GetComponent<Animator> (); private Vector2 lastPos;
lastPos = playerRB.position; public Vector2 deltaPos;
} private float lastFootstep;
public float footStepDelay = 0.3f;
// Update is called once per frame public Footsteps footsetps = Footsteps.GRASS;
void FixedUpdate () { private AudioSource audioSource;
Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
playerMove (input); public AudioClip[] grassFootsteps;
} public AudioClip[] waterFootsteps;
void playerMove (Vector2 input){ void Start () {
//Controls hero movement in all 8 directions playerRB = GetComponent<Rigidbody2D> ();
playerRB.MovePosition((Vector2)transform.position + input.normalized*playerSpeed); anim = GetComponent<Animator> ();
deltaPos = playerRB.position - lastPos; audioSource = GetComponent<AudioSource>();
lastPos = playerRB.position; lastPos = playerRB.position;
}
}
} // Update is called once per frame
void FixedUpdate () {
Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
playerMove (input);
if(deltaPos.magnitude > 0.001f && Time.time > lastFootstep) {
lastFootstep += footStepDelay;
Footstep();
}
}
void playerMove (Vector2 input){
//Controls hero movement in all 8 directions
playerRB.MovePosition((Vector2)transform.position + input.normalized*playerSpeed);
deltaPos = playerRB.position - lastPos;
lastPos = playerRB.position;
}
void Footstep() {
switch (footsetps) {
case Footsteps.GRASS:
audioSource.PlayOneShot(grassFootsteps[Random.Range(0, grassFootsteps.Length)]);
break;
case Footsteps.WATER:
audioSource.PlayOneShot(waterFootsteps[Random.Range(0, waterFootsteps.Length)]);
break;
}
}
}
...@@ -4,6 +4,7 @@ using System.Collections; ...@@ -4,6 +4,7 @@ using System.Collections;
public class WaterShieldProjectile : MonoBehaviour { public class WaterShieldProjectile : MonoBehaviour {
[HideInInspector] [HideInInspector]
public int damage = 1;
public float speed; public float speed;
private Rigidbody2D rb; private Rigidbody2D rb;
[HideInInspector] [HideInInspector]
...@@ -18,6 +19,11 @@ public class WaterShieldProjectile : MonoBehaviour { ...@@ -18,6 +19,11 @@ public class WaterShieldProjectile : MonoBehaviour {
void OnCollisionEnter2D(Collision2D c){ void OnCollisionEnter2D(Collision2D c){
if(c.transform.CompareTag("Enemy")){
Debug.Log ("hit");
c.transform.SendMessage ("GetHit", damage);
}
Destroy (this.gameObject); Destroy (this.gameObject);
} }
} }
fileFormatVersion: 2
guid: ea1a6002dd835b84c8cb196104f29465
timeCreated: 1479605618
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 2b436ec67dcd0974da38a413dae57e1a
timeCreated: 1479594217
licenseType: Free
TextureImporter:
fileIDToRecycleName:
21300000: Gadic_Four_FireAttack_0
21300002: Gadic_Four_FireAttack_1
21300004: Gadic_Four_FireAttack_2
21300006: Gadic_Four_FireAttack_3
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: 0
aniso: 16
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 2
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 16
alphaIsTransparency: 1
textureType: 8
buildTargetSettings: []
spriteSheet:
sprites:
- name: Gadic_Four_FireAttack_0
rect:
serializedVersion: 2
x: 1
y: 3
width: 12
height: 6
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: Gadic_Four_FireAttack_1
rect:
serializedVersion: 2
x: 13
y: 3
width: 12
height: 6
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: Gadic_Four_FireAttack_2
rect:
serializedVersion: 2
x: 25
y: 0
width: 12
height: 9
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: Gadic_Four_FireAttack_3
rect:
serializedVersion: 2
x: 37
y: 0
width: 11
height: 9
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: dada4a93ddd67fc439dcb02a0a37b5e7
timeCreated: 1479594116
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 8
buildTargetSettings: []
spriteSheet:
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
...@@ -7,7 +7,7 @@ TextureImporter: ...@@ -7,7 +7,7 @@ TextureImporter:
serializedVersion: 2 serializedVersion: 2
mipmaps: mipmaps:
mipMapMode: 0 mipMapMode: 0
enableMipMap: 1 enableMipMap: 0
linearTexture: 0 linearTexture: 0
correctGamma: 0 correctGamma: 0
fadeOut: 0 fadeOut: 0
...@@ -29,7 +29,7 @@ TextureImporter: ...@@ -29,7 +29,7 @@ TextureImporter:
textureFormat: -1 textureFormat: -1
maxTextureSize: 2048 maxTextureSize: 2048
textureSettings: textureSettings:
filterMode: -1 filterMode: 0
aniso: 16 aniso: 16
mipBias: -1 mipBias: -1
wrapMode: 1 wrapMode: 1
...@@ -44,7 +44,7 @@ TextureImporter: ...@@ -44,7 +44,7 @@ TextureImporter:
alignment: 0 alignment: 0
spritePivot: {x: 0.5, y: 0.5} spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 10 spritePixelsToUnits: 16
alphaIsTransparency: 1 alphaIsTransparency: 1
textureType: 8 textureType: 8
buildTargetSettings: [] buildTargetSettings: []
......
fileFormatVersion: 2
guid: 5ac09d79e8c125b4b9dda4ea8778ca0e
timeCreated: 1479599773
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0