Exemplo n.º 1
0
 public T CreateObject <T>()
     where T : UNObject, new()
 {
     if (m_objs.TryGetValue(typeof(T), out m_objGetList))
     {
         for (int i = 0; i < m_objGetList.Count; ++i)
         {
             if (m_objGetList[i].m_state == UNObjectStateType.Alive)
             {
                 continue;
             }
             m_objGetList[i].m_state = UNObjectStateType.Alive;
             return(m_objGetList[i] as T);
         }
         T obj = new T();
         obj.m_state = UNObjectStateType.Alive;
         m_objGetList.Add(obj);
         return(obj);
     }
     else
     {
         T obj = new T();
         obj.m_state = UNObjectStateType.Alive;
         var objList = new UNList <UNObject>();
         objList.Add(obj);
         m_objs.Add(typeof(T), objList);
         return(obj);
     }
 }
Exemplo n.º 2
0
    private void AddToObjects(UNResourceObject resObj)
    {
        var list = UNList <UNResourceObject> .New();

        list.Add(resObj);
        m_objs.Add(resObj.m_key, list);
    }
Exemplo n.º 3
0
 public override void Init()
 {
     base.Init();
     if (m_scripts.IsNull())
     {
         m_scripts = UNList <UNMonoBehaviorObject> .New();
     }
 }
Exemplo n.º 4
0
    public override void Init()
    {
        base.Init();
        Instance = this;
        m_wwws   = UNList <UNWWW> .New();

        InitAssetsBundle();
    }
Exemplo n.º 5
0
    public static UNBehavior New(UNBehaviorType bType,
                                 int priority = 0,
                                 UNBehaviorStateType bState = UNBehaviorStateType.Wait,
                                 UNList <UNBehaviorChangeStateCallBack> cbsBeforeChange = null,
                                 UNList <UNBehaviorChangeStateCallBack> cbsAfterChange  = null)
    {
        var obj = New();

        obj.ResetToBehavior(bType, priority, bState, cbsBeforeChange, cbsAfterChange);
        return(obj);
    }
Exemplo n.º 6
0
    public void DispatchEvent(EventType type, object[] pars)
    {
        UNList <object[]> objs = null;

        if (!m_triggers.TryGetValue(type, out objs))
        {
            objs = UNList <object[]> .New();

            m_triggers.Add(type, objs);
        }
        objs.Add(pars);
    }
Exemplo n.º 7
0
    public void AddEventListener(EventType type, EventCallBack cb)
    {
        UNList <EventCallBack> cbs = null;

        if (!m_listeners.TryGetValue(type, out cbs))
        {
            cbs = UNList <EventCallBack> .New();

            m_listeners.Add(type, cbs);
        }
        cbs.Add(cb);
    }
Exemplo n.º 8
0
    public void ResetToBehavior(UNBehaviorType bType,
                                int priority = 0,
                                UNBehaviorStateType bState = UNBehaviorStateType.Wait,
                                UNList <UNBehaviorChangeStateCallBack> cbsBeforeChange = null,
                                UNList <UNBehaviorChangeStateCallBack> cbsAfterChange  = null)
    {
        m_type            = bType;
        m_priority        = priority;
        m_curState        = bState;
        m_cbsBeforeChange = cbsBeforeChange;
        m_cbsAfterChange  = cbsAfterChange;

        Init();
    }
Exemplo n.º 9
0
 public override void Init()
 {
     base.Init();
     InitBehaviorsTrans();
     if (m_behaviorsWaitForExecute.IsNull())
     {
         m_behaviorsWaitForExecute = UNList <UNBehavior> .New();
     }
     if (m_cbsBeforeBehaviorChange.IsNull())
     {
         m_cbsBeforeBehaviorChange = UNList <UNBehaviorChangeStateCallBack> .New();
     }
     if (m_cbsAfterBehaviorChange.IsNull())
     {
         m_cbsAfterBehaviorChange = UNList <UNBehaviorChangeStateCallBack> .New();
     }
 }
Exemplo n.º 10
0
    public virtual void ChangeToState(UNBehaviorStateType state)
    {
        var oldState = m_curState;

        if (m_cbsBeforeChange != null)
        {
            for (int i = 0; i < m_cbsBeforeChange.Count; ++i)
            {
                m_cbsBeforeChange[i](m_type, oldState, state);
            }
        }
        m_stateCbs[state]();
        if (m_cbsAfterChange != null)
        {
            for (int i = 0; i < m_cbsAfterChange.Count; ++i)
            {
                m_cbsAfterChange[i](m_type, oldState, state);
            }
        }
    }
Exemplo n.º 11
0
    public void AddBehaviorsTransRule(UNBehaviorType fromType, UNBehaviorType toType)
    {
        UNList <UNBehaviorType> fromList = null;

        if (m_behaviorsTransRules.ContainsKey(toType))
        {
            if (!m_behaviorsTransRules[toType].Contains(fromType))
            {
                fromList = m_behaviorsTransRules[toType];
            }
        }
        else
        {
            fromList = UNList <UNBehaviorType> .New();
        }
        if (fromList != null)
        {
            fromList.Add(fromType);
        }
        AddBehaviorsTransRule(fromList, toType);
    }
Exemplo n.º 12
0
 public void AddBehaviorsTransRule(UNList <UNBehaviorType> fromTypes, UNBehaviorType toType)
 {
     m_behaviorsTransRules.Add(toType, fromTypes);
 }