public void eat() { if (gameController.getfoodStock() > 0) { dwarfcontroller.iseating = true; dwarfcontroller.setPoseBeforeeat(dwarfcontroller.transform.position); dwarfcontroller.setcurrentjob(dwarfcontroller.getjob()); Debug.Log("dwarf job : " + dwarfcontroller.getcurrentjob()); dwarfcontroller.setjobstatut("on Break"); TargetFood = getclosestfoodposition(); TargetFood.tag = "food_being_eat"; gameController.update_food_record(); Debug.Log("move to food"); movescript.setpos(TargetFood.transform.position); } }
private IEnumerator sleep(GameObject theBed) { if (theBed != null) { movescript.setpos(theBed.transform.position); yield return(new WaitUntil(() => theBed.GetComponent <Collider>().bounds.Contains(dwarfcontroller.transform.position))); } dwarfcontroller.setSleepStatut("Sleeping"); dwarfcontroller.setcurrentjob(dwarfcontroller.getjob()); dwarfcontroller.setjobstatut("on Break"); dwarfcontroller.updateStatutText(); Debug.Log(dwarfcontroller.getcurrentjob()); if (theBed != null && dwarfcontroller.transform.position == theBed.transform.position) { yield return(new WaitForSeconds(sleepTime)); } else //Si il est pas sur le lit ou qu'il y a pas de lit, il dors deux fois plus longtemps //Et si t'es pas content c'est la même, t'avais qu'à faire un lit { yield return(new WaitForSeconds(sleepTime * 2)); } dwarfcontroller.setSleepStatut("Awake"); dwarfcontroller.isSleaping = false; dwarfcontroller.setjobstatut(dwarfcontroller.getcurrentjob()); dwarfcontroller.updateStatutText(); if (dwarfcontroller.getjobplace() != null) { Debug.Log(dwarfcontroller.getjobplace()); dwarfcontroller.startwork(); } }
//*****************************************************************************************// IEnumerator work() { movescript.setpos(jobplace); while (readyToWork() && jobstatut != "idle") { Debug.Log(jobplace); Debug.Log("jobstatut = " + jobstatut); Debug.Log("Siffler en travaillant!! tululululululut"); yield return(new WaitForSeconds(5)); } }