diff --git a/Assets/Prefabs/Scorpion.prefab b/Assets/Prefabs/Scorpion.prefab index f2743e5..60aa844 100644 --- a/Assets/Prefabs/Scorpion.prefab +++ b/Assets/Prefabs/Scorpion.prefab @@ -52,7 +52,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1303102899095328} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 7.6580257, y: 3.506653, z: -0.08491792} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4615957218218632} diff --git a/Assets/Scenes/CodeDEV.unity b/Assets/Scenes/CodeDEV.unity index a3de4aa..e34dc74 100644 --- a/Assets/Scenes/CodeDEV.unity +++ b/Assets/Scenes/CodeDEV.unity @@ -113,6 +113,131 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &30160409 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 30160410} + - component: {fileID: 30160411} + m_Layer: 0 + m_Name: menu + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &30160410 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 30160409} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 120074943} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!82 &30160411 +AudioSource: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 30160409} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 243359265566762914, guid: efb934a745665924d8c7dd46c0a117ae, + type: 2} + m_audioClip: {fileID: 8300000, guid: a90787ea4a183c44699deb2babada64b, type: 3} + m_PlayOnAwake: 0 + m_Volume: 1 + m_Pitch: 1 + Loop: 0 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 --- !u!1 &120074942 GameObject: m_ObjectHideFlags: 0 @@ -140,6 +265,7 @@ Transform: m_Children: - {fileID: 1600556434} - {fileID: 801288608} + - {fileID: 30160410} m_Father: {fileID: 734498092} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -497,6 +623,11 @@ Prefab: propertyPath: m_IsActive value: 0 objectReference: {fileID: 0} + - target: {fileID: 60772848946696534, guid: 3d1911457c1e44f53b6b4044334db52f, + type: 2} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2} m_IsPrefabParent: 0 @@ -595,6 +726,11 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5d9a051e822e2cf4ea3ca01c5a4df37c, type: 3} m_Name: m_EditorClassIdentifier: + followSpeed: 0.05 + minZoom: 5 + zoomFactor: 4 + zoomSpeed: 0.05 + startingDist: 5 followThis: {fileID: 0} --- !u!114 &881384373 MonoBehaviour: @@ -608,13 +744,13 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: mixer: {fileID: 24100000, guid: efb934a745665924d8c7dd46c0a117ae, type: 2} - maintheme: {fileID: 24500006, guid: efb934a745665924d8c7dd46c0a117ae, type: 2} - end: {fileID: 245089854461186482, guid: efb934a745665924d8c7dd46c0a117ae, type: 2} + maintheme: {fileID: 1600556435} + menutheme: {fileID: 30160411} gameovers: {fileID: 801288609} soundeffects: - {fileID: 1908750963} - {fileID: 368878861} - - {fileID: 801288609} + - {fileID: 1908750963} --- !u!1 &1028937042 GameObject: m_ObjectHideFlags: 0 @@ -840,7 +976,7 @@ Prefab: - target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2} propertyPath: m_AnchoredPosition.x - value: 67.14285 + value: 65.89836 objectReference: {fileID: 0} - target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2} @@ -889,15 +1025,15 @@ Prefab: m_Modifications: - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} propertyPath: m_LocalPosition.x - value: 7.6580257 + value: 0 objectReference: {fileID: 0} - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} propertyPath: m_LocalPosition.y - value: 3.506653 + value: 0 objectReference: {fileID: 0} - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} propertyPath: m_LocalPosition.z - value: -0.08491792 + value: 0 objectReference: {fileID: 0} - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} propertyPath: m_LocalRotation.x @@ -919,6 +1055,10 @@ Prefab: propertyPath: m_RootOrder value: 5 objectReference: {fileID: 0} + - target: {fileID: 1303102899095328, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} m_IsPrefabParent: 0 @@ -959,9 +1099,10 @@ AudioSource: m_GameObject: {fileID: 1600556433} m_Enabled: 1 serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 0} - m_PlayOnAwake: 1 + OutputAudioMixerGroup: {fileID: 243359265566762914, guid: efb934a745665924d8c7dd46c0a117ae, + type: 2} + m_audioClip: {fileID: 8300000, guid: c89601ee48d799943a756d1d15cd4954, type: 3} + m_PlayOnAwake: 0 m_Volume: 1 m_Pitch: 1 Loop: 0 @@ -1239,6 +1380,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 87d25c2cd3eb97749b79f2cb5f7c5cea, type: 3} m_Name: m_EditorClassIdentifier: + scorpion: {fileID: 1303102899095328, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} BorderOuter: {fileID: 1062532744197412, guid: bc306521f11be424f9833117977b4319, type: 2} BorderInner: {fileID: 1893245914782828, guid: 7326753bf2b213d4e8c2ee93d78ba7d9, diff --git a/Assets/Scenes/TitleScene.unity b/Assets/Scenes/TitleScene.unity index dc13dd9..2bb8a9c 100644 --- a/Assets/Scenes/TitleScene.unity +++ b/Assets/Scenes/TitleScene.unity @@ -113,6 +113,131 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &52367873 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 52367874} + - component: {fileID: 52367875} + m_Layer: 0 + m_Name: menu + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &52367874 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 52367873} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 792683703} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!82 &52367875 +AudioSource: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 52367873} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 243359265566762914, guid: efb934a745665924d8c7dd46c0a117ae, + type: 2} + m_audioClip: {fileID: 8300000, guid: a90787ea4a183c44699deb2babada64b, type: 3} + m_PlayOnAwake: 1 + m_Volume: 1 + m_Pitch: 1 + Loop: 0 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 --- !u!1 &287217883 GameObject: m_ObjectHideFlags: 0 @@ -524,6 +649,7 @@ Transform: m_Children: - {fileID: 923869162} - {fileID: 287217884} + - {fileID: 52367874} m_Father: {fileID: 1926562125} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -564,9 +690,10 @@ AudioSource: m_GameObject: {fileID: 923869161} m_Enabled: 1 serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 0} - m_PlayOnAwake: 1 + OutputAudioMixerGroup: {fileID: 243359265566762914, guid: efb934a745665924d8c7dd46c0a117ae, + type: 2} + m_audioClip: {fileID: 8300000, guid: c89601ee48d799943a756d1d15cd4954, type: 3} + m_PlayOnAwake: 0 m_Volume: 1 m_Pitch: 1 Loop: 0 @@ -871,10 +998,13 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: mixer: {fileID: 24100000, guid: efb934a745665924d8c7dd46c0a117ae, type: 2} - maintheme: {fileID: 24500006, guid: efb934a745665924d8c7dd46c0a117ae, type: 2} - end: {fileID: 245089854461186482, guid: efb934a745665924d8c7dd46c0a117ae, type: 2} + maintheme: {fileID: 923869163} + menutheme: {fileID: 52367875} gameovers: {fileID: 287217885} - soundeffects: [] + soundeffects: + - {fileID: 1187801173} + - {fileID: 987581542} + - {fileID: 429380406} --- !u!1 &1039057777 GameObject: m_ObjectHideFlags: 0 @@ -1360,7 +1490,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: notifications: {fileID: 0} - gameOverPanel: {fileID: 0} + restartUIPanel: {fileID: 0} healthcontroller: {fileID: 0} mainMenuSceneIndex: 0 --- !u!1 &1586619316 @@ -1757,6 +1887,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: notifications: {fileID: 0} - gameOverPanel: {fileID: 0} + restartUIPanel: {fileID: 0} healthcontroller: {fileID: 0} mainMenuSceneIndex: 0 diff --git a/Assets/Scripts/AudioControl.cs b/Assets/Scripts/AudioControl.cs index 2a8246a..4469bde 100644 --- a/Assets/Scripts/AudioControl.cs +++ b/Assets/Scripts/AudioControl.cs @@ -6,22 +6,50 @@ using UnityEngine.Audio; public class AudioControl : MonoBehaviour { public AudioMixer mixer; - public AudioMixerSnapshot maintheme; - public AudioMixerSnapshot end; + public AudioSource maintheme; + public AudioSource menutheme; public AudioSource gameovers; public AudioSource[] soundeffects; - public enum Sfx { shoot, explosion, mobattack}; + public enum Sfx { shoot, explosion, mobattack }; - private float m_TransitionIn; - private float m_TransitionOut; - private bool endstate; + private const float lvlbgm = 6.79f; + private const float gobgm = 14.406f; + private const float loopdelay = 0.05f; + private bool menu; // Use this for initialization void Start() { - m_TransitionIn = 1.2f; - m_TransitionOut = 0.3f; + maintheme.loop = true; + menutheme.loop = true; + gameovers.loop = true; + } + + private void Update() + { + if (maintheme.time >= maintheme.clip.length - loopdelay) + maintheme.time = lvlbgm; + if (gameovers.time >= gameovers.clip.length - loopdelay) + gameovers.time = gobgm; + } + + public void GameOverBgm() + { + maintheme.Stop(); + gameovers.Play(); + } + + public void MenuBgm() + { + if (gameovers.isPlaying) + gameovers.Stop(); + menutheme.Play(); + } + + public void LevelBgm() + { + maintheme.Play(); } public void SfxPlay(int sound) @@ -42,4 +70,15 @@ public class AudioControl : MonoBehaviour { mixer.SetFloat("masterVolume", Mathf.Clamp(nvol, -80f, 20f)); } + + public void SetBgmVolume(float nvol) + { + mixer.SetFloat("bgmVolume", Mathf.Clamp(nvol, -80f, 20f)); + } + + public void SetSfxVolume(float nvol) + { + mixer.SetFloat("sfxVolume", Mathf.Clamp(nvol, -80f, 20f)); + } } + diff --git a/Assets/Scripts/BrakeBarController.cs b/Assets/Scripts/BrakeBarController.cs index f9c0ab8..5ecfdb0 100644 --- a/Assets/Scripts/BrakeBarController.cs +++ b/Assets/Scripts/BrakeBarController.cs @@ -28,16 +28,15 @@ public class BrakeBarController : MonoBehaviour { private void UpdatePointer() { - if (Input.GetKey(KeyCode.S)) + while (Input.GetKey(KeyCode.S)) { - firstTime = Time.time; + firstTime += 1; } if (Input.GetKeyUp(KeyCode.S)) { - secondTime = Time.time; - float difference = secondTime - firstTime; - gameObject.transform.Rotate(Vector3.forward, difference); + + gameObject.transform.Rotate(Vector3.forward, firstTime); } diff --git a/Assets/Scripts/Entities/Bug.cs b/Assets/Scripts/Entities/Bug.cs new file mode 100644 index 0000000..34e2062 --- /dev/null +++ b/Assets/Scripts/Entities/Bug.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using Assets.Scripts.Entities.Attack; + +namespace Assets.Scripts.Entities { + + public class Bug : Enemy { + + public Bug() : base(15) { + + } + + private void Start() { + SetAttack(new MeleeAttack(this.gameObject)); + } + } +} diff --git a/Assets/Scripts/Entities/Bug.cs.meta b/Assets/Scripts/Entities/Bug.cs.meta new file mode 100644 index 0000000..c7b9745 --- /dev/null +++ b/Assets/Scripts/Entities/Bug.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c5616b0c23c6dce40b9019a2217bc1a8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Entities/Enemy.cs b/Assets/Scripts/Entities/Enemy.cs index ee08494..9eb2959 100644 --- a/Assets/Scripts/Entities/Enemy.cs +++ b/Assets/Scripts/Entities/Enemy.cs @@ -4,7 +4,11 @@ using UnityEngine; using Assets.Scripts.Entities.Attack; namespace Assets.Scripts.Entities { - class Enemy : Mob { + public class Enemy : Mob { + public enum Enemys { + SCORPION, + BUG + } [SerializeField] private float speed = 1; diff --git a/Assets/Scripts/Entities/Player.cs b/Assets/Scripts/Entities/Player.cs index d684978..64309da 100644 --- a/Assets/Scripts/Entities/Player.cs +++ b/Assets/Scripts/Entities/Player.cs @@ -23,7 +23,7 @@ public class Player : Mob { void Update() { if ( Time.timeSinceLevelLoad >= nextAttackTime && attack != null) { - if ( Input.GetKey(KeyCode.Space) ) { + if ( Input.GetAxis("Fire") > 0 ) { Debug.Log("Attack pressed!"); attack.Attack(); nextAttackTime = Time.timeSinceLevelLoad + attack.GetCooldownTime(); diff --git a/Assets/Scripts/Entities/Spider.cs b/Assets/Scripts/Entities/Spider.cs new file mode 100644 index 0000000..88fa926 --- /dev/null +++ b/Assets/Scripts/Entities/Spider.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using Assets.Scripts.Entities.Attack; + +namespace Assets.Scripts.Entities +{ + class Spider : Enemy + { + public Spider() : base(45) + { + + } + + private void Start() + { + SetAttack(new SingleShot(this.gameObject)); + } + } +} diff --git a/Assets/Scripts/Entities/Spider.cs.meta b/Assets/Scripts/Entities/Spider.cs.meta new file mode 100644 index 0000000..18932e5 --- /dev/null +++ b/Assets/Scripts/Entities/Spider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bba8747a38e6f32488753602d0a3f3e4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index bf1e5d7..8caa4bd 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -1,11 +1,10 @@ -using System.Collections; +using Assets.Scripts.Entities; +using System.Collections; using System.Collections.Generic; using UnityEngine; public class GameController : MonoBehaviour { - - private Room start; private Room finish; @@ -13,6 +12,12 @@ public class GameController : MonoBehaviour { WIN, DIED } + // Enemy Prefabs + [Header("Enemys")] + [SerializeField] + GameObject scorpion; + + [Space(10)] // Generation Settings [Header("Tile Prefabs")] [SerializeField] @@ -67,6 +72,7 @@ public class GameController : MonoBehaviour { GameObject RockLRD; private Dictionary genPrefabs; + private Dictionary enemyPrefabs; [Space(10)] [Header("References")] @@ -97,32 +103,34 @@ public class GameController : MonoBehaviour { // Use this for initialization void Start () { - genPrefabs = new Dictionary(); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.BorderOuter, BorderOuter); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.BorderInner, BorderInner); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.BorderSingle, BorderSingle); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.Rock, Rock); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockL, RockL); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockU, RockU); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockR, RockR); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockD, RockD); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLU, RockLU); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLR, RockLR); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLD, RockLD); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLURD, RockLURD); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockRD, RockRD); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockUR, RockUR); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockUD, RockUD); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLUD, RockLUD); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLUR, RockLUR); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockURD, RockURD); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLRD, RockLRD); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.Ground0, Ground0); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.Ground1, Ground1); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.Ground2, Ground2); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.Ground3, Ground3); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.DoorInner, DoorInner); - genPrefabs.Add(GenerationProcessor.ExtendedTileType.DoorOuter, DoorOuter); + genPrefabs = new Dictionary { + { GenerationProcessor.ExtendedTileType.BorderOuter, BorderOuter }, + { GenerationProcessor.ExtendedTileType.BorderInner, BorderInner }, + { GenerationProcessor.ExtendedTileType.BorderSingle, BorderSingle }, + { GenerationProcessor.ExtendedTileType.Rock, Rock }, + { GenerationProcessor.ExtendedTileType.RockL, RockL }, + { GenerationProcessor.ExtendedTileType.RockU, RockU }, + { GenerationProcessor.ExtendedTileType.RockR, RockR }, + { GenerationProcessor.ExtendedTileType.RockD, RockD }, + { GenerationProcessor.ExtendedTileType.RockLU, RockLU }, + { GenerationProcessor.ExtendedTileType.RockLR, RockLR }, + { GenerationProcessor.ExtendedTileType.RockLD, RockLD }, + { GenerationProcessor.ExtendedTileType.RockLURD, RockLURD }, + { GenerationProcessor.ExtendedTileType.RockRD, RockRD }, + { GenerationProcessor.ExtendedTileType.RockUR, RockUR }, + { GenerationProcessor.ExtendedTileType.RockUD, RockUD }, + { GenerationProcessor.ExtendedTileType.RockLUD, RockLUD }, + { GenerationProcessor.ExtendedTileType.RockLUR, RockLUR }, + { GenerationProcessor.ExtendedTileType.RockURD, RockURD }, + { GenerationProcessor.ExtendedTileType.RockLRD, RockLRD }, + { GenerationProcessor.ExtendedTileType.Ground, Ground }, + { GenerationProcessor.ExtendedTileType.DoorInner, DoorInner }, + { GenerationProcessor.ExtendedTileType.DoorOuter, DoorOuter } + }; + enemyPrefabs = new Dictionary { + { Enemy.Enemys.SCORPION, scorpion } + }; + } // Update is called once per frame @@ -178,6 +186,7 @@ public class GameController : MonoBehaviour { doorRoot.name = "Doors"; doorRoot.transform.SetParent(goStart.transform); start = goStart.AddComponent(); + start.SetCenter(dg.start.GetCenter()); lt = lt.FindAll(x => x.tag == "door"); lt.ForEach(x => { x.SetParent(doorRoot.transform); @@ -185,7 +194,7 @@ public class GameController : MonoBehaviour { }); start.SetDoorsRootObject(doorRoot); - // WIP + // Spawnpoint GameObject spawnpointRoot = new GameObject(); spawnpointRoot.name = "Spawnpoints"; spawnpointRoot.transform.SetParent(goStart.transform); @@ -194,8 +203,9 @@ public class GameController : MonoBehaviour { spawn.transform.SetParent(spawnpointRoot.transform); spawn.transform.position = new Vector3(dg.start.GetCenter().x, dg.start.GetCenter().y, 0); start.SetSpawnPointsRootObject(spawnpointRoot); - + start.Reload(); + start.transform.SetParent(mapRoot.transform); // Finish room @@ -207,6 +217,7 @@ public class GameController : MonoBehaviour { doorRootf.transform.SetParent(goFinish.transform); ltf = ltf.FindAll(x => x.tag == "door"); finish = goFinish.AddComponent(); + finish.SetCenter(dg.end.GetCenter()); ltf.ForEach(x => { x.SetParent(doorRootf.transform); x.gameObject.GetComponent().SetParent(finish); @@ -219,18 +230,34 @@ public class GameController : MonoBehaviour { foreach (GenRoom gr in dg.rooms) { GameObject groom = gp.ProcessRoom(gr.tiles); List ltg = new List(groom.GetComponentsInChildren()); + + // Doors GameObject doorRootg = new GameObject(); doorRootg.name = "Doors"; doorRootg.transform.SetParent(groom.transform); Room grom = groom.AddComponent(); + grom.SetCenter(gr.GetCenter()); ltg = ltg.FindAll(x => x.tag == "door"); ltg.ForEach(x => { x.SetParent(doorRootg.transform); x.gameObject.GetComponent().SetParent(grom); }); - + + // Spawnpoints + GameObject tSpawnpointRoot = new GameObject(); + tSpawnpointRoot.name = "Spawnpoints"; + tSpawnpointRoot.transform.SetParent(groom.transform); + tSpawnpointRoot.transform.position = new Vector3(gr.roomPosition.x, gr.roomPosition.y, 0); + foreach(Vector2Int v in gr.spawnpoints) { + GameObject tspawn = new GameObject(); + tspawn.transform.SetParent(tSpawnpointRoot.transform); + tspawn.transform.position = new Vector3(v.x, v.y, 0); // is this the center or the top left corner of a block? + } + + grom.SetSpawnPointsRootObject(tSpawnpointRoot); grom.SetDoorsRootObject(doorRootg); grom.Reload(); + DungeonGenerator.GenerateObjective(grom); groom.transform.SetParent(mapRoot.transform); } @@ -242,6 +269,7 @@ public class GameController : MonoBehaviour { } private void Starting() { + StartObjective goal = new StartObjective(start, playerPrefab); start.SetObjective(goal); start.OnPlayerEnter(player); @@ -253,6 +281,7 @@ public class GameController : MonoBehaviour { Debug.Log("No Player spawned!"); } finish.SetObjective(new FinishObjective(finish)); + cam.GetComponent().LevelBgm(); } private void Running() { @@ -265,13 +294,12 @@ public class GameController : MonoBehaviour { if ( ui != null ) { Debug.Log("show end UI"); if(endCause == EndedCause.DIED) { - cam.GetComponent().SfxPlay(2); + cam.GetComponent().GameOverBgm(); ui.GetComponent().ShowGameOverUI(); } else if(endCause == EndedCause.WIN) { //cam.GetComponent().SfxPlay(2); ui.GetComponent().ShowWinUI(); } - } else { Debug.Log("No UI specified"); } @@ -285,6 +313,10 @@ public class GameController : MonoBehaviour { return ui.GetComponent(); } + public Dictionary GetEnemyPrefabs() { + return enemyPrefabs; + } + public bool GameEnded() { return state == GameState.ENDED; } diff --git a/Assets/Scripts/Generation/DungeonGenerator.cs b/Assets/Scripts/Generation/DungeonGenerator.cs index 7022036..80db011 100644 --- a/Assets/Scripts/Generation/DungeonGenerator.cs +++ b/Assets/Scripts/Generation/DungeonGenerator.cs @@ -1,4 +1,5 @@ -using System; +using Assets.Scripts.Entities; +using System; using System.Collections.Generic; using UnityEngine; @@ -214,13 +215,13 @@ public class DungeonGenerator { } foreach ( GenRoom r in rooms ) - makeRoomRelative(r); - makeRoomRelative(start); - makeRoomRelative(end); - makeRoomRelative(path); + MakeRoomRelative(r); + MakeRoomRelative(start); + MakeRoomRelative(end); + MakeRoomRelative(path); } - public void makeRoomRelative(GenRoom room) { + public void MakeRoomRelative(GenRoom room) { room.roomPosition = room.bounds.position; foreach ( Vector2Int v in room.tiles.Keys ) { v.Set(( v - room.roomPosition ).x, ( v - room.roomPosition ).y); @@ -439,4 +440,20 @@ public class DungeonGenerator { } } } + + public static void GenerateObjective(Room r) { + Dictionary enemyPrefabs = GameController.instance.GetEnemyPrefabs(); // TODO not so cool + // TODO add more types + Objective o; + + // ENTITYOBJECTIVE ENEMYS: + List lg = new List(); + //GameObject scorp = enemyPrefabs[Enemy.Enemys.SCORPION]; + lg.Add(enemyPrefabs[Enemy.Enemys.SCORPION]); + EntityObjective eo = new EntityObjective(r, lg); + o = eo; + + + r.SetObjective(o); + } } \ No newline at end of file diff --git a/Assets/Scripts/Generation/GenRoom.cs b/Assets/Scripts/Generation/GenRoom.cs index ada813e..c72452f 100644 --- a/Assets/Scripts/Generation/GenRoom.cs +++ b/Assets/Scripts/Generation/GenRoom.cs @@ -19,6 +19,7 @@ public class GenRoom { // All positions are in room space relative to the room's anchor public Dictionary tiles = new Dictionary(); public HashSet spawnpoints = new HashSet(); + public Objective objective = null; public float Distance(GenRoom r) { return Math.Abs(GetCenter().x - r.GetCenter().x) + Math.Abs(GetCenter().y - r.GetCenter().y); diff --git a/Assets/Scripts/Objectives/EntityObjective.cs b/Assets/Scripts/Objectives/EntityObjective.cs index 68603ad..169d14d 100644 --- a/Assets/Scripts/Objectives/EntityObjective.cs +++ b/Assets/Scripts/Objectives/EntityObjective.cs @@ -1,4 +1,5 @@ -using System.Collections; +using Assets.Scripts.Entities; +using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -26,13 +27,19 @@ public class EntityObjective : Objective { public override void ActivateGoal(Player ply) { if ( activated ) return; - activated = true; base.ActivateGoal(ply); foreach ( GameObject i in prefabList ) { Debug.Log("[ROOMS] Spawning Entity..."); + if(i == null || player == null) { + Debug.Log("[ROOMS] Failed.. Entity not set in GameController!"); + return; + } + GameObject tempObject = GameObject.Instantiate(i); List spawnPointList = room.GetSpawnpoints(); tempObject.transform.position = spawnPointList[Random.Range(0, spawnPointList.Count)].position; + tempObject.GetComponent().SetVictim(player.gameObject); + tempObject.GetComponent().SetObjective(this); entityList.Add(tempObject); } diff --git a/Assets/Scripts/PlayerMovement.cs b/Assets/Scripts/PlayerMovement.cs index 9bf3273..4989135 100644 --- a/Assets/Scripts/PlayerMovement.cs +++ b/Assets/Scripts/PlayerMovement.cs @@ -36,13 +36,13 @@ public class PlayerMovement : MonoBehaviour { { // Forward Vector3 acc = transform.up * acceleration; - if (Input.GetKey(KeyCode.S)) + if (Input.GetAxis("Vertical") < 0) acc *= 0; rb.AddForce(acc); } {// Drag Vector3 drag = speedVec.normalized * speed * speed * friction * -1; - if (Input.GetKey(KeyCode.S)) { + if (Input.GetAxis("Vertical") < 0) { drag *= brake; drag *= speed; } @@ -57,10 +57,10 @@ public class PlayerMovement : MonoBehaviour { //Debug.Log(br); Debug.DrawLine(transform.position, transform.position + br, Color.red, 0.01f, false); } - if ( Input.GetKey(KeyCode.A) ) + if ( Input.GetAxis("Horizontal") < 0 ) rb.MoveRotation(rb.rotation + turnSpeed); //transform.Rotate(Vector3.forward * turnSpeed); - if ( Input.GetKey(KeyCode.D) ) + if ( Input.GetAxis("Horizontal") > 0 ) rb.MoveRotation(rb.rotation - turnSpeed); //transform.Rotate(Vector3.forward * -turnSpeed); // Debug lines diff --git a/Assets/Scripts/Room.cs b/Assets/Scripts/Room.cs index 825cd8c..ca118f1 100644 --- a/Assets/Scripts/Room.cs +++ b/Assets/Scripts/Room.cs @@ -8,6 +8,8 @@ public class Room : MonoBehaviour { GROUND, WALL, DOOR, ROCK } + Vector2Int center; + List doors; List spawnpoints; @@ -41,6 +43,23 @@ public class Room : MonoBehaviour { Unlock(); } + /// + /// Center point in Generation phase. + /// + /// + public void SetCenter(Vector2Int v) { + center = v; + } + + /// + /// Returns the Center as global from the generation. TODO change this + /// Is available after Generation and after Start Phase. + /// + /// + public Vector2Int GetCenter() { + return center; + } + /// /// Reloads the spawnpoints and doors. /// diff --git a/Assets/Scripts/UIController.cs b/Assets/Scripts/UIController.cs index fc7d031..2568df7 100644 --- a/Assets/Scripts/UIController.cs +++ b/Assets/Scripts/UIController.cs @@ -25,7 +25,7 @@ public class UIController : MonoBehaviour void Update() { - if (Input.GetKey(KeyCode.R) && GameController.instance.GameEnded()) { + if (Input.GetAxis("Reset") > 0 && GameController.instance.GameEnded()) { LoadSceneByIndex(firstSceneIndex); } } diff --git a/Assets/graphics/textures/Entities/Enemies/Spider.png b/Assets/graphics/textures/Entities/Enemies/Spider.png new file mode 100644 index 0000000..792b1d7 Binary files /dev/null and b/Assets/graphics/textures/Entities/Enemies/Spider.png differ diff --git a/Assets/graphics/textures/Entities/Enemies/Spider.png.meta b/Assets/graphics/textures/Entities/Enemies/Spider.png.meta new file mode 100644 index 0000000..b81ddaa --- /dev/null +++ b/Assets/graphics/textures/Entities/Enemies/Spider.png.meta @@ -0,0 +1,84 @@ +fileFormatVersion: 2 +guid: e0921bbee8b59b14aa2eec08d09da8a4 +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 5 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 1a8d8bc173b67a34d8ad6da5a9124a07 + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/graphics/textures/car.meta b/Assets/graphics/textures/car.meta deleted file mode 100644 index 8504594..0000000 --- a/Assets/graphics/textures/car.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9ec323b9157704d00a3409f8ea6e46b2 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/graphics/textures/tmp.meta b/Assets/graphics/textures/tmp.meta deleted file mode 100644 index 7ebab68..0000000 --- a/Assets/graphics/textures/tmp.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: df6e7833427b5497b92308fb6f54e552 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/sound/AudioMixer.mixer b/Assets/sound/AudioMixer.mixer index b893e4e..de0a079 100644 --- a/Assets/sound/AudioMixer.mixer +++ b/Assets/sound/AudioMixer.mixer @@ -71,6 +71,7 @@ AudioMixerSnapshotController: m_SnapshotID: d3789ccdbdc046a448f1887d94c3f7f5 m_FloatValues: 25123d234de4ec84aafee1d0c380f3ad: 0.025578512 + 7e224658afaf14242ba3996793ac12a1: -7.436929 m_TransitionOverrides: {} --- !u!243 &243067197919102372 AudioMixerGroupController: diff --git a/Assets/sound/main(0.5).wav b/Assets/sound/main(0.5).wav new file mode 100644 index 0000000..390c75c Binary files /dev/null and b/Assets/sound/main(0.5).wav differ diff --git a/Assets/sound/main(0.5).wav.meta b/Assets/sound/main(0.5).wav.meta new file mode 100644 index 0000000..f9da932 --- /dev/null +++ b/Assets/sound/main(0.5).wav.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: c89601ee48d799943a756d1d15cd4954 +AudioImporter: + externalObjects: {} + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/sound/menuV1.wav b/Assets/sound/menuV1.wav new file mode 100644 index 0000000..83ede20 Binary files /dev/null and b/Assets/sound/menuV1.wav differ diff --git a/Assets/sound/menuV1.wav.meta b/Assets/sound/menuV1.wav.meta new file mode 100644 index 0000000..a7ebd32 --- /dev/null +++ b/Assets/sound/menuV1.wav.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: a90787ea4a183c44699deb2babada64b +AudioImporter: + externalObjects: {} + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset index 17c8f53..132dc85 100644 --- a/ProjectSettings/InputManager.asset +++ b/ProjectSettings/InputManager.asset @@ -38,11 +38,11 @@ InputManager: axis: 0 joyNum: 0 - serializedVersion: 3 - m_Name: Fire1 + m_Name: Fire descriptiveName: descriptiveNegativeName: negativeButton: - positiveButton: left ctrl + positiveButton: space altNegativeButton: altPositiveButton: mouse 0 gravity: 1000 @@ -293,3 +293,19 @@ InputManager: type: 0 axis: 0 joyNum: 0 + - serializedVersion: 3 + m_Name: Reset + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: r + altNegativeButton: + altPositiveButton: return + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0