private void TimerBullet_Tick(object sender, EventArgs e) { List bulletToRemove = new List(); foreach (Bullet b in bulletList) { bool collisionBulletGround = MapOpertations.CheckCollisionBulletGround(b.getRectangleCon(MapOpertations.mapSize, MapOpertations.fileMapSize), map); if (collisionBulletGround || CheckCollisionBulletUnit(b)) { if (collisionBulletGround) { int i = 0; foreach (Unit u in unitList) { if (b.InMove==0) { int rad = w.getRealBumPower() / 2; float dist = DistanceSquared(u.Position, b.Position); if (dist < rad * rad) { u.HurtInTurn = true; // u.Health = u.Health - (int)(Math.Sqrt(dist) * w.getBumPower() / 2); u.Health = u.Health - w.getRealBumPower(); if (u.Health < 0) u.Health = 0; this.Text = this.Text + "Unit" + i + ": -" + dist; UpdatePlayersHealth(); } //u.Health = u.Health - w.getBumPower(); //MessageBox.Show("Unit " + u.Health); //Console.Write("unit "+u.ToString()); Console.Write("\n\nposUnit [" + u.Position.X + "." + u.Position.Y + "]"); Console.Write("posBullet [" + b.Position.X + "." + b.Position.Y + "]"); Console.Write("dist [" + Math.Sqrt(dist) + "]"); Console.Write("rad [" + rad + "]"); } i++; } } BulletLoop(); if (b.InMove == 3) { map = MapOpertations.ExplosionGround(map, b, w); bulletToRemove.Add(b); } else { b.InMove++; } } else if (b.Position.X > MapOpertations.mapSize.X || b.Position.X < 0 || b.Position.Y > MapOpertations.mapSize.Y || b.Position.Y < -500) { bulletToRemove.Add(b); } else { b.Time = b.Time + (float)0.1; BulletLoop(); } } foreach (Bullet b in bulletToRemove) bulletList.Remove(b); bulletToRemove.Clear(); if (bulletList.Count == 0) { timerBullet.Enabled = false; timeShootingKeyPressed = 0; bulletLabel.Text = "...."; speedLabel.Text = "...."; nowLabel.Text = turn.ToString(); if (checkStateOfGame() != 2) return; resetHurts(); if (turn == Player.Computer) { RepaintMap(); ComputerMove(); } if (turn == Player.Computer) turn = Player.Human; } RepaintMap(); mapPictureBox.Invalidate(); }