예제 #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);
        }
예제 #2
0
        public static BTFsm CreateFromOwnerTemplate(BTFsm targetFsm, BTTemplate source)
        {
            for (int i = 0; i < source.totalEvent.Count; i++)
            {
                targetFsm.totalEvent[i].Owner = targetFsm;
            }
            targetFsm.totalState.Clear();

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

            for (int i = 0; i < targetFsm.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);
                    }
                }
            }
            targetFsm.totalVariable.Clear();
            for (int i = 0; i < source.totalVariable.Count; i++)
            {
                BTVariable.Create(targetFsm, source.totalVariable[i]);
            }

            targetFsm.startEvent = targetFsm.FindGlobalEvent(targetFsm.startEvent.Name);
            return(targetFsm);
        }
예제 #3
0
 public BTTemplate(BTFsm source)
 {
     totalEvent = source.totalEvent;
     totalState = source.totalState;
     startEvent = source.startEvent;
     this.name  = source.name;
 }
예제 #4
0
        public static BTTemplate Create(BTFsm source)
        {
            var template = XScriptableObject.CreateInstance <BTTemplate>();

            template.name = source.name;
            return(template);
        }
예제 #5
0
        public static BTEvent Create(BTFsm Owner)
        {
            var btEvent = new BTEvent();

            btEvent.Owner = Owner;
            Owner.totalEvent.Add(btEvent);
            return(btEvent);
        }
예제 #6
0
        public static BTState Create(BTFsm parentFsm, System.Type type)
        {
            var newState = XScriptableObject.CreateInstance(type) as BTState;

            newState.Owner = parentFsm;
            parentFsm.AddNewState(newState);
            return(newState);
        }
예제 #7
0
        public static BTState Create <T>(BTFsm parentFsm) where T : BTState
        {
            var newState = XScriptableObject.CreateInstance <T>();

            newState.Owner = parentFsm;
            parentFsm.AddNewState(newState);
            return(newState);
        }
예제 #8
0
        public static BTVariable Create(BTFsm btFsm, BTVariable source)
        {
            var btVar = Instantiate(source);

            btVar.Owner  = btFsm;
            btVar.Source = source;
            btVar.Name   = source.Name;
            btFsm.totalVariable.Add(btVar);
            return(btVar);
        }
예제 #9
0
        public static BTEvent Create(BTFsm Owner, BTEvent source)
        {
            var btEvent = new BTEvent();

            btEvent.Owner    = Owner;
            btEvent.isGlobal = source.isGlobal;
            btEvent.Name     = source.Name;
            Owner.totalEvent.Add(btEvent);
            return(btEvent);
        }
예제 #10
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);
        }