Exemplo n.º 1
0
        public override BTStateReturn FixedUpdate(int frames)
        {
            while (true)
            {
                BTStateReturn ret = f_states[m_index].FixedUpdate(frames);

                if (ret == BTStateReturn.Running)
                {
                    return(BTStateReturn.Running);
                }

                m_index = (m_index + 1) % f_states.Length;

                if (ret == BTStateReturn.True && (f_abortState & BTStateReturn.True) != 0)
                {
                    return(BTStateReturn.True);
                }

                if (ret == BTStateReturn.False && (f_abortState & BTStateReturn.False) != 0)
                {
                    return(BTStateReturn.False);
                }

                if (m_index == m_startIndex)
                {
                    return(ret);
                }

                f_states[m_index].Enter();
            }
        }
Exemplo n.º 2
0
        public override BTStateReturn FixedUpdate(int frames)
        {
            while (true)
            {
                BTStateReturn ret = f_states[m_index].FixedUpdate(frames);

                switch (ret)
                {
                case BTStateReturn.Running:
                case BTStateReturn.Error:
                    return(ret);

                case BTStateReturn.True:
                    ++m_index;
                    if (f_sequenceAbort == SequenceAbort.AbortWhenTrue || m_index == f_states.Length)
                    {
                        return(BTStateReturn.True);
                    }
                    break;

                case BTStateReturn.False:
                    ++m_index;
                    if (f_sequenceAbort == SequenceAbort.AbortWhenFalse || m_index == f_states.Length)
                    {
                        return(BTStateReturn.False);
                    }
                    break;
                }

                f_states[m_index].Enter();
            }
        }
Exemplo n.º 3
0
        public Switch(BTState[] states, bool resetIndex, BTStateReturn abortState)
        {
            Assert(abortState < BTStateReturn.Running);
            Assert(!(abortState == (BTStateReturn.True | BTStateReturn.False) && resetIndex));

            f_resetIndex = resetIndex;
            f_abortState = abortState;
        }
Exemplo n.º 4
0
    private void FixedUpdate()
    {
        BTStateReturn ret = f_bt.FixedUpdate(1);

        if (ret != BTStateReturn.Running)
        {
            enabled = false;
        }
    }
Exemplo n.º 5
0
        public override BTStateReturn FixedUpdate(int frames)
        {
            BTStateReturn ret = f_root.FixedUpdate(frames);

            if (ret != BTStateReturn.Running)
            {
                f_root.Enter();
            }
            return(ret);
        }
Exemplo n.º 6
0
        public override BTStateReturn FixedUpdate(int frames)
        {
            for (int i = 0; i < f_states.Length; ++i)
            {
                BTStateReturn ret = f_states[i].FixedUpdate(frames);

                if ((ret & f_abortState) != 0)
                {
                    return(ret);
                }
            }

            return(BTStateReturn.Running);
        }
Exemplo n.º 7
0
        public override BTStateReturn FixedUpdate(int frames)
        {
            BTStateReturn ret = f_childState.FixedUpdate(frames);

            switch (ret)
            {
            case BTStateReturn.Running:
                return(BTStateReturn.Running);

            case BTStateReturn.True:
                return(f_trueValue);

            case BTStateReturn.False:
                return(f_falseValue);

            default:
                return(BTStateReturn.Error);
            }
        }
Exemplo n.º 8
0
        public Mapper(BTState child, bool trueValue, bool falseValue)
        {
            f_childState = child;

            if (trueValue)
            {
                f_trueValue = BTStateReturn.True;
            }
            else
            {
                f_trueValue = BTStateReturn.False;
            }

            if (falseValue)
            {
                f_falseValue = BTStateReturn.True;
            }
            else
            {
                f_falseValue = BTStateReturn.False;
            }
        }
Exemplo n.º 9
0
        public override BTStateReturn FixedUpdate(int frames)
        {
            BTStateReturn ret = f_func();

            return(ret);
        }
Exemplo n.º 10
0
 public Parallel(BTStateReturn abortState, params BTState[] states)
 {
     Assert(states.Length > 0);
     f_abortState = abortState;
     f_states     = states;
 }