Browse Source

Merge branch 'develop' of https://git.joshuareason.com/Jam/GGJ_2021 into develop

develop
MrJDunn 3 years ago
parent
commit
fd66c05224
5 changed files with 74 additions and 30 deletions
  1. +2
    -1
      Assets/Baby.prefab
  2. +67
    -24
      Assets/ParentBehaviour.cs
  3. BIN
      Assets/Scenes/MainGameplayScene.unity
  4. +1
    -1
      Assets/Scripts/spawner.cs
  5. BIN
      ProjectSettings/TagManager.asset

+ 2
- 1
Assets/Baby.prefab View File

@ -422,7 +422,7 @@ GameObject:
- component: {fileID: 933390416532010}
m_Layer: 0
m_Name: Baby
m_TagString: Untagged
m_TagString: Child
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@ -539,6 +539,7 @@ MonoBehaviour:
faceObj: {fileID: 1577162025261597670}
topObj: {fileID: 6588930193113420027}
bottomObj: {fileID: 4834944236669872262}
m_RandomizeOnAwake: 0
--- !u!114 &933390416532010
MonoBehaviour:
m_ObjectHideFlags: 0

+ 67
- 24
Assets/ParentBehaviour.cs View File

@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ParentBehaviour : MonoBehaviour
{
@ -31,8 +32,11 @@ public class ParentBehaviour : MonoBehaviour
private void Start()
{
parentBodyObj.GetComponent<MeshRenderer>().material.mainTexture = parentBases[Random.Range(0, parentBases.Length)];
parentFaceObj.GetComponent<MeshRenderer>().material.mainTexture = parentFaceNeutral;
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);
}
[ContextMenu("Get Random Child")]
@ -45,13 +49,10 @@ public class ParentBehaviour : MonoBehaviour
child = babySpawner.transform.GetChild(_childIndex).gameObject;
if (otherParent.child != null)
if (!ReferenceEquals(child, otherParent.child) || otherParent.child == null)
{
if (child != otherParent.child)
{
//this prevents both parents asking for the same child
_validChild = true;
}
//this prevents both parents asking for the same child
_validChild = true;
}
}
Randomizer _childRandomizer = child.GetComponent<Randomizer>();
@ -67,6 +68,8 @@ public class ParentBehaviour : MonoBehaviour
order.Insert(Random.Range(0, order.Count), "eye");
order.Insert(Random.Range(0, order.Count), "top");
order.Insert(Random.Range(0, order.Count), "bottom");
GiveFirstDetail();
}
public bool CheckChild(GameObject _child)
@ -83,36 +86,43 @@ public class ParentBehaviour : MonoBehaviour
public Texture GiveDetails(GameObject _child)
{
for (int i = 0; i < order.Count; i++)
{
switch (order[i]){
case "base":
if (child.GetComponent<Randomizer>().baseObj.GetComponent<MeshRenderer>().material.mainTexture != baseVis)
if (_child.GetComponent<Randomizer>().baseObj.GetComponent<MeshRenderer>().material.mainTexture.name != baseVis.name)
{
print("returning baseVis");
return baseVis;
}
break;
case "hat":
if (child.GetComponent<Randomizer>().hatObj.GetComponent<MeshRenderer>().material.mainTexture != hatVis)
if (_child.GetComponent<Randomizer>().hatObj.GetComponent<MeshRenderer>().material.mainTexture.name != hatVis.name)
{
print("returning hatVis");
return hatVis;
}
break;
case "eye":
if (child.GetComponent<Randomizer>().eyeObj.GetComponent<MeshRenderer>().material.mainTexture != eyeVis)
if (_child.GetComponent<Randomizer>().eyeObj.GetComponent<MeshRenderer>().material.mainTexture.name != eyeVis.name)
{
print("returning eyeVis");
return eyeVis;
}
break;
case "top":
if (child.GetComponent<Randomizer>().topObj.GetComponent<MeshRenderer>().material.mainTexture != topVis)
if (_child.GetComponent<Randomizer>().topObj.GetComponent<MeshRenderer>().material.mainTexture.name != topVis.name)
{
print("returning topVis");
return topVis;
}
break;
case "bottom":
if (child.GetComponent<Randomizer>().bottomObj.GetComponent<MeshRenderer>().material.mainTexture != bottomVis)
if (_child.GetComponent<Randomizer>().bottomObj.GetComponent<MeshRenderer>().material.mainTexture.name != bottomVis.name)
{
print("returning bottomVis");
return bottomVis;
}
break;
@ -123,21 +133,54 @@ public class ParentBehaviour : MonoBehaviour
return null;
}
private void OnTriggerEnter(Collider other)
public void GiveFirstDetail()
{
if (other.gameObject.tag == "child")
Texture _displayGraphic;
switch (order[0])
{
if (CheckChild(other.gameObject))
{
//this is the correct child
}
else
case "base":
_displayGraphic = baseVis;
break;
case "hat":
_displayGraphic = hatVis;
break;
case "eye":
_displayGraphic = eyeVis;
break;
case "top":
_displayGraphic = topVis;
break;
case "bottom":
_displayGraphic = bottomVis;
break;
default:
_displayGraphic = null;
break;
}
parentDialougeObj.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);
}
private void OnCollisionEnter(Collision collision)
{
if (child != null)
{
if (collision.collider.gameObject.tag == "Child")
{
Texture _displayGraphic = GiveDetails(other.gameObject);
//display the display graphic
parentDialougeObj.GetComponent<MeshRenderer>().material.mainTexture = _displayGraphic;
if (CheckChild(collision.collider.gameObject))
{
print("correct child");
//this is the correct child
}
else
{
Texture _displayGraphic = GiveDetails(collision.collider.gameObject);
//display the display graphic
parentDialougeObj.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);
//yeet child back to centre of room
//child = collision.collider.gameObject
}
}
}
}
}

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

size 719035

+ 1
- 1
Assets/Scripts/spawner.cs View File

@ -24,7 +24,7 @@ public class spawner : MonoBehaviour
{
Vector3 _spawnPoint = RandomPointInBounds(spawnVolumes[Random.Range(0, spawnVolumes.Length)].bounds);
_spawnPoint.y = 1.5f;
_spawnPoint.y = 2.5f;
var _newChild = Instantiate(childPrefab, _spawnPoint, Quaternion.identity);
_newChild.transform.parent = this.transform;

BIN
ProjectSettings/TagManager.asset (Stored with Git LFS) View File

size 385

Loading…
Cancel
Save