public Planet() { GenerateName(); Colour = Color.FromArgb(Program.rnd.Next(128) + 64, Program.rnd.Next(128) + 64, Program.rnd.Next(128) + 64); Owner = null; Ships = Program.rnd.Next(10) + 5; ProductionRate = Program.rnd.Next(6) + 2; DefenceRate = (Program.rnd.Next(4) / 10.0) + 0.4; }
private void button1_Click(object sender, EventArgs e) { listBox1.Items.Add(textBox1.Text); Player p = new Player(); p.Name = textBox1.Text; p.Interaction = (checkBox1.Checked ? Player.Source.LocalComputer : Player.Source.LocalHuman); p.Colour = Color.FromArgb(Program.rnd.Next(192) + 64, Program.rnd.Next(192) + 64, Program.rnd.Next(192) + 64); mapControl1.Players.Add(p); mapControl1.GenerateMap(trackBar1.Value, new Size(9, 9)); textBox1.Text = ""; textBox1.Focus(); }
public void FleetArrived(Fleet F) { // Attacking Ships: Min( Attacking, Max( 0, Attacking - (Defending * (1 + (Defence% / 3))) ) ) // Defending Ships: Min( Defending, Max( 0, (Defending * (1 + (Defence% / 3))) - Attacking ) ) int a = (int)Math.Min(F.Ships, Math.Max(0, (double)F.Ships - ((double)Ships * (1.0 + (DefenceRate / 3.0))))); int d = (int)Math.Min(Ships, Math.Max(0, ((double)Ships * (1.0 + (DefenceRate / 3.0))) - (double)F.Ships)); if( a > d ) { Owner = F.Owner; Ships = a; } }