diff options
author | marcinzelent <marcin@zelent.net> | 2020-02-01 17:06:41 +0100 |
---|---|---|
committer | marcinzelent <marcin@zelent.net> | 2020-02-01 17:06:41 +0100 |
commit | a8fe54592f727ddad05040b82ccb490218682d7c (patch) | |
tree | 324d5be7c1e61a5f19daaf526147d69c6763f47e /nGJ2019/Assets/Scripts | |
parent | 98bb688bd7c709eca3e97c5e9d58415d7df65db3 (diff) |
Renamed to Dragon Dust
Diffstat (limited to 'nGJ2019/Assets/Scripts')
24 files changed, 0 insertions, 1408 deletions
diff --git a/nGJ2019/Assets/Scripts/DragonMovement.cs b/nGJ2019/Assets/Scripts/DragonMovement.cs deleted file mode 100644 index 69be151..0000000 --- a/nGJ2019/Assets/Scripts/DragonMovement.cs +++ /dev/null @@ -1,347 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; -using UnityEngine.SceneManagement; - -public class DragonMovement : MonoBehaviour -{ - public List<Renderer> solids; - - public GameObject hurtPrefab; - - public float horizontalSpeed = 0.1f; - public float verticalSpeed = 0.2f; - - private Vector3 direcV = Vector3.zero; - private Vector3 deltaV = Vector3.zero; - - public float horizontalBound = 6f; - public float verticalBound = 4f; - - private float slitherPhase = 0; - - public HealthBar healthBar; - - private float hurtCooldown = 0; - - private SwarmSystem swarm; - - private enum State { normal, swirl, slim, spread }; - private State state = State.normal; - - private void applyMotion(Vector3 direc) - { - direcV = direcV + direc; - } - - private void moveUp() - { - applyMotion(Vector3.up * verticalSpeed); - } - - private void moveDown() - { - applyMotion(Vector3.down * verticalSpeed); - } - - private void moveLeft() - { - applyMotion(Vector3.left * horizontalSpeed); - } - - private void moveRight() - { - applyMotion(Vector3.right * horizontalSpeed); - } - - private void turnVisible(bool visible) - { - foreach (Renderer solid in solids) - { - solid.enabled = visible; - } - } - - private IEnumerator transformSlim() - { - while (state == State.slim && swarm.Collapse < 0.8f) - { - swarm.Collapse += 0.05f; - yield return new WaitForSeconds(0.01f); - } - } - - private IEnumerator transformSpread() - { - while (state == State.spread && swarm.Noise < 3) - { - swarm.Noise += 0.05f; - yield return new WaitForSeconds(0.01f); - } - } - - private IEnumerator transformAntiSlim() - { - while (state == State.normal && swarm.Collapse > 0) - { - swarm.Collapse -= 0.07f; - yield return new WaitForSeconds(0.01f); - } - if (state == State.normal) - { - turnVisible(true); - swarm.activate(false); - } - } - - private IEnumerator transformAntiSpread() - { - while (state == State.normal && swarm.Noise > 0) - { - swarm.Noise -= 0.12f; - yield return new WaitForSeconds(0.01f); - } - if (state == State.normal) - { - turnVisible(true); - swarm.activate(false); - } - } - - private void turnSwirl() - { - resetTurn(); - turnVisible(false); - swarm.activate(true); - state = State.swirl; - } - - private void turnSlim() - { - resetTurn(); - turnVisible(false); - swarm.activate(true); - state = State.slim; - StartCoroutine("transformSlim"); - } - - private void turnSpread() - { - resetTurn(); - turnVisible(false); - swarm.activate(true); - state = State.spread; - StartCoroutine("transformSpread"); - } - - private void turnAntiSwirl() - { - if (state == State.swirl) - { - state = State.normal; - turnVisible(true); - swarm.activate(false); - } - } - - private void turnAntiSlim() - { - if (state == State.slim) - { - state = State.normal; - StartCoroutine("transformAntiSlim"); - } - } - - private void turnAntiSpread() - { - if (state == State.spread) - { - state = State.normal; - StartCoroutine("transformAntiSpread"); - } - } - - private void resetTurn() - { - swarm.Collapse = 0; - swarm.Noise = 0; - } - - void Start() - { - swarm = GetComponent<SwarmSystem>(); - swarm.activate(false); - } - - void FixedUpdate() - { - transform.Translate(deltaV); - deltaV = 0.6f * deltaV + 0.4f * direcV; - direcV = Vector3.zero; - - if (transform.position.y > verticalBound) - transform.position = new Vector3(transform.position.x, verticalBound, transform.position.z); - - if (transform.position.y < -verticalBound) - transform.position = new Vector3(transform.position.x, -verticalBound, transform.position.z); - - if (transform.position.x < -horizontalBound) - transform.position = new Vector3(-horizontalBound, transform.position.y, transform.position.z); - - if (transform.position.x > horizontalBound) - transform.position = new Vector3(horizontalBound, transform.position.y, transform.position.z); - - slitherPhase += 0.1f; - foreach (Transform t in swarm.meshRender.bones) - { - t.Translate(new Vector3(0, Mathf.Sin(t.position.x - transform.position.x + slitherPhase) * 0.002f, 0), Space.World); - } - foreach (Renderer r in solids) - { - r.transform.Translate(new Vector3(0, Mathf.Sin(r.transform.position.x - transform.position.x + slitherPhase + 0.2f) * -0.008f, 0), Space.World); - } - } - - void Update() - { - if (hurtCooldown > 0) - hurtCooldown -= Time.deltaTime; - - if (healthBar.health <= 0) - return; - - // keyboard scheme - if (Input.GetKey("w")) - moveUp(); - if (Input.GetKey("a")) - moveLeft(); - if (Input.GetKey("s")) - moveDown(); - if (Input.GetKey("d")) - moveRight(); - - if (Input.GetKeyDown("i")) - turnSwirl(); - if (Input.GetKeyUp("i")) - turnAntiSwirl(); - - if (Input.GetKeyDown("j")) - turnSlim(); - if (Input.GetKeyUp("j")) - turnAntiSlim(); - - if (Input.GetKeyDown("k")) - turnSpread(); - if (Input.GetKeyUp("k")) - turnAntiSpread(); - - - // xbox scheme - if (Input.GetAxis("JoystickY") < -0.5f) - moveUp(); - if (Input.GetAxis("JoystickX") < -0.5f) - moveLeft(); - if (Input.GetAxis("JoystickY") > 0.5f) - moveDown(); - if (Input.GetAxis("JoystickX") > 0.5f) - moveRight(); - - if (Input.GetButtonDown("X")) - turnSwirl(); - if (Input.GetButtonUp("X")) - turnAntiSwirl(); - - if (Input.GetButtonDown("A")) - turnSlim(); - if (Input.GetButtonUp("A")) - turnAntiSlim(); - - if (Input.GetButtonDown("Y")) - turnSpread(); - if (Input.GetButtonUp("Y")) - turnAntiSpread(); - } - - void OnDrawGizmosSelected() - { - Gizmos.color = Color.cyan; - Gizmos.DrawWireCube(Vector3.zero, new Vector3(2 * horizontalBound, 2 * verticalBound, 0)); - } - - private IEnumerator makeGoAway(Transform t, float spread) - { - Vector3 delta = Random.onUnitSphere * Random.Range(0.03f, 0.1f); - Vector3 start = t.position; - while ((start - t.position).magnitude < spread) - { - t.Translate(delta); - yield return new WaitForSeconds(0.01f); - } - Destroy(t.gameObject); - } - - private IEnumerator eventuallyStartOver() - { - for (int i = 0; i < 400; i++) - yield return new WaitForSeconds(0.01f); - SceneManager.LoadScene("Titlescreen"); - } - - private void getHurt() - { - if (hurtCooldown <= 0) - { - healthBar.health--; - if (healthBar.health == 0) - { - for (int i = 0; i < 200; i++) - { - Transform t = ((GameObject)Instantiate(hurtPrefab, transform.position + swarm.collapseCenter, Quaternion.identity)).transform; - StartCoroutine(makeGoAway(t, 6)); - } - StartCoroutine(eventuallyStartOver()); - turnVisible(false); - swarm.activate(false); - GetComponent<AudioSource>().Play(); - } - else if (healthBar.health > 0) - { - hurtCooldown = 1.5f; - - for (int i = 0; i < 30; i++) - { - Transform t = ((GameObject)Instantiate(hurtPrefab, transform.position + swarm.collapseCenter, Quaternion.identity)).transform; - StartCoroutine(makeGoAway(t, 3)); - } - GetComponent<AudioSource>().Play(); - } - } - } - - void OnTriggerEnter(Collider other) - { - EnemyCollider enemy = other.gameObject.GetComponent<EnemyCollider>(); - if (enemy != null) - { - switch (enemy.type) - { - case ObstacleType.caveWalls: - case ObstacleType.rockTop: - case ObstacleType.rockBottom: - case ObstacleType.rockJaws: - getHurt(); - break; - case ObstacleType.narrowPassage: - if (state != State.slim) - getHurt(); - break; - case ObstacleType.net: - if (state != State.spread) - getHurt(); - break; - } - } - } - -}
\ No newline at end of file diff --git a/nGJ2019/Assets/Scripts/DragonMovement.cs.meta b/nGJ2019/Assets/Scripts/DragonMovement.cs.meta deleted file mode 100644 index e56ae54..0000000 --- a/nGJ2019/Assets/Scripts/DragonMovement.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c679c8e35354b1b4abd84845391c133a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/nGJ2019/Assets/Scripts/EnemyCollider.cs b/nGJ2019/Assets/Scripts/EnemyCollider.cs deleted file mode 100644 index 89144d9..0000000 --- a/nGJ2019/Assets/Scripts/EnemyCollider.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class EnemyCollider : MonoBehaviour -{ - public ObstacleType type; -} diff --git a/nGJ2019/Assets/Scripts/EnemyCollider.cs.meta b/nGJ2019/Assets/Scripts/EnemyCollider.cs.meta deleted file mode 100644 index 6e3db15..0000000 --- a/nGJ2019/Assets/Scripts/EnemyCollider.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 59a101027e69992449080dd35f887c3b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/nGJ2019/Assets/Scripts/EventTimeline.cs b/nGJ2019/Assets/Scripts/EventTimeline.cs deleted file mode 100644 index 465815c..0000000 --- a/nGJ2019/Assets/Scripts/EventTimeline.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class EventTimeline -{ - public class SpawnEvent - { - public float time; - public Vector3 position; - public ObstacleType type; - - public SpawnEvent(float time, Vector3 position, ObstacleType type) - { - this.time = time; - this.position = position; - this.type = type; - } - } - - public class MessageEvent - { - public float time; - public String message; - - public MessageEvent(float time, String message) - { - this.time = time; - this.message = message; - } - } - - public event Action<SpawnEvent> OnSpawnEvent; - public event Action<MessageEvent> OnMessageEvent; - - private List<SpawnEvent> futureEvents; - private List<MessageEvent> futureMessages; - private float currentTime; - - public EventTimeline() - { - futureEvents = new List<SpawnEvent>(); - futureMessages = new List<MessageEvent>(); - currentTime = 0; - } - - public void Add(float time, Vector3 position, ObstacleType type) - { - futureEvents.Add(new SpawnEvent(time, position, type)); - futureEvents.Sort((x,y) => x.time.CompareTo(y.time)); - } - - public void Add(float time, String message) - { - futureMessages.Add(new MessageEvent(time, message)); - futureMessages.Sort((x,y) => x.time.CompareTo(y.time)); - } - - public void timeTick(float deltaTime) - { - currentTime += deltaTime; - - while(futureEvents.Count > 0 && currentTime > futureEvents[0].time) - { - SpawnEvent e = futureEvents[0]; - futureEvents.RemoveAt(0); - if(OnSpawnEvent != null) - OnSpawnEvent(e); - } - - while(futureMessages.Count > 0 && currentTime > futureMessages[0].time) - { - MessageEvent m = futureMessages[0]; - futureMessages.RemoveAt(0); - if(OnMessageEvent != null) - OnMessageEvent(m); - } - } -} diff --git a/nGJ2019/Assets/Scripts/EventTimeline.cs.meta b/nGJ2019/Assets/Scripts/EventTimeline.cs.meta deleted file mode 100644 index 7ea5066..0000000 --- a/nGJ2019/Assets/Scripts/EventTimeline.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 39ed87007e5d80541bf60e96528c595e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/nGJ2019/Assets/Scripts/HealthBar.cs b/nGJ2019/Assets/Scripts/HealthBar.cs deleted file mode 100644 index 685e297..0000000 --- a/nGJ2019/Assets/Scripts/HealthBar.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class HealthBar : MonoBehaviour -{ - public GameObject crystalPrefab; - public Material liveCrystal; - public Material deadCrystal; - - public int lives; - - private int currentHealth; - public int health - { - get{return currentHealth;} - set - { - currentHealth = value; - updateCrystals(); - } - } - - private List<Renderer> crystals = new List<Renderer>(); - - private void updateCrystals() - { - for(int i=0; i<lives; i++) - { - if(health > i) - crystals[i].material = liveCrystal; - else - crystals[i].material = deadCrystal; - } - } - - void Start() - { - for(int i=0; i<lives; i++) - { - GameObject crystal = Instantiate(crystalPrefab, transform.position + Vector3.right*1.4f*i, Quaternion.identity); - crystals.Add(crystal.GetComponentInChildren<Renderer>()); - } - - health = lives; - updateCrystals(); - } - - // Update is called once per frame - void Update() - { - - } -} diff --git a/nGJ2019/Assets/Scripts/HealthBar.cs.meta b/nGJ2019/Assets/Scripts/HealthBar.cs.meta deleted file mode 100644 index 05ccb6d..0000000 --- a/nGJ2019/Assets/Scripts/HealthBar.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 21df74cd7e633ea40bbc7a491852b38a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/nGJ2019/Assets/Scripts/LevelScrolling.cs b/nGJ2019/Assets/Scripts/LevelScrolling.cs deleted file mode 100644 index 7ca89e3..0000000 --- a/nGJ2019/Assets/Scripts/LevelScrolling.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-public class LevelScrolling : MonoBehaviour
-{
- public int UpdateRate = -5;
- public List<GameObject> Obstacles;
- public Transform Background;
-
- private Vector3 initialBgPos;
- private float[] backgroundSize;
-
- // Start is called before the first frame update
- void Start()
- {
- ResizeBackground();
- }
-
- // Update is called once per frame
- void Update()
- {
-
- }
-
- void FixedUpdate()
- {
- MoveBackground();
- MoveObstacles();
- DestroyObstacles();
- }
-
- void ResizeBackground()
- {
- var sr = Background.GetComponent<SpriteRenderer>();
- if (sr == null) return;
-
- Background.localScale = new Vector3(1, 1, 1);
-
- var width = sr.sprite.bounds.size.x;
- var height = sr.sprite.bounds.size.y;
-
- var worldScreenHeight = Camera.main.orthographicSize * 2.0;
- var worldScreenWidth = worldScreenHeight / Screen.height * Screen.width;
-
- var finalHeight = (float)(worldScreenHeight / height);
- var finalWidth = (float)(worldScreenWidth / width);
-
- Background.localScale = new Vector3(finalHeight, finalHeight, 1);
-
- var viewportX = Camera.main.ViewportToWorldPoint(new Vector3(0, 1, 0)).x;
- Background.position = new Vector3(viewportX * -1, 0, 10);
- initialBgPos = Background.position;
- }
-
- void MoveObstacles()
- {
- for (int i = 0; i < Obstacles.Count; i++)
- {
- Obstacles[i].transform.Translate(0.01f * UpdateRate, 0, 0);
- }
- }
-
- void DestroyObstacles()
- {
- if (Obstacles.Count > 0 && Obstacles[0].transform.position.x < -30)
- {
- Destroy(Obstacles[0]);
- Obstacles.RemoveAt(0);
- }
- }
-
- void MoveBackground()
- {
- if (Background.position.x > -initialBgPos.x)
- Background.Translate(0.01f * UpdateRate, 0, 0);
- else Background.position = initialBgPos;
- }
-}
diff --git a/nGJ2019/Assets/Scripts/LevelScrolling.cs.meta b/nGJ2019/Assets/Scripts/LevelScrolling.cs.meta deleted file mode 100644 index bd8ae9c..0000000 --- a/nGJ2019/Assets/Scripts/LevelScrolling.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: aaf20d9fc2cd6804e8bd7774f129d61a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/nGJ2019/Assets/Scripts/Messenger.cs b/nGJ2019/Assets/Scripts/Messenger.cs deleted file mode 100644 index b26fd74..0000000 --- a/nGJ2019/Assets/Scripts/Messenger.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System;
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEngine.UI;
-
-public class Messenger : MonoBehaviour
-{
- public Text MainText;
- public ObstacleSpawner Spawner;
- private EventTimeline timeline;
-
- // Start is called before the first frame update
- void Start()
- {
- timeline = Spawner.GetEventTimeline();
-
- var scene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
- if (scene.name == "Tutorial")
- {
- timeline.Add(2, "USE WSAD KEYS OR GAMEPAD THUMB TO CONTROL THE DRAGON");
- timeline.Add(8, "AVOID OBSTACLES, YOU WILL LOSE HEALTH IF YOU HIT THEM");
- timeline.Add(31, "USE I, J, AND K KEYS TO CHANGE THE DRAGON FORM");
- timeline.Add(39, "PRESS J TO SHRINK AND FIT IN THE NARROW PASSAGE AHEAD");
- timeline.Add(43, "");
- timeline.Add(55, "PRESS K TO SPLIT INTO PARTICLES AND GO THROUGH THE NET");
- timeline.Add(59, "");
- timeline.Add(62, "CONGRATULATIONS, YOU FINISHED THE TUTORIAL");
- timeline.Add(65, "YOU CAN NOW TEST YOUR SKILL IN A REAL LEVEL");
- }
-
- timeline.OnMessageEvent += MessageOnEvent;
- }
-
- // Update is called once per frame
- void Update()
- {
-
- }
-
- void MessageOnEvent(EventTimeline.MessageEvent e)
- {
- MainText.text = e.message;
- }
-}
diff --git a/nGJ2019/Assets/Scripts/Messenger.cs.meta b/nGJ2019/Assets/Scripts/Messenger.cs.meta deleted file mode 100644 index 82b0d45..0000000 --- a/nGJ2019/Assets/Scripts/Messenger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 37ad83f716361f142917156690ed3186 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs deleted file mode 100644 index b1614b3..0000000 --- a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class ObstacleSpawner : MonoBehaviour -{ - private EventTimeline timeline = new EventTimeline(); - - public GameObject caveWallsPrefab, rockTopPrefab, rockBottomPrefab, narrowPassagePrefab, rockJawsPrefab, netPrefab; - public LevelScrolling scrolling; - - public float spawnLine; - - private void spawnOnEvent(EventTimeline.SpawnEvent e) - { - GameObject prefab = null; - - switch (e.type) - { - case ObstacleType.caveWalls: - prefab = caveWallsPrefab; - break; - case ObstacleType.rockTop: - prefab = rockTopPrefab; - break; - case ObstacleType.rockBottom: - prefab = rockBottomPrefab; - break; - case ObstacleType.narrowPassage: - prefab = narrowPassagePrefab; - break; - case ObstacleType.rockJaws: - prefab = rockJawsPrefab; - break; - case ObstacleType.net: - prefab = netPrefab; - break; - } - - var o = Instantiate(prefab, new Vector3(spawnLine, e.position.y, e.position.z), Quaternion.identity); - scrolling.Obstacles.Add(o); - } - - void Start() - { - var scene = UnityEngine.SceneManagement.SceneManager.GetActiveScene(); - if (scene.name == "TitleScreen") - { - for (int i = 0; i < 1000; i++) - { - timeline.Add(i * 2.5f, new Vector3(0, 0, 0), ObstacleType.caveWalls); - timeline.Add(i * 12.5f + 3, new Vector3(0, 2.75f, 0), ObstacleType.rockTop); - timeline.Add(i * 12.5f + 6, new Vector3(0, 1, 0), ObstacleType.rockBottom); - timeline.Add(i * 12.5f + 9, new Vector3(0, 0, 0), ObstacleType.narrowPassage); - timeline.Add(i * 12.5f + 12.5f, new Vector3(0, -2.5f, 2), ObstacleType.rockJaws); - timeline.Add(i * 12.5f + 15f, new Vector3(0, 0.5f, 3), ObstacleType.net); - } - } - else if (scene.name == "Tutorial") - { - for (int i = 0; i < 60; i++) - timeline.Add(i * 2.5f, new Vector3(0, 0, 0), ObstacleType.caveWalls); - - timeline.Add(10, new Vector3(0, 2.75f, 0), ObstacleType.rockTop); - timeline.Add(15, new Vector3(0, 1, 0), ObstacleType.rockBottom); - timeline.Add(20, new Vector3(0, 2.75f, 0), ObstacleType.rockTop); - timeline.Add(23, new Vector3(0, 1, 0), ObstacleType.rockBottom); - timeline.Add(26, new Vector3(0, 2.75f, 0), ObstacleType.rockTop); - - timeline.Add(40, new Vector3(0, 0, 0), ObstacleType.narrowPassage); - timeline.Add(48, new Vector3(0, -2.5f, 2), ObstacleType.rockJaws); - timeline.Add(56, new Vector3(0, 0.5f, 3), ObstacleType.net); - } - else if (scene.name == "Level1") - { - System.Random random = new System.Random(); - for (int i = 0; i < 1000; i++) - { - timeline.Add(i * 2.5f, new Vector3(0,0,0), ObstacleType.caveWalls); - - Array values = Enum.GetValues(typeof(ObstacleType)); - ObstacleType randomObstacle = (ObstacleType)values.GetValue(random.Next(values.Length)); - Vector3 position; - - switch (randomObstacle) - { - case ObstacleType.rockTop: - position = new Vector3(0, 2.75f, 0); - break; - case ObstacleType.rockBottom: - position = new Vector3(0, 1, 0); - break; - case ObstacleType.rockJaws: - position = new Vector3(0, -2.5f, 2); - break; - case ObstacleType.net: - position = new Vector3(0, 0.5f, 3); - break; - default: - position = new Vector3(0,0,0); - break; - } - timeline.Add(i * 4, position, randomObstacle); - } - } - - timeline.OnSpawnEvent += spawnOnEvent; - } - - // Update is called once per frame - void Update() - { - timeline.timeTick(Time.deltaTime); - } - - void OnDrawGizmosSelected() - { - Gizmos.color = Color.green; - Gizmos.DrawLine(new Vector3(spawnLine, -10, 0), new Vector3(spawnLine, 10, 0)); - } - - public EventTimeline GetEventTimeline() - { - return timeline; - } -} diff --git a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs.meta b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs.meta deleted file mode 100644 index 80da9fc..0000000 --- a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d769188f2214e9f448de88193d84f4a2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/nGJ2019/Assets/Scripts/ObstacleType.cs b/nGJ2019/Assets/Scripts/ObstacleType.cs deleted file mode 100644 index c97a2ed..0000000 --- a/nGJ2019/Assets/Scripts/ObstacleType.cs +++ /dev/null @@ -1,5 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public enum ObstacleType { caveWalls, rockTop, rockBottom, narrowPassage, rockJaws, net } diff --git a/nGJ2019/Assets/Scripts/ObstacleType.cs.meta b/nGJ2019/Assets/Scripts/ObstacleType.cs.meta deleted file mode 100644 index 6a7d64e..0000000 --- a/nGJ2019/Assets/Scripts/ObstacleType.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c88d73ced43d44341a1c538d8690bb25 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/nGJ2019/Assets/Scripts/RockJaws.cs b/nGJ2019/Assets/Scripts/RockJaws.cs deleted file mode 100644 index 874d6d3..0000000 --- a/nGJ2019/Assets/Scripts/RockJaws.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-public class RockJaws : MonoBehaviour
-{
- public Transform TopJaw;
- public Transform BottomJaw;
- public int Speed = 10;
- private bool reverse = false;
- private float initialTopJawY;
- // Start is called before the first frame update
- void Start()
- {
- initialTopJawY = TopJaw.localPosition.y;
- }
-
- // Update is called once per frame
- void Update()
- {
-
- }
-
- void FixedUpdate()
- {
- var topJawHeight= TopJaw.GetComponent<MeshRenderer>().bounds.size.y;
- var bottomJawHeight= BottomJaw.GetComponent<MeshRenderer>().bounds.size.y;
-
- if (TopJaw.localPosition.y - topJawHeight / 2 < BottomJaw.localPosition.y + bottomJawHeight / 2) reverse = true;
- else if(TopJaw.localPosition.y > initialTopJawY) reverse = false;
-
- if (!reverse) {
- TopJaw.Translate(0, -0.01f * Speed, 0, Space.World);
- BottomJaw.Translate(0, 0.01f * Speed, 0, Space.World);
- } else {
- TopJaw.Translate(0, 0.01f * Speed, 0, Space.World);
- BottomJaw.Translate(0, -0.01f * Speed, 0, Space.World);
- }
- }
-}
diff --git a/nGJ2019/Assets/Scripts/RockJaws.cs.meta b/nGJ2019/Assets/Scripts/RockJaws.cs.meta deleted file mode 100644 index bd24b1e..0000000 --- a/nGJ2019/Assets/Scripts/RockJaws.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d508cc86bb112da41aab7f9073311fe5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/nGJ2019/Assets/Scripts/SwarmSystem.cs b/nGJ2019/Assets/Scripts/SwarmSystem.cs deleted file mode 100644 index 798cf13..0000000 --- a/nGJ2019/Assets/Scripts/SwarmSystem.cs +++ /dev/null @@ -1,436 +0,0 @@ -using UnityEngine; -using System.Collections.Generic; - -public class SwarmSystem : MonoBehaviour -{ - public GameObject swarmPrefab; - public GameObject anchorPrefab; - public int size = 1; - public Vector3 collapseCenter; - - public SkinnedMeshRenderer meshRender; - - public bool showGuides = false; - public bool showMesh = false; - - private List<Transform> units = new List<Transform>(); - private List<Transform> anchors = new List<Transform>(); - private List<Vector3> noiseDirecs = new List<Vector3>(); - - private List<Vector3> boneStarts = new List<Vector3>(); - private List<Vector3> boneEnds = new List<Vector3>(); - private List<Transform> boneTransforms = new List<Transform>(); - private List<Transform> boneTips = new List<Transform>(); - private List<int> boneCenterStarts = new List<int>(); - private List<float> boneCenterDists = new List<float>(); - - private List<int> unitTris = new List<int>(); - private List<List<int>> triGraph; - - public float Noise {get; set;} - public float Collapse {get; set;} - - private Mesh getCurrentMesh() - { - Mesh mesh = new Mesh(); - meshRender.BakeMesh(mesh); - return mesh; - } - - private bool triangleIntersection(Vector3 p1, Vector3 p2, Vector3 p3, Ray ray, out Vector3 intersect) - { - Vector3 e1, e2; - - Vector3 p, q, t; - float det, invDet, u, v; - float Epsilon = 0.001f; - - intersect = Vector3.zero; - - e1 = p2 - p1; - e2 = p3 - p1; - - //calculating determinant - p = Vector3.Cross(ray.direction, e2); - - det = Vector3.Dot(e1, p); - - //if determinant is near zero, ray lies in plane of triangle otherwise not - if (det > -Epsilon && det < Epsilon) - return false; - - invDet = 1.0f / det; - - t = ray.origin - p1; - - u = Vector3.Dot(t, p) * invDet; - - //Check for ray hit - if (u < 0 || u > 1) - return false; - - //Prepare to test v parameter - q = Vector3.Cross(t, e1); - - v = Vector3.Dot(ray.direction, q) * invDet; - - //Check for ray hit - if (v < 0 || u + v > 1) - return false; - - //ray does intersect - if ((Vector3.Dot(e2, q) * invDet) > Epsilon) - { - intersect = ray.origin + ray.direction * (Vector3.Dot(e2, q)*invDet); - return true; - } - - // No hit at all - return false; - } - - private bool triangleIndexIntersection(int idx, Vector3[] vertices, int[] triangles, Ray ray, out Vector3 intersect) - { - return triangleIntersection( meshRender.transform.TransformPoint(vertices[triangles[idx*3]]), - meshRender.transform.TransformPoint(vertices[triangles[idx*3+1]]), - meshRender.transform.TransformPoint(vertices[triangles[idx*3+2]]), - ray, out intersect); - } - - private Vector3 meshIntersection(int unitIdx, Vector3[] vertices, int[] triangles, Vector3 boneCenter) - { - Vector3 intersect; - - Ray ray = new Ray(boneCenter, anchors[unitIdx].position-boneCenter); - - if(unitTris[unitIdx] != -1) - { - if(triangleIndexIntersection(unitTris[unitIdx], vertices, triangles, ray, out intersect)) - { - return intersect; - } - - foreach(int tri in triGraph[unitTris[unitIdx]]) - { - if(triangleIndexIntersection(tri, vertices, triangles, ray, out intersect)) - { - unitTris[unitIdx] = tri; - return intersect; - } - } - } - - for(int i=0; i<triangles.Length; i+=3) - { - if(triangleIndexIntersection(i/3, vertices, triangles, ray, out intersect)) - { - unitTris[unitIdx] = i/3; - return intersect; - } - } - - return anchors[unitIdx].position; - } - - private void calculateTriGraph() - { - Mesh mesh = meshRender.sharedMesh; - - Vector3[] vertices = mesh.vertices; - - float epsilon = 0.001f; - - triGraph = new List<List<int>>(); - - Dictionary<int, int> vertexAlias = new Dictionary<int, int>(); - - List<int> vertexByMag = new List<int>(); - - for(int i=0; i<vertices.Length; i++) - vertexByMag.Add(i); - - vertexByMag.Sort((x,y) => vertices[x].magnitude.CompareTo(vertices[y].magnitude)); - - for(int i=0; i<vertices.Length; i++) - { - int minEq = i; - int j = i; - - while(j >= 0 && vertices[i].magnitude-vertices[j].magnitude < epsilon) - { - if((vertices[i]-vertices[j]).magnitude < epsilon) - minEq = j; - j--; - } - - vertexAlias.Add(i, minEq); - } - - List<List<int>> vertexTouch = new List<List<int>>(); - - for(int i=0; i<vertices.Length; i++) - vertexTouch.Add(new List<int>()); - - - for(int i=0; i<mesh.triangles.Length; i+=3) - { - vertexTouch[vertexAlias[mesh.triangles[i]]].Add(i/3); - vertexTouch[vertexAlias[mesh.triangles[i+1]]].Add(i/3); - vertexTouch[vertexAlias[mesh.triangles[i+2]]].Add(i/3); - } - - for(int i=0; i<mesh.triangles.Length; i+=3) - { - List<int> tris = new List<int>(); - - for(int k=0; k<3; k++) - { - foreach(int tri in vertexTouch[vertexAlias[mesh.triangles[i+k]]]) - { - if(tri != i/3 && !tris.Contains(tri)) - tris.Add(tri); - } - } - - triGraph.Add(tris); - } - } - - private void mapBones() - { - boneTips.Clear(); - - foreach(Transform b in meshRender.bones) - { - boneTransforms.Add(b.parent); - - if(b.GetChild(0).childCount == 0) - { - boneTransforms.Add(b); - boneTips.Add(b); - } - } - } - - private void refreshMesh() - { - boneStarts.Clear(); - boneEnds.Clear(); - - foreach(Transform b in meshRender.bones) - { - boneStarts.Add(b.parent.position); - boneEnds.Add(b.position); - if(boneTips.Contains(b)) - { - boneStarts.Add(b.position); - boneEnds.Add(b.GetChild(0).position); - } - } - } - - private void calculateBoneCenters() - { - boneCenterStarts.Clear(); - boneCenterDists.Clear(); - - foreach(Transform unit in units) - { - float minDist = float.PositiveInfinity; - Vector3 boneCenter = transform.position; - int boneIdx = 0; - - for(int i=0; i<boneStarts.Count; i++) - { - Vector3 start = boneStarts[i]; - Vector3 end = boneEnds[i]; - - Vector3 c = start + Vector3.Project(unit.position-start, end-start); - float dist = (c-unit.position).magnitude; - Vector3 direc = end-start; - - if(dist < minDist && (c-start).magnitude < direc.magnitude && (c-end).magnitude < direc.magnitude) - { - minDist = dist; - boneCenter = c; - boneIdx = i; - } - } - - boneCenterStarts.Add(boneIdx); - boneCenterDists.Add((boneCenter-boneStarts[boneIdx]).magnitude); - unit.parent = boneTransforms[boneIdx]; - } - } - - private Vector3 findBoneCenter(int unitIdx, out Vector3 boneDirec) - { - Vector3 start = boneStarts[boneCenterStarts[unitIdx]]; - boneDirec = boneEnds[boneCenterStarts[unitIdx]] - start; - return start + (boneCenterDists[unitIdx] * boneDirec); - } - - private void randomMeshSpawn() - { - Mesh mesh = getCurrentMesh(); - - List<float> accTriSizes = new List<float>(); - - for(int i=0; i<mesh.triangles.Length; i+=3) - { - float prev = 0; - - if(i>0) - prev = accTriSizes[(i/3)-1]; - - float area = Vector3.Cross(mesh.vertices[mesh.triangles[i+1]]-mesh.vertices[mesh.triangles[i]], mesh.vertices[mesh.triangles[i+2]]-mesh.vertices[mesh.triangles[i]]).magnitude/2; - - accTriSizes.Add(prev+area); - } - - float outOf = accTriSizes[accTriSizes.Count-1]; - - for(int i=0; i<size; i++) - { - float v = Random.value*outOf; - - int k=0; - while(accTriSizes[k+1] < v) - k++; - - float r1 = Mathf.Sqrt(Random.value); - float r2 = Random.value; - - Vector3 p = (1-r1)*mesh.vertices[mesh.triangles[k*3]] + (r1*(1-r2))*mesh.vertices[mesh.triangles[k*3+1]] + (r1*r2)*mesh.vertices[mesh.triangles[k*3+2]]; - - GameObject anchor = (GameObject)Instantiate(anchorPrefab, meshRender.transform.TransformPoint(p), Quaternion.identity); - - GameObject spawn = (GameObject)Instantiate(swarmPrefab, meshRender.transform.TransformPoint(p), Quaternion.identity); - - spawn.transform.parent = transform; - anchor.transform.parent = transform; - - units.Add(spawn.transform); - anchors.Add(anchor.transform); - noiseDirecs.Add(Random.onUnitSphere); - - unitTris.Add(k); - } - } - - public void activate(bool turnOn) - { - foreach(Transform u in units) - u.gameObject.SetActive(turnOn); - } - - public Transform rootBone() - { - return meshRender.bones[0]; - } - - public void setNoise(float noise) - { - - } - - void Start() - { - mapBones(); - - refreshMesh(); - - calculateTriGraph(); - - randomMeshSpawn(); - - calculateBoneCenters(); - } - - void FixedUpdate() - { - refreshMesh(); - - Mesh mesh = getCurrentMesh(); - - Transform root = meshRender.bones[0].parent; - - Vector3[] vertices = mesh.vertices; - int[] triangles = mesh.triangles; - - for(int u=0; u<units.Count; u++) - { - Transform unit = units[u]; - - Vector3 boneDirec; - - Vector3 boneCenter = findBoneCenter(u, out boneDirec); - - anchors[u].position = boneCenter + (Quaternion.AngleAxis(3f, boneDirec) * (anchors[u].position - boneCenter)); - - anchors[u].position = meshIntersection(u, vertices, triangles, boneCenter); - - unit.position = anchors[u].position + Noise*noiseDirecs[u]; - - Vector3 coll = transform.position + collapseCenter; - - Vector3 collapsedPos = Vector3.Project(unit.position - coll, Vector3.right)*0.3f + coll; - - unit.position = (1-Collapse)*unit.position + Collapse*collapsedPos; - } - } - - void OnDrawGizmos() - { - if(showGuides) - { - mapBones(); - refreshMesh(); - - Gizmos.color = Color.cyan; - - for(int i=0; i<boneStarts.Count; i++) - { - Gizmos.DrawLine(boneStarts[i], boneEnds[i]); - } - - Gizmos.color = Color.red; - - Mesh mesh = getCurrentMesh(); - - if(showMesh) - for(int i=0; i<mesh.triangles.Length; i+=3) - { - Gizmos.DrawSphere(meshRender.transform.TransformPoint(mesh.vertices[mesh.triangles[i]]), 0.1f); - Gizmos.DrawSphere(meshRender.transform.TransformPoint(mesh.vertices[mesh.triangles[i+1]]), 0.1f); - Gizmos.DrawSphere(meshRender.transform.TransformPoint(mesh.vertices[mesh.triangles[i+2]]), 0.1f); - } - - int tri = 0; - - Gizmos.color = Color.cyan; - - if(triGraph != null) - { - //Debug.Log(triGraph[tri].Count); - foreach(int t in triGraph[tri]) - { - Gizmos.DrawLine(meshRender.transform.TransformPoint(mesh.vertices[mesh.triangles[t*3]]), meshRender.transform.TransformPoint(mesh.vertices[mesh.triangles[t*3+1]])); - Gizmos.DrawLine(meshRender.transform.TransformPoint(mesh.vertices[mesh.triangles[t*3+1]]), meshRender.transform.TransformPoint(mesh.vertices[mesh.triangles[t*3+2]])); - Gizmos.DrawLine(meshRender.transform.TransformPoint(mesh.vertices[mesh.triangles[t*3+2]]), meshRender.transform.TransformPoint(mesh.vertices[mesh.triangles[t*3]])); - - } - } - - Gizmos.color = Color.magenta; - - Gizmos.DrawLine(meshRender.transform.TransformPoint(mesh.vertices[mesh.triangles[tri*3]]), meshRender.transform.TransformPoint(mesh.vertices[mesh.triangles[tri*3+1]])); - Gizmos.DrawLine(meshRender.transform.TransformPoint(mesh.vertices[mesh.triangles[tri*3+1]]), meshRender.transform.TransformPoint(mesh.vertices[mesh.triangles[tri*3+2]])); - Gizmos.DrawLine(meshRender.transform.TransformPoint(mesh.vertices[mesh.triangles[tri*3+2]]), meshRender.transform.TransformPoint(mesh.vertices[mesh.triangles[tri*3]])); - - Gizmos.color = Color.green; - Gizmos.DrawLine(transform.position + collapseCenter - Vector3.right*5, transform.position + collapseCenter + Vector3.right*5); - - } - } -}
\ No newline at end of file diff --git a/nGJ2019/Assets/Scripts/SwarmSystem.cs.meta b/nGJ2019/Assets/Scripts/SwarmSystem.cs.meta deleted file mode 100644 index ec0a4ee..0000000 --- a/nGJ2019/Assets/Scripts/SwarmSystem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 888f7bff577b8164eb5f07ccefb62e5f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/nGJ2019/Assets/Scripts/TitleScreen.cs b/nGJ2019/Assets/Scripts/TitleScreen.cs deleted file mode 100644 index 00875da..0000000 --- a/nGJ2019/Assets/Scripts/TitleScreen.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.EventSystems; -using UnityEngine.SceneManagement; - -public class TitleScreen : MonoBehaviour -{ - void Update() - { - // quit application when back button is clicked - if (Input.GetKeyDown(KeyCode.Escape)) - Application.Quit(); - } - - public void OpenTutorial() - { - SceneManager.LoadScene("Tutorial"); - } - - public void OpenLevelOne() - { - SceneManager.LoadScene("Level1"); - } - - public void Quit() - { - Application.Quit(); - } -} diff --git a/nGJ2019/Assets/Scripts/TitleScreen.cs.meta b/nGJ2019/Assets/Scripts/TitleScreen.cs.meta deleted file mode 100644 index 8b15597..0000000 --- a/nGJ2019/Assets/Scripts/TitleScreen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a33c115845f094d1ea23a02866431be0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/nGJ2019/Assets/Scripts/TutorialTimer.cs b/nGJ2019/Assets/Scripts/TutorialTimer.cs deleted file mode 100644 index 899d45e..0000000 --- a/nGJ2019/Assets/Scripts/TutorialTimer.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEngine.SceneManagement;
-
-public class TutorialTimer : MonoBehaviour
-{
- // Start is called before the first frame update
- void Start()
- {
- StartCoroutine("Timer");
- }
-
- // Update is called once per frame
- void Update()
- {
-
- }
-
- IEnumerator Timer()
- {
- yield return new WaitForSeconds(70);
- SceneManager.LoadScene("Level1");
- }
-}
diff --git a/nGJ2019/Assets/Scripts/TutorialTimer.cs.meta b/nGJ2019/Assets/Scripts/TutorialTimer.cs.meta deleted file mode 100644 index 5d3492c..0000000 --- a/nGJ2019/Assets/Scripts/TutorialTimer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 36e56514c4a9b4d5bae9925bf2859b10 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: |