PASTEBIN
| #1 paste tool since 2002
create new paste
tools
api
archive
real-time
faq
PASTEBIN
create new paste
trending pastes
sign up
login
my alerts
my settings
my profile
Got an iPhone or iPad? We have a brand new Pastebin App for both devices, and it's totally free!
Click here to download the new Pastebin App for iOS
.
Public Pastes
Untitled
2 sec ago
Untitled
2 sec ago
Untitled
3 sec ago
Untitled
4 sec ago
Untitled
7 sec ago
Untitled
8 sec ago
Untitled
9 sec ago
Untitled
9 sec ago
New Paste
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Text; using System.Drawing; using System.Windows.Forms; using SdlDotNet.Input; using SdlDotNet.Core; using SdlDotNet.Graphics; using SdlDotNet.Graphics.Sprites; namespace BALOONS { public class Main { #region Fields public Collection<Rectangle> rects = new Collection<Rectangle>(); public Collection<Rectangle> bals = new Collection<Rectangle>(); public Collection<Rectangle> active_rec = new Collection<Rectangle>(); public Collection<Rectangle> bullets_rec = new Collection<Rectangle>(); public SpriteCollection main = new SpriteCollection(); public SpriteCollection bal = new SpriteCollection(); public SpriteCollection active_spr = new SpriteCollection(); public SpriteCollection bullets_spr = new SpriteCollection(); public Surface screen; public ReadStep rs; private Sprite board; public List<Baloon> baloon = new List<Baloon>(); public int baloons = 0; private int counter = 0; private Random rand = new Random(); public int killed = 0; private MapGenerator mapengine; public SdlDotNet.Graphics.Font font; public SdlDotNet.Graphics.Font cfont; public SdlDotNet.Graphics.Font ufont; public Surface[] rightText = new Surface[3]; public Surface[] leftText = new Surface[3]; public Surface[] uText = new Surface[2]; public string[] lefttxt = new string[3]; public string[] righttxt = new string[3]; public string[] utxt = new string[2]; public long money; public int life; public Surface[] centerText = new Surface[2]; public bool pause = true; private bool gameover = false; private int update_c = 0; private Levels levels; #endregion #region Main public Main(string map, int dif) { Events.Fps = 65; Events.Tick += new EventHandler<TickEventArgs>(Tick); Events.KeyboardDown += new EventHandler<KeyboardEventArgs>(KeyboardDown); Events.MouseButtonDown += new EventHandler<MouseButtonEventArgs>(MouseDown); screen = Video.SetVideoMode(700, 805, 16, false, false, true, false, true); string fontpath = "failai/other/COPRGTB.TTF"; font = new SdlDotNet.Graphics.Font(@fontpath, 17); cfont = new SdlDotNet.Graphics.Font(@fontpath, 30); ufont = new SdlDotNet.Graphics.Font(@"failai/other/AGENCYR.TTF", 18); righttxt[0] = "Choose the tower to build, "; righttxt[1] = "or click on your towers to "; righttxt[2] = "sell or upgrade them."; for (int i = 0; i < 2; i++) { utxt[i] = ""; uText[i] = ufont.Render(utxt[i], Color.Black); } switch (dif) { case 1: life = 150; money = 500; break; case 2: life = 100; money = 350; break; case 3: life = 50; money = 200; break; } lefttxt[0] = "Life: " + life.ToString() + "."; lefttxt[1] = "Round: 1."; lefttxt[2] = "$" + money.ToString() + "."; for (int i = 0; i < 3; i++) { leftText[i] = font.Render(lefttxt[i], Color.Gold); rightText[i] = font.Render(righttxt[i], Color.White); } Video.WindowCaption = "PRO-BALOONS :: By Profas"; board = new Sprite(new Surface(@"failai/buttom_board.bmp")); board.Position = new Point(0, 705); board.Z = 2; main.Add(board); rs = new ReadStep("failai/map/" + map); mapengine = new MapGenerator(rs, main); BuyEngine buyengine = new BuyEngine(this, mapengine.buildBlocks); centerText[0] = cfont.Render(":: ROUND 1 ::", Color.White); centerText[1] = cfont.Render(":: CLICK TO START ::", Color.White); levels = new Levels(this); screen.Blit(main); screen.Update(); } ~Main() { } #endregion #region Tick private void Tick(object sender, TickEventArgs args) { if (!gameover) { rects = screen.Blit(main); bals = screen.Blit(bal); active_rec = screen.Blit(active_spr); bullets_rec = screen.Blit(bullets_spr); for (int i = 0; i < 3; i++) screen.Blit(rightText[i], new Point(418, 715 + (i * 25))); for (int i = 0; i < 3; i++) screen.Blit(leftText[i], new Point(10, 715 + (i * 25))); for (int i = 0; i < 2; i++) screen.Blit(uText[i], new Point(413, 745 + (i * 25))); if (!pause) walk(); else { screen.Blit(centerText[0], new Point(255, 250)); screen.Blit(centerText[1], new Point(208, 300)); screen.Update(new Rectangle(new Point(208, 250), new Size(400, 500))); } screen.Update(bals); screen.Update(active_rec); screen.Update(bullets_rec); screen.Update(new Rectangle(new Point(0, 700), new Size(700, 105))); if (update_c++ == 500) { update_c = 0; screen.Update(new Rectangle(new Point(0, 0), new Size(700, 700))); } if (!screen.FullScreen) Video.WindowCaption = ( " :: PRO-BALOONS :: By Profas" + " :: FPS: " + Events.Fps.ToString() + " :: Baloons IN: " + (baloons - killed).ToString() + " :: Baloons: " + baloons.ToString() + " :: Killed: " + killed.ToString() + " ::"); } else { screen.Blit(centerText[0], new Point(255, 250)); screen.Blit(centerText[1], new Point(208, 300)); screen.Update(new Rectangle(new Point(0, 0), new Size(700, 805))); } } #endregion #region walk private void walk() { if (counter++ == 40 - levels.speed) { counter = 0; if (!levels.wait) { int getbaloon; if ((getbaloon = levels.GetBaloon()) != 0) { baloon.Add(new Baloon(rand.Next(levels.baloon_speed_min, levels.baloon_speed), this, getbaloon)); bal.Add(baloon[baloon.Count - 1]); baloons++; } } else if (baloons - killed == 0) { pause = true; levels.NewLevel(); } } } #endregion #region MouseDown private void MouseDown(object sender, MouseButtonEventArgs args) { if (pause) pause = false; } #endregion #region KeyboardDown private void KeyboardDown(object sender, KeyboardEventArgs args) { if (args.Key == Key.Escape) Events.QuitApplication(); } #endregion #region CheckMapGeneratorBuildBlock public int CheckMapGeneratorBuildBlock(int X, int Y, bool id) { if (id) return mapengine.CheckBuildBlock(X, Y, id); if (mapengine.CheckBuildBlock(X, Y, id) == 1) return 1; return 2; } #endregion #region GameOver public void GameOver(int nr) { if (!gameover) { bals.Clear(); main.Clear(); screen.Fill(Color.Black); if (nr == 0) centerText[0] = cfont.Render(" :: GAME OVER ::", Color.White); else centerText[0] = cfont.Render(" :: YOU WIN! ::", Color.White); centerText[1] = cfont.Render(":: PRESS ESC TO QUIT ::", Color.White); screen.Update(); gameover = true; } } #endregion } public class BuyEngine { #region Fields private Tower[] tower = new Tower[12]; private Functions fc = new Functions(); private Sprite[] red_blue = new Sprite[2]; private Sprite selectItem; private Main main; private List<ShootingTower> sTower = new List<ShootingTower>(); private int sTowersCount = 0; private int cur_buy_tower; private bool selected_buy = false; private bool buy = false; private int buildBlocks; private int[] blocksPer; private bool builded; private bool upgrade = false; private int currentUpgrade = -1; #endregion #region BuyEngine public BuyEngine(Main main, int buildBlocks) { this.main = main; this.buildBlocks = buildBlocks; string _path = "failai/other/"; blocksPer = new int[196]; red_blue[0] = new Sprite(new Surface(@_path + "red.bmp")); red_blue[1] = new Sprite(new Surface(@_path + "blue.bmp")); selectItem = new Sprite(new Surface(@_path + "itemselect.bmp")); selectItem.Z = 3; selectItem.Visible = false; selectItem.Transparent = true; selectItem.TransparentColor = Color.Black; main.active_spr.Add(selectItem); for (int i = 0; i < 2; i++) { red_blue[i].Visible = false; red_blue[i].Position = new Point(600, 710); red_blue[i].Z = 3; red_blue[i].Transparent = true; red_blue[i].TransparentColor = Color.Black; main.active_spr.Add(red_blue[i]); } SuperRw rw = new SuperRw(); Coder coder = new Coder(); string towers_info = coder.UnCode(rw.Read(@"failai/tower_info.txt")); string[,] buy_info = new string[12, 3]; for (int i = 0; i < 12; i++) { buy_info[i, 0] = "- [ BUY ] :: [ " + fc.ReadWord(i + 1, 1, towers_info, ':', false) + " ] -"; buy_info[i, 1] = "- Cost: " + fc.ReadWord(i + 1, 2, towers_info, ':', false) + "$. Damage: " + fc.ReadWord(i + 1, 3, towers_info, ':', false) + ". -"; buy_info[i, 2] = "- Speed: " + fc.ReadWord(i + 1, 4, towers_info, ':', false) + ". Region: " + fc.ReadWord(i + 1, 5, towers_info, ':', false) + ". -"; } int a = 0; int b = 0; for (int i = 0; i < 12; i++) { a++; tower[i] = new Tower(i); tower[i].Z = 5; tower[i].Position = new Point((46 * a) + 85, (46 * b) + 712); tower[i].name = fc.ReadWord(i + 1, 1, towers_info, ':', false); tower[i].cost = Convert.ToInt32(fc.ReadWord(i + 1, 2, towers_info, ':', false)); tower[i].damage = Convert.ToInt32(fc.ReadWord(i + 1, 3, towers_info, ':', false)); tower[i].speed = Convert.ToInt32(fc.ReadWord(i + 1, 4, towers_info, ':', false)); tower[i].region = Convert.ToInt32(fc.ReadWord(i + 1, 5, towers_info, ':', false)); for (int j = 0; j < 3; j++) tower[i].info[j] = buy_info[i, j]; if (i == 5) { a = 0; b++; } main.main.Add(tower[i]); } Events.MouseButtonDown += new EventHandler<MouseButtonEventArgs>(MouseDown); Events.MouseMotion += new EventHandler<MouseMotionEventArgs>(MouseMove); } ~BuyEngine() { } #endregion #region MouseDown private void MouseDown(object sender, MouseButtonEventArgs args) { if (args.Button == MouseButton.PrimaryButton) { if (UpgradeClick(args)) { if (!buy) { for (int i = 0; i < 12; i++) if ((args.Position.X > tower[i].X) && (args.Position.X < tower[i].X + tower[i].Width)) if ((args.Position.Y > tower[i].Y) && (args.Position.Y < tower[i].Y + tower[i].Height)) { cur_buy_tower = i; selected_buy = true; selectItem.Visible = true; selectItem.Position = new Point(tower[cur_buy_tower].X - 2, tower[cur_buy_tower].Y - 2); for (int j = 0; j < 3; j++) if (j != 0) main.rightText[j] = main.font.Render(tower[i].info[j], Color.Gold); else main.rightText[j] = main.font.Render(tower[i].info[j], Color.LightBlue); break; } for (int i = 0; i < sTowersCount; i++) sTower[i].imgRegion.Visible = false; if (upgrade) { upgrade = false; InfoRefresh(); } for (int i = 0; i < sTowersCount; i++) { int selected = -1; if ((args.X > sTower[i].Position.X) && (args.X < sTower[i].Position.X + sTower[i].Width)) if ((args.Y > sTower[i].Position.Y) && (args.Y < sTower[i].Position.Y + sTower[i].Height)) { selected = i; sTower[i].imgRegion.Visible = true; SelectTowerUpgrade(i); selected_buy = false; upgrade = true; break; } if (selected != -1) { } else sTower[i].imgRegion.Visible = false; } } if (buy) if ((args.Position.X > 0) && (args.Position.X < 700)) if ((args.Position.Y > 0) && (args.Position.Y < 700)) { if (main.CheckMapGeneratorBuildBlock(args.Position.X, args.Position.Y, false) == 1) { int gID = main.CheckMapGeneratorBuildBlock(args.Position.X, args.Position.Y, true); builded = false; for (int i = 0; i < 196; i++) if (gID == blocksPer[i]) builded = true; if (!builded) { blocksPer[gID] = gID; red_blue[0].Visible = false; red_blue[1].Visible = false; buy = false; main.leftText[2] = main.font.Render("$" + (main.money -= tower[cur_buy_tower].cost).ToString() + ".", Color.Gold); Point posXY = args.Position; while (posXY.X-- % 50 != 0) ; while (posXY.Y-- % 50 != 0) ; sTower.Add(new ShootingTower(main, new Point(posXY.X + 6, posXY.Y + 6), tower[cur_buy_tower].damage, tower[cur_buy_tower].speed, tower[cur_buy_tower].region, tower[cur_buy_tower].name, tower[cur_buy_tower].cost, tower[cur_buy_tower].Surface, cur_buy_tower)); sTower[sTowersCount].id = gID; main.main.Add(sTower[sTowersCount++]); main.screen.Blit(main.main); main.screen.Update(new Rectangle(new Point(sTower[sTowersCount - 1].Center.X - 50, sTower[sTowersCount - 1].Center.Y - 50), new Size(100, 100))); SelectTowerUpgrade((currentUpgrade = sTowersCount - 1)); selected_buy = false; main.screen.Fill(Color.Black); } else main.rightText[2] = main.font.Render("You Cant Build There.", Color.Red); } } if (selected_buy) if ((args.Position.X > 440) && (args.Position.X < 680)) if ((args.Position.Y > 710) && (args.Position.Y < 745)) { if (main.money >= tower[cur_buy_tower].cost) { buy = true; selected_buy = false; main.rightText[0] = main.font.Render(" :: [ " + tower[cur_buy_tower].name + " ] ::", Color.LightBlue); main.rightText[1] = main.font.Render("Choose place to build.", Color.Gold); main.rightText[2] = main.font.Render("(Right Click to Cancel.)", Color.Gold); } else main.rightText[2] = main.font.Render("Dont have money enought.", Color.Red); } } } else if (args.Button == MouseButton.SecondaryButton) { for (int i = 0; i < sTowersCount; i++) sTower[i].imgRegion.Visible = false; if (buy) { buy = false; selected_buy = true; red_blue[0].Visible = false; red_blue[1].Visible = false; } upgrade = false; InfoRefresh(); } main.screen.Blit(main.main); main.screen.Update(new Rectangle(new Point(0,0),new Size(700,700))); } #endregion #region InfoRefresh private void InfoRefresh() { selected_buy = true; for (int j = 0; j < 3; j++) if (j != 0) main.rightText[j] = main.font.Render(tower[cur_buy_tower].info[j], Color.Gold); else main.rightText[j] = main.font.Render(tower[cur_buy_tower].info[j], Color.LightBlue); for (int j = 0; j < 2; j++) main.uText[j] = main.ufont.Render("", Color.Black); } #endregion #region SelectTowerUpgrade private void SelectTowerUpgrade(int nr) { currentUpgrade = nr; upgrade = true; for (int i = 1; i < 3; i++) main.rightText[i] = main.font.Render("", Color.Black); TowerInfoRefresh(nr); } #endregion #region TowerInfoRefresh public void TowerInfoRefresh(int nr) { main.rightText[0] = main.font.Render(":: [ " + sTower[nr].name + " Upgrade ] ::", Color.LightBlue); main.uText[0] = main.ufont.Render(":: [ Speed " + sTower[nr].speed.ToString() + "+" + sTower[nr].uspeed.ToString() + " $80 ] : " + "[ Region " + sTower[nr].region.ToString() + "+" + sTower[nr].uregion.ToString() + " $90 (2x) ] ::", Color.Gold); main.uText[1] = main.ufont.Render(":: [ Damage " + sTower[nr].dmg.ToString() + "+" + sTower[nr].udmg.ToString() + " $110 ] : " + "[ SELL " + (sTower[nr].cost / 2).ToString() + " (50%) ] ::", Color.Gold); } #endregion #region UpgradeClick private bool UpgradeClick(MouseButtonEventArgs args) { if (upgrade) if (fc.PositionCheck(args.Position, new Point(425, 670), new Point(700, 820))) { if (fc.PositionCheck(args.Position, new Point(412, 543), new Point(744, 766))) sTower[currentUpgrade].Upgrade(1); else if (fc.PositionCheck(args.Position, new Point(557, 690), new Point(744, 766))) sTower[currentUpgrade].Upgrade(2); else if (fc.PositionCheck(args.Position, new Point(412, 550), new Point(775, 798))) sTower[currentUpgrade].Upgrade(3); TowerInfoRefresh(currentUpgrade); if (fc.PositionCheck(args.Position, new Point(565, 690), new Point(775, 798))) { SellTower(currentUpgrade); InfoRefresh(); } return false; } return true; } #endregion #region MouseMove private void MouseMove(object sender, MouseMotionEventArgs args) { if (upgrade) { if (fc.PositionCheck(args.Position, new Point(412, 527), new Point(744, 766))) Cursor.Current = Cursors.Hand; else if (fc.PositionCheck(args.Position, new Point(547, 690), new Point(744, 766))) Cursor.Current = Cursors.Hand; else if (fc.PositionCheck(args.Position, new Point(412, 540), new Point(775, 798))) Cursor.Current = Cursors.Hand; else if (fc.PositionCheck(args.Position, new Point(560, 690), new Point(775, 798))) Cursor.Current = Cursors.Hand; } else if (selected_buy) if (fc.PositionCheck(args.Position, new Point(440, 680), new Point(710, 745))) Cursor.Current = Cursors.Hand; if (buy) { for (int i = 0; i < 2; i++) main.screen.Update(new Rectangle(new Point(red_blue[i].Position.X - 50, red_blue[i].Position.Y - 50), new Size(red_blue[i].Size.Width + 100, red_blue[i].Size.Height + 100))); if (fc.PositionCheck(args.Position, new Point(0, 700), new Point(0, 700))) { if (main.CheckMapGeneratorBuildBlock(args.Position.X, args.Position.Y, false) == 1) { red_blue[1].Position = new Point(args.Position.X - (red_blue[1].Width / 2), args.Position.Y - (red_blue[1].Height / 2)); red_blue[1].Visible = true; red_blue[0].Visible = false; } else { red_blue[0].Position = new Point(args.Position.X - (red_blue[0].Width / 2), args.Position.Y - (red_blue[0].Height / 2)); red_blue[0].Visible = true; red_blue[1].Visible = false; } } } } #endregion #region SellTower private void SellTower(int nr) { blocksPer[sTower[nr].id] = -1; Rectangle last_pos = sTower[nr]._region; sTower[nr].Sell(); main.screen.Update(last_pos); main.leftText[2] = main.font.Render("$" + (main.money += (sTower[nr].cost/2)).ToString() + ".", Color.Gold); InfoRefresh(); upgrade = false; } #endregion } public class Start : Sprite { #region Fields private Sprite start_spr = new Sprite(); private Surface screen; private bool run = true; private bool meniu = true; private string map; private Sprite checker; #endregion #region Start public Start() { map = "map3.txt"; Events.MouseButtonDown += new EventHandler<MouseButtonEventArgs>(MouseDown); screen = Video.SetVideoMode(700, 805, 16, false, false, true, false, true); start_spr = new Sprite(new Surface(@"failai/start/start_1.bmp")); checker = new Sprite(new Surface(@"failai/other/checker.bmp")); checker.Transparent = true; checker.Visible = false; checker.TransparentColor = Color.Green; checker.Z = 5; checker.Position = new Point(97, 122); screen.Blit(start_spr); screen.Update(); Events.Run(); } ~Start() { } #endregion #region MouseDown private void MouseDown(object sender, MouseButtonEventArgs args) { if (run) { if (meniu) { if ((args.X > 260) && (args.X < 410)) if ((args.Y > 285) && (args.Y < 320)) { checker.Visible = true; start_spr.Surface = new Surface(@"failai/start/start_2.bmp"); screen.Blit(start_spr); screen.Blit(checker); screen.Update(); meniu = false; } if ((args.X > 275) && (args.X < 385)) if ((args.Y > 350) && (args.Y < 390)) Events.QuitApplication(); } if (!meniu) { if ((args.X > 95) && (args.X < 300)) if ((args.Y > 120) && (args.Y < 325)) { checker.Position = new Point(97, 122); screen.Blit(start_spr); screen.Blit(checker); screen.Update(); map = "map3.txt"; } if ((args.X > 387) && (args.X < 590)) if ((args.Y > 120) && (args.Y < 325)) { checker.Position = new Point(386, 122); screen.Blit(start_spr); screen.Blit(checker); screen.Update(); map = "map1.txt"; } if ((args.X > 95) && (args.X < 300)) if ((args.Y > 360) && (args.Y < 560)) { checker.Position = new Point(97, 364); screen.Blit(start_spr); screen.Blit(checker); screen.Update(); map = "map2.txt"; } if ((args.X > 387) && (args.X < 590)) if ((args.Y > 360) && (args.Y < 560)) { checker.Position = new Point(386, 364); screen.Blit(start_spr); screen.Blit(checker); screen.Update(); map = "map4.txt"; } if ((args.X > 25) && (args.X < 180)) if ((args.Y > 700) && (args.Y < 745)) Go(1); if ((args.X > 210) && (args.X < 455)) if ((args.Y > 700) && (args.Y < 745)) Go(2); if ((args.X > 475) && (args.X < 675)) if ((args.Y > 700) && (args.Y < 745)) Go(3); } } } #endregion #region Go private void Go(int dif) { run = false; start_spr.Dispose(); start_spr.Close(); start_spr.Kill(); start_spr.Visible = false; Main main = new Main(map, dif); screen.Dispose(); this.Dispose(); this.Kill(); this.Close(); } #endregion } public class Shoot { #region Fields private Main main; private Sprite bullet; private Point location; private Point destination; private Rectangle region; private int counterX=0; private int counterY=0; private int x; private int y; private int division = 2; private int speed = 5; private int dmg; private bool dead = false; private Baloon baloon; private Rectangle dest_new; private int generate; #endregion #region Shoot public Shoot(Main main, Point location, Rectangle region, Baloon baloon, int dmg) { this.main = main; this.dmg = dmg; this.baloon = baloon; this.location = location; this.destination = baloon.Center; this.region = region; x = destination.X - location.X; y = destination.Y - location.Y; if (x <= 0) x *= -1; if (y <= 0) y *= -1; generate = ((y + x) / 2) + (region.Width / 10); if (generate < 35) generate += 10; dest_new = new Rectangle(new Point(baloon.Center.X - 15, baloon.Center.Y - 15), new Size(30, 30)); bullet = new Sprite(new Surface(@"failai/bullets/bullet.bmp")); bullet.Z = 5; bullet.Transparent = true; bullet.TransparentColor = Color.White; bullet.Position = new Point(location.X - (bullet.Width / 2), location.Y - (bullet.Height / 2)); main.bullets_spr.Add(bullet); Events.Tick += new EventHandler<TickEventArgs>(MoveTick); } ~Shoot() { } #endregion #region GoBullet private void GoBullet() { if (dead == false) { if ((bullet.Center.X > region.X) && (bullet.Center.X < region.X + region.Width)) if ((bullet.Center.Y > region.Y) && (bullet.Center.Y < region.Y + region.Height)) { for (int i = 0; i < generate; i++) { if ((bullet.Center.X > dest_new.X) && (bullet.Center.X < dest_new.X + dest_new.Width)) if ((bullet.Center.Y > dest_new.Y) && (bullet.Center.Y < dest_new.Y + dest_new.Height)) { dead = true; break; } if (location.Y > destination.Y) if (counterY++ == y / division - 5) { counterY = 0; bullet.Y -= speed; } else { } else if (location.Y < destination.Y) if (counterY++ == y / division - 5) { counterY = 0; bullet.Y += speed; } if (location.X > destination.X) if (counterX++ == x / division - 5) { counterX = 0; bullet.X -= speed; } else { } else if (location.X < destination.X) if (counterX++ == x / division - 5) { counterX = 0; bullet.X += speed; } } } else dead = true; else dead = true; if ((bullet.Center.X > dest_new.X) && (bullet.Center.X < dest_new.X + dest_new.Width)) if ((bullet.Center.Y > dest_new.Y) && (bullet.Center.Y < dest_new.Y + dest_new.Height)) dead = true; if (dead == true) KillBullet(); } } #endregion #region KillBullet private void KillBullet() { baloon.ShootAtIt(dmg); dead = true; bullet.Visible = false; Rectangle last_pos = new Rectangle(new Point(bullet.X - 25, bullet.Y - 25), new Size(bullet.Width + 50, bullet.Height + 50)); bullet.Kill(); bullet.Close(); bullet.Dispose(); Events.CloseTimer(); main.screen.Blit(main.main); main.screen.Update(last_pos); } #endregion #region MoveTick private void MoveTick(object sender, TickEventArgs args) { GoBullet(); } #endregion } public class Baloon : Sprite { #region Fields private int count = 0; private ReadStep rs; private int speed = 5; private int direction = 1; private int cur_step = 28; public bool enabled = true; private int life; private SpriteCollection bals; private Main main; private int number; private int takedmg; private int morelife; #endregion #region Baloon public Baloon(int speed, Main main, int number) { this.number = number; this.main = main; this.rs = main.rs; this.bals = main.bal; this.life = number; if (number > 9) this.morelife = number; if (speed == 3) speed += 2; if (speed == 4) speed += 6; this.speed = speed; Surface _all = new Surface(@"failai/baloons/b" + number.ToString() + ".bmp"); this.Surface = _all; this.Position = new Point(0, 100); this.Z = 3; this.Transparent = true; this.TransparentColor = Color.Green; Events.Tick += new EventHandler<TickEventArgs>(MoveTick); } ~Baloon() { } #endregion #region Move public void Move() { if (enabled) { Point center = new Point(this.X + (this.Width / 2), this.Y + (this.Height / 2)); if (center.Y > 660) { main.leftText[0] = main.font.Render("Life: " + (--main.life).ToString() + ".", Color.Gold); if (main.life <= 0) main.GameOver(0); KillIt(); } switch (direction) { case 0: if (rs.GetStep(cur_step - 14) != "0") { count += speed; this.Y -= speed; if (count == 50) { count = 0; cur_step -= 14; } } else direction = FindDirection(direction); break; case 1: if (rs.GetStep(cur_step + 1) != "0") { count += speed; this.X += speed; if (count == 50) { count = 0; cur_step++; } } else direction = FindDirection(direction); break; case 2: if (rs.GetStep(cur_step + 14) != "0") { count += speed; this.Y += speed; if (count == 50) { count = 0; cur_step += 14; } } else direction = FindDirection(direction); break; case 3: if (rs.GetStep(cur_step - 1) != "0") { count += speed; this.X -= speed; if (count == 50) { count = 0; cur_step -= 1; } } else direction = FindDirection(direction); break; } } } #endregion #region FindDirection private int FindDirection(int current) { if ((rs.GetStep(cur_step + 1) != "0") && (current != 3)) return 1; else if ((rs.GetStep(cur_step + 14) != "0") && (current != 0)) return 2; else if ((rs.GetStep(cur_step - 1) != "0") && (current != 1)) return 3; else if ((rs.GetStep(cur_step - 14) != "0") && (current != 2)) return 0; return 0; } #endregion #region MoveTick private void MoveTick(object sender, TickEventArgs args) { Move(); } #endregion #region ShootAtIt public void ShootAtIt(int dmg) { if (this.Visible == true) { if (dmg >= life) takedmg = life; else takedmg = dmg; if (takedmg > 0) if (number > 9) morelife -= takedmg; if (morelife <= 0) { if (takedmg > 0) { main.leftText[2] = main.font.Render("$" + (main.money += takedmg).ToString() + ".", Color.Gold); life -= dmg; } if (life > 0) { this.Surface = new Surface(@"failai/baloons/b" + life.ToString() + ".bmp"); this.Z = 3; this.Transparent = true; this.TransparentColor = Color.Green; } else { life--; KillIt(); } } } } #endregion #region KillIt public void KillIt() { Rectangle last_pos = new Rectangle(new Point(this.Position.X - 25, this.Position.Y - 25), new Size(this.Size.Width + 50, this.Size.Height + 50)); this.Visible = false; main.killed++; Events.CloseTimer(); bals.Remove(this); this.Kill(); this.Dispose(); this.enabled = false; main.rects = main.screen.Blit(main.main); main.screen.Update(last_pos); } #endregion } public class ShootingTower : Sprite { #region Fields public int id; public Sprite imgRegion; public int dmg; public int speed; public int region; public Rectangle _region; public int cost; public string name; private Main main; private int counter = 0; private Shoot shoot; private bool enabled = true; public int udmg; public int uregion; public int uspeed; private int totalspeed; #endregion #region ShootingTower public ShootingTower(Main main, Point position, int dmg, int speed, int region, string name, int cost, Surface surf, int id) { this.main = main; this.dmg = dmg; this.speed = speed; this.region = region; this.cost = cost; this.name = name; this.Surface = surf; this.Position = position; DrawRegion(_region = ChangeRegion(region+uregion)); Events.Tick += new EventHandler<TickEventArgs>(ShootCheck); } #endregion #region ChangeRegion public Rectangle ChangeRegion(int region) { Point center = this.Center; Size _size = new Size((10 + region) * 10, (10 + region) * 10); Point _point = new Point(center.X - (_size.Width / 2), center.Y - (_size.Height / 2)); return new Rectangle(_point, _size); } #endregion #region DrawRegion private void DrawRegion(Rectangle rec) { Surface surRegion = new Surface(@"failai/other/region.bmp"); surRegion.Transparent = true; surRegion.TransparentColor = Color.Black; surRegion = surRegion.CreateScaledSurface(region+uregion + 10, false); surRegion.Alpha = 80; surRegion.AlphaBlending = true; imgRegion = new Sprite(surRegion); imgRegion.Z = 5; imgRegion.Position = new Point(rec.Location.X, rec.Location.Y); main.screen.Blit(imgRegion); main.active_spr.Add(imgRegion); main.screen.Update(new Rectangle(new Point(0, 0), new Size(700, 700))); } #endregion #region ShootCheck private void ShootCheck(object sender, TickEventArgs args) { if (enabled) { int baloons_count = main.baloon.Count; totalspeed = 49 - (speed + uspeed); if (counter++ == totalspeed - 3) { counter = 0; for (int i = 0; i < baloons_count; i++) if (main.baloon[i].enabled) if ((main.baloon[i].Center.X > _region.X) && (main.baloon[i].Center.X < _region.X + _region.Width)) if ((main.baloon[i].Center.Y > _region.Y) && (main.baloon[i].Center.Y < _region.Y + _region.Height)) { shoot = new Shoot(main, this.Center, this._region, main.baloon[i], dmg + udmg); break; } else { } else { } else { baloons_count--; main.baloon.RemoveAt(i); continue; } } if (counter > 46) counter = 0; } } #endregion #region Sell public void Sell() { imgRegion.Visible = false; imgRegion.Kill(); imgRegion.Dispose(); enabled = false; this.Position = new Point(-50, -50); this.Visible = false; } #endregion #region Upgrade public void Upgrade(int upgr) { switch (upgr) { case 1: if(main.money>=80) if (totalspeed > 20) { uspeed++; cost += 80; main.money -= 80; } break; case 2: if(main.money>=90) if ((region + uregion) < 34) { uregion += 2; cost += 90; main.money -= 90; imgRegion.Visible = false; imgRegion.Dispose(); imgRegion.Kill(); DrawRegion(_region = ChangeRegion(region + uregion)); } break; case 3: if(main.money>=110) if (dmg + udmg < 16) { udmg++; cost += 100; main.money -= 100; } break; } main.leftText[2] = main.font.Render("$" + (main.money).ToString() + ".", Color.Gold); } #endregion } public class Coder { #region Coder public Coder() { } ~Coder() { } #endregion #region ToCode public string ToCode(string SourceData) { int charASCII; int Step; string Data; string CodedData = ""; Data = SourceData; for (int i = 0; i < Data.Length;i++) { if ((Data[i] == '\n') || (Data[i] == '\r')) { CodedData = CodedData + Data[i]; continue; } charASCII = (int)Data[i]; Step = ((((Data.Length + i) % 7) * 52) % 92) + 33; if (charASCII + Step > 126) { Step = Step - (126 - charASCII); charASCII = Step + 33; } else charASCII = charASCII + Step; CodedData = CodedData + Convert.ToChar(charASCII); } return CodedData; } #endregion #region UnCode public string UnCode(string SourceData) { int charASCII; int Step; string Data; string UnCodedData = ""; Data = SourceData; for (int i = 0; i < Data.Length; i++) { if ((Data[i] == '\n') || (Data[i] == '\r')) { UnCodedData = UnCodedData + Data[i]; continue; } charASCII = (int)Data[i]; Step = ((((Data.Length + i) % 7) * 52) % 92) + 33; if (charASCII - Step < 33) { Step = Step - charASCII; charASCII = 126 - Step - 33; } else charASCII = charASCII - Step; UnCodedData = UnCodedData + Convert.ToChar(charASCII); } return UnCodedData; } #endregion } class Functions { #region Functions public Functions() { } ~Functions() { } #endregion #region ReadWord public string ReadWord(int line, int word, string text, char sign, bool only_line) { string buf = ""; string text_line = ""; int line_nr = 0; int sign_nr = 1; bool end = false; --line; if (word > 0) { for (int i = 0; i < text.Length; i++) { if (line != 0) { if (text[i] == '\n') line_nr++; else continue; if (line_nr == line) { ++i; while ((i != text.Length) && (text[i] != '\n') && (text[i] != '\r')) text_line += text[i++]; if (only_line != false) return text_line; break; } } else { while ((i != text.Length) && (text[i] != '\n') && (text[i] != '\r')) text_line += text[i++]; if (only_line != false) return text_line; break; } } for (int i = 0; i < text_line.Length; i++) { if (word == 1) { while ((i != text_line.Length) && (text_line[i] != sign) && (text[i] != '\n') && (text[i] != '\r')) buf += text_line[i++]; return buf; } else { for (int j = 0; j < text_line.Length; j++) { while (sign_nr != word) if (text_line[j++] == sign) sign_nr++; while ((j != text_line.Length) && (text_line[j] != '\n') && (text_line[j] != sign)) buf += text_line[j++]; end = true; if (end == true) break; } } if (end == true) break; } } else return null; if (buf != "") return buf; else return null; } #endregion #region ChangeWord public string ChangeWord(int line, int word, string text, string newWord, char sign) { string buf = ""; string text_line = ""; int line_nr = 0; int sign_nr = 1; bool end = false; --line; if (word > 0) { for (int i = 0; i < text.Length; i++) { if (line != 0) { if (text[i] == '\n') line_nr++; else continue; if (line_nr == line) { ++i; while ((i != text.Length) && (text[i] != '\n') && (text[i] != '\r')) text_line += text[i++]; break; } } else { while ((i != text.Length) && (text[i] != '\n') && (text[i] != '\r')) text_line += text[i++]; break; } } for (int i = 0; i < text_line.Length; i++) { if (word == 1) { while (text_line[i] != sign) i++; while ((i != text_line.Length) && (text_line[i] != '\n')) buf += text_line[i++]; buf = newWord + buf; } else { for (int j = 0; j < text_line.Length; j++) { while (sign_nr != word) { buf += text_line[j]; if (text_line[j++] == sign) sign_nr++; } buf += newWord; while ((j != text_line.Length) && (text_line[j] != '\n') && (text_line[j] != sign)) j++; while (j != text_line.Length) buf += text_line[j++]; end = true; if (end != false) break; } } if (end != false) break; } } else return null; int curline = 0; string all = ""; for (int i = 0; i < text.Length; i++) { if (text[i] == '\n') curline++; if (curline == line_nr) { all += buf; while ((++i != text.Length) && (text[i] != '\n')) continue; while (i != text.Length) all += text[i++]; break; } all += text[i]; } if (all != "") return all; else return null; } #endregion #region LineCount public int LineCount(string text) { int line = 0; for (int i = 0; i < text.Length; i++) if (text[i] == '\n') ++line; return line; } #endregion #region LineDelete public string LineDelete(int nr, string text) { int current = 0; string buf = ""; if (nr != 0) { for (int i = 0; i < text.Length; i++) { if (text[i] == '\n') current++; if (current == nr) { while (text[++i] != '\n') current++; } if (i <= text.Length) buf += text[i]; } } else { int line = 0; while (text[line++] != '\n') continue; for (int i = line; i < text.Length; i++) buf += text[i]; } return buf; } #endregion #region PositionCheck public bool PositionCheck(Point args, Point X, Point Y) { if ((args.X > X.X) && (args.X < X.Y)) if ((args.Y > Y.X) && (args.Y < Y.Y)) return true; else return false; else return false; } #endregion } public class Levels { #region Fields public int round; public int[] count = new int[21]; public int speed; public int baloon_nr; private int dif_baloons; private Main main; private int current; public bool wait = false; public int baloon_speed; public int baloon_speed_min; private int max; #endregion #region Levels public Levels(Main main) { baloon_speed_min = 1; baloon_speed = 2; speed = 0; this.main = main; dif_baloons = 1; round = 1; count[0] = 6; current = 0; max = 10; } #endregion #region GetBaloon public int GetBaloon() { int all = 0; for (int i = 0; i < dif_baloons; i++) all += count[i]; //System.Diagnostics.Debug.WriteLine("ALL: "+all.ToString()); if (all != 0) { if (--count[current] > 0) return current + 1; else { current++; return current; } } else { wait = true; return 0; } } #endregion #region NewLevel public void NewLevel() { if (++round < 71) { wait = false; current = 0; main.money += 100; if (dif_baloons < 20) if (round % 4 == 0) dif_baloons++; if (round == 15) dif_baloons++; if (round == 30) dif_baloons++; if (round == 50) dif_baloons++; if (round == 65) dif_baloons++; if (round == 70) speed = 40; for (int i = 0; i < dif_baloons; i++) count[i] = max; if (round % 25 == 0) max += 20; if (round == 5) max += 2; if (speed < 38) if (round % 1 == 0) speed++; if (baloon_speed < 5) if (round % 7 == 0) baloon_speed++; if (round == 42) baloon_speed++; if (dif_baloons > 2) for (int i = 0; i < dif_baloons - 2; i++) count[i] -= 5; if (round == 45) baloon_speed_min++; if (round == 50) { baloon_speed_min++; speed++; } if (round == 55) baloon_speed_min++; if (round == 25) speed -= 3; if (dif_baloons > 5) for (int i = 0; i < 3; i++) count[i] -= 3; if (dif_baloons > 10) for (int i = 0; i < 6; i++) count[i] -= 4; if (dif_baloons > 16) for (int i = 0; i < 12; i++) count[i] -= 5; if (dif_baloons > 18) for (int i = 0; i < 15; i++) count[i] -= 15; if (round > 50) { for (int i = 0; i < 7; i++) count[i] -= 10; for (int i = 5; i < 9; i++) count[i] = i; } main.centerText[0] = main.cfont.Render(":: ROUND " + round.ToString() + " ::", System.Drawing.Color.White); main.leftText[1] = main.font.Render("Round: " + round.ToString() + ".", System.Drawing.Color.Gold); main.leftText[2] = main.font.Render("$" + (main.money).ToString(), System.Drawing.Color.Gold); } else main.GameOver(1); } #endregion } static class Program { [STAThread] static void Main() { Start start = new Start(); } } public class ReadStep { #region Fields private string file; private int step; private string info = ""; #endregion #region ReadStep public ReadStep(string file) { this.file = file; info = ReadFile(); } ~ReadStep() { } #endregion #region ReadFile private string ReadFile() { try { Coder coder = new Coder(); SuperRw rw = new SuperRw(); return coder.UnCode(rw.Read(@file)); } catch { return null; } } #endregion #region GetStep public string GetStep(int step) { this.step = step; string buf = ""; if ((step > -1) && (step < info.Length + 1)) for (int i = 0; i < info.Length; i++) { if ((info[i] == '\r') || (info[i] == '\n')) step++; buf = info[i].ToString(); if (i == step) break; } return buf; } #endregion } public class SuperRw { #region SuperRw public SuperRw() { } ~SuperRw() { } #endregion #region Read public string Read(string file) { FileStream rfile = new FileStream(file, FileMode.OpenOrCreate, FileAccess.Read); StreamReader read = new StreamReader(rfile); string info = read.ReadToEnd(); read.Close(); rfile.Close(); return info; } #endregion #region Write public void Write(string info, string file) { FileStream wfile = new FileStream(@file, FileMode.Create, FileAccess.Write); StreamWriter write = new StreamWriter(wfile); write.Write(info); write.Close(); wfile.Close(); } #endregion #region FLineRead public string FLineRead(string file, int line) { string info = Read(file); string buf = ""; int ln = 0; for (int i = 0; i < info.Length; i++) { if (info[i] == '\n') ln++; if (line == ln) { if (line != 0) ++i; while ((i != info.Length) && (info[i] != '\n')) if (info[i++] != '\r') buf += info[i - 1]; break; } } return buf; } #endregion } public class Tower : Sprite { #region Fields public string[] info = new string[3]; public string name; public int number; public int cost; public int damage; public int region; public int speed; #endregion #region Tower public Tower(int number) { this.number = number; Surface img = new Surface(@"failai/towers/" + number.ToString() + ".bmp"); this.Surface = img; this.Transparent = true; this.TransparentColor = Color.Magenta; } ~Tower() { } #endregion } public class MapGenerator { #region Fields private Sprite[] blocks = new Sprite[196]; private ReadStep rs; private int map_size; public int buildBlocks = 0; #endregion #region MapGenerator public MapGenerator(ReadStep rs, SpriteCollection main) { this.rs = rs; map_size = 196; int a = 0; int b = 0; string g; for (int i = 0; i < map_size; i++) { g = rs.GetStep(i).ToString(); if (g == "0") buildBlocks++; Surface _map = new Surface(@"failai/map/" + g + ".bmp"); blocks[i] = new Sprite(_map); blocks[i].Position = new Point(a * 50, b * 50); blocks[i].Z = 1; a++; if (a == 14) { a = 0; b++; } main.Add(blocks[i]); } } ~MapGenerator() { } #endregion #region CheckBuildBlock public int CheckBuildBlock(int X, int Y, bool id) { for (int i = 0; i < map_size; i++) if (blocks[i] != null) if ((X > blocks[i].X) && (X < blocks[i].X + blocks[i].Width)) if ((Y > blocks[i].Y) && (Y < blocks[i].Y + blocks[i].Height)) if (rs.GetStep(i) == "0") if (!id) return 1; else return i; return 2; } #endregion } }
Optional Paste Settings
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
HTML 5
Java
JavaScript
Lua
None
Perl
PHP
Python
Rails
-------------
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
ActionScript
ActionScript 3
Ada
ALGOL 68
Apache Log
AppleScript
APT Sources
ASM (NASM)
ASP
autoconf
Autohotkey
AutoIt
Avisynth
Awk
BASCOM AVR
Bash
Basic4GL
BibTeX
Blitz Basic
BNF
BOO
BrainFuck
C
C for Macs
C Intermediate Language
C#
C++
C++ (with QT extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
ChaiScript
Clojure
Clone C
Clone C++
CMake
COBOL
CoffeeScript
ColdFusion
CSS
Cuesheet
D
DCS
Delphi
Delphi Prism (Oxygene)
Diff
DIV
DOS
DOT
E
ECMAScript
Eiffel
Email
EPC
Erlang
F#
Falcon
FO Language
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
Game Maker
GDB
Genero
Genie
GetText
Go
Groovy
GwBasic
Haskell
HicEst
HQ9 Plus
HTML
HTML 5
Icon
IDL
INI file
Inno Script
INTERCAL
IO
J
Java
Java 5
JavaScript
jQuery
KiXtart
Latex
Liberty BASIC
Linden Scripting
Lisp
LLVM
Loco Basic
Logtalk
LOL Code
Lotus Formulas
Lotus Script
LScript
Lua
M68000 Assembler
MagikSF
Make
MapBasic
MatLab
mIRC
MIX Assembler
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MPASM
MXML
MySQL
newLISP
None
NullSoft Installer
Oberon 2
Objeck Programming Langua
Objective C
OCalm Brief
OCaml
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
Pascal
PAWN
PCRE
Per
Perl
Perl 6
PHP
PHP Brief
Pic 16
Pike
Pixel Bender
PL/SQL
PostgreSQL
POV-Ray
Power Shell
PowerBuilder
ProFTPd
Progress
Prolog
Properties
ProvideX
PureBasic
PyCon
Python
q/kdb+
QBasic
R
Rails
REBOL
REG
Robots
RPM Spec
Ruby
Ruby Gnuplot
SAS
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
SQL
SystemVerilog
T-SQL
TCL
Tera Term
thinBasic
TypoScript
Unicon
UnrealScript
Vala
VB.NET
VeriLog
VHDL
VIM
Visual Pro Log
VisualBasic
VisualFoxPro
WhiteSpace
WHOIS
Winbatch
XBasic
XML
Xorg Config
XPP
YAML
Z80 Assembler
ZXBasic
Paste Expiration:
Never
10 Minutes
1 Hour
1 Day
1 Month
Paste Exposure:
Public
Unlisted
Private (members only)
Paste Name / Title:
Hello
Guest
Sign Up
or
Login
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login