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
guid: b641e451acdc12541acef94eaf7d4c8e
timeCreated: 1478834377
guid: 0ba698c06397ec44e8ab14d4f7c8487a
timeCreated: 1479439371
licenseType: Free
NativeFormatImporter:
userData:
......
fileFormatVersion: 2
guid: 5841dd40cb838a648bbe46a681bc8748
timeCreated: 1479432922
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
......@@ -9,6 +9,8 @@ public class Actions : MonoBehaviour {
private int abilitiesCounter = 0; // A counter which lets you cycle through the abilities
private Image abilitiesImage; // Picture which shows which ability it active
public int health;
private Color abilityUnusable;
private Color abilityUsable;
......@@ -17,6 +19,7 @@ public class Actions : MonoBehaviour {
public bool waterShieldUsable = true;
private float waterShieldTimer = 0.0f;
public float waterShieldCooldown = 5.0f;
public float fireballCooldown = 0.5f;
private Vector3 LastInput = new Vector2(0, -1);
......@@ -45,8 +48,8 @@ public class Actions : MonoBehaviour {
}
if(waterShieldUsable == false) {
waterShieldTimer += Time.deltaTime;
if(waterShieldTimer > waterShieldCooldown) {
waterShieldTimer -= Time.deltaTime;
if(waterShieldTimer <= 0) {
waterShieldUsable = true;
waterShieldTimer = 0.0f;
}
......@@ -90,9 +93,14 @@ public class Actions : MonoBehaviour {
switch(myCurrentAbility) {
case "Ability - Fireball":
GameObject clone = Instantiate (currentAbility, this.transform.position, Quaternion.identity) as GameObject;
clone.GetComponent<FireballProjectile>().move = LastInput;
clone.GetComponent<FireballProjectile>().speed = fireballSpeed;
if (waterShieldUsable == true) {
GameObject clone = Instantiate (currentAbility, this.transform.position, Quaternion.identity) as GameObject;
clone.GetComponent<FireballProjectile> ().move = LastInput;
clone.GetComponent<FireballProjectile> ().speed = fireballSpeed;
waterShieldTimer = fireballCooldown;
waterShieldUsable = false;
}
break;
case "Ability - Water Shield":
......@@ -100,6 +108,7 @@ public class Actions : MonoBehaviour {
GameObject myShield = (GameObject)Instantiate(currentAbility, transform.position, Quaternion.identity);
WaterShield waterShield = myShield.GetComponent<WaterShield>();
waterShieldTimer = waterShieldCooldown;
waterShieldUsable = false;
}
break;
......@@ -130,4 +139,8 @@ public class Actions : MonoBehaviour {
return LastInput;
}
void GetHit(int d){
health -= d;
}
}
using UnityEngine;
using System.Collections;
public class Boss : MonoBehaviour {
private Rigidbody2D rb;
public float speed = 1f;
public GameObject[] waypoints;
private Transform currentWaypoint;
public float distanceThreshold = 0.5f;
public GameObject projectile;
public float attackCooldown = 2.0f;
public float attackRandom = 1.0f;
private float lastAttack = 0;
public float projectileSpeed = 5;
public int health = 100;
public GameObject diety;
// Use this for initialization
void Start () {
waypoints = GameObject.FindGameObjectsWithTag("Waypoint");
rb = GetComponent<Rigidbody2D>();
PickWaypoint();
}
// Update is called once per frame
void Update () {
if (currentWaypoint) {
if (Vector2.Distance(transform.position, currentWaypoint.position) < distanceThreshold) {
PickWaypoint();
} else {
Vector2 dir = currentWaypoint.position - transform.position;
Vector2 force = new Vector2(dir.x, dir.y) * speed;
rb.AddForce(Vector2.ClampMagnitude(force, speed));
}
}
if(Time.time > lastAttack) {
lastAttack = Time.time + attackCooldown + Random.Range(0, attackRandom);
Shoot(0);
Shoot(90);
Shoot(180);
Shoot(270);
}
}
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) {
health -= health;
if (health <= 0) {
Die();
}
}
void Die() {
Instantiate(diety, transform.position, Quaternion.identity);
Destroy(gameObject);
}
}
using UnityEngine;
using System.Collections;
public class Boss : MonoBehaviour {
private Rigidbody2D rb;
public float speed = 75f;
public float dangerSpeedMultiplier = 2f;
public int dangerTheshold = 10;
public GameObject[] waypoints;
private Transform currentWaypoint;
public float distanceThreshold = 0.5f;
public GameObject projectile;
public float attackCooldown = 2.0f;
public float attackRandom = 1.0f;
private float lastAttack = 0;
public float projectileSpeed = 5;
public AudioClip attackSound;
public int health = 100;
public GameObject diety;
public Color damageColor;
public float damageColorSpeed = 8;
public AudioClip damageSound;
public Color dangerColor;
private SpriteRenderer sr;
private Animator animator;
public AudioClip bossMusic;
private AudioSource bgm;
private AudioSource audioSource;
GameObject player;
private bool triggered = false;
public float triggerDist = 10f;
// Use this for initialization
void Start () {
waypoints = GameObject.FindGameObjectsWithTag("Waypoint");
rb = GetComponent<Rigidbody2D>();
sr = GetComponent<SpriteRenderer>();
animator = GetComponent<Animator>();
player = GameObject.FindGameObjectWithTag("Player");
PickWaypoint();
rb.isKinematic = true;
bgm = Camera.main.GetComponentInChildren<AudioSource>();
audioSource = GetComponent<AudioSource>();
}
// Update is called once per frame
void Update () {
if (currentWaypoint && triggered) {
if (Vector2.Distance(transform.position, currentWaypoint.position) < distanceThreshold) {
PickWaypoint();
} else {
Vector2 dir = currentWaypoint.position - transform.position;
Vector2 force = new Vector2(dir.x, dir.y) * speed * (health < dangerTheshold ? dangerSpeedMultiplier : 1);
rb.AddForce(Vector2.ClampMagnitude(force, speed * (health < dangerTheshold ? dangerSpeedMultiplier : 1)));
}
}
if(Time.time > lastAttack) {
lastAttack = Time.time + (attackCooldown + Random.Range(0, attackRandom)) / (health < dangerTheshold ? dangerSpeedMultiplier : 1);
StartCoroutine(Attack());
}
// Set color
sr.color = Color.Lerp(sr.color, (health < dangerTheshold ? dangerColor : Color.white), Time.deltaTime * damageColorSpeed);
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 {
[HideInInspector]
public float speed;
public int damage = 1;
private Rigidbody2D rb;
public Vector2 move;
......@@ -18,6 +19,11 @@ public class FireballProjectile : MonoBehaviour {
void OnCollisionEnter2D(Collision2D c){
if(c.transform.CompareTag("Enemy")){
Debug.Log ("hit");
c.transform.SendMessage ("GetHit", damage);
}
Destroy (this.gameObject);
}
}
using UnityEngine;
using System.Collections;
public class HeroMobility : MonoBehaviour {
public float playerSpeed = 1f;
private Rigidbody2D playerRB;
Animator anim;
private Vector2 lastPos;
public Vector2 deltaPos;
void Start () {
playerRB = GetComponent<Rigidbody2D> ();
anim = GetComponent<Animator> ();
lastPos = playerRB.position;
}
// Update is called once per frame
void FixedUpdate () {
Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
playerMove (input);
}
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;
}
}
using UnityEngine;
using System.Collections;
public class HeroMobility : MonoBehaviour {
public enum Footsteps {
GRASS,
WATER
}
public float playerSpeed = 1f;
private Rigidbody2D playerRB;
Animator anim;
private Vector2 lastPos;
public Vector2 deltaPos;
private float lastFootstep;
public float footStepDelay = 0.3f;
public Footsteps footsetps = Footsteps.GRASS;
private AudioSource audioSource;
public AudioClip[] grassFootsteps;
public AudioClip[] waterFootsteps;
void Start () {
playerRB = GetComponent<Rigidbody2D> ();
anim = GetComponent<Animator> ();
audioSource = GetComponent<AudioSource>();
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;
public class WaterShieldProjectile : MonoBehaviour {
[HideInInspector]
public int damage = 1;
public float speed;
private Rigidbody2D rb;
[HideInInspector]
......@@ -18,6 +19,11 @@ public class WaterShieldProjectile : MonoBehaviour {
void OnCollisionEnter2D(Collision2D c){
if(c.transform.CompareTag("Enemy")){
Debug.Log ("hit");
c.transform.SendMessage ("GetHit", damage);
}
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:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
enableMipMap: 0
linearTexture: 0
correctGamma: 0
fadeOut: 0
......@@ -29,7 +29,7 @@ TextureImporter:
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
filterMode: 0
aniso: 16
mipBias: -1
wrapMode: 1
......@@ -44,7 +44,7 @@ TextureImporter:
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 10
spritePixelsToUnits: 16
alphaIsTransparency: 1
textureType: 8
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
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: 1
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: []
outline: []
spritePackingTag:
userData:
assetBundleName: