private async void lbTEXT_MouseLeave(object sender, EventArgs e) { if (IsAnimEnd) { if (lbTEXT.Text == "1" || lbTEXT.Text == "2" || lbTEXT.Text == "3") { IsAnimEnd = false; await Anim.ChangeTextAsync(lbTEXT, "HEALTH", Anim.Speed._15); IsAnimEnd = true; } if (lbTEXT.Text == "NEW GAME" && !IsEndGame || lbTEXT.Text == "CONTINUE") { Anim.StopTransfusion(); Anim.Transfusion(lbTEXT, FlickColor.R, FlickColor.G, FlickColor.B, Anim.Speed._12); } if (lbTEXT.Text == "NEW GAME" && IsEndGame) { IsAnimEnd = false; Anim.ChangeColor(lbTEXT, 169, 0, 0, Anim.Speed._15); await Anim.ChangeTextAsync(lbTEXT, "GAME OVER", Anim.Speed._15); IsAnimEnd = true; } } }
private async void label2_Click(object sender, EventArgs e) { if (IsAnimEnd) { Anim.StopTransfusion(); Anim.ChangeText(lbNEWGAME, "N", Anim.Speed._15); if (counterLVL != 1) { foreach (Panel p in ActivityPanels) { Anim.ChangeColor(p, StartColor.R, StartColor.G, StartColor.B, Anim.Speed._10); } } await SetTileByLvl(1); tsmLevel.Enabled = true; Clock.Stop(); lbCLOCK.Text = String.Empty; if (lbTEXT.Text != "") { NewGame(); } } }
private async void lbTEXT_MouseEnter(object sender, EventArgs e) { if (IsAnimEnd) { if (lbTEXT.Text == "HEALTH") { IsAnimEnd = false; await Anim.ChangeTextAsync(lbTEXT, $"{3 - unsuccessfulClick}", Anim.Speed._15); IsAnimEnd = true; } if (lbTEXT.Text == "NEW GAME" && !IsEndGame || lbTEXT.Text == "CONTINUE") { Anim.StopTransfusion(); } if (lbTEXT.Text == "GAME OVER" && IsEndGame) { IsAnimEnd = false; Anim.ChangeColor(lbTEXT, FlickColor.R, FlickColor.G, FlickColor.B, Anim.Speed._15); await Anim.ChangeTextAsync(lbTEXT, "NEW GAME", Anim.Speed._15); IsAnimEnd = true; } } }
private void tsmRed_Click(object sender, EventArgs e) { ToolStripMenuItem tsm = sender as ToolStripMenuItem; IsColored = (tsm.Text.Length > 1) ? true : false; FlickColor = tsm.BackColor; Anim.ChangeColor(pLine, FlickColor.R, FlickColor.G, FlickColor.B, Anim.Speed._4); }
private async void lbNEWGAME_MouseLeave(object sender, EventArgs e) { Label lb = sender as Label; Anim.ChangeColor(lb, MoveColor.R, MoveColor.G, MoveColor.B, Anim.Speed._15); if (IsAnimEnd && lb.Text == "NEW GAME") { IsAnimEnd = false; await Anim.ChangeTextAsync(lbNEWGAME, "N", Anim.Speed._15); IsAnimEnd = true; } }
private async void lbTEXT_Click(object sender, EventArgs e) { if (lbTEXT.Text == "CONTINUE") { AreaClear(); await SetTileByLvl(counterLVL + 1); counterLVL++; lbLVL.Text = $"LVL {counterLVL}"; Anim.StopTransfusion(); Anim.ChangeText(lbTEXT, "", Anim.Speed._15); ResetSettingsToContinue(); await Task.Delay(1000); StartGame(); } if (lbTEXT.Text == "NEW GAME") { ChangeH(609); ChangeW(1139); await Task.Delay(500); this.MinimumSize = new Size(1139, 609); lbLVL.Visible = true; lbNEWGAME.Visible = true; tsmColorTools.Enabled = true; tsmLevel.Enabled = true; await SetTileByLvl(1); AreaClear(); Anim.StopTransfusion(); Anim.ChangeText(lbNEWGAME, "N", Anim.Speed._15); Anim.ChangeText(lbLVL, "LVL 1", Anim.Speed._15); Anim.ChangeText(lbTEXT, "", Anim.Speed._15); Anim.ChangeColor(pLine, FlickColor.R, FlickColor.G, FlickColor.B, Anim.Speed._8); ResetData(); await Task.Delay(1000); StartGame(); } }
private async void StartGame() { r = new Random(); matches = new List <string>(); RandomSequence.Mix(); flag = true; IsEndGame = false; IsAnimEnd = false; RandomColor.Mix(); Clock.Stop(); lbCLOCK.Text = String.Empty; for (int i = 0; i < 4; i++) { matches.Add(ActivityPanels[RandomSequence[i]].Name); if (IsColored) { await Anim.ChangeColorAsync(ActivityPanels[RandomSequence[i]], colors[RandomColor[i], 0], colors[RandomColor[i], 1], colors[RandomColor[i], 2], Complexity(counterLVL)); } else { await Anim.ChangeColorAsync(ActivityPanels[RandomSequence[i]], FlickColor.R, FlickColor.G, FlickColor.B, Complexity(counterLVL)); } await Anim.ChangeColorAsync(ActivityPanels[RandomSequence[i]], StartColor.R, StartColor.G, StartColor.B, Complexity(counterLVL)); } foreach (var Health in HealthList) { Health.Visible = true; } IsStarted = true; IsBreak = false; Clock.Start(lbCLOCK); Anim.ChangeColor(lbTEXT, 255, 128, 128, Anim.Speed._5); Anim.ChangeText(lbTEXT, "HEALTH", Anim.Speed._15); if (!IsFirstHealth) { HealthAnimation(); IsFirstHealth = true; } IsAnimEnd = true; }
private async void NewGame() { IsAnimEnd = false; AreaClear(); IsBreak = true; IsFirstHealth = false; foreach (var Health in HealthList) { Health.Visible = false; } Anim.ChangeText(lbTEXT, String.Empty, Anim.Speed._15); Anim.ChangeColor(pLine, FlickColor.R, FlickColor.G, FlickColor.B, Anim.Speed._8); ResetData(); lbLVL.Text = $"LVL {counterLVL}"; await Task.Delay(1000); StartGame(); }
private async void Form1_Load(object sender, EventArgs e) { dict = new Dictionary <int, Anim.Speed>() { { 1, Anim.Speed._5 }, { 2, Anim.Speed._8 }, { 3, Anim.Speed._10 }, { 4, Anim.Speed._15 } }; HealthList = Dock.Controls.OfType <Panel>().Where <Panel>(a => a.Name.Contains("hp")).ToList(); ResetData(); HideControls(); IsColored = false; IsAnimEnd = false; await Task.Delay(400); await Anim.ChangeTextAsync(lbTEXT, "NEW GAME", Anim.Speed._14); Anim.Transfusion(lbTEXT, FlickColor.R, FlickColor.G, FlickColor.B, Anim.Speed._12); IsAnimEnd = true; colors = new int[, ] { { 87, 130, 207 }, //blue { 255, 128, 128 }, //red { 192, 255, 192 }, //green { 255, 214, 0 } //yellow }; ListAllPanels = Controls.OfType <Panel>().Where <Panel>(d => d.Name.Contains("panel")).ToList(); foreach (Panel panel in ListAllPanels) { panel.MouseEnter += (s, a) => { Panel pnl = s as Panel; if (pnl.BackColor == StartColor) { pnl.BackColor = MoveColor; } }; panel.MouseLeave += (s, a) => { Panel pnl = s as Panel; if (pnl.BackColor == MoveColor) { pnl.BackColor = StartColor; } }; panel.MouseClick += async(s, a) => { //CLICK PANEL Panel pnl = s as Panel; if (!IsEndGame && IsStarted) { if (!(pnl.BackColor == StartColor || pnl.BackColor == MoveColor)) { return; } if (pnl.Name == matches[ClickCounter] && !IsEndGame) { ClickCounter++; if (ClickCounter == AmountOfPoint) { //WIN IsStarted = false; IsAnimEnd = false; IsEndGame = true; IsBreak = true; Clock.Stop(); Anim.ChangeColor(ActivityPanels, 192, 255, 192, Anim.Speed._12); //green await Anim.ChangeTextAsync(lbTEXT, "CONTINUE", Anim.Speed._15); Anim.StopTransfusion(); Anim.Transfusion(lbTEXT, FlickColor.R, FlickColor.G, FlickColor.B, Anim.Speed._12); IsAnimEnd = true; return; } pnl.BackColor = Color.FromArgb(192, 255, 192); //green } else if (!IsEndGame) { unsuccessfulClick++; switch (unsuccessfulClick) { case 1: hp3.Visible = false; break; case 2: hp2.Visible = false; break; case 3: hp1.Visible = false; //LOSE IsStarted = false; IsEndGame = true; IsAnimEnd = false; tsmLevel.Enabled = false; Clock.Stop(); Anim.ChangeColor(ActivityPanels, 22, 22, 25, Anim.Speed._5); Anim.ChangeText(lbTEXT, "GAME OVER", Anim.Speed._14); Anim.ChangeColor(lbTEXT, 169, 0, 0, Anim.Speed._5); Anim.ChangeColor(pLine, 169, 0, 0, Anim.Speed._5); IsFirstHealth = false; IsAnimEnd = true; return; } if (pnl.BackColor == MoveColor || pnl.BackColor == StartColor) //ANIMATION RED PANEL { pnl.BackColor = Color.FromArgb(255, 128, 128); //red } if (pnl.BackColor == Color.FromArgb(255, 128, 128)) { IsAnimEnd = false; Anim.ChangeColor(pnl, StartColor.R, StartColor.G, StartColor.B, Anim.Speed._2); IsAnimEnd = true; } } } }; } }
private async Task SetTileByLvl(int lvl) { Dictionary <int, int> dic = new Dictionary <int, int>() { { 1, 16 }, { 2, 20 }, { 3, 24 }, { 4, 32 } }; if (lvl > dic.Count) { return; } IsAnimEnd = false; int NumPanel = 0; int j = 0; if (lvl == 4 || counterLVL == 4) { j = 1; } if (lvl - counterLVL > 0) { for (int i = 0; i < lvl - counterLVL + j; i++) { foreach (Panel panel in ListAllPanels) { ShiftAnimation(panel, true); await Task.Delay(1); } await Task.Delay(100); } } else if (lvl - counterLVL != 0) { for (int i = 0; i < counterLVL - lvl + j; i++) { foreach (Panel panel in ListAllPanels) { ShiftAnimation(panel, false); await Task.Delay(1); } await Task.Delay(100); } } foreach (Panel panel in ListAllPanels) { NumPanel = Convert.ToInt32(panel.Name.Remove(0, 5)); if (NumPanel >= 1 && NumPanel <= dic[lvl]) { Anim.ChangeColor(panel, StartColor.R, StartColor.G, StartColor.B, Anim.Speed._3); } else { Anim.ChangeColor(panel, 22, 22, 25, Anim.Speed._3); } } await Task.Delay(1000); ActivityPanels = Controls.OfType <Panel>().Where <Panel>(e => e.Name.Contains("panel") && e.BackColor != Color.FromArgb(22, 22, 25)).ToArray(); IsAnimEnd = true; }
private void AreaClear() { Anim.ChangeColor(ActivityPanels, StartColor.R, StartColor.G, StartColor.B, Anim.Speed._5); }