Global Game Jam 2021
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.6 KiB

3 years ago
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class ParentBehaviour : MonoBehaviour
  5. {
  6. public spawner babySpawner;
  7. public GameObject child;
  8. public Texture baseVis;
  9. public Texture hatVis;
  10. public Texture eyeVis;
  11. public Texture topVis;
  12. public Texture bottomVis;
  13. public List<string> order = new List<string>();
  14. [ContextMenu("Get Random Child")]
  15. public void GetRandomChild()
  16. {
  17. int _childIndex = Random.Range(0, babySpawner.transform.childCount);
  18. child = babySpawner.transform.GetChild(_childIndex).gameObject;
  19. //CHECK IF OTHER PARENT WANTS THIS CHILD (if otherParent.child == child)
  20. Randomizer _childRandomizer = child.GetComponent<Randomizer>();
  21. baseVis = _childRandomizer.baseObj.GetComponent<MeshRenderer>().material.mainTexture;
  22. hatVis = _childRandomizer.hatObj.GetComponent<MeshRenderer>().material.mainTexture;
  23. eyeVis = _childRandomizer.eyeObj.GetComponent<MeshRenderer>().material.mainTexture;
  24. topVis = _childRandomizer.topObj.GetComponent<MeshRenderer>().material.mainTexture;
  25. bottomVis = _childRandomizer.bottomObj.GetComponent<MeshRenderer>().material.mainTexture;
  26. order.Insert(Random.Range(0, order.Count), "base");
  27. order.Insert(Random.Range(0, order.Count), "hat");
  28. order.Insert(Random.Range(0, order.Count), "eye");
  29. order.Insert(Random.Range(0, order.Count), "top");
  30. order.Insert(Random.Range(0, order.Count), "bottom");
  31. foreach (string item in order)
  32. {
  33. print(item);
  34. }
  35. }
  36. }