diff --git a/Assets/Scripts/Actions.cs b/Assets/Scripts/Actions.cs new file mode 100644 index 0000000000000000000000000000000000000000..2d07e909e3e5b99166a35bed27aa37e55bd205c6 --- /dev/null +++ b/Assets/Scripts/Actions.cs @@ -0,0 +1,133 @@ +using UnityEngine; +using System.Collections; +using UnityEngine.UI; + +public class Actions : MonoBehaviour { + + public GameObject[] abilities = new GameObject[4]; // The array full of the character's abilities + 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 Color abilityUnusable; + private Color abilityUsable; + + public int fireballSpeed = 5; + + public bool waterShieldUsable = true; + private float waterShieldTimer = 0.0f; + public float waterShieldCooldown = 5.0f; + + private Vector3 LastInput = new Vector2(0, -1); + + void Start () { + + abilitiesImage = GameObject.FindGameObjectWithTag ("Cycle").GetComponent(); + // Set the initial ability to something so that it's not null + CycleAbility(); + + abilityUnusable = new Color(255.0f,255.0f,255.0f,0.5f); + abilityUsable = new Color(255.0f,255.0f,255.0f,1.0f); + } + + + + void Update () { + + RaycastHit2D hit = Physics2D.Raycast(transform.position, GetLastDirection()); + Debug.DrawRay(transform.position, GetLastDirection(), Color.red); + + // Constantly check where the player is facing + GetLastDirection(); + + if(Input.GetButtonDown("Fire1")) { + UseAbility(currentAbility.name); + } + + if(waterShieldUsable == false) { + waterShieldTimer += Time.deltaTime; + if(waterShieldTimer > waterShieldCooldown) { + waterShieldUsable = true; + waterShieldTimer = 0.0f; + } + + abilitiesImage.GetComponent().color = abilityUnusable; + } else { + abilitiesImage.GetComponent().color = abilityUsable; + } + + // If the player presses the button to choose an ability... + if(Input.GetButtonDown("Fire2")) { + + // Increment the counter + abilitiesCounter++; + + // Call the ChooseAbility() function + CycleAbility(); + } + } + + + + void CycleAbility() { + + // If the counter goes out of range of the array's size, reset it to 0 + if(abilitiesCounter > abilities.Length - 1) { + abilitiesCounter = 0; + } + + // Set the currentAbility to the one chosen by the abilitiesCounter + currentAbility = abilities[abilitiesCounter]; + + // Set the image of the gameObject of the ability equal to the picture of the currentAbility + abilitiesImage.GetComponent().sprite = currentAbility.GetComponent().sprite; + } + + + + public void UseAbility(string myCurrentAbility) { + + switch(myCurrentAbility) { + + case "Ability - Fireball": + GameObject clone = Instantiate (currentAbility, this.transform.position, Quaternion.identity) as GameObject; + clone.GetComponent().move = LastInput; + clone.GetComponent().speed = fireballSpeed; + break; + + case "Ability - Water Shield": + if(waterShieldUsable == true) { + GameObject myShield = (GameObject)Instantiate(currentAbility, transform.position, Quaternion.identity); + WaterShield waterShield = myShield.GetComponent(); + + waterShieldUsable = false; + } + break; + + case "Ability - Rock": + Debug.Log("Throwing a rock!"); + break; + + case "Ability - Breath of Air": + Debug.Log("Casting breath of air!"); + break; + } + } + + + + public Vector2 GetLastDirection() { + + Vector3 input = new Vector3 (Input.GetAxisRaw ("Horizontal"), Input.GetAxisRaw ("Vertical"), 0); + + if (input.x == 0 && input.y == 0) { + //do nothing + } else if (input.y != 0) { + LastInput = new Vector2 (0, input.y); + } else { + LastInput = new Vector2 (input.x, 0); + } + + return LastInput; + } +} diff --git a/Assets/Scripts/Actions.cs.meta b/Assets/Scripts/Actions.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..95880c25f882500ba9b60d93227ac9aa53e878ed --- /dev/null +++ b/Assets/Scripts/Actions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2da14653c84e44ccbaeb9e90ae797be1 +timeCreated: 1475808355 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Boss.cs b/Assets/Scripts/Boss.cs new file mode 100644 index 0000000000000000000000000000000000000000..2daaae8ade26c4c60898f4123f86f5f99c99e43b --- /dev/null +++ b/Assets/Scripts/Boss.cs @@ -0,0 +1,72 @@ +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(); + 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().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); + } +} diff --git a/Assets/Scripts/Boss.cs.meta b/Assets/Scripts/Boss.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..0ebb2b6ded4005fb7aa4a51d4101a82439b673e3 --- /dev/null +++ b/Assets/Scripts/Boss.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1637c8df298d2ef448fab676ee167299 +timeCreated: 1479433452 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/EnemyProjectile.cs b/Assets/Scripts/EnemyProjectile.cs new file mode 100644 index 0000000000000000000000000000000000000000..ca7871c64e25f5ae4aaf8104fb9b8172e9c57ec6 --- /dev/null +++ b/Assets/Scripts/EnemyProjectile.cs @@ -0,0 +1,12 @@ +using UnityEngine; +using System.Collections; + +public class EnemyProjectile : MonoBehaviour { + + // TEMPORARY + // Does not damage player + + void OnCollisionEnter2D(Collision2D col) { + Destroy(gameObject); + } +} diff --git a/Assets/Scripts/EnemyProjectile.cs.meta b/Assets/Scripts/EnemyProjectile.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..a2e11be5526350d56799a367cf54944fca6e0113 --- /dev/null +++ b/Assets/Scripts/EnemyProjectile.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 70394bdca2dfef640ba97907cce063d9 +timeCreated: 1479437610 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/FireballMove.cs b/Assets/Scripts/FireballMove.cs new file mode 100644 index 0000000000000000000000000000000000000000..80c8ea0b2f5f10bc6976898a1dd884acc28fb7b8 --- /dev/null +++ b/Assets/Scripts/FireballMove.cs @@ -0,0 +1,20 @@ +using UnityEngine; +using System.Collections; + +public class FireballMove : MonoBehaviour { + public float speed; + private Rigidbody2D fireRB; + public Vector2 move; + + // Use this for initialization + void Start () { + fireRB = GetComponent (); + fireRB.velocity = (move * speed); + + } + + void OnCollisionEnter2D(Collision2D c){ + + Destroy (gameObject); + } +} diff --git a/Assets/Scripts/FireballMove.cs.meta b/Assets/Scripts/FireballMove.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..ff0878ba300f9695411359a96ffb11cadba44086 --- /dev/null +++ b/Assets/Scripts/FireballMove.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b245668d1f70fae43ba9905676a8f688 +timeCreated: 1477616043 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/FireballProjectile.cs b/Assets/Scripts/FireballProjectile.cs new file mode 100644 index 0000000000000000000000000000000000000000..9b9f22666c87c405a8b2e4ef70ee6a0d122b077e --- /dev/null +++ b/Assets/Scripts/FireballProjectile.cs @@ -0,0 +1,23 @@ +using UnityEngine; +using System.Collections; + +public class FireballProjectile : MonoBehaviour { + + [HideInInspector] + public float speed; + private Rigidbody2D rb; + public Vector2 move; + + + + void Start () { + rb = GetComponent(); + rb.velocity = (move * speed); + } + + + + void OnCollisionEnter2D(Collision2D c){ + Destroy (this.gameObject); + } +} diff --git a/Assets/Scripts/FireballProjectile.cs.meta b/Assets/Scripts/FireballProjectile.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..c5b3c4eb11fdc6cc3b92e8aaac53617970bcc7f6 --- /dev/null +++ b/Assets/Scripts/FireballProjectile.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 72a2310fc34324288bd211ed6e4ca008 +timeCreated: 1478834992 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/MenuActions.cs b/Assets/Scripts/MenuActions.cs new file mode 100644 index 0000000000000000000000000000000000000000..4f50c3ce37b20608878b4d2f27378cad647c761d --- /dev/null +++ b/Assets/Scripts/MenuActions.cs @@ -0,0 +1,19 @@ +using UnityEngine; +using System.Collections; + +public class MenuActions : MonoBehaviour { + + public string levelName = "player_animation_test"; + + public void NewGame(){ + Application.LoadLevel (levelName); + } + + public void LoadGame(){ + Application.LoadLevel (levelName); + } + + public void QuitGame(){ + Application.Quit (); + } +} diff --git a/Assets/Scripts/MenuActions.cs.meta b/Assets/Scripts/MenuActions.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..61a394e224998b6a3fc1a0f717ebaa9716156d43 --- /dev/null +++ b/Assets/Scripts/MenuActions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ee297bebcf01cc54c91c6680e27c1943 +timeCreated: 1478831417 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/RandomSprite.cs b/Assets/Scripts/RandomSprite.cs new file mode 100644 index 0000000000000000000000000000000000000000..26a9814b219ac8b97b684eba9321beced824c0e0 --- /dev/null +++ b/Assets/Scripts/RandomSprite.cs @@ -0,0 +1,12 @@ +using UnityEngine; +using System.Collections; + +public class RandomSprite : MonoBehaviour { + + public Sprite[] tiles; + + // Use this for initialization + void Start () { + GetComponent().sprite = tiles[Random.Range(0, tiles.Length)]; + } +} diff --git a/Assets/Scripts/RandomSprite.cs.meta b/Assets/Scripts/RandomSprite.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..3d3f8e7a296d32ba29ef12a433a8d42de425f033 --- /dev/null +++ b/Assets/Scripts/RandomSprite.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 19ce3dd12dc0bee4492ca01b39754add +timeCreated: 1478220172 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/WalkParticles.cs b/Assets/Scripts/WalkParticles.cs new file mode 100644 index 0000000000000000000000000000000000000000..f1d342a0b72ccf546412b173c65959ee01703421 --- /dev/null +++ b/Assets/Scripts/WalkParticles.cs @@ -0,0 +1,34 @@ +using UnityEngine; +using System.Collections; + +public class WalkParticles : MonoBehaviour { + + private ParticleSystem ps; + private ParticleSystem.EmissionModule module; + private HeroMobility hm; + public float speedThreshold = 0.001f; + + + // Use this for initialization + void Start () { + ps = GetComponentInChildren(); + module = ps.emission; + hm = GetComponent(); + } + + // Update is called once per frame + void LateUpdate () { + if (hm.deltaPos.sqrMagnitude > speedThreshold) { + if (!ps.isPlaying) { + ps.Simulate(0.0f, true, false); + module.enabled = true; + ps.Play(); + } + } else { + if (ps.isPlaying) { + module.enabled = false; + ps.Stop(); + } + } + } +} diff --git a/Assets/Scripts/WalkParticles.cs.meta b/Assets/Scripts/WalkParticles.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..9c997b413a4c70a252b9db4bb2114f42cf714e1f --- /dev/null +++ b/Assets/Scripts/WalkParticles.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c02d1600d235a814fa07fba8e5b0289f +timeCreated: 1477012137 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/WaterShield.cs b/Assets/Scripts/WaterShield.cs new file mode 100644 index 0000000000000000000000000000000000000000..ea4513d1e91e034b9512dc07d67e7ee413e4239b --- /dev/null +++ b/Assets/Scripts/WaterShield.cs @@ -0,0 +1,53 @@ +using UnityEngine; +using System.Collections; + +public class WaterShield : MonoBehaviour { + + private float timerOfShield = 0.0f; + public float durationOfShield = 2.0f; + public GameObject projectilePrefab; + public int projectileSpeed = 5; + public int numberOfProjectiles = 5; + private GameObject player; + [HideInInspector] + public Vector2 playerDirection; + + void Start() { + player = GameObject.FindGameObjectWithTag("Player"); + } + + void Update () { + playerDirection = player.GetComponent().GetLastDirection(); + transform.position = player.transform.position; + + timerOfShield += Time.deltaTime; + + if(timerOfShield >= durationOfShield) { + Explode(); + Destroy(this.gameObject); + } + } + + + + void Explode() { + for(int i = 0; i < numberOfProjectiles; i++) { + GameObject waterShieldProjectile = (GameObject)Instantiate(projectilePrefab, transform.position, Quaternion.identity); + waterShieldProjectile.GetComponent().direction = Rotate(playerDirection, 20 - (i * 10)); + waterShieldProjectile.GetComponent().speed = projectileSpeed; + } + } + + + + public Vector2 Rotate(Vector2 v, float degrees) { + float sin = Mathf.Sin(degrees * Mathf.Deg2Rad); + float cos = Mathf.Cos(degrees * Mathf.Deg2Rad); + + float tx = v.x; + float ty = v.y; + v.x = (cos * tx) - (sin * ty); + v.y = (sin * tx) + (cos * ty); + return v; + } +} diff --git a/Assets/Scripts/WaterShield.cs.meta b/Assets/Scripts/WaterShield.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..e02de3d87338e54517a2834cd289bdcd1de32504 --- /dev/null +++ b/Assets/Scripts/WaterShield.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1978d911fc9b14ab4939f59a8c10d901 +timeCreated: 1477009011 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/WaterShieldProjectile.cs b/Assets/Scripts/WaterShieldProjectile.cs new file mode 100644 index 0000000000000000000000000000000000000000..6583e2241440eda61ff5674812d5bf031823dcbc --- /dev/null +++ b/Assets/Scripts/WaterShieldProjectile.cs @@ -0,0 +1,23 @@ +using UnityEngine; +using System.Collections; + +public class WaterShieldProjectile : MonoBehaviour { + + [HideInInspector] + public float speed; + private Rigidbody2D rb; + [HideInInspector] + public Vector2 direction; + + + void Start () { + rb = GetComponent(); + rb.velocity = (direction * speed); + } + + + + void OnCollisionEnter2D(Collision2D c){ + Destroy (this.gameObject); + } +} diff --git a/Assets/Scripts/WaterShieldProjectile.cs.meta b/Assets/Scripts/WaterShieldProjectile.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..1c7e8e0ec91c3020c34dac76550aab506da18627 --- /dev/null +++ b/Assets/Scripts/WaterShieldProjectile.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 46b11dc52679b4ddab143bfb8fb3e812 +timeCreated: 1478844869 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/ZSort.cs b/Assets/Scripts/ZSort.cs new file mode 100644 index 0000000000000000000000000000000000000000..53e2cd843ccda25dfd080d11079a6586418b7c47 --- /dev/null +++ b/Assets/Scripts/ZSort.cs @@ -0,0 +1,22 @@ +using UnityEngine; +using System.Collections; + +public class ZSort : MonoBehaviour { + + private SpriteRenderer sr; + public float offset = 0; + + void Start () { + sr = GetComponent(); + if (sr) { + sr.sortingLayerName = "Moving"; + offset += sr.sprite.bounds.extents.y; + } + } + + void LateUpdate () { + if (sr) { + sr.sortingOrder = (int)((transform.position.y - offset) * -100); + } + } +} diff --git a/Assets/Scripts/ZSort.cs.meta b/Assets/Scripts/ZSort.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..990de672fe4d44fe654715add3bdcede63174c8d --- /dev/null +++ b/Assets/Scripts/ZSort.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b087211a03739c44b8dd007f71f5a81d +timeCreated: 1478222920 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sounds/.gitkeep b/Assets/Sounds/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391