protected override bool ExecCommand(StoryInstance instance, long delta) { if (m_StartTime <= 0) { long startTime = GameFramework.TimeUtility.GetLocalMilliseconds(); m_StartTime = startTime; } bool triggered = false; string _namespace = instance.Namespace; if (string.IsNullOrEmpty(_namespace)) { for (int i = 0; i < m_MsgIds.Count; i++) { long time = instance.GetMessageTriggerTime(m_MsgIds[i].Value); if (time > m_StartTime) { triggered = true; break; } } } else { for (int i = 0; i < m_MsgIds.Count; i++) { long time = instance.GetMessageTriggerTime(string.Format("{0}:{1}", _namespace, m_MsgIds[i].Value)); if (time > m_StartTime) { triggered = true; break; } } } bool ret = false; if (triggered) { string varName = m_SetVar.Value; object varVal = m_SetVal.Value; instance.SetVariable(varName, varVal); } else { int curTime = m_CurTime; m_CurTime += (int)delta; if (curTime <= m_TimeoutVal.Value) { ret = true; } else { string varName = m_TimeoutSetVar.Value; object varVal = m_TimeoutSetVal.Value; instance.SetVariable(varName, varVal); } } return(ret); }
protected override bool ExecCommand(StoryInstance instance, StoryMessageHandler handler, long delta) { bool ret = false; UserThread userThread = instance.Context as UserThread; if (null != userThread) { if (m_StartTime <= 0) { long startTime = GameFramework.TimeUtility.GetLocalMilliseconds(); m_StartTime = startTime; } bool triggered = false; for (int i = 0; i < m_MsgIds.Count; i++) { long time = instance.GetMessageTriggerTime(m_MsgIds[i].Value); if (time > m_StartTime) { triggered = true; break; } } if (triggered) { string varName = m_SetVar.Value; object varVal = m_SetVal.Value; instance.SetVariable(varName, varVal); } else { int curTime = m_CurTime; m_CurTime += (int)delta; if (curTime <= m_TimeoutVal.Value) { ret = true; } else { string varName = m_TimeoutSetVar.Value; object varVal = m_TimeoutSetVal.Value; instance.SetVariable(varName, varVal); } } } return(ret); }
protected override bool ExecCommand(StoryInstance instance, long delta) { if (m_StartTime <= 0) { long startTime = GameFramework.TimeUtility.GetLocalMilliseconds(); m_StartTime = startTime; } bool triggered = false; string _namespace = instance.Namespace; if (string.IsNullOrEmpty(_namespace)) { for (int i = 0; i < m_MsgIds.Count; i++) { long time = instance.GetMessageTriggerTime(m_MsgIds[i].Value); if (time > m_StartTime) { triggered = true; break; } } } else { for (int i = 0; i < m_MsgIds.Count; i++) { long time = instance.GetMessageTriggerTime(string.Format("{0}:{1}", _namespace, m_MsgIds[i].Value)); if (time > m_StartTime) { triggered = true; break; } } } bool ret = false; if (triggered) { string varName = m_SetVar.Value; object varVal = m_SetVal.Value; instance.SetVariable(varName, varVal); } else { int curTime = m_CurTime; m_CurTime += (int)delta; if (curTime <= m_TimeoutVal.Value) { ret = true; } else { string varName = m_TimeoutSetVar.Value; object varVal = m_TimeoutSetVal.Value; instance.SetVariable(varName, varVal); } } return ret; }