Exemple #1
0
        public override void OnTick(float deltaTime)
        {
#if UNITY_EDITOR
            EditorDebugTime += Time.unscaledDeltaTime;
#endif
            mState = OnUpdate(deltaTime);
        }
 public override void Abort()
 {
     mState = OnAbort();
     if (mState <= EBTState.running || m_SuccessForAbort)
     {
         mState = m_SuccessForAbort ? EBTState.success : EBTState.failed;
     }
 }
 public override void OnEnd()
 {
     m_CurrentStatus = OnExit();
     foreach (var elem in m_ChildrenLst)
     {
         elem.OnEnd();
     }
 }
Exemple #4
0
 public void ResetStatus()
 {
     CurrentStatus = EBTState.UnReach;
     foreach (var elem in m_ChildrenLst)
     {
         elem.ResetStatus();
     }
 }
Exemple #5
0
 public override void OnEnd()
 {
     m_CurrentStatus = OnExit();
     foreach (var elem in m_ChildrenLst)
     {
         elem.OnEnd();
     }
 }
Exemple #6
0
	    public void ResetStatus()
	    {
	        CurrentStatus = EBTState.UnReach;
	        foreach (var elem in m_ChildrenLst)
	        {
	            elem.ResetStatus();
	        }
	    }
 public override EBTState OnReturn(EBTState state)
 {
     if (state == EBTState.success)
     {
         return(EBTState.success);
     }
     mExecI++;
     return(mExecI < mExecIndex.Length ? EBTState.running : EBTState.failed);
 }
        public override void Start()
        {
#if UNITY_EDITOR
            if (EditorBreakToggle)
            {
                Debug.Break();
            }
#endif
            mState = OnStart();
            StartDecorator();
        }
        public override EBTState OnStart()
        {
#if UNITY_EDITOR
            if (mRandom ^ (m_Random && mChildren.Length > 0))
            {
                Init();
            }
#endif
            mExecI     = 0;
            mLastState = EBTState.inactive;
            return(mChildren.Length > 0 ? EBTState.running : EBTState.failed);
        }
 public override EBTState OnReturn(EBTState state)
 {
     if (mChildren.Length > 0)
     {
         mExecI = (mExecI + 1) % mChildren.Length;
         if (mExecI == 0 && m_LoopMode == ELoopMode.PingPong && mChildren.Length > 2)
         {
             mRevert = !mRevert;
             mExecI++;
         }
     }
     return(state);
 }
Exemple #11
0
 public override EBTState OnReturn(EBTState state)
 {
     if (state == EBTState.failed)
     {
         return(EBTState.failed);
     }
     mIndex++;
     if (mIndex < mChildren.Length)
     {
         return(EBTState.running);
     }
     else
     {
         return(EBTState.success);
     }
 }
Exemple #12
0
 protected void SetChildElementStatus(EBTState status, int index)
 {
     if (index >= m_ChildrenLst.Count || index < 0)
     {
         return;
     }
     if (index >= m_CurrentRunningStatus.Count)
     {
         while (m_CurrentRunningStatus.Count == index + 1)
         {
             m_CurrentRunningStatus.Add(EBTState.UnReach);
         }
         while (m_LastRunningStatus.Count == index + 1)
         {
             m_LastRunningStatus.Add(EBTState.UnReach);
         }
     }
 }
 public override EBTState OnReturn(EBTState state)
 {
     mLastState = state;
     if (m_LoopCondition == ELoopMode.UntilSuccess && state == EBTState.success)
     {
         return(GetResult(true));
     }
     if (m_LoopCondition == ELoopMode.UntilFailed && state == EBTState.failed)
     {
         return(GetResult(true));
     }
     mExecI++;
     if (mExecI >= mChildren.Length)
     {
         mExecI = 0;
     }
     return(EBTState.running);
 }
	    protected void SetChildElementStatus(EBTState status,int index)
	    {
	        if (index >= m_ChildrenLst.Count || index < 0)
	        {
	            return;
	        }
	        if (index >= m_CurrentRunningStatus.Count)
	        {
	            while (m_CurrentRunningStatus.Count == index + 1)
	            {
	                m_CurrentRunningStatus.Add(EBTState.UnReach);
	            }
                while (m_LastRunningStatus.Count == index + 1)
                {
                    m_LastRunningStatus.Add(EBTState.UnReach);
                }
	        }
	    }
