public virtual bool Remove(bool triggerEvent) { if (triggerEvent) { if (ItemDestroy != null) { ItemDestroy.Invoke(); ItemDestroy = null; } } return(true); }
public void Tick() { while (true) { Semaphore.WaitOne(); if (this.Move(Speed) && !win) { this.Print(ConsoleColor.Yellow); Semaphore.Release(); Thread.Sleep(40); } else { Console.SetCursorPosition(X, Y + 2); Console.Write(' '); Mutex mutex = Mutex.OpenExisting("CollisionMutex"); mutex.WaitOne(); using (MemoryMappedFile mmf = MemoryMappedFile.OpenExisting("RocketsMap")) { using (MemoryMappedViewStream stream = mmf.CreateViewStream(X + MapSize[0] * Y, 0)) { BinaryWriter writer = new BinaryWriter(stream); writer.Write(0); } } mutex.ReleaseMutex(); ItemDestroy?.Invoke(this); if (Pattern != BlowPattern) { Item blow = new Item(BlowPattern, new int[] { X, Y }, MapSize, 0, 1); blow.Print(); Thread.Sleep(40); blow.ChangePattern(EmptyPattern); blow.Print(); } Semaphore.Release(); break; } } }