Exemplo n.º 1
0
    // update 等待 行为
    private void UpdateWaitBehavior()
    {
        var        priority = -1;
        UNBehavior behavior = null;

        for (int i = 0; i < m_behaviorsWaitForExecute.Count; ++i)
        {
            if (!m_behaviorsWaitForExecute[i].CanChangeToState(UNBehaviorStateType.Execute))
            {
                continue;
            }
            if (priority < m_behaviorsWaitForExecute[i].m_priority)
            {
                behavior = m_behaviorsWaitForExecute[i];
                priority = m_behaviorsWaitForExecute[i].m_priority;
            }
        }
        m_behaviorsWaitForExecute.Clear();
        if (behavior.IsNull())
        {
            return;
        }
        m_curBehavior = behavior;
        m_curBehavior.ChangeToState(UNBehaviorStateType.Execute);
    }
Exemplo n.º 2
0
 public void AddWaitBehavior(UNBehaviorType bType,
                             int priority = 0,
                             UNBehaviorStateType bState = UNBehaviorStateType.Wait,
                             UNBehaviorChangeStateCallBack cbBeforeChange = null,
                             UNBehaviorChangeStateCallBack cbAfterChange  = null)
 {
     m_cbsBeforeBehaviorChange.Add(cbBeforeChange);
     m_cbsAfterBehaviorChange.Add(cbAfterChange);
     AddWaitBehavior(UNBehavior.New(bType, priority, bState, m_cbsBeforeBehaviorChange, m_cbsAfterBehaviorChange));
 }
Exemplo n.º 3
0
 public void AddBehaviorImmediate(UNBehaviorType bType,
                                  int priority = 0,
                                  UNBehaviorStateType bState = UNBehaviorStateType.Wait,
                                  UNBehaviorChangeStateCallBack cbBeforeChange = null,
                                  UNBehaviorChangeStateCallBack cbAfterChange  = null)
 {
     m_cbsBeforeBehaviorChange.Add(cbBeforeChange);
     m_cbsAfterBehaviorChange.Add(cbAfterChange);
     if (m_curBehavior.IsNull())
     {
         m_curBehavior = UNBehavior.New();
         m_curBehavior.ResetToBehavior(bType, priority, bState, m_cbsBeforeBehaviorChange, m_cbsAfterBehaviorChange);
     }
     else
     {
         m_curBehavior.ChangeToState(UNBehaviorStateType.Finish);
         m_curBehavior.ResetToBehavior(bType, priority, bState, m_cbsBeforeBehaviorChange, m_cbsAfterBehaviorChange);
     }
     m_curBehavior.ChangeToState(UNBehaviorStateType.Execute);
 }
Exemplo n.º 4
0
 public void AddWaitBehavior(UNBehavior behavior)
 {
     m_behaviorsWaitForExecute.Add(behavior);
 }