private TrapAction CreateObj(TrapAction.ENType newType) { LinkedList <TrapAction> outList; if (m_pool.TryGetValue(newType, out outList)) { if (outList.Count > 0) { TrapAction obj = outList.Last.Value as TrapAction; outList.RemoveLast(); return(obj); } } switch (newType) { case TrapAction.ENType.enAttackAction: return(new TrapAttackAction()); // break; //站立 case TrapAction.ENType.enBackAction: return(new TrapBackAction()); // break; case TrapAction.ENType.enStandAction: return(new TrapStandAction()); // break; } throw new Exception("Miss Action Create for" + newType.ToString()); }
public TrapAction AddAction(TrapAction.ENType newType) { if (!IsDisable(newType)) { bool isValidateActionState = false; for (int index = m_actionList.Count - 1; index >= 0; --index) { TrapAction item = m_actionList[index]; if (!item.IsEnable) { continue; } if (TrapAction.ENRelation.enReplace == CheckRelation(newType, item.GetActionType())) { m_actionList.RemoveAt(index); isValidateActionState = true; item.OnInterupt(newType); RemoveDisableCount(item.GetActionType()); item.IsEnable = false; ReleaseObj(item); } } TrapAction obj = CreateObj(newType); obj.CurrentActor = CurrentActor; ActioningObjArray[(int)newType] = obj; m_actionList.Add(obj); AddDisableCount(obj.GetActionType()); if (isValidateActionState) { for (int i = 0; i < ActioningArray.Length; i++) { ActioningArray[i] = 0; ActioningObjArray[i] = null; } for (int i = 0; i < m_actionList.Count; i++) { TrapAction ac = m_actionList[i]; ActioningObjArray[(int)ac.GetActionType()] = ac; ActioningArray[(int)ac.GetActionType()]++; } } return(obj); } else { string currentActions = CurrentActor.GetType() + ":" + newType.ToString() + " Current Actions:"; foreach (TrapAction action in m_actionList) { currentActions += action.GetActionType().ToString() + ", "; } //Debug.LogWarning("Add action failed:" + newType.ToString()+" actor type:"+CurrentActor.Type.ToString()); return(null); } }