// method for notify registrated objects about event public void OnUseLeaf(NewWishEventArgs e) { // if object registrated if (useLeaf != null) { useLeaf(this, e); // notify object int leafsCount = flower.GetLeafCount(); int index = new Random().Next(0, leafsCount); this.Spell(); Console.WriteLine("Не успела она это сказать, как в тот же миг"); Console.WriteLine("желание ({0}) исполнилось", wish); } }
// method for translation information about event public void TakeOffLeaf(string wish) { int leafIndex = new Random().Next(0,this.flower.GetLeafCount()); NewWishEventArgs e = new NewWishEventArgs(wish, leafIndex); OnUseLeaf(e); }