private void Awake() { gameScreen = FindObjectOfType <Game>(); petNameLabel = transform.gameObject.GetComponent <Text>(); pet = FindObjectOfType <PetBehavior>(); }
// Use this for initialization void Awake() { // get existing pet object from screen pet = GameObject.FindObjectOfType <PetBehavior>(); petRenderer = GameObject.FindObjectOfType <PetRenderer>(); // set bar values, crude way energySlider = GameObject.FindGameObjectWithTag("energyBar").GetComponent <Slider>(); happinessSlider = GameObject.FindGameObjectWithTag("happinessBar").GetComponent <Slider>(); energySlider.value = pet.energy; happinessSlider.value = pet.happiness; // set buttons eatButton = GameObject.FindGameObjectWithTag("eatButton").GetComponent <Button>(); bathButton = GameObject.FindGameObjectWithTag("bathButton").GetComponent <Button>(); playButton = GameObject.FindGameObjectWithTag("playButton").GetComponent <Button>(); sleepButton = GameObject.FindGameObjectWithTag("sleepButton").GetComponent <Button>(); treatPetButton = GameObject.FindGameObjectWithTag("medicineButton").GetComponent <Button>(); patButton = GameObject.FindGameObjectWithTag("patButton").GetComponent <Button>(); // timers eatTimer = GameObject.FindGameObjectWithTag("foodTimer").GetComponent <Text>(); playTimer = GameObject.FindGameObjectWithTag("playTimer").GetComponent <Text>(); rubTimer = GameObject.FindGameObjectWithTag("rubTimer").GetComponent <Text>(); sleepTimer = GameObject.FindGameObjectWithTag("sleepTimer").GetComponent <Text>(); }
// Use this for initialization void Start() { currentPet = GameObject.FindObjectOfType <PetBehavior>(); if (File.Exists(savePath)) { Load(); } // Debug.Log(currentPet.isSleep); // currentPet.SleepWake(); petDataLoaded = true; }
public PetBehavior CreatePet(uint sceneid, string uid, int entityType, GameObject go) { PetBehavior pet = go.GetComponent <PetBehavior>(); if (pet == null) { pet = go.AddComponent <PetBehavior>(); } entityBehaviors.Add(uid, pet); pet.uid = uid; pet.entityType = entityType; pet.sceneid = sceneid; pet.OnNewObject(); return(pet); }
static int CreatePet(IntPtr L) { try { ToLua.CheckArgsCount(L, 5); EntityBehaviorMgr obj = (EntityBehaviorMgr)ToLua.CheckObject(L, 1, typeof(EntityBehaviorMgr)); uint arg0 = (uint)LuaDLL.luaL_checknumber(L, 2); string arg1 = ToLua.CheckString(L, 3); int arg2 = (int)LuaDLL.luaL_checknumber(L, 4); UnityEngine.GameObject arg3 = (UnityEngine.GameObject)ToLua.CheckUnityObject(L, 5, typeof(UnityEngine.GameObject)); PetBehavior o = obj.CreatePet(arg0, arg1, arg2, arg3); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
// Use this for initialization void Awake() { pet = GameObject.FindObjectOfType <PetBehavior>(); animator = GetComponent <Animator>(); }