public int PlanetCount(PlanetOwner owner) { int sum = 0; foreach (SilverlightControlPlanet planet in Planets) { if (planet.Owner == owner) { sum++; } } return(sum); }
public int ShipCount(PlanetOwner owner) { int sum = 0; foreach (SilverlightControlFleet fleet in fleets) { if (fleet.Owner == owner && fleet.IsActive) { sum += fleet.ShipNum; } } return(sum); }
public void SetPlanets(SilverlightControlPlanet startplanet, SilverlightControlPlanet destplanet) { start = startplanet; destination = destplanet; double startx = (double)start.GetValue(Canvas.LeftProperty) + start.Width / 2.0 - this.Width / 2.0; double starty = (double)start.GetValue(Canvas.TopProperty) + start.Height / 2.0 - this.Height / 2.0; destx = (double)destination.GetValue(Canvas.LeftProperty) + destination.Width / 2.0 - this.Width / 2.0; desty = (double)destination.GetValue(Canvas.TopProperty) + destination.Height / 2.0 - this.Width / 2.0; xk = startx; yk = starty; double dx = destx - startx; double dy = desty - starty; double d = PlanetMath.Length(dx, dy); px = Speed * (dx / d); py = Speed * (dy / d); owner = start.Owner; if (owner == PlanetOwner.Player) { ImageFleet.Source = ship_player; } else { ImageFleet.Source = ship_enemy; } FleetRotate.Angle = PlanetMath.RotationAngle(startx, starty, destx, desty); IsActive = true; }
public SilverlightControlGameOver() { InitializeComponent(); winner = PlanetOwner.Neutral; }