diff --git a/.gitignore b/.gitignore deleted file mode 100644 index b848ed6..0000000 --- a/.gitignore +++ /dev/null @@ -1,63 +0,0 @@ -# This .gitignore file should be placed at the root of your Unity project directory -# -# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore -# -/[Ll]ibrary/ -/[Tt]emp/ -/[Oo]bj/ -/[Bb]uild/ -/[Bb]uilds/ -/[Ll]ogs/ -/[Mm]emoryCaptures/ - -# Never ignore Asset meta data -!/[Aa]ssets/**/*.meta - -# Uncomment this line if you wish to ignore the asset store tools plugin -# /[Aa]ssets/AssetStoreTools* - -# TextMesh Pro files -[Aa]ssets/TextMesh*Pro/ - -# Autogenerated Jetbrains Rider plugin -[Aa]ssets/Plugins/Editor/JetBrains* - -# Visual Studio cache directory -.vs/ - -# Gradle cache directory -.gradle/ - -# Autogenerated VS/MD/Consulo solution and project files -ExportedObj/ -.consulo/ -*.csproj -*.unityproj -*.sln -*.suo -*.tmp -*.user -*.userprefs -*.pidb -*.booproj -*.svd -*.pdb -*.mdb -*.opendb -*.VC.db - -# Unity3D generated meta files -*.pidb.meta -*.pdb.meta -*.mdb.meta - -# Unity3D generated file on crash reports -sysinfo.txt - -# Builds -*.apk -*.unitypackage - -# Crashlytics generated file -crashlytics-build.properties - diff --git a/AudioEvent.meta b/AudioEvent.meta deleted file mode 100644 index 9c7c3ca..0000000 --- a/AudioEvent.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 1220f59d44ff1894fa44088749e66805 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AudioEvent/Editor.meta b/AudioEvent/Editor.meta deleted file mode 100644 index 71d66d7..0000000 --- a/AudioEvent/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a96e7eb2ddb7a534abaeeb1cc2f568aa -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AudioEvent/Editor/CustomInspectors.meta b/AudioEvent/Editor/CustomInspectors.meta deleted file mode 100644 index ac156e3..0000000 --- a/AudioEvent/Editor/CustomInspectors.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 71f62c415c75a764c96d4e1f3b86e51a -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AudioEvent/Editor/CustomInspectors/AudioEventInspector.cs.meta b/AudioEvent/Editor/CustomInspectors/AudioEventInspector.cs.meta deleted file mode 100644 index 062390a..0000000 --- a/AudioEvent/Editor/CustomInspectors/AudioEventInspector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0373dd91d1668e041b7bf832d8bc1bdb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AudioEvent/Runtime.meta b/AudioEvent/Runtime.meta deleted file mode 100644 index bf8ad97..0000000 --- a/AudioEvent/Runtime.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9bcc5f534b0cca64a9a36934a8dbf04a -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AudioEvent/Runtime/AudioEvent.cs.meta b/AudioEvent/Runtime/AudioEvent.cs.meta deleted file mode 100644 index 371db85..0000000 --- a/AudioEvent/Runtime/AudioEvent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 22fab10465bd9734099aa2aa507307b7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AudioEvent/Runtime/SimpleAudioEvent.cs.meta b/AudioEvent/Runtime/SimpleAudioEvent.cs.meta deleted file mode 100644 index 8b6249e..0000000 --- a/AudioEvent/Runtime/SimpleAudioEvent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b9efd6bfb94ac7a438475c81db125207 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/ChildUpdator/UpdateChildObjects.cs b/ChildUpdator/UpdateChildObjects.cs new file mode 100644 index 0000000..c98e0dd --- /dev/null +++ b/ChildUpdator/UpdateChildObjects.cs @@ -0,0 +1,20 @@ +using UnityEngine; + +public class UpdateChild{ + + public static void recursiveCallOnChild (GameObject _obj) + { + if (_obj == null) + return; + + //Changes to the current object + + foreach (Transform _child in _obj.transform) + { + if (_child == null) + continue; + + recursiveCallOnChild(_child.gameObject); + } + } +} \ No newline at end of file diff --git a/DiceRolling/ApplyRandForce.cs b/DiceRolling/ApplyRandForce.cs new file mode 100644 index 0000000..a918af3 --- /dev/null +++ b/DiceRolling/ApplyRandForce.cs @@ -0,0 +1,27 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ApplyRandForce : MonoBehaviour { + + public string buttonName = "Fire1"; + public float forceAmount = 10.0f; + public float torqueAmount = 10.0f; + public ForceMode forceMode; + public float maxAngularVelocity; + public Rigidbody rb; + + void Start() { + + rb.maxAngularVelocity = maxAngularVelocity; + } + + void FixedUpdate () + { + if(Input.GetButtonDown(buttonName)) + { + rb.AddForce(Random.onUnitSphere*forceAmount,forceMode); + rb.AddTorque(Random.onUnitSphere * torqueAmount, forceMode); + } + } +} diff --git a/DiceRolling/DieValue.cs b/DiceRolling/DieValue.cs new file mode 100644 index 0000000..df466e9 --- /dev/null +++ b/DiceRolling/DieValue.cs @@ -0,0 +1,11 @@ +using UnityEngine; + +public class DieValue : MonoBehaviour +{ + public int value; + + public int getValue() { + + return value; + } +} diff --git a/DiceRolling/DisplayCurrentDieValue.cs b/DiceRolling/DisplayCurrentDieValue.cs new file mode 100644 index 0000000..5427942 --- /dev/null +++ b/DiceRolling/DisplayCurrentDieValue.cs @@ -0,0 +1,31 @@ +using UnityEngine; + +public class DisplayCurrentDieValue : MonoBehaviour +{ + public LayerMask dieValueColliderLayer; + public Rigidbody rb; + + private int currentValue; + private bool rollComplete = false; + + void Update () { + + if (rb.IsSleeping() && !rollComplete) + { + rollComplete = true; + Debug.Log("Dice stopped rolling, result is: " + currentValue.ToString()); + } + else if(!rb.IsSleeping()) + { + rollComplete = false; + } + + RaycastHit hit; + + if(Physics.Raycast(transform.position,Vector3.up,out hit,Mathf.Infinity,dieValueColliderLayer)){ + + // Reading the value of the collider on the die top face + currentValue = hit.collider.GetComponent().getValue(); + } + } +} \ No newline at end of file diff --git a/Grid System/GridSystem.cs b/Grid System/GridSystem.cs new file mode 100644 index 0000000..a64fa67 --- /dev/null +++ b/Grid System/GridSystem.cs @@ -0,0 +1,226 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class GridSystem : MonoBehaviour { + + public LayerMask mask; + public GameObject prefab; + public float nodeSize = 1f; + + private Grid grid; + private GameObject currentPrefab; + private int gridSizeX; + private int gridSizeZ; + private Boolean currentPrefabOnMat = false; + + // Use this for initialization + void Start () { + + //Get Size of the gameMat + GetGridSize(); + + //Create the grid of nodes to the size of the mat + CreateGrid(); + } + + void Update () { + + CheckKeyDown(); + + CheckMouseDown(); + + currentPrefabOnMat = MovePrefabToMouse(); + } + + private Boolean MovePrefabToMouse() { + + int x; + int y; + + if (MouseOnTableMat(out x, out y)) { + + if (currentPrefab != null) { + + if (x != -1 && y != -1) { + + MoveCurrentPrefab(x, y); + return prefabOnMat(); + } + } + } + + return false; + } + + private bool prefabOnMat() { + + Boolean onMat = true; + + foreach (Transform child in currentPrefab.transform) { + + int x = Mathf.FloorToInt(currentPrefab.transform.position.x - + nodeSize / 2 + + child.localPosition.x / nodeSize + + gridSizeX / 2 - + transform.position.x); + + int y = Mathf.FloorToInt(currentPrefab.transform.position.z - + nodeSize / 2 + + child.localPosition.z / nodeSize + + gridSizeZ / 2 - + transform.position.z); + + if (!(Mathf.Clamp(x, 0, gridSizeX - 1) == x && + Mathf.Clamp(y, 0, gridSizeZ - 1) == y)) { + + onMat = false; + } else { + + if (grid.grid[x, y].occupied) { + + onMat = false; + } + } + } + + return onMat; + } + + private void CheckMouseDown() { + + if (Input.GetMouseButtonDown(0) && currentPrefabOnMat) { + + foreach (Transform child in currentPrefab.transform) { + + int x = Mathf.Clamp( + Mathf.FloorToInt(currentPrefab.transform.position.x - + nodeSize / 2 + + child.localPosition.x / nodeSize + + gridSizeX / 2 - + transform.position.x), + 0, gridSizeX - 1); + + int y = Mathf.Clamp( + Mathf.FloorToInt(currentPrefab.transform.position.z - + nodeSize / 2 + + child.localPosition.z / nodeSize + + gridSizeZ / 2 - + transform.position.z), + 0, gridSizeZ - 1); + + grid.grid[x, y].occupied = true; + } + + currentPrefab = null; + } + } + + private void CheckKeyDown() { + + if (Input.GetKeyDown(KeyCode.A)) { + + if (currentPrefab == null) { + + currentPrefab = Instantiate(prefab) + } else { + + Destroy(currentPrefab); + } + } + } + + private void MoveCurrentPrefab(int x, int y) { + + currentPrefab.transform.position = grid.grid[x,y].centerWorldPosition; + } + + private bool MouseOnTableMat(out int x, out int y) { + + Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); + RaycastHit hitPoint; + + if (Physics.Raycast(ray, out hitPoint, Mathf.Infinity, mask)) { + + if (hitPoint.collider == GetComponent()) { + + x = Mathf.Clamp( + Mathf.FloorToInt(hitPoint.point.x - transform.position.x + gridSizeX / 2), + 0, gridSizeX - 1); + + y = Mathf.Clamp( + Mathf.FloorToInt(hitPoint.point.z - transform.position.z + gridSizeZ / 2), + 0, gridSizeZ - 1); + + return true; + } + } + x = -1; + y = -1; + return false; + } + + private void GetGridSize() { + + Bounds borders = GetComponent().bounds; + gridSizeX = Mathf.RoundToInt(borders.size.x); + gridSizeZ = Mathf.RoundToInt(borders.size.z); + + } + + private void CreateGrid() { + + grid = new Grid(transform.position, gridSizeX, gridSizeZ, nodeSize); + + } +} + +public class Node{ + + public Vector3 centerWorldPosition; + public bool occupied; + + public Node(Vector3 centerWorldPosition) + { + this.centerWorldPosition = centerWorldPosition; + occupied = false; + } +} + +public class Grid{ + + public Node[,] grid; + + public Grid(Vector3 gridCenter, int gridSizeX, int gridSizeZ, float NodeSize){ + + grid = new Node[gridSizeX, gridSizeZ]; + + for (int row = 0 ; row < gridSizeX; row++){ + for (int collumn = 0; collumn < gridSizeZ ; collumn++){ + + Vector3 centerWorldPosition = gridCenter - (Vector3.right * gridSizeX / 2) - + (Vector3.forward * gridSizeZ / 2) + + (Vector3.right * NodeSize * row) + + (Vector3.forward * NodeSize * collumn) + + (Vector3.right * NodeSize / 2) + + (Vector3.forward * NodeSize / 2); + + grid[row,collumn] = new Node(centerWorldPosition); + } + } + } + + public String toString() { + + String str = ""; + + for (int i = 0; i < 8; i++) { + for (int y = 0; y < 4; y++) { + str += $"\n[{i},{y}] : {grid[i, y].centerWorldPosition} - {grid[i, y].occupied}"; + } + } + + return str; + } +} \ No newline at end of file diff --git a/ObjectPool.meta b/ObjectPool.meta deleted file mode 100644 index e4055dd..0000000 --- a/ObjectPool.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ed104cff818dd9643a0c648e14fd1f31 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/ObjectPool/ObjectPool.cs.meta b/ObjectPool/ObjectPool.cs.meta deleted file mode 100644 index 765ec6c..0000000 --- a/ObjectPool/ObjectPool.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2a32ed5a87970504ab455fe01309c3d6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/README.md.meta b/README.md.meta deleted file mode 100644 index 2409896..0000000 --- a/README.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 763c15382e59a164ebdff5864aecb39e -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/RangedFloat.meta b/RangedFloat.meta deleted file mode 100644 index ce66796..0000000 --- a/RangedFloat.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3ac8f31b4b5810f4c90b404c9d3b97da -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/RangedFloat/Editor.meta b/RangedFloat/Editor.meta deleted file mode 100644 index fed90bb..0000000 --- a/RangedFloat/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6d8cb581925ee804885a8ec82903d2b4 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/RangedFloat/Editor/PropertyDrawers.meta b/RangedFloat/Editor/PropertyDrawers.meta deleted file mode 100644 index 5a7f1ce..0000000 --- a/RangedFloat/Editor/PropertyDrawers.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e8cc4ef9992a5324d967ec33b1b45a83 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/RangedFloat/Editor/PropertyDrawers/RangedFloatDrawer.cs.meta b/RangedFloat/Editor/PropertyDrawers/RangedFloatDrawer.cs.meta deleted file mode 100644 index 9a00415..0000000 --- a/RangedFloat/Editor/PropertyDrawers/RangedFloatDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 51f16956506f22d4fa6beb4d34e1d305 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/RangedFloat/Runtime.meta b/RangedFloat/Runtime.meta deleted file mode 100644 index 250dd15..0000000 --- a/RangedFloat/Runtime.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 168620767289dab44bd06658329309f2 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/RangedFloat/Runtime/MinMaxRangeAttribute.cs.meta b/RangedFloat/Runtime/MinMaxRangeAttribute.cs.meta deleted file mode 100644 index 6dedfb0..0000000 --- a/RangedFloat/Runtime/MinMaxRangeAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 29292e9219556084ca741e3c38de8bdc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/RangedFloat/Runtime/RangedFloat.cs.meta b/RangedFloat/Runtime/RangedFloat.cs.meta deleted file mode 100644 index 783f046..0000000 --- a/RangedFloat/Runtime/RangedFloat.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 24e8535b0b8f8ee438da963a2d30a8d7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/UI.meta b/UI.meta deleted file mode 100644 index c206e6a..0000000 --- a/UI.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 62b9a4f94fa31be4b86d5a1d759f47d8 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/UI/Components.meta b/UI/Components.meta deleted file mode 100644 index b0b8df3..0000000 --- a/UI/Components.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 170d1dc9c78555242810089f9a3a199a -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/UI/Components/ComponentBase.cs.meta b/UI/Components/ComponentBase.cs.meta deleted file mode 100644 index 4dddf51..0000000 --- a/UI/Components/ComponentBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d961a027f07f54e4fa6d29c5a89cbdae -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/UI/Components/SliderComponent.cs.meta b/UI/Components/SliderComponent.cs.meta deleted file mode 100644 index b0aec6c..0000000 --- a/UI/Components/SliderComponent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 495594b1395bddc46b61b4cd39db5b9e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/UI/Components/TextComponent.cs.meta b/UI/Components/TextComponent.cs.meta deleted file mode 100644 index ddd3a1c..0000000 --- a/UI/Components/TextComponent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 787c538390b3f55469e462126272a197 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Unity.johnsonutils.asmdef b/Unity.johnsonutils.asmdef deleted file mode 100644 index 4222b6d..0000000 --- a/Unity.johnsonutils.asmdef +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "johnsonutils", - "references": [ - "GUID:6055be8ebefd69e48b49212b09b47b2f" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Unity.johnsonutils.asmdef.meta b/Unity.johnsonutils.asmdef.meta deleted file mode 100644 index bb521ab..0000000 --- a/Unity.johnsonutils.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 81a2d0c288f3eb34abca706b734ef42c -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Utility/PopupMessage.cs b/Utility/PopupMessage.cs new file mode 100644 index 0000000..a67ede5 --- /dev/null +++ b/Utility/PopupMessage.cs @@ -0,0 +1,38 @@ +using System.Collections; +using UnityEngine; +using UnityEngine.UI; +using TMPro; + +/// +/// This class sets the text and image of the popup message +/// +public class PopupMessage : MonoBehaviour +{ + public TextMeshProUGUI popupMessage; + private Image image; + + /// + /// Gets the X mark image in the child object + /// + private void Awake() + { + image = GetComponentsInChildren()[1]; + } + + + /// + /// Sets the new test and shows or hides the X mark image. + /// Hides the whole gameObject after 2 seconds + /// + /// + /// + /// + public IEnumerator Reset(string newText, bool enabled = false) + { + + popupMessage.text = newText; + image.gameObject.SetActive(enabled); + yield return new WaitForSeconds(2f); + gameObject.SetActive(false); + } +} diff --git a/package.json b/package.json deleted file mode 100644 index 6bbf68c..0000000 --- a/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "com.johnson-utils", - "version": "1.0.1", - "displayName": "Johnson Utils", - "description": "Utility used in prototypes and game dev", - "unity": "2019.3", - "author":{ - "name": "Martin Johnson", - "email": "martinjohnson@live.ca" - } -} diff --git a/package.json.meta b/package.json.meta deleted file mode 100644 index c463447..0000000 --- a/package.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 3f5fd77dea328bc47b5c1f706630fddb -PackageManifestImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: