static void Main(string[] args) { // create an instance from the derived type EventStack <int> eStack = new EventStack <int>(); // upcast to the base generic class GenericStack <int> gSTack = eStack; // use a lambda expression to register with the event eStack.PoppedEvent += (sender, eventArg) => { Console.WriteLine("Popped Event Invoked"); }; // push some data into the stack eStack.Push(1); eStack.Push(2); eStack.Push(3); // pop the data back out of the stack for (int i = 0; i < 3; i++) { Console.WriteLine("Popped Value: {0}", eStack.Pop()); } // wait for input before exiting Console.WriteLine("Press enter to finish"); Console.ReadLine(); }
public void Update() { while (!EventStack.IsEmpty) { Event nextEvent = EventStack.PopEvent(); Logger.Log("Processing Event", nextEvent.Name); } }
/// <summary> /// Notifies all registered listeners to invoke their events. /// </summary> public void Raise() { #if UNITY_EDITOR GameEventLog log = new GameEventLog(new List <IEventListener>(), DateTime.Now); EventStack.Add(log); #endif for (int i = Listeners.Count - 1; i >= 0; i--) { #if UNITY_EDITOR log.Listener.Add(Listeners[i]); #endif try { Listeners[i].OnEventRaised(this); #if UNITY_EDITOR log.IsError.Add(false); #endif } catch (Exception e) { Exception baseException = e.GetBaseException(); #if UNITY_EDITOR log.IsError.Add(true); log.ErrorMessages.Add(baseException.Message); log.StackTraces.Add(baseException.StackTrace); List <GameEventErrorData> errorData = new List <GameEventErrorData>(); StackTrace stackTrace = new StackTrace(baseException, true); for (int j = 0; j < stackTrace.FrameCount; j++) { StackFrame stackFrame = stackTrace.GetFrame(j); int lineNumber = stackFrame.GetFileLineNumber(); if (lineNumber > 0) { errorData.Add(new GameEventErrorData(stackFrame.GetMethod().Name, stackFrame.GetFileName(), stackFrame.GetFileLineNumber())); } } log.ErrorData.Add(errorData); #endif Debug.LogError($"[Game Event Error] {DateTime.Now:T} | {i} | {name} | {(Listeners[i].GetGameObject() == null ? "No Game Object" : Listeners[i].GetGameObject().name)} | {Listeners[i].GetObjectType().Name}"); Debug.LogException(baseException); } finally { #if UNITY_EDITOR GameEventLogWindow.LogEvent(this); #endif } } }
protected override void OnDestroy() { base.OnDestroy(); if (_instance == this) { _instance = null; } if (Game.game) { Game.hooks.Unhook(this); } }
protected override void Awake() { base.Awake(); if (_instance != null && _instance != this) { Debug.LogWarning($"Multiple {typeof(EventStack).Name} GameObjects!", this); Debug.LogWarning($"Main instance of {typeof(EventStack).Name}: {_instance}", _instance); } else { _instance = this as EventStack; } Game.hooks.Hook(this); }
protected virtual void OnValidate() { #endif #if UNITY_EDITOR // Prevent activation in prefabs if (UnityEditor.SceneManagement.PrefabStageUtility.GetPrefabStage(gameObject) == null && !UnityEditor.PrefabUtility.IsPartOfPrefabAsset(gameObject)) #endif if (_instance != null && _instance != this) { Debug.LogWarning($"Multiple {typeof(EventStack).Name} GameObjects!", this); Debug.LogWarning($"Main instance of {typeof(EventStack).Name}: {_instance}", _instance); } else { _instance = this as EventStack; } }
public void NextPhase() { int phaseNumber = currentPlayer.phase++; if (phaseNumber > PhaseCount) { NextTurn(); } phases.TryGetValue(phaseNumber, out currentPhase); if (currentPhase == null) { Logger.Log("Turn Manager ERROR", "missing phase " + phaseNumber); } UnityEngine.Debug.Log("Starting Phase"); EventStack.PushEvent(new Event("new phase")); }
static void Main(string[] args) { // create an instance from the derived type EventStack <int> eStack = new EventStack <int>(); // push some data into the stack eStack.Push(1); eStack.Push(2); eStack.Push(3); // pop the data back out of the stack for (int i = 0; i < 3; i++) { Console.WriteLine("Popped Value: {0}", eStack.Pop()); } // wait for input before exiting Console.WriteLine("Press enter to finish"); Console.ReadLine(); }
public string GetAllEvents(int userId) { var result = EventStack.UpdateEventData(userId); return(result?.ToJson()); }
public int IsEventStackUpdated(int userId) { var result = EventStack.IsEventStackUpdated(userId); return(result); }
// Use this for initialization void Awake() { CommonStack = this; Scroll.verticalNormalizedPosition = -0.2f; }
public string MakeEventBox(EventStack.Event eventElement) { string str = @"<div id=""divUserEvent{0}"" class=""UserEvent""> <div class=""EventPOI""> <a href=""{1}"" style=""{14}"">{2}</a></div> <img src=""{3}"" alt=""{2}"" width=""64px"" style=""clear: both; float: right; margin-right: 20px; border: 1px solid #ff4747;"" /> <dl class=""EventInfo""> <dt class=""EventCreatedDate"">Posted: </dt> <dd class=""EventCreatedDate""> <span class=""eventstack-datetime"">Posted: {4}</span> </dd> <dt class=""EventID"">ID: </dt> <dd class=""EventID""> #{0} </dd> <dt class=""EventAuthor"">Assigned To: </dt> <dd class=""EventAuthor""> for <a href=""{5}"" style=""{12}"">{6}</a> </dd> <dt class=""EventType"">Type: </dt> <dd class=""EventType""> <em>{7}</em> </dd> <dt class=""EventDueDate"">Due: </dt> <dd class=""EventDueDate""> <span class=""eventstack-datetime"">Due: {8}</span> </dd> <dt class=""EventDueDate"">Reminder: </dt> <dd class=""EventDueDate""> <span class=""eventstack-datetime"">Reminder: {15}</span> </dd> <dt class=""EventStatus"">Status: </dt> <dd class=""EventStatus"" style=""{9}""> <em>{10}</em> <select onchange=""{13}""> <option selected=""selected"" value="""">Change Status</option> <option value=""Done"">Done</option> <option value=""Active"">Active</option> <option value=""Inactive"">Inactive</option> </select> </dd>"; if( Session["TypeUser"].ToString() == "Admin") { str += @"<dd><input type=button onclick=""{16}"" value=' delete ' alt='This wil remove the entire event. Please be careful.'></dd>"; } str += @"</dl> <div class=""EventContent""> <span></span> <p> {11} </p> </div> </div>"; string ClientPostBackUrl = ""; string ClientName = EventStack.GetClientName(eventElement.iExistingClientID, eventElement.iNewClientID); string path = EventStack.GetClientImageFile(eventElement.iExistingClientID); if (File.Exists(Server.MapPath(path))) { path = ResolveUrl(path); } string ClientPhotoURL = path; string PostDate = eventElement.dtCreated.ToString("yyyy/MM/dd HH:mm") + " " + EventStack.GetUserFullName(eventElement.iUserID); string UserPostBackUrl = ""; string UserName = EventStack.GetUserFullName(eventElement.iAssignedUserID); string EventType = eventElement.sEventType; string DueDate = eventElement.dtDue.Value.ToString("yyyy/MM/dd HH:mm"); string StatusStyle = "border-color: #FF6666; color: #663333 !important;"; string EventStatus = "Unknown status."; if (eventElement.sStatus == "Active") { StatusStyle = "border-color: #DAC366; color: #666633 !important;"; EventStatus = "This event is still active."; } else if (eventElement.sStatus == "Done") { StatusStyle = "border-color: #7AC366; color: #336633 !important;"; EventStatus = "This event is complete."; } else if (eventElement.sStatus == "Overdue") { StatusStyle = "border-color: #FF6666; color: #663333 !important;"; EventStatus = "This event is overdue."; } else if (eventElement.sStatus == "Inactive") { StatusStyle = "border-color: #FF6666; color: #333333 !important;"; EventStatus = "This event is inactive."; } string Message = (eventElement.sMessage == "") ? "No Message" : eventElement.sMessage; string AuthorStyle = "text-decoration:none; border-right: 20px solid #" + EventStack.GetUserColor(eventElement.iAssignedUserID) + "; padding-right: 5px; cursor: default;"; string EventStatusChangeScript = "return OnEventStatusChange(this.value, '" + eventElement.iEventID.ToString() + "');"; string EventDeleteScript = "return OnEventDeleteClick('" + eventElement.iEventID.ToString() + "');"; string POIStyle = "text-decoration:none; cursor: default;"; string Reminder; if (eventElement.dtReminder != null) { Reminder = " " + eventElement.dtReminder.Value.ToString("yyyy/MM/dd HH:mm"); } else { Reminder = " None"; } string result = string.Format(str, eventElement.iEventID, ClientPostBackUrl, ClientName, ClientPhotoURL, PostDate, UserPostBackUrl, UserName, EventType, DueDate, StatusStyle, EventStatus, Message, AuthorStyle, EventStatusChangeScript, POIStyle, Reminder, EventDeleteScript); return result; }