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); } }
private void AddToObjects(UNResourceObject resObj) { var list = UNList <UNResourceObject> .New(); list.Add(resObj); m_objs.Add(resObj.m_key, list); }
public override void Init() { base.Init(); if (m_scripts.IsNull()) { m_scripts = UNList <UNMonoBehaviorObject> .New(); } }
public override void Init() { base.Init(); Instance = this; m_wwws = UNList <UNWWW> .New(); InitAssetsBundle(); }
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); }
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); }
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); }
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(); }
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(); } }
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); } } }
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); }
public void AddBehaviorsTransRule(UNList <UNBehaviorType> fromTypes, UNBehaviorType toType) { m_behaviorsTransRules.Add(toType, fromTypes); }