|
@ -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 |
|
|
{ |
|
|
{ |
|
|