public void Reset() { foreach (var v in Buttons) { v.IsFlag = false; v.Enabled = true; v.IsMined = RandomIsMined(); v.Update(); } snd_reveal.play(); }
public void RevealOrExplode(bool LocalPlayer, Action OnBangDirect) { if (this.IsMined) { this.img = img_mine_found; snd_explosion.play(); RevealHiddenMines(); if (OnBang != null) { OnBang(LocalPlayer); } if (OnBangDirect != null) { OnBangDirect(); } } else { if (Reveal()) { snd_reveal.play(); } else { snd_click.play(); } if (OneStepClosedToTheEnd != null) { OneStepClosedToTheEnd(LocalPlayer); } } this.Enabled = false; }
public void TakeNextMap(bool LocalPlayer) { this.mouseChildren = false; Action <int, Action> Delay = (time, h) => { var t = new Timer(time, 1); t.timer += delegate { h(); }; t.start(); }; Action <int, Action[]> DelayArray = (time, h) => { var i = 0; var Next = default(Action); Next = delegate { if (i < h.Length) { Delay(time, delegate { h[i](); i++; Next(); } ); } }; Next(); }; DelayArray(1000, new Action[] { delegate { snd_tick.play(); Values.ForEach(i => i.Value = true); }, delegate { snd_tick.play(); Values.ForEach(i => i.Value = false); }, delegate { if (LocalPlayer) { Reset(); if (GameResetByLocalPlayer != null) { GameResetByLocalPlayer(); } } if (GameReset != null) { GameReset(); } } }); }
public static Action <MouseEvent> ToMouseEvent(this SoundAsset c) { return(delegate { c.play(); }); }
public MineButton() { this.Enabled = true; this.mouseDown += delegate { if (!Enabled) { return; } this.img = img_empty; }; this.mouseOut += delegate { if (!Enabled) { return; } Update(); }; this.mouseUp += e => { if (!Enabled) { return; } if (this.Field.DisallowClicks) { snd_buzzer.play(); return; } if (e.altKey || e.ctrlKey || e.shiftKey) { snd_flag.play(); this.IsFlag = !this.IsFlag; if (IsFlagChanged != null) { IsFlagChanged(); } Update(); } else { if (IsFlag) { snd_buzzer.play(); return; } if (OnReveal != null) { OnReveal(); } RevealOrExplode(true, null); } CheckComplete(true); }; Update(); }
public MineField(int FieldXCount, int FieldYCount, double percentage) { this.percentage = percentage; var a = new List <MineButton>(); var k = 0; for (int x = 0; x < FieldXCount; x++) { for (int y = 0; y < FieldYCount; y++) { var n = new MineButton { x = x * MineButton.Width, y = y * MineButton.Height, FieldX = x, FieldY = y, Others = a, Field = this }; var j = k; n.IsFlagChanged += delegate { if (IsFlagChanged != null) { IsFlagChanged(j, n.IsFlag); } }; n.OnReveal += delegate { if (OnReveal != null) { OnReveal(j); } }; n.OneStepClosedToTheEnd += LocalPlayer => { if (this.OneStepClosedToTheEnd != null) { this.OneStepClosedToTheEnd(LocalPlayer); } }; a.Add( n ); k++; } } Buttons = a.ToArray(); Action <int, Action> Delay = (time, h) => { var t = new Timer(time, 1); t.timer += delegate { h(); }; t.start(); }; Action <int, Action[]> DelayArray = (time, h) => { var i = 0; var Next = default(Action); Next = delegate { if (i < h.Length) { Delay(time, delegate { h[i](); i++; Next(); } ); } }; Next(); }; foreach (var v in a) { var z = v; v.OnComplete += LocalPlayer => { foreach (var i in a) { i.Enabled = false; } if (OnComplete != null) { OnComplete(LocalPlayer); } DelayArray(1000, new Action[] { delegate { snd_tick.play(); }, delegate { snd_tick.play(); }, delegate { if (LocalPlayer) { Reset(); if (GameResetByLocalPlayer != null) { GameResetByLocalPlayer(); } } if (GameReset != null) { GameReset(LocalPlayer); } } }); }; v.OnBang += LocalPlayer => { if (OnBang != null) { OnBang(LocalPlayer); } Delay( 3000, delegate { DelayArray(1000, new Action[] { delegate { snd_tick.play(); z.img = z.img_mine; }, delegate { snd_tick.play(); if (z.img == z.img_mine) { z.img = z.img_mine_found; } }, delegate { if (LocalPlayer) { Reset(); if (GameResetByLocalPlayer != null) { GameResetByLocalPlayer(); } } if (GameReset != null) { GameReset(LocalPlayer); } } }); } ); }; addChild(v); } Reset(); }