protected override bool Enter(GoapAgent agent) { _time = 0; Target = agent.SearchActionData("targetHerb") as GameObject; _bar = agent.GetComponent <ProgressBar>(); _farmer = agent.GetComponent <Farmer>(); //Debug.Log("pick up enter"); return(true); }
protected override bool Run(GoapAgent agent) { var target = agent.SearchActionData("targetHerb") as GameObject; if (target == null) { Debug.Log("farmer: target disappear while picking"); return(false); } _time += Time.deltaTime; agent.GetComponent <ProgressBar>().SetRate(_time / Duration); if (_time > Duration) { agent.GetComponent <ProgressBar>().SetValue(0); agent.GetComponent <Farmer>().ToolCount--; agent.GetComponent <Farmer>().HerbCount++; Destroy(target); ActionOver(); } return(true); }
protected override bool Enter(GoapAgent agent) { _food = agent.SearchActionData("targetFood") as GameObject; return(true); }