コード例 #1
0
ファイル: Planet.cs プロジェクト: pmprog/Konquestor.NET
		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;
		}
コード例 #2
0
ファイル: NewLocal.cs プロジェクト: pmprog/Konquestor.NET
		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();
		}
コード例 #3
0
ファイル: Planet.cs プロジェクト: pmprog/Konquestor.NET
		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;
			}
		}