From b179b44888e2ce399abb93eab69b28690f7caf72 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Sat, 19 Nov 2016 17:07:51 -0500 Subject: [PATCH] Organized Folders --- Assets/Scripts/Actions.cs | 133 +++++++++++++++++++ Assets/Scripts/Actions.cs.meta | 12 ++ Assets/Scripts/Boss.cs | 72 ++++++++++ Assets/Scripts/Boss.cs.meta | 12 ++ Assets/Scripts/EnemyProjectile.cs | 12 ++ Assets/Scripts/EnemyProjectile.cs.meta | 12 ++ Assets/Scripts/FireballMove.cs | 20 +++ Assets/Scripts/FireballMove.cs.meta | 12 ++ Assets/Scripts/FireballProjectile.cs | 23 ++++ Assets/Scripts/FireballProjectile.cs.meta | 12 ++ Assets/Scripts/MenuActions.cs | 19 +++ Assets/Scripts/MenuActions.cs.meta | 12 ++ Assets/Scripts/RandomSprite.cs | 12 ++ Assets/Scripts/RandomSprite.cs.meta | 12 ++ Assets/Scripts/WalkParticles.cs | 34 +++++ Assets/Scripts/WalkParticles.cs.meta | 12 ++ Assets/Scripts/WaterShield.cs | 53 ++++++++ Assets/Scripts/WaterShield.cs.meta | 12 ++ Assets/Scripts/WaterShieldProjectile.cs | 23 ++++ Assets/Scripts/WaterShieldProjectile.cs.meta | 12 ++ Assets/Scripts/ZSort.cs | 22 +++ Assets/Scripts/ZSort.cs.meta | 12 ++ Assets/Sounds/.gitkeep | 0 23 files changed, 555 insertions(+) create mode 100644 Assets/Scripts/Actions.cs create mode 100644 Assets/Scripts/Actions.cs.meta create mode 100644 Assets/Scripts/Boss.cs create mode 100644 Assets/Scripts/Boss.cs.meta create mode 100644 Assets/Scripts/EnemyProjectile.cs create mode 100644 Assets/Scripts/EnemyProjectile.cs.meta create mode 100644 Assets/Scripts/FireballMove.cs create mode 100644 Assets/Scripts/FireballMove.cs.meta create mode 100644 Assets/Scripts/FireballProjectile.cs create mode 100644 Assets/Scripts/FireballProjectile.cs.meta create mode 100644 Assets/Scripts/MenuActions.cs create mode 100644 Assets/Scripts/MenuActions.cs.meta create mode 100644 Assets/Scripts/RandomSprite.cs create mode 100644 Assets/Scripts/RandomSprite.cs.meta create mode 100644 Assets/Scripts/WalkParticles.cs create mode 100644 Assets/Scripts/WalkParticles.cs.meta create mode 100644 Assets/Scripts/WaterShield.cs create mode 100644 Assets/Scripts/WaterShield.cs.meta create mode 100644 Assets/Scripts/WaterShieldProjectile.cs create mode 100644 Assets/Scripts/WaterShieldProjectile.cs.meta create mode 100644 Assets/Scripts/ZSort.cs create mode 100644 Assets/Scripts/ZSort.cs.meta create mode 100644 Assets/Sounds/.gitkeep diff --git a/Assets/Scripts/Actions.cs b/Assets/Scripts/Actions.cs new file mode 100644 index 0000000..2d07e90 --- /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 0000000..95880c2 --- /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 0000000..2daaae8 --- /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 0000000..0ebb2b6 --- /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 0000000..ca7871c --- /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 0000000..a2e11be --- /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 0000000..80c8ea0 --- /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 0000000..ff0878b --- /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 0000000..9b9f226 --- /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 0000000..c5b3c4e --- /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 0000000..4f50c3c --- /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 0000000..61a394e --- /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 0000000..26a9814 --- /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 0000000..3d3f8e7 --- /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 0000000..f1d342a --- /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 0000000..9c997b4 --- /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 0000000..ea4513d --- /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 0000000..e02de3d --- /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 0000000..6583e22 --- /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 0000000..1c7e8e0 --- /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 0000000..53e2cd8 --- /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 0000000..990de67 --- /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 0000000..e69de29 -- GitLab