public override void Enter(object extraData = null) { base.Enter(extraData); Debug.Log("배고파!"); //1순위- 사료공장, 2순위- 저장소, 3순위- 완료된 작물, 4순위- 물고기and지렁이 targetBuilding = World.GetInstance().FindFoodLeftRestaurant(owner); restaurant = targetBuilding as IFoodConsumeableBuilding; if (targetBuilding != null) { recognitionDistance = targetBuilding.recognitionDistance; } ChangeEatingState("goingToRestaurant"); }
public override void Update() { if (owner.Hunger <= 45) { owner.ChangeState("Idle"); return; } //상태 분기 switch (currentState) { case "goingToRestaurant": if (restaurant.FoodIsEmpty()) { if (targetBuilding is MainStorage) { //사료공장도 비었고, 저장소도 비었다 //작물이나 물고기를 먹자 ChangeEatingState("FindSomethingFood"); } else { //가려던 사료공장이 중간에 비었다. //다른 사료공장을 찾아보자 targetBuilding = World.GetInstance().FindFoodLeftRestaurant(owner); restaurant = targetBuilding as IFoodConsumeableBuilding; if (targetBuilding != null) { recognitionDistance = targetBuilding.recognitionDistance; } owner.Move(targetBuilding.transform.position); } } break; case "goingToSomethingFood": if (targetFood == null || targetFood.transform.parent != null) { ChangeEatingState("FindSomethingFood"); } break; default: Debug.Log("state가 잘못됐어!"); break; } }