From 316c17c945b9133aa1094edf6de5c5f38e456d3c Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Sat, 27 Apr 2019 14:32:46 +0200 Subject: Added basic obstacles --- nGJ2019/Assets/Scripts/DragonMovement.cs | 2 +- nGJ2019/Assets/Scripts/ObstacleSpawner.cs | 91 ++++++++++++++++++------------- nGJ2019/Assets/Scripts/ObstacleType.cs | 2 +- 3 files changed, 55 insertions(+), 40 deletions(-) (limited to 'nGJ2019/Assets/Scripts') diff --git a/nGJ2019/Assets/Scripts/DragonMovement.cs b/nGJ2019/Assets/Scripts/DragonMovement.cs index 4ba179d..9ae8fbb 100644 --- a/nGJ2019/Assets/Scripts/DragonMovement.cs +++ b/nGJ2019/Assets/Scripts/DragonMovement.cs @@ -205,7 +205,7 @@ public class DragonMovement : MonoBehaviour EnemyCollider enemy = other.gameObject.GetComponent(); if(enemy != null) { - Debug.Log(enemy.type == ObstacleType.alfa ? "alfa hit" : "beta hit"); + Debug.Log(enemy.type == ObstacleType.narrowPassage ? "alfa hit" : "beta hit"); healthBar.health--; } } diff --git a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs index 102df97..a9d1078 100644 --- a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs +++ b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs @@ -4,47 +4,62 @@ using UnityEngine; public class ObstacleSpawner : MonoBehaviour { - private EventTimeline timeline = new EventTimeline(); - - public GameObject alfaPrefab; - public GameObject betaPrefab; - public LevelScrolling scrolling; - - public float spawnLine; - - private void spawnOnEvent(EventTimeline.SpawnEvent e) - { - GameObject prefab = null; - - if(e.type == ObstacleType.alfa) - prefab = alfaPrefab; - - if(e.type == ObstacleType.beta) - prefab = betaPrefab; - - var transformT = ((GameObject) Instantiate(prefab, new Vector3(spawnLine, e.height, 0), Quaternion.identity)).transform; - scrolling.Obstacles.Add(transformT); - } - - void Start() + private EventTimeline timeline = new EventTimeline(); + + public GameObject caveWallsPrefab, rockTopPrefab, rockBottomPrefab, narrowPassagePrefab, rockJawsPrefab; + public LevelScrolling scrolling; + + public float spawnLine; + + private void spawnOnEvent(EventTimeline.SpawnEvent e) + { + GameObject prefab = null; + + switch (e.type) { - for(int i = 0; i < 120; i += 5) - { - timeline.Add(i, 0, ObstacleType.alfa); - } - - timeline.OnSpawnEvent += spawnOnEvent; + 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; } - // Update is called once per frame - void Update() + var transformT = ((GameObject)Instantiate(prefab, new Vector3(spawnLine, e.height, 0), Quaternion.identity)).transform; + scrolling.Obstacles.Add(transformT); + } + + void Start() + { + for (int i = 0; i < 120; i += 5) { - timeline.timeTick(Time.deltaTime); + timeline.Add(i, 0, ObstacleType.caveWalls); } - - void OnDrawGizmosSelected() - { - Gizmos.color = Color.green; - Gizmos.DrawLine(new Vector3(spawnLine,-10,0), new Vector3(spawnLine,10,0)); - } + timeline.Add(2, 2.75f, ObstacleType.rockTop); + timeline.Add(8, -2, ObstacleType.rockBottom); + timeline.Add(20, 0, ObstacleType.narrowPassage); + + 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)); + } } diff --git a/nGJ2019/Assets/Scripts/ObstacleType.cs b/nGJ2019/Assets/Scripts/ObstacleType.cs index c62f629..79a4980 100644 --- a/nGJ2019/Assets/Scripts/ObstacleType.cs +++ b/nGJ2019/Assets/Scripts/ObstacleType.cs @@ -2,4 +2,4 @@ using System.Collections.Generic; using UnityEngine; -public enum ObstacleType {alfa, beta} +public enum ObstacleType { caveWalls, rockTop, rockBottom, narrowPassage, rockJaws } -- cgit v1.2.3 From 9222754ebc29c533d70c283896895dfb852c3cdc Mon Sep 17 00:00:00 2001 From: Mikkel Bybjerg Date: Sat, 27 Apr 2019 14:41:12 +0200 Subject: merge --- nGJ2019/Assets/Scripts/DragonMovement.cs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'nGJ2019/Assets/Scripts') diff --git a/nGJ2019/Assets/Scripts/DragonMovement.cs b/nGJ2019/Assets/Scripts/DragonMovement.cs index 4ba179d..24b6666 100644 --- a/nGJ2019/Assets/Scripts/DragonMovement.cs +++ b/nGJ2019/Assets/Scripts/DragonMovement.cs @@ -169,6 +169,7 @@ public class DragonMovement : MonoBehaviour void Update() { + // keyboard scheme if(Input.GetKey("w")) moveUp(); if(Input.GetKey("a")) @@ -192,6 +193,32 @@ public class DragonMovement : MonoBehaviour 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() @@ -205,7 +232,7 @@ public class DragonMovement : MonoBehaviour EnemyCollider enemy = other.gameObject.GetComponent(); if(enemy != null) { - Debug.Log(enemy.type == ObstacleType.alfa ? "alfa hit" : "beta hit"); + //Debug.Log(enemy.type == ObstacleType.alfa ? "alfa hit" : "beta hit"); healthBar.health--; } } -- cgit v1.2.3 From 0cfee1d1f1a2a06c86080f62ce26a3eabe6b5ffd Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Sat, 27 Apr 2019 14:59:32 +0200 Subject: Refactoring --- nGJ2019/Assets/Scripts/LevelScrolling.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'nGJ2019/Assets/Scripts') diff --git a/nGJ2019/Assets/Scripts/LevelScrolling.cs b/nGJ2019/Assets/Scripts/LevelScrolling.cs index 025bf40..0122a69 100644 --- a/nGJ2019/Assets/Scripts/LevelScrolling.cs +++ b/nGJ2019/Assets/Scripts/LevelScrolling.cs @@ -4,7 +4,7 @@ using UnityEngine; public class LevelScrolling : MonoBehaviour { - public int UpdateRate = 1; + public int UpdateRate = -5; public List Obstacles; public Transform Background; @@ -56,14 +56,14 @@ public class LevelScrolling : MonoBehaviour { foreach (var o in Obstacles) { - o.Translate(new Vector2(0.01f * UpdateRate, 0)); + o.Translate(0.01f * UpdateRate, 0, 0); } } private void MoveBackground() { if (Background.position.x > -initialBgPos.x) - Background.Translate(new Vector2(0.01f * UpdateRate, 0)); + Background.Translate(0.01f * UpdateRate, 0, 0); else Background.position = initialBgPos; } } -- cgit v1.2.3 From 7539e35ce26437c5aa0325936dea68132408c8b0 Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Sat, 27 Apr 2019 15:23:18 +0200 Subject: Added rock jaws obstacle --- nGJ2019/Assets/Scripts/ObstacleSpawner.cs | 1 + nGJ2019/Assets/Scripts/RockJaws.cs | 37 +++++++++++++++++++++++++++++++ 2 files chan