Kyaria

Clicker_Game

Apr 2nd, 2017
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.85 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace Clicker_Game
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         private int clicker_counter = 0;
  16.         private TimeSpan user_time;
  17.         private DateTime alternate_user_time;
  18.  
  19.         public Form1()
  20.         {
  21.             InitializeComponent();
  22.  
  23.             label1.Visible = false;
  24.             label2.Visible = false;
  25.  
  26.             panel1.Visible = false;
  27.             panel1.BackColor = System.Drawing.Color.DarkBlue;
  28.  
  29.             radioButton1.Checked = true;
  30.         }
  31.  
  32.         private void button1_Click(object sender, EventArgs e)
  33.         {
  34.             DialogResult new_resulution = MessageBox.Show("How hard should it be? [YES == Hard][NO == Medium][CANCEL == Easy]","Choose difficulty",MessageBoxButtons.YesNoCancel);
  35.  
  36.             if (new_resulution == DialogResult.Yes)
  37.             {
  38.                 panel1.Size = new Size(10,10);
  39.             }
  40.             if (new_resulution == DialogResult.No)
  41.             {
  42.                 panel1.Size = new Size(30, 30);
  43.             }
  44.             if (new_resulution == DialogResult.Cancel)
  45.             {
  46.                 panel1.Size = new Size(50, 50);
  47.             }
  48.  
  49.             label1.Visible = true;
  50.             label2.Visible = true;
  51.  
  52.             panel1.Visible = true;
  53.  
  54.             radioButton1.Visible = false;
  55.             radioButton2.Visible = false;
  56.  
  57.             button1.Visible = false;
  58.  
  59.             alternate_user_time = DateTime.Now;
  60.  
  61.             timer1.Start();
  62.         }
  63.  
  64.         private void panel1_MouseClick(object sender, MouseEventArgs e)
  65.         {
  66.             Random Rand_X = new Random();
  67.             int X_Random = Rand_X.Next(0, (this.Width - 50));
  68.  
  69.             Random Rand_Y = new Random();
  70.             int Y_Random = Rand_Y.Next(0, (this.Height - 50));
  71.  
  72.             panel1.Location = new Point(X_Random, Y_Random);
  73.  
  74.             clicker_counter++;
  75.             label1.Text = "Points: " + clicker_counter;
  76.         }
  77.  
  78.         private void radioButton1_CheckedChanged(object sender, EventArgs e) { }
  79.  
  80.         private void timer1_Tick(object sender, EventArgs e)
  81.         {
  82.             user_time = DateTime.Now - alternate_user_time;
  83.  
  84.             label2.Text = "Time: " + new DateTime(user_time.Ticks).ToString("ss.f");
  85.  
  86.             if (radioButton1.Checked == true)
  87.             {
  88.                 if (clicker_counter >= 10)
  89.                 {
  90.                     timer1.Stop();
  91.  
  92.                     DialogResult Resulution = MessageBox.Show("Congratulations! You lost with " + new DateTime(user_time.Ticks).ToString("ss.f") + " seconds and " + clicker_counter + " Hits! LOOSER!" + Environment.NewLine + "Wanna play again?", "Importance[Shouting at you]", MessageBoxButtons.YesNo);
  93.  
  94.                     if (Resulution == DialogResult.Yes)
  95.                     {
  96.                         clicker_counter = 0;
  97.                         label1.Text = "Points: " + clicker_counter;
  98.  
  99.                         label1.Visible = false;
  100.                         label2.Visible = false;
  101.  
  102.                         panel1.Visible = false;
  103.  
  104.                         radioButton1.Visible = true;
  105.                         radioButton2.Visible = true;
  106.  
  107.                         button1.Visible = true;
  108.                     }
  109.                     else
  110.                     {
  111.                         MessageBox.Show("Have a nice day! Not!");
  112.                         this.Close();
  113.                     }
  114.                 }
  115.             }
  116.             if (radioButton2.Checked == true)
  117.             {
  118.                 if (new DateTime(user_time.Ticks).ToString("ss") == "10")
  119.                 {
  120.                     timer1.Stop();
  121.  
  122.                     DialogResult Resulution = MessageBox.Show("Congratulations! You lost with " + new DateTime(user_time.Ticks).ToString("ss") + " seconds and " + clicker_counter + " Hits! LOOSER!" + Environment.NewLine + "Wanna play again?", "Importance[Shouting at you]", MessageBoxButtons.YesNo);
  123.  
  124.                     if (Resulution == DialogResult.Yes)
  125.                     {
  126.                         clicker_counter = 0;
  127.                         label1.Text = "Points: " + clicker_counter;
  128.  
  129.                         label1.Visible = false;
  130.                         label2.Visible = false;
  131.  
  132.                         panel1.Visible = false;
  133.  
  134.                         radioButton1.Visible = true;
  135.                         radioButton2.Visible = true;
  136.  
  137.                         button1.Visible = true;
  138.                     }
  139.                     else
  140.                     {
  141.                         MessageBox.Show("Have a nice day! Not!");
  142.                         this.Close();
  143.                     }
  144.  
  145.                 }
  146.             }
  147.         }
  148.     }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment