示例#1
0
        // Use this for initialization
        void Start()
        {
            var btFsm   = gameObject.AddComponent <BTFsm>();
            var btEvent = btFsm.CreateStartEvent();
            var btState = BTState.Create <BTState>(btFsm);

            btState.Name        = "Dynamic1State";
            btEvent.TargetState = btState;
            btState.Bounds      = new Rect(250, 200, 100, 100);



            var btState1 = BTState.Create <BTState> (btFsm);

            btState1.Name   = "Dynamic2State";
            btState1.Bounds = new Rect(400, 200, 100, 100);

            var privateEvent = BTEvent.Create(btState);

            privateEvent.Name        = "Finish";
            privateEvent.TargetState = btState1;

            var privateEvent2 = BTEvent.Create(btState1);

            privateEvent2.Name        = "Finish";
            privateEvent2.TargetState = btState;

            var waitAction = BTAction.CreateAction <WaitingAction>(btState);

            waitAction.time = 1;
            var waitAction1 = BTAction.CreateAction <WaitingAction>(btState1);

            waitAction1.time = 1;
        }
示例#2
0
        public static BTAction CreateAction(BTAction source, BTState parentState)
        {
//			BTAction action = XScriptableObject.CreateInstance(source.GetType()) as BTAction;
            BTAction action = Instantiate <BTAction>(source);

            action.Name  = source.Name;
            action.Owner = parentState;
            parentState.totalActions.Add(action);


            return(action);
        }
示例#3
0
        public static BTState Create(BTFsm parentFsm, BTState source)
        {
            var newState = Instantiate <BTState>(source);

            newState.Source = source;
            newState.Name   = source.Name;
            newState.Owner  = parentFsm;
            newState.Owner.AddNewState(newState);

            newState.totalActions.Clear();
            for (int i = 0; i < source.totalActions.Count; i++)
            {
                BTAction.CreateAction(source.totalActions[i], newState);
            }

            newState.FindEvent(newState.GlobalEvent);

            return(newState);
        }