public void Repair(Building b) { Point p = new Point((int)(b.x + (b.texture.Width / 2)), (int)(b.y + (b.texture.Height / 2))); // Add a point that is on the circle near the building, not inside the building! Point targetPoint = new Point(0, 0); if (this.waypoints.Count() == 0) targetPoint = new Point((int)this.x, (int)this.y); else targetPoint = this.waypoints.ElementAt(this.waypoints.Count() - 1); // Move to the point around the circle of the building, but increase the radius a bit // so we're not standing on the exact top of the building this.MoveToQueue( Util.GetPointOnCircle(p, b.GetCircleRadius() + this.texture.Width / 2, Util.GetHypoteneuseAngleDegrees(p, targetPoint))); b.constructedBy = this; this.constructing = b; if (b.state == Building.State.Interrupted) { b.state = Building.State.Constructing; } else if (b.state == Building.State.Finished || b.state == Building.State.Producing) { b.state = Building.State.Repairing; } }
public ProgressBar(Building building) { this.texture = TextureManager.GetInstance().GetSolidTexture(); this.building = building; this.z = this.building.z - 0.1f; }
public Circle(int radius, Building drawOn, Color color) { this.radius = radius; this.outerRadius = radius * 2 + 2; // So circle doesn't go out of bounds this.outline = new Texture2D(Game1.GetInstance().GraphicsDevice, outerRadius, outerRadius); this.drawOn = drawOn; this.color = color; Color[] data = new Color[outerRadius * outerRadius]; // Color the entire texture transparent first. for (int i = 0; i < data.Length; i++) data[i] = Color.Transparent; // Work out the minimum step necessary using trigonometry + sine approximation. double angleStep = 1f / radius; for (double angle = 0; angle < Math.PI * 2; angle += angleStep) { // Use the parametric definition of a circle: http://en.wikipedia.org/wiki/Circle#Cartesian_coordinates int x = (int)Math.Round(radius + radius * Math.Cos(angle)); int y = (int)Math.Round(radius + radius * Math.Sin(angle)); data[y * outerRadius + x + 1] = Color.White; } this.outline.SetData(data); }
public HealthBar(Building building) { texture = TextureManager.GetInstance().GetSolidTexture(); this.building = building; this.type = Type.Building; this.z = this.building.z - 0.01f; }
public Boolean AlreadyInQueue(Building building) { try { for (int i = 0; i < this.buildingList.Count(); i++) { Building currentBuilding = this.buildingList.ElementAt(i); if (currentBuilding == building) return true; } return false; } catch (Exception e) { return false; } }
public HealthBar(Building building) { texture = Game1.GetInstance().Content.Load<Texture2D>("Misc/solid"); this.building = building; this.type = Type.Building; }
public void QueueBuilding(Building building) { this.buildingList.AddLast(building); }
public BuildingMultiplayerData(Building building, Boolean isLocal) : base(isLocal) { this.building = building; }
public ObjectProcess(Object obj, Point target) { if (obj is Unit) { unit = (Unit)obj; building = null; } else { building = (Building)obj; unit = null; } this.target = target; }
public void AttackBuilding(Building enemyBuilding) { this.unitToDefend = null; this.unitToStalk = null; this.buildingToDestroy = enemyBuilding; }
public ProgressBar(Building building) { this.texture = Game1.GetInstance().Content.Load<Texture2D>("Misc/solid"); this.building = building; }
public void QueueBuilding(Building building) { if (!this.AlreadyInQueue(building)) this.buildingList.AddLast(building); }