// Start is called before the first frame update void Start() { _petMovement = GetComponent <PetMovement>(); _jellyMesh = GetComponent <JellyMesh>(); _renderer = GetComponent <MeshRenderer>(); _animator = GetComponent <Animator>(); _foodSpawner = GameObject.Find("FoodSpawner").GetComponent <FoodSpawner>(); _interactor = GetComponent <PetInteractor>(); _sounds = GetComponent <PetSounds>(); _stats = GetComponent <PetStats>(); string debugActionList = ""; // Use reflection to find every type that inherits from BasePetAction, instansiate it, and stick it in _actions foreach (var type in System.AppDomain.CurrentDomain.GetAllDerivedTypes(typeof(BasePetAction))) { var action = (BasePetAction)Activator.CreateInstance(type); action.Init(gameObject); _actions.Add(action); debugActionList += type.ToString() + " "; } Debug.Log("Loaded " + _actions.Count + " pet actions: " + debugActionList); StartCoroutine(Tick()); }
/// <summary> /// Pull the relevant scripts from the Pet gameobject, called once at start of game /// </summary> /// <param name="pet"></param> public void Init(GameObject pet) { _petMovement = pet.GetComponent <PetMovement>(); _foodSpawner = GameObject.Find("FoodSpawner").GetComponent <FoodSpawner>(); _stockpileArea = GameObject.Find("StockpileArea").GetComponent <StockpileArea>(); _interactor = pet.GetComponent <PetInteractor>(); _sounds = pet.GetComponent <PetSounds>(); _stats = pet.GetComponent <PetStats>(); _observer = pet.GetComponent <PetObserver>(); this._pet = pet; }
// Start is called before the first frame update void Start() { _petMovement = GetComponent <PetMovement>(); _jellyMesh = GetComponent <JellyMesh>(); _renderer = GetComponent <MeshRenderer>(); _animator = GetComponent <Animator>(); _foodSpawner = GameObject.Find("FoodSpawner").GetComponent <FoodSpawner>(); _stockpileArea = GameObject.Find("StockpileArea").GetComponent <StockpileArea>(); _interactor = GetComponent <PetInteractor>(); _sounds = GetComponent <PetSounds>(); StartCoroutine(Tick()); }
void Start() { _petMovement = GetComponent <PetMovement>(); _sounds = GetComponent <PetSounds>(); }