public MechaConfig ExportMechaConfig() { MechaConfig mechaConfig = new MechaConfig(); mechaConfig.MechaConfigName = name; MechaComponentBase[] mcs = transform.GetComponentsInChildren <MechaComponentBase>(); foreach (MechaComponentBase mcb in mcs) { MechaConfig.Config config = new MechaConfig.Config(); config.MechaComponentKey = mcb.name; config.MechaComponentAlias = mcb.EditorAlias; config.MechaComponentQuality = mcb.EditorQuality; config.GridPosR = GridPosR.GetGridPosByLocalTrans(mcb.transform, 1); mechaConfig.MechaComponentList.Add(config); } BehaviourTreeOwner bto = GetComponent <BehaviourTreeOwner>(); if (bto != null) { mechaConfig.MechaAIConfigKey = bto.behaviour.name; } mechaConfig.MechaAIParams = MechaAIParams.Clone(); return(mechaConfig); }
protected override void Awake() { base.Awake(); type = Type.Npc; owner = GetComponent <BehaviourTreeOwner>(); if (!owner) { owner = gameObject.AddComponent <BehaviourTreeOwner>(); } blackboard = GetComponent <Blackboard>(); if (!blackboard) { blackboard = gameObject.AddComponent <Blackboard>(); } ResManager.LoadAsync(aiResPath, (obj) => { BehaviourTree bt = obj as BehaviourTree; owner.behaviour = Instantiate(bt); }); ResManager.LoadAsync(bbResPath, (obj) => { TextAsset ta = obj as TextAsset; blackboard.Deserialize(ta.text); }); }
private void OnValidate() { if (tree == null) { tree = GetComponent <BehaviourTreeOwner>(); } }
private BehaviourTreeOwner GetBehaviourTreeOwner() { if (_behaviourTreeOwner == null) { _behaviourTreeOwner = GetGameObject().GetComponent <BehaviourTreeOwner>(); } return(_behaviourTreeOwner); }
public async Task Run() { if (behaviourTreeOwner == null) { behaviourTreeOwner = GameEntry.AI.GetBehaviourTreeOwner(owner); } var grahp = GameEntry.AI.GetBehaviourTreeGraph(owner); grahp.repeat = false; battle = GameEntry.Context.Battle; battle.pointerClickedMonster = owner.View.gameObject; battle.selectMonsters.Clear(); battle.selectMonsters.Add(battle.playerMonsters[0].View.gameObject); behaviourTreeOwner.StartBehaviour(grahp); await TaskExtensions.WaitUntil(() => grahp.rootStatus != NodeCanvas.Framework.Status.Running); }
static void TestBTree() { GameObject rootObj = new GameObject("Unit"); BehaviourTreeOwner owner = rootObj.AddComponent <BehaviourTreeOwner>(); BehaviourTree jsonTree = new BehaviourTree(); string path = "./../../Resources/LLogTree.BT"; //string path = "./../../Resources/LLogTree.BT"; string jsonGraph = System.IO.File.ReadAllText(path); Console.WriteLine(jsonGraph); GraphSerializationData graphData = jsonTree.Deserialize(jsonGraph, true, null); owner.StartBehaviour(jsonTree, (bool val) => { Loger.Log("StartBehaviour Callback : " + val); }); }
void Awake() { animator = GetComponent <Animator>(); hitReaction = GetComponent <HitReaction>(); rigidbody = GetComponent <Rigidbody>(); if (targetPlayer == null) { targetPlayer = GameObject.FindGameObjectWithTag("Player"); } if (wayPoints.Length == 0) { wayPoints = GameObject.FindGameObjectsWithTag("WayPoint"); } if (blackBoard == null) { blackBoard = gameObject.GetComponent <Blackboard>(); } if (behaviourTree == null) { behaviourTree = gameObject.GetComponent <BehaviourTreeOwner>(); } if (blackBoard != null) { blackBoard.SetValue("target", targetPlayer); } if (behaviourTree != null) { List <GameObject> wps = new List <GameObject>(wayPoints); blackBoard.SetValue("PatrolWayPoints", wps); } currentHP = HP; ragdollUtility = GetComponent <RagdollUtility>(); }
// Use this for initialization void Start() { mAnimator = GetComponent <Animator>(); mCharacterController = GetComponent <CharacterMotor>(); mBehaviourTreeOwner = GetComponent <BehaviourTreeOwner>(); mObservableStateMachineTrigger = mAnimator.GetBehaviour <ObservableStateMachineTrigger>(); mObservableStateMachineTrigger .OnStateExitAsObservable() .Subscribe(info => { OnExitState(info.StateInfo); }); mObservableStateMachineTrigger .OnStateEnterAsObservable() .Subscribe(info => { OnEnterState(info.StateInfo); }); }
void Awake() { animator = GetComponent<Animator>(); hitReaction = GetComponent<HitReaction>(); rigidbody = GetComponent<Rigidbody>(); if (targetPlayer == null) { targetPlayer = GameObject.FindGameObjectWithTag("Player"); } if (wayPoints.Length == 0) { wayPoints = GameObject.FindGameObjectsWithTag("WayPoint"); } if(blackBoard == null) blackBoard = gameObject.GetComponent<Blackboard>(); if (behaviourTree == null) behaviourTree = gameObject.GetComponent<BehaviourTreeOwner>(); if (blackBoard != null) blackBoard.SetValue("target", targetPlayer); if (behaviourTree != null) { List<GameObject> wps = new List<GameObject>(wayPoints); blackBoard.SetValue("PatrolWayPoints", wps); } currentHP = HP; ragdollUtility = GetComponent<RagdollUtility>(); }
// Use this for initialization void Start() { mAnimator = GetComponent <Animator>(); mCharacterController = GetComponent <CharacterMotor>(); mBehaviourTreeOwner = GetComponent <BehaviourTreeOwner>(); mObservableStateMachineTrigger = mAnimator.GetBehaviour <ObservableStateMachineTrigger>(); mObservableStateMachineTrigger .OnStateExitAsObservable() .Subscribe(info => { OnExitState(info.StateInfo); }); mObservableStateMachineTrigger .OnStateEnterAsObservable() .Subscribe(info => { OnEnterState(info.StateInfo); }); mAnimator.SetInteger("Death", Mathf.RoundToInt(UnityEngine.Random.Range(1, 3))); }
void Awake() { aurielBehaviourTree = GetComponent <BehaviourTreeOwner>(); }
private void Awake() { tree = GetComponent <BehaviourTreeOwner>(); }
public void RemoveBehaviourTreeOwner(BehaviourTreeOwner bto) { BehaviourTreeOwners.Remove(bto); }
public void AddBehaviourTreeOwner(BehaviourTreeOwner bto) { BehaviourTreeOwners.Add(bto); }