|
|
@ -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<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")] |
|
|
@ -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<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) |
|
|
|
{ |
|
|
|
|
|
|
@ -170,6 +212,16 @@ public class ParentBehaviour : MonoBehaviour |
|
|
|
{ |
|
|
|
print("correct child"); |
|
|
|
//this is the correct child
|
|
|
|
GameObject player = collision.collider.gameObject.GetComponent<YeetHandle>().lastHeld; |
|
|
|
player.GetComponent<PlayerDataHolder>().AddScore(1); |
|
|
|
|
|
|
|
//destroy baby, spawn 2 more
|
|
|
|
Destroy(collision.collider.gameObject); |
|
|
|
babySpawner.SpawnBaby(); |
|
|
|
babySpawner.SpawnBaby(); |
|
|
|
|
|
|
|
//Slide, cha cha real smooth
|
|
|
|
StartCoroutine(SlideInOut(parentRoot.position + slideDistance, 2)); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|