From 6320a8cbe8b56655f75f78e24d26feacfd9194ac Mon Sep 17 00:00:00 2001 From: JoshuaReason Date: Thu, 21 Mar 2019 16:35:48 +1100 Subject: [PATCH] -For Loop -Jump Block -Pro tools --- Assets/Logic Blocks/ForLoop.asset | 3 ++ Assets/Logic Blocks/ForLoop.asset.meta | 8 ++++ Assets/Logic Blocks/Jump.asset | 3 ++ Assets/Logic Blocks/Jump.asset.meta | 8 ++++ Assets/Models.meta | 8 ++++ Assets/Scenes/TuteLevelFive.unity | 46 +++++++++++++++++++- Assets/Scripts/BlockInput.cs | 23 ++++++++++ Assets/Scripts/BlockInput.cs.meta | 11 +++++ Assets/Scripts/Logic/BlockReader.cs | 11 ++--- Assets/Scripts/Logic/Blocks/CombinedBlock.cs | 37 ++++++++++++++-- Assets/Scripts/Logic/Blocks/Jump.cs | 28 ++++++++++++ Assets/Scripts/Logic/Blocks/Jump.cs.meta | 11 +++++ Assets/Scripts/LogicBlocks.meta | 8 ++++ Packages/manifest.json | 6 ++- 14 files changed, 199 insertions(+), 12 deletions(-) create mode 100644 Assets/Logic Blocks/ForLoop.asset create mode 100644 Assets/Logic Blocks/ForLoop.asset.meta create mode 100644 Assets/Logic Blocks/Jump.asset create mode 100644 Assets/Logic Blocks/Jump.asset.meta create mode 100644 Assets/Models.meta create mode 100644 Assets/Scripts/BlockInput.cs create mode 100644 Assets/Scripts/BlockInput.cs.meta create mode 100644 Assets/Scripts/Logic/Blocks/Jump.cs create mode 100644 Assets/Scripts/Logic/Blocks/Jump.cs.meta create mode 100644 Assets/Scripts/LogicBlocks.meta diff --git a/Assets/Logic Blocks/ForLoop.asset b/Assets/Logic Blocks/ForLoop.asset new file mode 100644 index 0000000..8003853 --- /dev/null +++ b/Assets/Logic Blocks/ForLoop.asset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:815e838d40fc858ba3fca1d9f6ac75c76fdd5b6e1859a7145c142a7f636d3a5f +size 616 diff --git a/Assets/Logic Blocks/ForLoop.asset.meta b/Assets/Logic Blocks/ForLoop.asset.meta new file mode 100644 index 0000000..546bcab --- /dev/null +++ b/Assets/Logic Blocks/ForLoop.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 194f051bd7d3e7d4fb5b96a8e1d5b162 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Logic Blocks/Jump.asset b/Assets/Logic Blocks/Jump.asset new file mode 100644 index 0000000..3f6b9f7 --- /dev/null +++ b/Assets/Logic Blocks/Jump.asset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b1a4c27ea4794695f72f8d3f5d345c28103a2b6cc53e67b8f24f0757617b5e7 +size 449 diff --git a/Assets/Logic Blocks/Jump.asset.meta b/Assets/Logic Blocks/Jump.asset.meta new file mode 100644 index 0000000..efb2a9d --- /dev/null +++ b/Assets/Logic Blocks/Jump.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8f19e10be0ee35345a97f600791a8747 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Models.meta b/Assets/Models.meta new file mode 100644 index 0000000..5346456 --- /dev/null +++ b/Assets/Models.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 296bd90e667df1f4697823a0aa45acf0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/TuteLevelFive.unity b/Assets/Scenes/TuteLevelFive.unity index a5efd38..2986733 100644 --- a/Assets/Scenes/TuteLevelFive.unity +++ b/Assets/Scenes/TuteLevelFive.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.4465785, g: 0.49641222, b: 0.57481694, a: 1} + m_IndirectSpecularColor: {r: 0.44657868, g: 0.49641263, b: 0.57481706, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -1517,6 +1517,11 @@ PrefabInstance: propertyPath: nextScene value: objectReference: {fileID: 0} + - target: {fileID: 2631002120179805110, guid: c176f4ae8f7b4074db99b27b2e015a2a, + type: 3} + propertyPath: m_Enabled + value: 0 + objectReference: {fileID: 0} - target: {fileID: 1116712125457233699, guid: c176f4ae8f7b4074db99b27b2e015a2a, type: 3} propertyPath: m_Materials.Array.data[0] @@ -3475,6 +3480,45 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: bf82e6870e62966448210c1718aa3fb3, type: 3} +--- !u!1 &1510348215 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 7426725930156175983, guid: c176f4ae8f7b4074db99b27b2e015a2a, + type: 3} + m_PrefabInstance: {fileID: 421711684} + m_PrefabAsset: {fileID: 0} +--- !u!114 &1510348216 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1510348215} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c0bbbf19cb68b2742bd80855243b64e3, type: 3} + m_Name: + m_EditorClassIdentifier: + character: {fileID: 1510348219} + blockReader: + LogicChain: + - {fileID: 11400000, guid: 48f0ea7af28c10846b5b76ce70d06b60, type: 2} + - {fileID: 11400000, guid: 48f0ea7af28c10846b5b76ce70d06b60, type: 2} + - {fileID: 11400000, guid: aa238796cf1886244951ec8c2fed1855, type: 2} + - {fileID: 11400000, guid: 0b1bcd75cb7dade4fb598ee3412594c2, type: 2} + - {fileID: 11400000, guid: 41f4cb946475b2849a802a8297d81e25, type: 2} + - {fileID: 11400000, guid: 194f051bd7d3e7d4fb5b96a8e1d5b162, type: 2} +--- !u!114 &1510348219 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 2862111851184665482, guid: c176f4ae8f7b4074db99b27b2e015a2a, + type: 3} + m_PrefabInstance: {fileID: 421711684} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1510348215} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 73c2eff8a9a01a44bb9b2c007539fc60, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &1510549798 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/BlockInput.cs b/Assets/Scripts/BlockInput.cs new file mode 100644 index 0000000..b3f9e4f --- /dev/null +++ b/Assets/Scripts/BlockInput.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class BlockInput : MonoBehaviour +{ + + public Character character; + public BlockReader blockReader; + + public void Update() + { + if (Input.GetKeyDown(KeyCode.Space)) + ReadNext(); + } + + [ContextMenu ("Read Next")] + public void ReadNext() + { + blockReader.Read(character); + } + +} diff --git a/Assets/Scripts/BlockInput.cs.meta b/Assets/Scripts/BlockInput.cs.meta new file mode 100644 index 0000000..9c74938 --- /dev/null +++ b/Assets/Scripts/BlockInput.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c0bbbf19cb68b2742bd80855243b64e3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Logic/BlockReader.cs b/Assets/Scripts/Logic/BlockReader.cs index c1c079c..0e09673 100644 --- a/Assets/Scripts/Logic/BlockReader.cs +++ b/Assets/Scripts/Logic/BlockReader.cs @@ -5,14 +5,11 @@ using UnityEngine; /// /// Class which reads a a list of logic blocks and applies to a character /// -public class BlockReader : MonoBehaviour +[System.Serializable] +public class BlockReader { #region Inspector Variables - [SerializeField] - [Tooltip("Character to be controllered by the Logic Chain")] - protected Character character; - [SerializeField] [Tooltip("List of LogicBlocks which will affected this character")] protected List LogicChain; @@ -41,9 +38,9 @@ public class BlockReader : MonoBehaviour /// /// Reads the current block in the logic chain /// + /// Character to control /// Returns false if other readers should wait for this one to run again - [ContextMenu("Do Read")] - public bool Read() + public bool Read(Character character) { //return that this is done if no more blocks left in chain if (LogicChain.Count <= currentBlockIndex) diff --git a/Assets/Scripts/Logic/Blocks/CombinedBlock.cs b/Assets/Scripts/Logic/Blocks/CombinedBlock.cs index a6255ac..93aa086 100644 --- a/Assets/Scripts/Logic/Blocks/CombinedBlock.cs +++ b/Assets/Scripts/Logic/Blocks/CombinedBlock.cs @@ -2,14 +2,45 @@ using System.Collections.Generic; using UnityEngine; +[CreateAssetMenu(menuName = "Major Project/Combined Block")] public class CombinedBlock : LogicBlock { - + #region Inspector Variables [SerializeField] - protected List SubBlocks ; + [Tooltip("Blocks this will run through")] + protected BlockReader blockReader; + #endregion Inspector Variables + + #region Private Variables + + #endregion Private Variables + + + public override bool Run(Character player) + { + BlockLogic(player); + + if (blockReader.Finished) + { + blockReader.Reset(); + RepeatCount++; + } + + return isFinished(); + } protected override void BlockLogic(Character player) { - throw new System.NotImplementedException(); + blockReader.Read(player); + } + + /// + /// Resets the block to be ready to used again + /// + public override void Reset() + { + base.Reset(); + blockReader.Reset(); } + } diff --git a/Assets/Scripts/Logic/Blocks/Jump.cs b/Assets/Scripts/Logic/Blocks/Jump.cs new file mode 100644 index 0000000..212efa1 --- /dev/null +++ b/Assets/Scripts/Logic/Blocks/Jump.cs @@ -0,0 +1,28 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +/// +/// Logic block which deals with jumping a character in a direction +/// +[CreateAssetMenu(menuName = "Major Project/Jump Block")] +public class Jump : LogicBlock +{ + + [SerializeField] + [Tooltip("Direction to Jump")] + protected Direction direction = Direction.Forward; + + #region Class Functions + + /// + /// Implementation of BlockLogic, moves the player forward + /// + /// Player to move + protected override void BlockLogic(Character player) + { + player.Jump(direction); + } + + #endregion Class Functions +} \ No newline at end of file diff --git a/Assets/Scripts/Logic/Blocks/Jump.cs.meta b/Assets/Scripts/Logic/Blocks/Jump.cs.meta new file mode 100644 index 0000000..b6f2f9f --- /dev/null +++ b/Assets/Scripts/Logic/Blocks/Jump.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4c5d56197e5cfdc40afd3ac716cda850 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/LogicBlocks.meta b/Assets/Scripts/LogicBlocks.meta new file mode 100644 index 0000000..98af9d1 --- /dev/null +++ b/Assets/Scripts/LogicBlocks.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8936b441d7647f74884c94f97bfb8931 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/manifest.json b/Packages/manifest.json index bd0c348..c244bd2 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -7,6 +7,7 @@ "com.unity.purchasing": "2.0.3", "com.unity.textmeshpro": "1.3.0", "com.unity.modules.ai": "1.0.0", + "com.unity.progrids": "3.0.0", "com.unity.modules.animation": "1.0.0", "com.unity.modules.assetbundle": "1.0.0", "com.unity.modules.audio": "1.0.0", @@ -36,5 +37,8 @@ "com.unity.modules.vr": "1.0.0", "com.unity.modules.wind": "1.0.0", "com.unity.modules.xr": "1.0.0" - } + }, + + "registry":"http://staging-packages.unity.com" + }