private void Awake()
    {
        gameScreen   = FindObjectOfType <Game>();
        petNameLabel = transform.gameObject.GetComponent <Text>();

        pet = FindObjectOfType <PetBehavior>();
    }
コード例 #2
0
    // 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>();
    }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        currentPet = GameObject.FindObjectOfType <PetBehavior>();

        if (File.Exists(savePath))
        {
            Load();
        }

        // Debug.Log(currentPet.isSleep);
        // currentPet.SleepWake();

        petDataLoaded = true;
    }
コード例 #4
0
ファイル: EntityBehavior.cs プロジェクト: hw233/mmoclient
    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);
    }
コード例 #5
0
 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));
     }
 }
コード例 #6
0
 // Use this for initialization
 void Awake()
 {
     pet      = GameObject.FindObjectOfType <PetBehavior>();
     animator = GetComponent <Animator>();
 }