From a8fe54592f727ddad05040b82ccb490218682d7c Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Sat, 1 Feb 2020 17:06:41 +0100 Subject: Renamed to Dragon Dust --- nGJ2019/Assets/Scripts/DragonMovement.cs | 347 -------------------- nGJ2019/Assets/Scripts/DragonMovement.cs.meta | 11 - nGJ2019/Assets/Scripts/EnemyCollider.cs | 8 - nGJ2019/Assets/Scripts/EnemyCollider.cs.meta | 11 - nGJ2019/Assets/Scripts/EventTimeline.cs | 80 ----- nGJ2019/Assets/Scripts/EventTimeline.cs.meta | 11 - nGJ2019/Assets/Scripts/HealthBar.cs | 54 --- nGJ2019/Assets/Scripts/HealthBar.cs.meta | 11 - nGJ2019/Assets/Scripts/LevelScrolling.cs | 79 ----- nGJ2019/Assets/Scripts/LevelScrolling.cs.meta | 11 - nGJ2019/Assets/Scripts/Messenger.cs | 45 --- nGJ2019/Assets/Scripts/Messenger.cs.meta | 11 - nGJ2019/Assets/Scripts/ObstacleSpawner.cs | 127 ------- nGJ2019/Assets/Scripts/ObstacleSpawner.cs.meta | 11 - nGJ2019/Assets/Scripts/ObstacleType.cs | 5 - nGJ2019/Assets/Scripts/ObstacleType.cs.meta | 11 - nGJ2019/Assets/Scripts/RockJaws.cs | 40 --- nGJ2019/Assets/Scripts/RockJaws.cs.meta | 11 - nGJ2019/Assets/Scripts/SwarmSystem.cs | 436 ------------------------- nGJ2019/Assets/Scripts/SwarmSystem.cs.meta | 11 - nGJ2019/Assets/Scripts/TitleScreen.cs | 30 -- nGJ2019/Assets/Scripts/TitleScreen.cs.meta | 11 - nGJ2019/Assets/Scripts/TutorialTimer.cs | 25 -- nGJ2019/Assets/Scripts/TutorialTimer.cs.meta | 11 - 24 files changed, 1408 deletions(-) delete mode 100644 nGJ2019/Assets/Scripts/DragonMovement.cs delete mode 100644 nGJ2019/Assets/Scripts/DragonMovement.cs.meta delete mode 100644 nGJ2019/Assets/Scripts/EnemyCollider.cs delete mode 100644 nGJ2019/Assets/Scripts/EnemyCollider.cs.meta delete mode 100644 nGJ2019/Assets/Scripts/EventTimeline.cs delete mode 100644 nGJ2019/Assets/Scripts/EventTimeline.cs.meta delete mode 100644 nGJ2019/Assets/Scripts/HealthBar.cs delete mode 100644 nGJ2019/Assets/Scripts/HealthBar.cs.meta delete mode 100644 nGJ2019/Assets/Scripts/LevelScrolling.cs delete mode 100644 nGJ2019/Assets/Scripts/LevelScrolling.cs.meta delete mode 100644 nGJ2019/Assets/Scripts/Messenger.cs delete mode 100644 nGJ2019/Assets/Scripts/Messenger.cs.meta delete mode 100644 nGJ2019/Assets/Scripts/ObstacleSpawner.cs delete mode 100644 nGJ2019/Assets/Scripts/ObstacleSpawner.cs.meta delete mode 100644 nGJ2019/Assets/Scripts/ObstacleType.cs delete mode 100644 nGJ2019/Assets/Scripts/ObstacleType.cs.meta delete mode 100644 nGJ2019/Assets/Scripts/RockJaws.cs delete mode 100644 nGJ2019/Assets/Scripts/RockJaws.cs.meta delete mode 100644 nGJ2019/Assets/Scripts/SwarmSystem.cs delete mode 100644 nGJ2019/Assets/Scripts/SwarmSystem.cs.meta delete mode 100644 nGJ2019/Assets/Scripts/TitleScreen.cs delete mode 100644 nGJ2019/Assets/Scripts/TitleScreen.cs.meta delete mode 100644 nGJ2019/Assets/Scripts/TutorialTimer.cs delete mode 100644 nGJ2019/Assets/Scripts/TutorialTimer.cs.meta (limited to 'nGJ2019/Assets/Scripts') 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 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(); - 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().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().Play(); - } - } - } - - void OnTriggerEnter(Collider other) - { - EnemyCollider enemy = other.gameObject.GetComponent(); - 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 OnSpawnEvent; - public event Action OnMessageEvent; - - private List futureEvents; - private List futureMessages; - private float currentTime; - - public EventTimeline() - { - futureEvents = new List(); - futureMessages = new List(); - 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 crystals = new List(); - - private void updateCrystals() - { - for(int i=0; i i) - crystals[i].material = liveCrystal; - else - crystals[i].material = deadCrystal; - } - } - - void Start() - { - for(int i=0; i()); - } - - 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 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(); - 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().bounds.size.y; - var bottomJawHeight= BottomJaw.GetComponent().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 units = new List(); - private List anchors = new List(); - private List noiseDirecs = new List(); - - private List boneStarts = new List(); - private List boneEnds = new List(); - private List boneTransforms = new List(); - private List boneTips = new List(); - private List boneCenterStarts = new List(); - private List boneCenterDists = new List(); - - private List unitTris = new List(); - private List> 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>(); - - Dictionary vertexAlias = new Dictionary(); - - List vertexByMag = new List(); - - for(int i=0; i vertices[x].magnitude.CompareTo(vertices[y].magnitude)); - - for(int i=0; i= 0 && vertices[i].magnitude-vertices[j].magnitude < epsilon) - { - if((vertices[i]-vertices[j]).magnitude < epsilon) - minEq = j; - j--; - } - - vertexAlias.Add(i, minEq); - } - - List> vertexTouch = new List>(); - - for(int i=0; i()); - - - for(int i=0; i tris = new List(); - - 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 accTriSizes = new List(); - - for(int i=0; i0) - 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