/// <summary> /// Constructor /// </summary> /// <param name="name">Name of the event</param> /// <param name="cyclical">Is event cyclical over time?</param> /// <param name="cycles">0 means infinite looping</param> /// <param name="startingState">first game event state</param> public GameEvent(string name, bool cyclical, int cycles = 0, EGameEventStates startingState = EGameEventStates.WAITING) { m_eventId = name; m_currentState = startingState; m_cyclicalEvent = cyclical; m_currentCycleCounter = cycles; }
/// <summary> /// Constructor /// </summary> public GameEvent() { m_eventId = "Default"; m_currentState = EGameEventStates.WAITING; m_cyclicalEvent = false; m_currentCycleCounter = 0; }
/// <summary> /// Sets the event current state to finnished, if its cyclical its set to waiting /// </summary> public void EndGameEvent() { m_currentState = EGameEventStates.FINISHED; if (!m_cyclicalEvent || !(m_cycles == 0 || m_currentCycleCounter < m_cycles)) { return; } m_currentState = EGameEventStates.WAITING; m_currentCycleCounter += 1; }
/// <summary> /// Sets the current state of the event to finished or waiting (if cyclical) and executes an On End and On Loop function /// </summary> /// <param name="OnEndGameEventMethod">function to execute it has to be void return and have no arguments</param> /// <param name="OnLoopGameEventMethod">function to execute it has to be void return and have no arguments</param> public void EndGameEvent(OnLoopGameEvent OnLoopGameEventMethod, OnEndGameEvent OnEndGameEventMethod) { m_currentState = EGameEventStates.FINISHED; if (!m_cyclicalEvent || !(m_cycles == 0 || m_currentCycleCounter < m_cycles)) { OnEndGameEventMethod(); return; } OnLoopGameEventMethod(); m_currentState = EGameEventStates.WAITING; m_currentCycleCounter += 1; }
/// <summary> /// Sets the current state of the event to running and executes an On Init function /// </summary> /// <param name="OnInitGameEventMethod">function to execute it has to be void return and have no arguments</param> public void InitGameEvent(OnInitGameEvent OnInitGameEventMethod) { m_currentState = EGameEventStates.RUNNING; OnInitGameEventMethod(); }
/// <summary> /// Sets current state of the event to running /// </summary> public void InitGameEvent() { m_currentState = EGameEventStates.RUNNING; }