private void Init() { Money = Config.InitialMoney; lastSpawn = DateTime.Now; spawn = 100; m = new Map(11, 6); st = DateTime.Now; Cannons = new List<Cannon>(); Cannon1 c = new Cannon1(); c.position = new Vector2d(560, 80); Cannons.Add(c); c = new Cannon1(); c.position = new Vector2d(400, 200); Cannons.Add(c); c = new Cannon1(); c.position = new Vector2d(240, 100); Cannons.Add(c); c = new Cannon1(); c.position = new Vector2d(240, 180); Cannons.Add(c); c = new Cannon1(); c.position = new Vector2d(240, 240); Cannons.Add(c); Bullets = new List<Bullet>(); Enemies = new LinkedList<Enemy>(); Enemy a = new Enemy(); a.position = new Vector2d(0, 0); Enemies.AddFirst(a); }
void glControl1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { Cannon c = null; if (CanSwitcher == 1 && cann1.Enabled) { c = new Cannon1(); Money -= Config.Cannon1Price; } else if (CanSwitcher == 2 && cann2.Enabled) { c = new Cannon2(); Money -= Config.Cannon2Price; } else if (CanSwitcher == 3 && cann3.Enabled) { c = new Cannon3(); Money -= Config.Cannon3Price; } if (c == null) return; c.position = new Vector2d(e.X, glControl1.Height - e.Y); if (m.IsOffTrack(e.X, glControl1.Height - e.Y)) Cannons.Add(c); } else if (e.Button == MouseButtons.Right) { prew = DateTime.Now; preview = true; xx = e.X; yy = glControl1.Height - e.Y; } }