private void btnLast_Click(object sender, RoutedEventArgs e) { if (LastEvent != null) { LastEvent.Invoke(); } }
public override void Save() { base.Save(); var settings = new TaskSettings(Task); settings.SaveValue(Config.LastEventName, LastEvent.ToString()); }
private string GetBadTradeText() { string generic = Datastructures.SelectRandom(Faction.Race.Speech.BadTrades); if (LastEvent.IsHate()) { generic += " We are offended by this trade."; } return(generic); }
public static void InsertEvent(LastEvent paramEvent) { try { _collection.InsertOne(paramEvent); } catch (Exception Ex) { Console.WriteLine($"Error Insert Event on MongoDB! Err = {Ex.Message}."); } }
public override int GetHashCode() { unchecked { var hashCode = (Payload != null ? Payload.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (EmitterId != null ? EmitterId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (LastEvent != null ? LastEvent.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CurrentTime != null ? CurrentTime.GetHashCode() : 0); hashCode = (hashCode * 397) ^ SequenceNr.GetHashCode(); foreach (var deliveryAttempt in DeliveryAttempts) { hashCode = (hashCode * 397) ^ deliveryAttempt.GetHashCode(); } foreach (var onEventRequest in PersistOnEventRequests) { hashCode = (hashCode * 397) ^ onEventRequest.GetHashCode(); } return(hashCode); } }
IEnumerable <SpeechNode> WaitForTrade() { TradeDialog dialog = TradeDialog.Popup(GUI, GUI.RootComponent, Faction, Resources); LastEvent = null; dialog.OnTraded += dialog_OnClicked; while (LastEvent == null && dialog.IsVisible) { yield return(null); } if (LastEvent != null) { TradeEvent.Profit profit = LastEvent.GetProfit(); if (LastEvent.IsHate() && !Politics.HasEvent("you tried to give us something offensive")) { Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent() { Change = -0.25f, Description = "you tried to give us something offensive", Duration = new TimeSpan(4, 0, 0, 0), Time = World.Time.CurrentDate }); } else if ((!LastEvent.IsHate() && LastEvent.IsLike()) && !Politics.HasEvent("you gave us something we liked")) { Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent() { Change = 0.25f, Description = "you gave us something we liked", Duration = new TimeSpan(4, 0, 0, 0), Time = World.Time.CurrentDate }); } if (profit.PercentProfit > 0.25f && !LastEvent.IsHate()) { DoTrade(LastEvent); if (!Politics.HasEvent("we had profitable trade")) { Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent() { Change = 0.25f, Description = "we had profitable trade", Duration = new TimeSpan(2, 0, 0, 0), Time = World.Time.CurrentDate }); } yield return(new SpeechNode() { Text = GetGoodTradeText(), Actions = new List <SpeechNode.SpeechAction>() { new SpeechNode.SpeechAction() { Text = "Ok", Action = () => SpeechNode.Echo(DialougeTree) } } }); } else { yield return(new SpeechNode() { Text = GetBadTradeText(), Actions = new List <SpeechNode.SpeechAction>() { new SpeechNode.SpeechAction() { Text = "Sorry.", Action = () => SpeechNode.Echo(DialougeTree) } } }); } yield break; } else { yield return(DialougeTree); } yield break; }
/// <summary> /// トラックに単一のイベントを挿入 /// insertEventをtargetEventの直前に入れる。時刻が不正な場合、自動訂正する。 /// targetEvent==NULLの場合、トラックの最後に入れる。 /// </summary> /// <param name="insertEvent">挿入するイベント</param> /// <param name="targetEvent">挿入ターゲット</param> internal void InsertSingleEventBefore(Event insertEvent, Event targetEvent) { /* イベントが既に他のトラックに属している場合、却下する */ if (insertEvent.Parent != null || insertEvent.PrevEvent != null || insertEvent.NextEvent != null) { throw new MIDIDataLibException("イベントは既に他のトラックに属しています。"); } /* EOTを二重に入れるのを防止 */ if (LastEvent != null) { if (LastEvent.Kind == Kind.EndofTrack && insertEvent.Kind == Kind.EndofTrack) { return; } } /* SMFフォーマット1の場合 */ if (Parent != null) { if (Parent.Format == Format.Format1) { /* コンダクタートラックにMIDIEventを入れるのを防止 */ if (ReferenceEquals(Parent.FirstTrack, this)) { if (insertEvent.IsMIDIEvent) { throw new MIDIDataLibException("コンダクタートラックにMIDIEventを挿入することはできません。"); } } /* 非コンダクタートラックにテンポ・拍子などを入れるのを防止 */ else { if (insertEvent.Kind == Kind.Tempo || insertEvent.Kind == Kind.SMPTEOffset || insertEvent.Kind == Kind.TimeSignature || insertEvent.Kind == Kind.KeySignature) { throw new MIDIDataLibException("非コンダクタートラックにテンポ・拍子などを挿入することはできません。"); } } } } /* pTargetの直前に挿入する場合 */ if (targetEvent != null) { /* ターゲットの所属トラックが異なる場合却下 */ if (targetEvent.Parent != this) { throw new MIDIDataLibException("ターゲットの所属トラックが異なります。"); } targetEvent.SetPrevEvent(insertEvent); } /* トラックの最後に挿入する場合(pTarget==NULL) */ else if (LastEvent != null) { /* EOTの後に挿入しようとした場合、EOTを後ろに移動しEOTの直前に挿入 */ if (LastEvent.Kind == Kind.EndofTrack) { /* EOTを正しく移動するため、先に時刻の整合調整 */ if (LastEvent._time < insertEvent._time) { LastEvent._time = insertEvent._time; } LastEvent.SetPrevEvent(insertEvent); } /* EOT以外の後に挿入しようとした場合、普通に挿入 */ else { LastEvent.SetNextEvent(insertEvent); } } /* 空トラックに挿入する場合 */ else { insertEvent.Parent = this; insertEvent.NextEvent = null; insertEvent.PrevEvent = null; insertEvent.NextSameKindEvent = null; insertEvent.PrevSameKindEvent = null; FirstEvent = insertEvent; LastEvent = insertEvent; NumEvent++; } }
public WorkflowAction DefaultActionOnLastEvent() { return(LastEvent.DefaultAction(_workflow)); }
private IEnumerator OnResponseEvent(WWW req, TextMeshProUGUI text) { yield return(req); text.text = JsonHelper.FormatJson(req.text); eventData = JsonUtility.FromJson <RootObject>(req.text); if (eventData.datas.items[0].id != lastEventID) { lastEventID = eventData.datas.items[0].id; lastEventIDField.text = lastEventID.ToString(); PlayerPrefs.SetInt("lastEventID", lastEventID); PlayerPrefs.Save(); if (eventData.datas.items[0].type.Equals("subscription") && subsActive == true) { ActivateAlert(alertState.subs); if (lastEvents.Count > 3) { Destroy(lastEvents.First <LastEvent>().Holder); lastEvents.RemoveAt(0); } LastEvent last = new LastEvent(); last.Holder = Instantiate(lastEventsPrefab, EventsLayoutGroup); last.Holder.GetComponent <RectTransform>().SetAsFirstSibling(); last.User = last.Holder.transform.GetChild(0).GetComponent <TextMeshProUGUI>(); last.User.text = eventData.datas.items[0].parameters.username; last.Type = last.Holder.transform.GetChild(1).GetComponent <TextMeshProUGUI>(); last.Type.text = eventData.datas.items[0].type.ToUpper(); last.Amount = last.Holder.transform.GetChild(2).GetComponent <TextMeshProUGUI>(); last.Amount.text = eventData.datas.items[0].parameters.amount.ToString() + eventData.datas.items[0].parameters.currency; last.Message = last.Holder.transform.GetChild(3).GetComponent <TextMeshProUGUI>(); last.Message.text = eventData.datas.items[0].parameters.message; lastEvents.Add(last); } if (eventData.datas.items[0].type.Equals("follow") && followsActive == true) { ActivateAlert(alertState.follow); if (lastEvents.Count > 3) { Destroy(lastEvents.First <LastEvent>().Holder); lastEvents.RemoveAt(0); } LastEvent last = new LastEvent(); last.Holder = Instantiate(lastEventsPrefab, EventsLayoutGroup); last.Holder.GetComponent <RectTransform>().SetAsFirstSibling(); last.User = last.Holder.transform.GetChild(0).GetComponent <TextMeshProUGUI>(); last.User.text = eventData.datas.items[0].parameters.username; last.Type = last.Holder.transform.GetChild(1).GetComponent <TextMeshProUGUI>(); last.Type.text = eventData.datas.items[0].type.ToUpper(); last.Amount = last.Holder.transform.GetChild(2).GetComponent <TextMeshProUGUI>(); last.Amount.text = eventData.datas.items[0].parameters.amount.ToString() + eventData.datas.items[0].parameters.currency; last.Message = last.Holder.transform.GetChild(3).GetComponent <TextMeshProUGUI>(); last.Message.text = eventData.datas.items[0].parameters.message; lastEvents.Add(last); } if (eventData.datas.items[0].type.Equals("donation") && donationsActive == true) { ActivateAlert(alertState.donation); if (lastEvents.Count > 3) { Destroy(lastEvents.First <LastEvent>().Holder); lastEvents.RemoveAt(0); } LastEvent last = new LastEvent(); last.Holder = Instantiate(lastEventsPrefab, EventsLayoutGroup); last.Holder.GetComponent <RectTransform>().SetAsFirstSibling(); last.User = last.Holder.transform.GetChild(0).GetComponent <TextMeshProUGUI>(); last.User.text = eventData.datas.items[0].parameters.username; last.Type = last.Holder.transform.GetChild(1).GetComponent <TextMeshProUGUI>(); last.Type.text = eventData.datas.items[0].type.ToUpper(); last.Amount = last.Holder.transform.GetChild(2).GetComponent <TextMeshProUGUI>(); last.Amount.text = eventData.datas.items[0].parameters.amount.ToString() + eventData.datas.items[0].parameters.currency; last.Message = last.Holder.transform.GetChild(3).GetComponent <TextMeshProUGUI>(); last.Message.text = eventData.datas.items[0].parameters.message; lastEvents.Add(last); } if (eventData.datas.items[0].type.Equals("hosting") && hostsActive == true) { ActivateAlert(alertState.host); if (lastEvents.Count > 3) { Destroy(lastEvents.First <LastEvent>().Holder); lastEvents.RemoveAt(0); } LastEvent last = new LastEvent(); last.Holder = Instantiate(lastEventsPrefab, EventsLayoutGroup); last.Holder.GetComponent <RectTransform>().SetAsFirstSibling(); last.User = last.Holder.transform.GetChild(0).GetComponent <TextMeshProUGUI>(); last.User.text = eventData.datas.items[0].parameters.username; last.Type = last.Holder.transform.GetChild(1).GetComponent <TextMeshProUGUI>(); last.Type.text = eventData.datas.items[0].type.ToUpper(); last.Amount = last.Holder.transform.GetChild(2).GetComponent <TextMeshProUGUI>(); last.Amount.text = eventData.datas.items[0].parameters.amount.ToString() + eventData.datas.items[0].parameters.currency; last.Message = last.Holder.transform.GetChild(3).GetComponent <TextMeshProUGUI>(); last.Message.text = eventData.datas.items[0].parameters.message; lastEvents.Add(last); } } }