資源簡介
一個 GOAP AI Unity 實現Demo,包含行為 買菜,做飯,吃飯。根據自身變化以及世界狀態,自動執行行為

代碼片段和文件信息
using?System.Collections;
using?System.Collections.Generic;
using?UnityEngine;
using?Goap;
public?class?GoapActionBuyVegetables?:?GoapAction?{
public?GoapActionBuyVegetables(GoapGoal?goapGoal):base(goapGoal)
????{
????}
????public?override?void?InitStatus()
????{
????????base.InitStatus();
????????preconditionsStatus.AddState(GoapCondition.hasSellVegetables?true);
????????preconditionsStatus.AddState(GoapCondition.hasVegetables?false);
????????effectsStatus.AddState(GoapCondition.hasVegetables?true);
????}
????public?override?bool?CheckProceduralPrecondition()
????{
????????Gameobject?Vegetables?=?Gameobject.Find(“Vegetables“);
????????target?=?Vegetables.transform;
????????return?Vegetables?!=?null;
????}
????public?override?void?Run()
????{
????????if?(!IsInRange())
????????{
????????????MoveController.instance.Move(goapGoal.transform?target.position?6);
????????????return;
????????}
????????base.Run();
????????if?(target?==?null)
????????{
????????????Fail();
????????????return;
????????}
????????if?(goapGoal.GetType()?==?typeof(Person))
????????{
????????????Person?person?=?(Person)goapGoal;
????????????person.AddVegetables(1);
????????????if?(person.VegetablesEnougth())
????????????{
????????????????Finish();
????????????}
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-01-23?15:16??GoapDemo\
?????目錄???????????0??2018-01-16?11:37??GoapDemo\Assets\
?????目錄???????????0??2018-01-16?11:37??GoapDemo\Assets\Material\
?????文件?????????200??2018-01-10?20:03??GoapDemo\Assets\Material.me
?????文件????????5020??2018-01-10?20:03??GoapDemo\Assets\Material\Person.mat
?????文件?????????187??2018-01-10?20:03??GoapDemo\Assets\Material\Person.mat.me
?????目錄???????????0??2018-01-16?12:00??GoapDemo\Assets\Scene\
?????文件?????????191??2018-01-16?11:37??GoapDemo\Assets\Scene.me
?????文件???????40480??2018-01-16?12:00??GoapDemo\Assets\Scene\Test.unity
?????文件?????????182??2018-01-10?20:03??GoapDemo\Assets\Scene\Test.unity.me
?????目錄???????????0??2018-01-16?11:37??GoapDemo\Assets\sc
?????文件?????????200??2018-01-10?20:03??GoapDemo\Assets\sc
?????目錄???????????0??2018-01-16?12:22??GoapDemo\Assets\sc
?????文件?????????200??2018-01-10?20:03??GoapDemo\Assets\sc
?????文件????????1333??2018-01-16?12:22??GoapDemo\Assets\sc
?????文件?????????262??2018-01-16?11:57??GoapDemo\Assets\sc
?????文件????????1374??2018-01-16?12:12??GoapDemo\Assets\sc
?????文件?????????262??2018-01-11?18:49??GoapDemo\Assets\sc
?????文件????????1464??2018-01-16?11:56??GoapDemo\Assets\sc
?????文件?????????274??2018-01-10?20:03??GoapDemo\Assets\sc
?????目錄???????????0??2018-01-16?12:24??GoapDemo\Assets\sc
?????文件?????????200??2018-01-10?20:03??GoapDemo\Assets\sc
?????文件????????2632??2018-01-11?19:58??GoapDemo\Assets\sc
?????文件?????????274??2018-01-10?20:03??GoapDemo\Assets\sc
?????文件????????1758??2018-01-11?19:37??GoapDemo\Assets\sc
?????文件?????????274??2018-01-10?20:03??GoapDemo\Assets\sc
?????文件????????1301??2018-01-11?19:40??GoapDemo\Assets\sc
?????文件?????????274??2018-01-10?20:03??GoapDemo\Assets\sc
?????文件?????????827??2018-01-10?20:03??GoapDemo\Assets\sc
?????文件?????????274??2018-01-10?20:03??GoapDemo\Assets\sc
?????文件????????4229??2018-01-16?12:24??GoapDemo\Assets\sc
............此處省略40個文件信息
- 上一篇:基于匯編語言的萬年歷的設計
- 下一篇:BehaviorTreeEditor.zip
評論
共有 條評論