Exemple #15
0
		public override EBTState Tick ()
        {
            if (!m_Database.GetData<bool>(EDataBaseKey.IsLock))
            {
                m_iCurrentIndex = 0;
            }
		    do
		    {

		        bool isBreak = false;

                for (; m_iCurrentIndex < m_ChildrenLst.Count; ++m_iCurrentIndex)
                {
                    m_CurrentStatus = m_ChildrenLst[m_iCurrentIndex].Tick();

                    //mark status
                    SetChildElementStatus(EBTState.UnReach, m_iCurrentIndex);

                    if (m_CurrentStatus != EBTState.True)
                    {
                        isBreak = true;
                        break;
                    }
                }
		        if (isBreak)
		        {
		            break;
		        }
                m_iCurrentIndex = 0;
                m_CurrentStatus = EBTState.True;
		    } while (false);

            for (int i = m_iCurrentIndex; i < m_ChildrenLst.Count; ++i)
            {
                //mark status
                SetChildElementStatus(EBTState.UnReach, i);
            }

            //mark status
            CurrentStatus = m_CurrentStatus;

            return m_CurrentStatus;
		}
Exemple #16
0
        public override EBTState Tick()
        {
            if (!m_Database.GetData <bool>(EDataBaseKey.IsLock))
            {
                m_iCurrentIndex = 0;
            }
            do
            {
                bool isBreak = false;

                for (; m_iCurrentIndex < m_ChildrenLst.Count; ++m_iCurrentIndex)
                {
                    m_CurrentStatus = m_ChildrenLst[m_iCurrentIndex].Tick();

                    //mark status
                    SetChildElementStatus(EBTState.UnReach, m_iCurrentIndex);

                    if (m_CurrentStatus != EBTState.True)
                    {
                        isBreak = true;
                        break;
                    }
                }
                if (isBreak)
                {
                    break;
                }
                m_iCurrentIndex = 0;
                m_CurrentStatus = EBTState.True;
            } while (false);

            for (int i = m_iCurrentIndex; i < m_ChildrenLst.Count; ++i)
            {
                //mark status
                SetChildElementStatus(EBTState.UnReach, i);
            }

            //mark status
            CurrentStatus = m_CurrentStatus;

            return(m_CurrentStatus);
        }
Exemple #17
0
	    public override EBTState Tick()
	    {
            if (m_CurrentStatus != EBTState.Running)
            {
                m_CurrentStatus = OnEnter();
            }
	        if (m_CurrentStatus == EBTState.Running)
	        {
	            m_CurrentStatus = OnRunning();
	        }
	        if (m_CurrentStatus != EBTState.Running)
	        {
                m_CurrentStatus = OnExit();
	        }

            //mark current status
	        CurrentStatus = m_CurrentStatus;

	        return m_CurrentStatus;
	    }
Exemple #18
0
        public override EBTState Tick()
        {
            if (m_CurrentStatus != EBTState.Running)
            {
                m_CurrentStatus = OnEnter();
            }
            if (m_CurrentStatus == EBTState.Running)
            {
                m_CurrentStatus = OnRunning();
            }
            if (m_CurrentStatus != EBTState.Running)
            {
                m_CurrentStatus = OnExit();
            }

            //mark current status
            CurrentStatus = m_CurrentStatus;

            return(m_CurrentStatus);
        }
Exemple #19
0
            public void SetState(EBTState stat)
            {
                switch (stat)
                {
                case EBTState.running:
                    color    = RUN_COLOR;
                    progress = 1;
                    break;

                case EBTState.success:
                    color    = GOOD_COLOR;
                    progress = 1;
                    break;

                case EBTState.failed:
                    color    = BAD_COLOR;
                    progress = 1;
                    break;

                default:
                    //color = LINE_COLOR;
                    break;
                }
            }
Exemple #20
0
 public override void ReturnState(EBTState state)
 {
 }
 public override void ReturnState(EBTState state)
 {
     mState = OnReturn(state);
 }
 public abstract void ReturnState(EBTState state);
 public abstract EBTState OnReturn(EBTState state);