Example #1
0
        public static BTFsm CreateFromOtherTemplate(BTFsm targetFsm, BTTemplate source)
        {
            for (int i = 0; i < source.totalEvent.Count; i++)
            {
                BTEvent.Create(targetFsm, source.totalEvent[i]);
            }

            for (int i = 0; i < source.totalState.Count; i++)
            {
                BTState.Create(targetFsm, source.totalState[i]);
            }
            for (int i = 0; i < source.totalState.Count; i++)
            {
                var state = targetFsm.totalState[i];
                state.ReFindEvent();
            }

            for (int i = 0; i < source.totalVariable.Count; i++)
            {
                BTVariable.Create(targetFsm, source.totalVariable[i]);
            }

            targetFsm.startEvent = targetFsm.FindGlobalEvent(source.startEvent.Name);

            return(targetFsm);
        }
Example #2
0
 public BTEvent CreateEvent(string name)
 {
     startEvent          = BTEvent.Create(this);
     startEvent.Name     = name;
     startEvent.isGlobal = true;
     return(startEvent);
 }
Example #3
0
        public static BTFsm CreateFromOtherTemplate(BTFsm targetFsm, BTTemplate source)
        {
            for (int i = 0; i < source.totalEvent.Count; i++)
            {
                BTEvent.Create(targetFsm, source.totalEvent[i]);
            }

            for (int i = 0; i < source.totalState.Count; i++)
            {
                BTState.Create(targetFsm, source.totalState[i]);
            }
            for (int i = 0; i < source.totalState.Count; i++)
            {
                var state = targetFsm.totalState[i];
                for (int j = 0; j < state.totalEvent.Count; j++)
                {
                    if (state.totalEvent[j].TargetState != null)
                    {
                        state.totalEvent[j].TargetState = targetFsm.FindState(state.totalEvent[j].TargetState.Name);
                    }
                }
            }

            for (int i = 0; i < source.totalVariable.Count; i++)
            {
                BTVariable.Create(targetFsm, source.totalVariable[i]);
            }

            targetFsm.startEvent = targetFsm.FindGlobalEvent(source.startEvent.Name);

            return(targetFsm);
        }
Example #4
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;
        }