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 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 lbLVL_MouseEnter(object sender, EventArgs e) { if (lbLVL.Text.Contains("LVL") && IsAnimEnd) { IsAnimEnd = false; await Anim.ChangeTextAsync(lbLVL, $"LEVEL {counterLVL}", Anim.Speed._14); IsAnimEnd = true; } }
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 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; } } } }; } }