public void DoActionImmediately(PEActionType type, PEActionParam para = null) { if (HasAction(type)) { if (IsActionRunning(type)) { m_ActionDic[(int)type].ResetAction(para); } else { if (null != m_SkEntity._net) { ((SkNetworkInterface)m_SkEntity._net).SendDoAction(type, para); } ActionRelationData data = ActionRelationData.GetData(type); if (null != onActionStart) { onActionStart(type); } RunningAction runningAction = GetRunningAction(); runningAction.Do(m_ActionDic[(int)type], data, para, true); m_RunningAction[(int)type] = runningAction; } } }
bool CheckExecution(ActionRelationData data) { for (int i = 0; i < data.m_EndAction.Count; ++i) { if (m_MotionMgr.IsActionRunning(data.m_EndAction[i])) { return(false); } } return(true); }
public void Do(PEAction action, ActionRelationData relationData, PEActionParam para, bool doImmediately = false) { m_Action = action; m_RelationData = relationData; m_Para = para; m_WaitRelation = !doImmediately; m_DoAction = true; action.PreDoAction(); CheckRelation(doImmediately); TryDoAction(); }
public bool CanDoAction(PEActionType type, PEActionParam para = null) { if (HasAction(type)) { if (IsActionRunning(type)) { return(true); } else if (m_ActionDic[(int)type].CanDoAction(para)) { ActionRelationData data = ActionRelationData.GetData(type); return(CheckDepend(data)); } } return(false); }
public bool DoAction(PEActionType type, PEActionParam para = null) { if (HasAction(type)) { if (IsActionRunning(type)) { // if(null != m_SkEntity._net) // ((SkNetworkInterface)m_SkEntity._net).SendDoAction(type,para); m_ActionDic[(int)type].ResetAction(para); return(true); } else if (m_ActionDic[(int)type].CanDoAction(para)) { ActionRelationData data = ActionRelationData.GetData(type); if (null == data) { return(false); } if (CheckDepend(data)) { if (null != m_SkEntity._net) { ((SkNetworkInterface)m_SkEntity._net).SendDoAction(type, para); } if (null != onActionStart) { onActionStart(type); } RunningAction runningAction = GetRunningAction(); runningAction.Do(m_ActionDic[(int)type], data, para, false); m_RunningAction[(int)type] = runningAction; #if UNITY_EDITOR if (ShowLog) { Debug.LogError("DoAction: " + type.ToString()); } #endif return(true); } } } return(false); }
bool CheckDepend(ActionRelationData data) { if (null == data) { return(false); } for (int i = 0; i < data.m_DependMask.Count; ++i) { if (data.m_DependMask[i].maskValue != m_MaskArray[(int)data.m_DependMask[i].maskType]) { #if UNITY_EDITOR if (ShowLog) { Debug.LogError("ActionMask: " + data.m_DependMask[i].maskType.ToString() + "don't match"); } #endif return(false); } } return(true); }
public static void LoadActionRelation() { m_Relations = new ActionRelationData[(int)PEActionType.Max]; SqliteDataReader reader = LocalDatabase.Instance.ReadFullTable("ActionRelation"); int fieldCount = reader.FieldCount; while (reader.Read()) { ActionRelationData data = new ActionRelationData(); data.m_ActionType = (PEActionType)Convert.ToInt32(reader.GetString(reader.GetOrdinal("ActionType"))); data.m_DependMask = new List <DependData>(); int startIndex = 5; for (int i = startIndex; i < fieldCount; i++) { int mask = Convert.ToInt32(reader.GetString(i)); if (mask > 0) { DependData dependData = new DependData(); dependData.maskType = (PEActionMask)(i - startIndex); dependData.maskValue = (mask == 1); data.m_DependMask.Add(dependData); } } data.m_PauseAction = new List <PEActionType>(); string[] pauseStr = reader.GetString(reader.GetOrdinal("PauseAction")).Split(','); foreach (string str in pauseStr) { if ("0" != str) { data.m_PauseAction.Add((PEActionType)Convert.ToInt32(str)); } } data.m_EndAction = new List <PEActionType>(); string[] endStr = reader.GetString(reader.GetOrdinal("EndAction")).Split(','); foreach (string str in endStr) { if ("0" != str) { data.m_EndAction.Add((PEActionType)Convert.ToInt32(str)); } } data.m_EndImmediately = new List <PEActionType>(); string[] endImmediatelyStr = reader.GetString(reader.GetOrdinal("EndImmediately")).Split(','); foreach (string str in endImmediatelyStr) { if ("0" != str) { data.m_EndImmediately.Add((PEActionType)Convert.ToInt32(str)); } } if ((int)data.m_ActionType < m_Relations.Length) { m_Relations[(int)data.m_ActionType] = data; } } }