diff --git a/Assets/ParentBehaviour.cs b/Assets/ParentBehaviour.cs index f7258bb..d8985da 100644 --- a/Assets/ParentBehaviour.cs +++ b/Assets/ParentBehaviour.cs @@ -29,14 +29,15 @@ public class ParentBehaviour : MonoBehaviour public GameObject parentBodyObj; public GameObject parentFaceObj; public GameObject parentDialougeObj; + public GameObject parentDialogueOutline; + public Transform parentRoot; + + public Vector3 slideDistance = Vector3.right; private void Start() { - Texture _displayGraphic = parentBases[Random.Range(0, parentBases.Length)]; - parentBodyObj.GetComponent().sprite = Sprite.Create((Texture2D)_displayGraphic, new Rect(0.0f, 0.0f, _displayGraphic.width, _displayGraphic.height), new Vector2(0.5f, 0.5f), 100.0f); - - _displayGraphic = parentFaceNeutral; - parentFaceObj.GetComponent().sprite = Sprite.Create((Texture2D)_displayGraphic, new Rect(0.0f, 0.0f, _displayGraphic.width, _displayGraphic.height), new Vector2(0.5f, 0.5f), 100.0f); + GetRandomChild(); + GenerateVisuals(); } [ContextMenu("Get Random Child")] @@ -74,7 +75,7 @@ public class ParentBehaviour : MonoBehaviour public bool CheckChild(GameObject _child) { - if (_child == child) + if (ReferenceEquals(_child, child)) { return true; } @@ -84,6 +85,47 @@ public class ParentBehaviour : MonoBehaviour } } + public IEnumerator SlideInOut(Vector3 endPos, float slideTime) + { + parentDialougeObj.SetActive(false); + parentDialogueOutline.SetActive(false); + + Vector3 startPos = parentRoot.position; + float timeElapsed = 0; + + while(timeElapsed < slideTime) + { + parentRoot.position = Vector3.Lerp(startPos, endPos, timeElapsed / slideTime); + yield return new WaitForEndOfFrame(); + timeElapsed += Time.deltaTime; + } + + parentRoot.position = endPos; + + GetRandomChild(); + GenerateVisuals(); + + while (timeElapsed < slideTime) + { + parentRoot.position = Vector3.Lerp(endPos, startPos, timeElapsed / slideTime); + yield return new WaitForEndOfFrame(); + timeElapsed += Time.deltaTime; + } + + parentRoot.position = startPos; + parentDialougeObj.SetActive(true); + parentDialogueOutline.SetActive(true); + } + + public void GenerateVisuals() + { + Texture _displayGraphic = parentBases[Random.Range(0, parentBases.Length)]; + parentBodyObj.GetComponent().sprite = Sprite.Create((Texture2D)_displayGraphic, new Rect(0.0f, 0.0f, _displayGraphic.width, _displayGraphic.height), new Vector2(0.5f, 0.5f), 100.0f); + + _displayGraphic = parentFaceNeutral; + parentFaceObj.GetComponent().sprite = Sprite.Create((Texture2D)_displayGraphic, new Rect(0.0f, 0.0f, _displayGraphic.width, _displayGraphic.height), new Vector2(0.5f, 0.5f), 100.0f); + } + public Texture GiveDetails(GameObject _child) { @@ -170,6 +212,9 @@ public class ParentBehaviour : MonoBehaviour { print("correct child"); //this is the correct child + GameObject player = collision.collider.gameObject.GetComponent().lastHeld; + player.GetComponent().AddScore(1); + StartCoroutine(SlideInOut(parentRoot.position + slideDistance, 2)); } else { diff --git a/Assets/Scenes/MainGameplayScene.unity b/Assets/Scenes/MainGameplayScene.unity index 4117a60..4c599fe 100644 --- a/Assets/Scenes/MainGameplayScene.unity +++ b/Assets/Scenes/MainGameplayScene.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cd6c2b026d418348f41a0b308c5edda29bf1146439af0f4c10d0263bbc759a20 -size 721162 +oid sha256:708cbd87a4974182228caa13000e3f07016a9f0c7d6aba855f750510ccac0df2 +size 723429 diff --git a/Assets/Scripts/Behaviours/YeetController.cs b/Assets/Scripts/Behaviours/YeetController.cs index 5c748c8..563c6eb 100644 --- a/Assets/Scripts/Behaviours/YeetController.cs +++ b/Assets/Scripts/Behaviours/YeetController.cs @@ -46,7 +46,7 @@ public class YeetController : InputBehaviour public void Hold(GameObject child) { - m_audioSource.clip = childClips[Random.Range(0,childClips.Length)]; + m_audioSource.clip = childClips[Random.Range(0, childClips.Length)]; _child = child; _child.transform.parent = parent.transform; @@ -73,7 +73,7 @@ public class YeetController : InputBehaviour public void Yeet() { - m_audioSource.clip = yeetClips[Random.Range(0,yeetClips.Length)]; + m_audioSource.clip = yeetClips[Random.Range(0, yeetClips.Length)]; m_YeetAnimator.SetBool("Yeet", false); m_YeetAnimator.SetBool("Carry", false); @@ -93,20 +93,20 @@ public class YeetController : InputBehaviour void Start() { - + } void Update() { - switch(yeetState) + switch (yeetState) { case YeetState.Yeeting: m_time -= Time.deltaTime; - if(m_time <= 0f) + if (m_time <= 0f) { Debug.Log("YeetController.Update: Yeet finished"); - yeetState = YeetState.Unheld; + yeetState = YeetState.Unheld; } break; case YeetState.Preyeet: @@ -160,26 +160,30 @@ public class YeetController : InputBehaviour } private void OnTriggerExit(Collider collider) - { + { m_child = null; } private void OnYeet(InputAction.CallbackContext args) { + parent = m_body; switch (yeetState) { case YeetController.YeetState.Unheld: - if(m_child) + if (m_child/* && args.phase == InputActionPhase.Performed*/) Hold(m_child); // Grab nearest baby break; case YeetState.Preyeet: - Yeet(); + /*if (args.phase == InputActionPhase.Performed)*/ + Yeet(); break; case YeetController.YeetState.Held: + /*if (args.phase == InputActionPhase.Started)*/ + Preyeet(); // Yeet baby - Preyeet(); + break; case YeetController.YeetState.Yeeting: // Cooldown? @@ -190,10 +194,12 @@ public class YeetController : InputBehaviour public override void RegisterInput(PlayerInput playerInput) { playerInput.currentActionMap.FindAction("Yeet").performed += OnYeet; + playerInput.currentActionMap.FindAction("Yeet").started += OnYeet; } public override void UnregisterInput(PlayerInput playerInput) { playerInput.currentActionMap.FindAction("Yeet").performed -= OnYeet; + playerInput.currentActionMap.FindAction("Yeet").started -= OnYeet; } } \ No newline at end of file diff --git a/Assets/Scripts/Player Scripts/PlayerDataHolder.cs b/Assets/Scripts/Player Scripts/PlayerDataHolder.cs index 5e657d8..f134d36 100644 --- a/Assets/Scripts/Player Scripts/PlayerDataHolder.cs +++ b/Assets/Scripts/Player Scripts/PlayerDataHolder.cs @@ -1,16 +1,26 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.InputSystem; -public class PlayerDataHolder : MonoBehaviour +public class PlayerDataHolder : InputBehaviour { - private PlayerData m_Data; + + public void AddScore(int value) + { + m_data.Score += value; + } + + public override void RegisterInput(PlayerInput playerInput) + { + //do nothing + } - public void Initialise(PlayerData data) + public override void UnregisterInput(PlayerInput playerInput) { - m_Data = data; + //do nothing } } diff --git a/Assets/Scripts/Player Scripts/PlayerList.cs b/Assets/Scripts/Player Scripts/PlayerList.cs index 3abf563..7677cb0 100644 --- a/Assets/Scripts/Player Scripts/PlayerList.cs +++ b/Assets/Scripts/Player Scripts/PlayerList.cs @@ -30,8 +30,6 @@ public class PlayerList : ScriptableObject PlayerData data = PlayerData.Initialise(ID, color, input); - data.Score = Random.Range(2, 10); - Players.Add(input, data); OnPlayerJoin?.Invoke(this,data); diff --git a/Assets/World Assets/Materials/YeetLine.mat b/Assets/World Assets/Materials/YeetLine.mat new file mode 100644 index 0000000..e028dd6 --- /dev/null +++ b/Assets/World Assets/Materials/YeetLine.mat @@ -0,0 +1,91 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-2257088553846951987 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 2 +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: YeetLine + m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: 2000 + stringTagMap: + RenderType: Opaque + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _AlphaClip: 0 + - _Blend: 0 + - _BumpScale: 1 + - _Cull: 2 + - _Cutoff: 0.5 + - _DstBlend: 0 + - _EnvironmentReflections: 1 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _Metallic: 0 + - _OcclusionStrength: 1 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _Surface: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/World Assets/Materials/YeetLine.mat.meta b/Assets/World Assets/Materials/YeetLine.mat.meta new file mode 100644 index 0000000..1fc8144 --- /dev/null +++ b/Assets/World Assets/Materials/YeetLine.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e4dd9001cbdeb53449bec6dddcf07c3d +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/World Assets/Prefabs/Player.prefab b/Assets/World Assets/Prefabs/Player.prefab index 3f5a316..fa352e4 100644 --- a/Assets/World Assets/Prefabs/Player.prefab +++ b/Assets/World Assets/Prefabs/Player.prefab @@ -149,10 +149,10 @@ MonoBehaviour: - {fileID: 8300000, guid: e94b59152076fa3438110c323273dd1b, type: 3} - {fileID: 8300000, guid: 1c23e0594d4849e48bbdd0f8825a87d4, type: 3} yeetVelocity: 20 - yeetDuration: 2 - windupSpeed: 0.05 + yeetDuration: 0 + windupSpeed: 0.1 m_YeetAnimator: {fileID: 7280267804803618209} - trajectoryLineMaterial: {fileID: 10301, guid: 0000000000000000f000000000000000, type: 0} + trajectoryLineMaterial: {fileID: 2100000, guid: e4dd9001cbdeb53449bec6dddcf07c3d, type: 2} --- !u!1 &6496616781582263990 GameObject: m_ObjectHideFlags: 0