Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- namespace KILLEMO3
- {
- public partial class Form1 : Form
- {
- private Label[] meniu = new Label[4];
- private Objector obj = new Objector();
- private TextBox username = new TextBox();
- private ComboBox difficulty = new ComboBox();
- private string[] meniunames;
- private string[] diffnames;
- private string title;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- PictureBox bg = new PictureBox();
- title = "KILL EMO 3: DON`T LET THEM KILL THEMSELFS! :: By Profas";
- this.Text = title;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.Size = new Size(645, 570);
- bg = obj.OPictureBox(new Point(0,0), Image.FromFile(@"img/GUI/enter"));
- this.Controls.Add(bg);
- meniunames = new string[4] { "- START - ", "- SCORES -", "- ABOUT -", "- EXIT -" };
- diffnames = new string[3] { "Hard", "Normal", "Easy" };
- for (int i = 0; i < 4; i++)
- {
- meniu[i] = obj.OLabel(new Point(50, (i * 50) + 150), Color.Transparent, meniunames[i]);
- meniu[i].Size = new Size(225, 50);
- meniu[i].Font = new Font("Tahoma", 28);
- meniu[i].Cursor = Cursors.Hand;
- meniu[i].MouseClick += new MouseEventHandler(MeniuClick);
- meniu[i].MouseEnter += new EventHandler(MeniuEnter);
- meniu[i].MouseLeave += new EventHandler(MeniuLeave);
- bg.Controls.Add(meniu[i]);
- }
- username = obj.OTextBox(new Point(160, 445), 150, BorderStyle.FixedSingle);
- difficulty = obj.OComboBox(new Point(160, 475), 150, FlatStyle.Flat);
- for (int i = 0; i < 3; i++)
- difficulty.Items.Add(diffnames[i]);
- difficulty.SelectedIndex = 1;
- username.Font = new Font("Tahoma", 10);
- difficulty.Font = new Font("Tahoma", 10);
- bg.Controls.Add(username);
- bg.Controls.Add(difficulty);
- }
- #region MeniuClick
- private void MeniuClick(object sender, MouseEventArgs args)
- {
- Label prv = (sender as Label);
- if (prv.Text == meniunames[0])
- {
- if (username.Text != "")
- {
- GameEngine game = new GameEngine(this.Location, this.Size, username.Text, difficulty.Text, title);
- game.StartEngine();
- }
- else
- MessageBox.Show("Enter Your Name.", "n00b");
- }
- else if (prv.Text == meniunames[1])
- {
- MessageBox.Show("STATISTICS");
- }
- else if (prv.Text == meniunames[2])
- {
- MessageBox.Show("ABOUT");
- }
- else if (prv.Text == meniunames[3])
- this.Close();
- }
- #endregion
- #region Events
- private void MeniuEnter(object sender, EventArgs args)
- {
- (sender as Label).ForeColor = Color.Red;
- }
- private void MeniuLeave(object sender, EventArgs args)
- {
- (sender as Label).ForeColor = Color.Black;
- }
- #endregion
- }
- public class BuyEngine : Form
- {
- #region Variable
- private PictureBox bg;
- private Objector obj = new Objector();
- private Button[] player_upgr = new Button[3];
- private Button[] gun_upgr = new Button[6];
- private Button[] other_upgr = new Button[2];
- #endregion
- #region BuyEngine
- public BuyEngine(Player player, Guns guns, Levels levels, GameEngine engine)
- {
- bg = obj.OPictureBox(new Point(0, 0), Image.FromFile(@"img/GUI/buygui.jpg"));
- bg.Size = bg.Image.Size;
- this.Controls.Add(bg);
- this.Size = new Size(645, 570);
- this.Text = "It's Time For Some Upgrade! :-)";
- string but = "UPGRADE";
- for (int i = 0; i < 3; i++)
- {
- player_upgr[i] = obj.OButton(new Point(250, (i * 21) + 160), new Size(75, 20), Color.Black, but);
- player_upgr[i].Font = new Font("Tahoma", 7);
- player_upgr[i].TextAlign = ContentAlignment.TopCenter;
- player_upgr[i].ForeColor = Color.White;
- bg.Controls.Add(player_upgr[i]);
- }
- for (int i = 0; i < 6; i++)
- {
- gun_upgr[i] = obj.OButton(new Point(250, (i * 21) + 273), new Size(75, 20), Color.Black, but);
- gun_upgr[i].Font = new Font("Tahoma", 7);
- gun_upgr[i].TextAlign = ContentAlignment.TopCenter;
- gun_upgr[i].ForeColor = Color.White;
- bg.Controls.Add(gun_upgr[i]);
- }
- for (int i = 0; i < 2; i++)
- {
- other_upgr[i] = obj.OButton(new Point(250, (i * 21) + 445), new Size(75, 20), Color.Black, but);
- other_upgr[i].Font = new Font("Tahoma", 7);
- other_upgr[i].TextAlign = ContentAlignment.TopCenter;
- other_upgr[i].ForeColor = Color.White;
- bg.Controls.Add(other_upgr[i]);
- }
- }
- ~BuyEngine() { }
- #endregion
- }
- public class Guns
- {
- #region Variable
- private const int nr = 5;
- public int[] gun_dmg;
- public int[] gun_bullet;
- public int[] gun_reload;
- public int[] gun_critical;
- public string[] gun_name;
- public string[] gun_sound;
- public string[] gun_image;
- public string[] gun_target;
- public int choosen;
- private Random random;
- #endregion
- #region Guns
- public Guns()
- {
- choosen = 0;
- gun_name = new string[nr] { "USP", "Deagle", "AK-47", "Sniper", "Super Lazer" };
- gun_sound = new string[nr] { "usp.wav", "deagle.wav", "ak-47.wav", "sniper.wav", "lazer.wav" };
- gun_image = new string[nr] { "usp.jpg", "deagle.jpg", "ak-47.jpg", "sniper.jpg", "lazer.jpg" };
- gun_target = new string[nr] { "usp.cur", "deagle.cur", "ak-47.cur", "sniper.cur", "lazer.cur" };
- gun_dmg = new int[nr] { 10, 25, 8, 120, 1000 };
- gun_bullet = new int[nr] { 12, 7, 32, 1, 5 };
- gun_reload = new int[nr] { 3, 4, 8, 2, 12 };
- gun_critical = new int[nr] { 5, 25, 30, 50, 80 };
- random = new Random(System.Environment.ProcessorCount);
- }
- ~Guns() { }
- #endregion
- #region Reload
- public int Reload()
- {
- return gun_reload[choosen];
- }
- #endregion
- #region SetSound
- private void SetSound()
- {
- }
- #endregion
- #region DoDamage
- public int DoDamage()
- {
- if (CountCritical())
- return gun_dmg[choosen] * 2;
- else return
- gun_dmg[choosen];
- }
- #endregion
- #region CountCritical
- private bool CountCritical()
- {
- int chance = random.Next(0, 100);
- if (chance < gun_critical[choosen])
- return true;
- else
- return false;
- }
- #endregion
- #region ChooseGun
- public void ChooseGun(string name)
- {
- }
- #endregion
- }
- public class Objector
- {
- #region Objector
- public Objector() { }
- ~Objector() { }
- #endregion
- #region PictureBox
- public PictureBox OPictureBox(Point location, Image image)
- {
- try
- {
- PictureBox img = new PictureBox();
- img.Image = image;
- img.Location = location;
- img.Size = img.Image.Size;
- return img;
- }
- catch { return null; }
- }
- #endregion
- #region Form
- public Form OForm(Point location, Size size, bool border)
- {
- try
- {
- Form form = new Form();
- if (border != true)
- form.FormBorderStyle = FormBorderStyle.None;
- form.Size = size;
- form.StartPosition = FormStartPosition.Manual;
- form.Location = location;
- return form;
- }
- catch { return null; }
- }
- #endregion
- #region Label
- public Label OLabel(Point location, Color backcolor, string text)
- {
- try
- {
- Label label = new Label();
- label.Text = text;
- label.Location = location;
- label.BackColor = backcolor;
- return label;
- }
- catch { return null; }
- }
- #endregion
- #region Textbox
- public TextBox OTextBox(Point location, int width, BorderStyle borderstyle)
- {
- try
- {
- TextBox textbox = new TextBox();
- textbox.Width = width;
- textbox.Location = location;
- textbox.BorderStyle = borderstyle;
- return textbox;
- }
- catch { return null; }
- }
- #endregion
- #region GroupBox
- public GroupBox OGroupBox(Point location, Size size, string text)
- {
- try
- {
- GroupBox groupbox = new GroupBox();
- groupbox.Location = location;
- groupbox.Size = size;
- groupbox.Text = text;
- return groupbox;
- }
- catch { return null; }
- }
- #endregion
- #region Panel
- public Panel OPanel(Point location, Size size, Color color)
- {
- try
- {
- Panel panel = new Panel();
- panel.Location = location;
- panel.Size = size;
- panel.BackColor = color;
- return panel;
- }
- catch { return null; }
- }
- #endregion
- #region ListBox
- public ListBox OListBox(Point location, Size size, Color color)
- {
- try
- {
- ListBox listbox = new ListBox();
- listbox.Location = location;
- listbox.Size = size;
- listbox.BackColor = color;
- return listbox;
- }
- catch { return null; }
- }
- #endregion
- #region RichTextBox
- public RichTextBox ORichTextBox(Point location, Size size, Color bgcolor, Color fcolor)
- {
- try
- {
- RichTextBox rich = new RichTextBox();
- rich.Location = location;
- rich.Size = size;
- rich.BackColor = bgcolor;
- rich.ForeColor = fcolor;
- return rich;
- }
- catch { return null; }
- }
- #endregion
- #region Button
- public Button OButton(Point location, Size size, Color bgcolor, string text)
- {
- try
- {
- Button button = new Button();
- button.Location = location;
- button.Size = size;
- button.BackColor = bgcolor;
- button.Text = text;
- button.Cursor = Cursors.Hand;
- button.FlatStyle = FlatStyle.Flat;
- return button;
- }
- catch { return null; }
- }
- #endregion
- #region ComboBox
- public ComboBox OComboBox(Point location, int width, FlatStyle border)
- {
- try
- {
- ComboBox box = new ComboBox();
- box.Location = location;
- box.Width = width;
- box.FlatStyle = border;
- box.DropDownStyle = ComboBoxStyle.DropDownList;
- return box;
- }
- catch { return null; }
- }
- #endregion
- }
- public class Player
- {
- #region Variable
- public int bullets;
- public int reloading;
- public int money;
- public Guns guns;
- public bool reloaded;
- private string username;
- private PictureBox gun_img = new PictureBox();
- private string gun;
- private int life;
- private Label[] info = new Label[5];
- private PictureBox lifebox;
- private Objector obj = new Objector();
- private GameEngine engine;
- private string[] _info = new string[5];
- private int tick;
- SoundPlayer reload_sound;
- #endregion
- #region Player
- public Player(string user, GameEngine gameengine)
- {
- reloaded = true;
- engine = gameengine;
- username = user;
- life = 100;
- money = 50;
- guns = new Guns();
- guns.choosen = Convert.ToInt32(user)-1;
- reload_sound = new SoundPlayer(@"sounds/reload.wav");
- gun = guns.gun_name[guns.choosen];
- bullets = guns.gun_bullet[guns.choosen];
- reloading = guns.gun_reload[guns.choosen];
- gun_img = obj.OPictureBox(new Point(559, 416), Image.FromFile(@"img/guns/" + guns.gun_image[guns.choosen]));
- gameengine.bg.Controls.Add(gun_img);
- _info = new string[5] { life.ToString(), money.ToString(), bullets.ToString(), reloading.ToString(), gun };
- Point[] _location = new Point[5] { new Point(300, 405), new Point(320, 498), new Point(485, 402), new Point(508, 425), new Point(465, 445) };
- int[] _fonts = new int[5] { 16, 16, 12, 12, 12 };
- for (int i = 0; i < 5; i++)
- {
- info[i] = obj.OLabel(_location[i], Color.Transparent, _info[i]);
- info[i].Font = new Font("Tahoma", _fonts[i]);
- engine.bg.Controls.Add(info[i]);
- }
- lifebox = obj.OPictureBox(new Point(208, 443), Image.FromFile(@"img/sprites/life.bmp"));
- engine.bg.Controls.Add(lifebox);
- ChangeInfo();
- }
- ~Player() { }
- #endregion
- #region ChangeLife
- public void ChangeLife(int count)
- {
- lifebox.Size = new Size((int)(((float)(life -= count) / 100) * 174), lifebox.Height);
- info[0].Text = life.ToString();
- if (life <= 0)
- {
- info[0].Text = "0";
- engine.GameOver();
- }
- }
- #endregion
- #region Reload
- public void Reload()
- {
- ChangeInfo();
- tick = this.guns.gun_reload[guns.choosen];
- Timer reload = new Timer();
- reload.Interval = 1000;
- reload.Tick += new EventHandler(Reloading);
- reload.Enabled = true;
- }
- private void Reloading(object sender, EventArgs args)
- {
- reload_sound.Play();
- reloading = --tick;
- ChangeInfo();
- if (tick == 0)
- {
- reloaded = true;
- bullets = guns.gun_bullet[guns.choosen];
- reloading = guns.gun_reload[guns.choosen];
- ChangeInfo();
- (sender as Timer).Enabled = false;
- (sender as Timer).Dispose();
- }
- }
- #endregion
- #region ChangeInfo
- public void ChangeInfo()
- {
- string[] change = new string[5] { life.ToString(), money.ToString(), bullets.ToString(), reloading.ToString(), gun };
- gun = guns.gun_name[guns.choosen];
- for (int i = 0; i < 5; i++)
- info[i].Text = change[i];
- }
- #endregion
- }
- public class GameEngine : Form
- {
- #region Variables
- private Objector obj = new Objector();
- private Timer enginer = new Timer();
- private Timer checker = new Timer();
- private EmoVeryEasy EVECurrent;
- public PictureBox bg = new PictureBox();
- private Random random = new Random();
- private Player player;
- private Levels levels = new Levels();
- #endregion
- #region GameEngine
- public GameEngine(Point location, Size size, string user, string diff, string title)
- {
- this.Cursor = new Cursor(@"img/targets/1.cur");
- bg = obj.OPictureBox(new Point(0,0), Image.FromFile(@"img/GUI/EGUI.jpg"));
- this.Text = title;
- this.Size = size;
- this.Location = location;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.Controls.Add(bg);
- player = new Player(user, this);
- BuyEngine buyengine = new BuyEngine(player, player.guns, levels, this);
- buyengine.Show();
- enginer.Tick += new EventHandler(EngineON);
- enginer.Enabled = true;
- enginer.Interval = 2000;
- checker.Tick += new EventHandler(CheckerON);
- checker.Enabled = false;
- checker.Interval = 10;
- }
- ~GameEngine() { }
- #endregion
- #region CheckerON
- private void CheckerON(object sender, EventArgs args)
- {
- }
- #endregion
- #region EngineON
- private void EngineON(object sender, EventArgs args)
- {
- EVECurrent = new EmoVeryEasy(random.Next(1, 290), player);
- bg.Controls.Add(EVECurrent);
- EVECurrent.BringToFront();
- }
- #endregion
- #region GameOver
- public void GameOver()
- {
- checker.Enabled = false;
- enginer.Enabled = false;
- MessageBox.Show("GAME IS OVER", "n00b");
- }
- #endregion
- #region StartEngine
- public bool StartEngine()
- {
- this.ShowDialog();
- return true;
- }
- #endregion
- }
- static class Program
- {
- [STAThread]
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new Form1());
- }
- }
- public class Levels
- {
- #region Variable
- #endregion
- #region Levels
- public Levels()
- {
- }
- ~Levels() { }
- #endregion
- }
- public interface IUnitInfo
- {
- #region IUnitInfo
- void Walk();
- void Die();
- void Suicide();
- int life { get; set; }
- int dmg { get; set; }
- int speed { get; set; }
- int money { get; set; }
- string name { get; set; }
- #endregion
- }
- public class GameUnits : PictureBox, IUnitInfo
- {
- #region Variable
- private int _life;
- private int _speed;
- private int _dmg;
- private int _money;
- private string _name;
- private Timer go;
- private SoundPlayer playsound;
- protected Player _player;
- private bool dead;
- #endregion
- #region GameUnits
- public GameUnits()
- {
- _life = life;
- _speed = speed;
- _name = name;
- _dmg = dmg;
- _money = money;
- dead = false;
- this.MouseClick += new MouseEventHandler(Shoot);
- RNGCryptoServiceProvider gen = new RNGCryptoServiceProvider();
- byte[] random = new byte[3];
- gen.GetBytes(random);
- int rand = Convert.ToInt32(random[0]);
- this.Location = new Point(640, rand);
- go = new Timer();
- go.Tick += new EventHandler(GoGoGo);
- go.Interval = 10;
- go.Enabled = true;
- }
- ~GameUnits() { }
- #endregion
- #region Shoot
- private void Shoot(object sender, MouseEventArgs args)
- {
- if (_player.reloaded)
- {
- if (_player.bullets == 1)
- {
- _player.reloaded = false;
- _player.Reload();
- }
- if (_player.bullets > 0)
- {
- PictureBox bullet = new PictureBox();
- Bitmap _bmp = new Bitmap(@"img/sprites/bullet.bmp");
- _bmp.MakeTransparent(Color.FromArgb(255, 0, 255));
- bullet.Image = (Image)_bmp;
- bullet.MouseClick += new MouseEventHandler(BulletClick);
- bullet.Size = bullet.Image.Size;
- bullet.Location = args.Location;
- this.Controls.Add(bullet);
- _player.bullets--;
- _player.ChangeInfo();
- LifeCheck();
- Sounds();
- }
- }
- }
- #endregion
- #region BulletClick
- private void BulletClick(object sender, MouseEventArgs args)
- {
- Sounds();
- LifeCheck();
- }
- #endregion
- #region LifeCheck
- private void LifeCheck()
- {
- life -= _player.guns.DoDamage();
- if (life <= 0)
- Die();
- }
- #endregion
- #region Sounds
- private void Sounds()
- {
- playsound = new SoundPlayer(@"sounds/" + _player.guns.gun_sound[_player.guns.choosen]);
- playsound.Play();
- }
- #endregion
- #region Property
- public int life
- {
- get
- {
- return _life;
- }
- set
- {
- _life = value;
- }
- }
- public int speed
- {
- get
- {
- return _speed;
- }
- set
- {
- _speed = value;
- }
- }
- public string name
- {
- get
- {
- return _name;
- }
- set
- {
- _name = value;
- }
- }
- public int dmg
- {
- get
- {
- return _dmg;
- }
- set
- {
- _dmg = value;
- }
- }
- public int money
- {
- get
- {
- return _money;
- }
- set
- {
- _money = value;
- }
- }
- #endregion
- #region Walk
- public void Walk()
- {
- this.Left -= _speed;
- }
- #endregion
- #region Die
- public void Die()
- {
- _player.money += money;
- _player.ChangeInfo();
- go.Enabled = false;
- this.Dispose();
- }
- #endregion
- #region Suicide
- public void Suicide()
- {
- _player.ChangeLife(this.dmg);
- this.Dispose();
- go.Enabled = false;
- }
- #endregion
- #region GoGoGo
- private void GoGoGo(object sender, EventArgs args)
- {
- if (this.Left >= 170)
- this.Walk();
- else
- if (dead != true)
- {
- dead = true;
- this.Suicide();
- }
- }
- #endregion
- }
- public class EmoVeryEasy : GameUnits
- {
- #region EmoVeryEasy
- public EmoVeryEasy(int location, Player player)
- {
- _player = player;
- Bitmap bmp = new Bitmap(@"img/emos/emoveryeasy.bmp");
- bmp.MakeTransparent(Color.FromArgb(255, 0, 255));
- this.BackColor = Color.Transparent;
- this.Image = (Image)bmp;
- this.Size = Image.Size;
- speed = 1;
- life = 50;
- money = 84;
- dmg = player.guns.gun_dmg[player.guns.choosen];
- name = "1HitKill";
- }
- #endregion
- }
- public class EmoEasy : GameUnits
- {
- #region EmoEasy
- public EmoEasy()
- {
- }
- ~EmoEasy() { }
- #endregion
- }
- public class EmoNormal : GameUnits
- {
- #region EmoNormal
- public EmoNormal()
- {
- }
- ~EmoNormal() { }
- #endregion
- }
- public class EmoHard : GameUnits
- {
- #region EmoHard
- public EmoHard()
- {
- }
- ~EmoHard() { }
- #endregion
- }
- public class EmoVeryHard : GameUnits
- {
- #region EmoVeryHard
- public EmoVeryHard()
- {
- }
- ~EmoVeryHard() { }
- #endregion
- }
- public class EmoBoss : GameUnits
- {
- #region EmoBoss
- public EmoBoss()
- {
- }
- ~EmoBoss() { }
- #endregion
- }
- public class EmoBonus : GameUnits
- {
- #region EmoBonus
- public EmoBonus()
- {
- }
- ~EmoBonus() { }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement