void ExtinguishFire(object sender, FireEventArgs fe) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { output2(sender.ToString() + "对象调用,灭火事件 ExtinguishFire函数\n"); })); if (fe.ferocity < 2) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { output2("火情发生在" + fe.room + ",浇水后被扑灭了\n"); })); } else if (fe.ferocity < 5) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { output2("火情发生在" + fe.room + ",使用灭火器后被扑灭了\n"); })); } else { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { output2("火情发生在" + fe.room + ",灭不了打119吧\n"); })); } }
public void LifeOurTown() { const string OK = "В городе {0} все спокойно! Пожаров не было."; bool wasFire = false; for (int day = 1; day <= days; day++) { for (int building = 1; building <= buildings; building++) { if (rnd.NextDouble() < fireProbability) { FireEventArgs e = new FireEventArgs(building, day); OnFire(e); wasFire = true; for (int i = 0; i < resultService.Length; i++) { Console.WriteLine(resultService[i]); } } } } if (!wasFire) { Console.WriteLine(string.Format(OK, townName)); } }
//激活事件的方法,创建了FireEventArgs 对象,发起事件,并将事件参数对象传递过去 public void ActivateFireAlarm(string room, int ferocity) { FireEventArgs fireArgs = new FireEventArgs(room, ferocity); //执行对象事件处理函数指针,必须保证处理函数要和声明代理时的参数列表相同 FireEvent(this, fireArgs); }
void WatchFire(object sender, FireEventArgs fe) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { output2(sender.ToString() + "对象调用,群众发现火情事件 WatchFire函数\n"); })); if (fe.ferocity < 2) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { output2("群众发现火情发生在" + fe.room + ",浇水后被扑灭了\n"); })); } else if (fe.ferocity < 5) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { output2("群众发现火情发生在" + fe.room + ",群众帮助下使用灭火器后被扑灭了\n"); })); } else { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { output2("群众发现火情发生在" + fe.room + ",群众无法控制,拨打119\n"); })); } }
public static void HasbandCry(object sender, EventArgs e) { EasternGastriloquy wesGas2 = (EasternGastriloquy)sender; FireEventArgs fe = (FireEventArgs)e; Console.WriteLine($"派别:{wesGas2.GasType.ToString()};燃点:{fe.BurnPoint};当前温度:{fe.NowTemp}"); Console.WriteLine("夫起大呼"); }
void FireNadeEnded_Event(object sender, FireEventArgs e) { if (e.ThrownBy != null) { Grenade grenade = CurrentRound.Players[e.ThrownBy.SteamID].PlayerRoundGrenade.Decoys.Last(); grenade.EndTick = parser.CurrentTick; grenade.EndTime = parser.CurrentTime; } }
protected void HandleFireNadeStarted(object sender, FireEventArgs e) { if (!isMatchStarted || e.ThrownBy == null || currentRoundNumber > stopRoundNumber) { return; } sbNade.AppendLine(parser.CurrentTick + "," + e.ThrownBy.SteamID + "," + e.ThrownBy.Name + "," + (int)e.NadeType + "," + (int)ActionEnum.HurtByNade + "," + e.Position.X + "," + e.Position.Y + "," + e.Position.Z); }
// This will be the starting point of our event-- it will create FireEventArgs, // and then raise the event, passing FireEventArgs. public void ActivateFireAlarm(string room, int ferocity) { FireEventArgs fireArgs = new FireEventArgs(room, ferocity); // Now, raise the event by invoking the delegate. Pass in // the object that initated the event (this) as well as FireEventArgs. // The call must match the signature of FireEventHandler. FireEvent(this, fireArgs); }
private void HandleFireNadeEnded(object sender, FireEventArgs e) { FireNadeEndedEvent newEvent = new FireNadeEndedEvent() { ThrownBySteamID = e.ThrownBy.SteamID, NadeType = (Models.EquipmentElement)((int)e.NadeType), Position = new Models.Vector(e.Position.X, e.Position.Y, e.Position.Z) }; CurrentTick.Events.Add(newEvent); }
// This is the function to be executed when a fire event is raised. void ExtinguishFire(object sender, FireEventArgs fe) { Console.WriteLine("\nThe ExtinguishFire function was called by {0}.", sender.ToString()); // Now, act in response to the event. if (fe.ferocity < 2) Console.WriteLine("This fire in the {0} is no problem. I'm going to pour some water on it.", fe.room); else if (fe.ferocity < 5) Console.WriteLine("I'm using FireExtinguisher to put out the fire in the {0}.", fe.room); else Console.WriteLine("The fire in the {0} is out of control. I'm calling the fire department!", fe.room); }
void FireFighting(object sender, FireEventArgs args) { if (((House)sender).IsFire) { if (args.IsPowerful) { if (!_firetruck1.IsBusy && !_firetruck2.IsBusy) { _firetruck1.IsBusy = true; _firetruck2.IsBusy = true; //((House)sender).IsFire = false; _firetruck1.IsBusy = false; _firetruck2.IsBusy = false; } else { FireFighting(sender, args); } } else { if (!_firetruck1.IsBusy) { _firetruck1.IsBusy = true; //((House)sender).IsFire = false; _firetruck2.IsBusy = false; } else if (!_firetruck2.IsBusy) { _firetruck2.IsBusy = true; //((House)sender).IsFire = false; _firetruck2.IsBusy = false; } else { FireFighting(sender, args); } } } }
void FireNadeStarted_Event(object sender, FireEventArgs e) { if (e.ThrownBy != null) { CurrentRound.Players[e.ThrownBy.SteamID].PlayerRoundGrenade.Fires.Add(new Grenade { StartTick = parser.CurrentTick, StartTime = parser.CurrentTime, Type = (int)e.NadeType }); if (MatchData.Players[e.ThrownBy.SteamID].Team == 0) { CurrentRound.Team1.FiresThrown += 1; } else { CurrentRound.Team2.FiresThrown += 1; } } }
//当起火事件发生时,用于处理火情的事件 void WatchFire(object sender, FireEventArgs fe) { OutStr.sw.WriteLine(" {0} 对象调用,群众发现火情WatchFire 函数.", sender.ToString()); parent.showComment(sender.ToString() + " 对象调用,群众发现火情WatchFire 函数."); //根据火情状况,输出不同的信息. if (fe.ferocity < 2) { OutStr.sw.WriteLine(" 群众察到火情发生在{0},主人浇水后火情被扑灭了", fe.room); parent.showComment(" 群众察到火情发生在 " + fe.room + ",主人浇水后火情被扑灭了"); } else if (fe.ferocity < 5) { OutStr.sw.WriteLine(" 群众察到火情发生在{0},群众帮助主人{0} 火势.", fe.room); parent.showComment(" 群众察到火情发生在 " + fe.room + ",群众帮助主人{0} 火势."); } else { OutStr.sw.WriteLine(" 群众无法控制{0} 的火情,消防官兵来到!", fe.room); parent.showComment(" 群众无法控制 " + fe.room + " 的火情,消防官兵来到!"); } }
//当起火事件发生时,用于处理火情的事件 void ExtinguishFire(object sender, FireEventArgs fe) { OutStr.sw.WriteLine(" {0} 对象调用,灭火事件ExtinguishFire 函数.", sender.ToString()); parent.showComment(sender.ToString() + " 对象调用,灭火事件ExtinguishFire 函数."); //根据火情状况,输出不同的信息. if (fe.ferocity < 2) { OutStr.sw.WriteLine(" 火情发生在{0},主人浇水后火情被扑灭了", fe.room); parent.showComment(" 火情发生在 " + fe.room + ",主人浇水后火情被扑灭了"); } else if (fe.ferocity < 5) { OutStr.sw.WriteLine(" 主人正在使用灭火器处理{0} 火势.", fe.room); parent.showComment(" 主人正在使用灭火器处理 " + fe.room + " 火势."); } else { OutStr.sw.WriteLine("{0} 的火情无法控制,主人打119!", fe.room); parent.showComment(fe.room + " 的火情无法控制,主人打119!"); } }
protected virtual void OnFire(FireEventArgs e) { const string MESSAGE_FIRE = "В городе {0} пожар! Дом {1}. День {2}-й"; Console.WriteLine(string.Format(MESSAGE_FIRE, townName, e.Building, e.Day)); if (Fire != null) { Delegate[] eventHandlers = Fire.GetInvocationList(); resultService = new string[eventHandlers.Length]; int k = 0; foreach (FireEventHandler evHandler in eventHandlers) { evHandler(this, e); resultService[k++] = e.Result; } } }
public void ActivateFireAlarm(string room, int ferocity) { FireEventArgs fireEventArgs = new FireEventArgs(room, ferocity); fireEvent(this, fireEventArgs); }
protected void EventInvoke(FireEventArgs fireEventArgs) { // can only invoke in current class,(FireHandler in abstractPerform) // so build this method to be used by derived class FireHandler?.Invoke(this, fireEventArgs); }
private void CurrentDemoParser_FireNadeEnded(object sender, FireEventArgs e) { SteamController.LogToConsole(e.NadeType + " that was thrown by " + (e.ThrownBy != null ? e.ThrownBy.Name : "nobody") + " ended at " + e.Position); }
void HandleFireNadeStarted(object sender, FireEventArgs e) { Fire.AddPoint(MapPoint(e.Position)); }