Browse Source

Bug fixes

develop
Joshua Reason 3 years ago
parent
commit
f0a6e0facf
8 changed files with 185 additions and 27 deletions
  1. +51
    -6
      Assets/ParentBehaviour.cs
  2. BIN
      Assets/Scenes/MainGameplayScene.unity
  3. +16
    -10
      Assets/Scripts/Behaviours/YeetController.cs
  4. +14
    -4
      Assets/Scripts/Player Scripts/PlayerDataHolder.cs
  5. +0
    -2
      Assets/Scripts/Player Scripts/PlayerList.cs
  6. +91
    -0
      Assets/World Assets/Materials/YeetLine.mat
  7. +8
    -0
      Assets/World Assets/Materials/YeetLine.mat.meta
  8. +3
    -3
      Assets/World Assets/Prefabs/Player.prefab

+ 51
- 6
Assets/ParentBehaviour.cs View File

@ -29,14 +29,15 @@ public class ParentBehaviour : MonoBehaviour
public GameObject parentBodyObj; public GameObject parentBodyObj;
public GameObject parentFaceObj; public GameObject parentFaceObj;
public GameObject parentDialougeObj; public GameObject parentDialougeObj;
public GameObject parentDialogueOutline;
public Transform parentRoot;
public Vector3 slideDistance = Vector3.right;
private void Start() private void Start()
{ {
Texture _displayGraphic = parentBases[Random.Range(0, parentBases.Length)];
parentBodyObj.GetComponent<Image>().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<Image>().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")] [ContextMenu("Get Random Child")]
@ -74,7 +75,7 @@ public class ParentBehaviour : MonoBehaviour
public bool CheckChild(GameObject _child) public bool CheckChild(GameObject _child)
{ {
if (_child == child)
if (ReferenceEquals(_child, child))
{ {
return true; 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<Image>().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<Image>().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) public Texture GiveDetails(GameObject _child)
{ {
@ -170,6 +212,9 @@ public class ParentBehaviour : MonoBehaviour
{ {
print("correct child"); print("correct child");
//this is the correct child //this is the correct child
GameObject player = collision.collider.gameObject.GetComponent<YeetHandle>().lastHeld;
player.GetComponent<PlayerDataHolder>().AddScore(1);
StartCoroutine(SlideInOut(parentRoot.position + slideDistance, 2));
} }
else else
{ {

BIN
Assets/Scenes/MainGameplayScene.unity (Stored with Git LFS) View File

size 723429

+ 16
- 10
Assets/Scripts/Behaviours/YeetController.cs View File

@ -46,7 +46,7 @@ public class YeetController : InputBehaviour
public void Hold(GameObject child) 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 = child;
_child.transform.parent = parent.transform; _child.transform.parent = parent.transform;
@ -73,7 +73,7 @@ public class YeetController : InputBehaviour
public void Yeet() 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("Yeet", false);
m_YeetAnimator.SetBool("Carry", false); m_YeetAnimator.SetBool("Carry", false);
@ -93,20 +93,20 @@ public class YeetController : InputBehaviour
void Start() void Start()
{ {
} }
void Update() void Update()
{ {
switch(yeetState)
switch (yeetState)
{ {
case YeetState.Yeeting: case YeetState.Yeeting:
m_time -= Time.deltaTime; m_time -= Time.deltaTime;
if(m_time <= 0f)
if (m_time <= 0f)
{ {
Debug.Log("YeetController.Update: Yeet finished"); Debug.Log("YeetController.Update: Yeet finished");
yeetState = YeetState.Unheld;
yeetState = YeetState.Unheld;
} }
break; break;
case YeetState.Preyeet: case YeetState.Preyeet:
@ -160,26 +160,30 @@ public class YeetController : InputBehaviour
} }
private void OnTriggerExit(Collider collider) private void OnTriggerExit(Collider collider)
{
{
m_child = null; m_child = null;
} }
private void OnYeet(InputAction.CallbackContext args) private void OnYeet(InputAction.CallbackContext args)
{ {
parent = m_body; parent = m_body;
switch (yeetState) switch (yeetState)
{ {
case YeetController.YeetState.Unheld: case YeetController.YeetState.Unheld:
if(m_child)
if (m_child/* && args.phase == InputActionPhase.Performed*/)
Hold(m_child); Hold(m_child);
// Grab nearest baby // Grab nearest baby
break; break;
case YeetState.Preyeet: case YeetState.Preyeet:
Yeet();
/*if (args.phase == InputActionPhase.Performed)*/
Yeet();
break; break;
case YeetController.YeetState.Held: case YeetController.YeetState.Held:
/*if (args.phase == InputActionPhase.Started)*/
Preyeet();
// Yeet baby // Yeet baby
Preyeet();
break; break;
case YeetController.YeetState.Yeeting: case YeetController.YeetState.Yeeting:
// Cooldown? // Cooldown?
@ -190,10 +194,12 @@ public class YeetController : InputBehaviour
public override void RegisterInput(PlayerInput playerInput) public override void RegisterInput(PlayerInput playerInput)
{ {
playerInput.currentActionMap.FindAction("Yeet").performed += OnYeet; playerInput.currentActionMap.FindAction("Yeet").performed += OnYeet;
playerInput.currentActionMap.FindAction("Yeet").started += OnYeet;
} }
public override void UnregisterInput(PlayerInput playerInput) public override void UnregisterInput(PlayerInput playerInput)
{ {
playerInput.currentActionMap.FindAction("Yeet").performed -= OnYeet; playerInput.currentActionMap.FindAction("Yeet").performed -= OnYeet;
playerInput.currentActionMap.FindAction("Yeet").started -= OnYeet;
} }
} }

+ 14
- 4
Assets/Scripts/Player Scripts/PlayerDataHolder.cs View File

@ -1,16 +1,26 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; 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
} }
} }

+ 0
- 2
Assets/Scripts/Player Scripts/PlayerList.cs View File

@ -30,8 +30,6 @@ public class PlayerList : ScriptableObject
PlayerData data = PlayerData.Initialise(ID, color, input); PlayerData data = PlayerData.Initialise(ID, color, input);
data.Score = Random.Range(2, 10);
Players.Add(input, data); Players.Add(input, data);
OnPlayerJoin?.Invoke(this,data); OnPlayerJoin?.Invoke(this,data);

+ 91
- 0
Assets/World Assets/Materials/YeetLine.mat View File

@ -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: []

+ 8
- 0
Assets/World Assets/Materials/YeetLine.mat.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e4dd9001cbdeb53449bec6dddcf07c3d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

+ 3
- 3
Assets/World Assets/Prefabs/Player.prefab View File

@ -149,10 +149,10 @@ MonoBehaviour:
- {fileID: 8300000, guid: e94b59152076fa3438110c323273dd1b, type: 3} - {fileID: 8300000, guid: e94b59152076fa3438110c323273dd1b, type: 3}
- {fileID: 8300000, guid: 1c23e0594d4849e48bbdd0f8825a87d4, type: 3} - {fileID: 8300000, guid: 1c23e0594d4849e48bbdd0f8825a87d4, type: 3}
yeetVelocity: 20 yeetVelocity: 20
yeetDuration: 2
windupSpeed: 0.05
yeetDuration: 0
windupSpeed: 0.1
m_YeetAnimator: {fileID: 7280267804803618209} m_YeetAnimator: {fileID: 7280267804803618209}
trajectoryLineMaterial: {fileID: 10301, guid: 0000000000000000f000000000000000, type: 0}
trajectoryLineMaterial: {fileID: 2100000, guid: e4dd9001cbdeb53449bec6dddcf07c3d, type: 2}
--- !u!1 &6496616781582263990 --- !u!1 &6496616781582263990
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

Loading…
Cancel
Save