public DamageEvent(Projectile by, Unit target) { this.by = by; this.target = target; this.usedModifier = this.GetModifier(); this.damageDone = by.baseDamage * this.usedModifier; }
public DamageEvent(DamageSource by, Damageable target, Unit source) { this.source = source; this.by = by; this.target = target; this.usedModifier = this.GetModifier(); this.damageDone = by.baseDamage * this.usedModifier; }
public ProductionUnit(float maxHealth, double productionDuration, Unit.Type type) { this.currentHealth = 0; this.maxHealth = maxHealth; this.productionDuration = productionDuration; this.productionProgress = 0; this.type = type; }
protected override Unit createUnit(Unit.Type type, int x, int y) { switch (type) { case Unit.Type.Engineer: return new Engineer(player, x, y); case Unit.Type.Melee: return new Swordman(player, x, y); default: Console.WriteLine("Null Returned"); return null; } }
public HealthBar(Unit unit) { texture = TextureManager.GetInstance().GetSolidTexture(); this.unit = unit; this.type = Type.Unit; this.useDynamicColoring = true; fullColor = new Color(0, 255, 0, 255); emptyColor = new Color(255, 0, 0, 255); this.z = this.unit.z - 0.01f; }
/// <summary> /// Removes a unit from the process list. /// </summary> /// <param name="unit">The unit.</param> public void Remove(Unit unit) { for( int i = 0; i < toProcess.Count; i++ ) { UnitProcess up = toProcess.ElementAt(i); if (up.unit == unit) { toProcess.Remove(up); break; } } }
public Boolean AlreadyInQueue(Unit unit) { try { for (int i = 0; i < this.unitList.Count(); i++) { Unit currentUnit = this.unitList.ElementAt(i); if (currentUnit == unit) return true; } return false; } catch (Exception e) { return false; } }
/// <summary> /// Pushes a unit onto the list. /// </summary> /// <param name="unit">The unit</param> /// <param name="target">The target of the unit</param> public void Push(Unit unit, Point target) { toProcess.AddLast(new UnitProcess(unit, target)); }
public ObjectProcess(Object obj, Point target) { if (obj is Unit) { unit = (Unit)obj; building = null; } else { building = (Building)obj; unit = null; } this.target = target; }
/// <summary> /// Gets the point that is closest of a collection from a unit. /// </summary> /// <param name="unit">The unit.</param> /// <param name="points">The list of points to chose from</param> /// <returns>The point.</returns> private Point GetClosestPoint(Unit unit, CustomArrayList<Point> points) { Point closestPoint = new Point(0, 0); double closestDistance = Double.MaxValue; Point unitLocation = new Point((int)unit.x, (int)unit.y); for( int i = 0; i < points.Count(); i++){ Point p = points.ElementAt(i); double currentDistance = Util.GetHypoteneuseLength(p, unitLocation); if (currentDistance < closestDistance) { closestPoint = p; closestDistance = currentDistance; } } return closestPoint; }
private Boolean isUnitDead(Unit unit) { if (unit != null && unit.isDead) { unit = null; return true; } return false; }
/// <summary> /// Sets the target to attack /// </summary> /// <param name="unitToAttack"></param> public void Attack(Unit unitToAttack) { this.unitToDefend = null; this.unitToStalk = unitToAttack; }
public void QueueUnit(Unit unit) { this.unitList.AddLast(unit); }
/// <summary> /// Gets the point that is closest of a collection from a unit. /// </summary> /// <param name="unit">The unit.</param> /// <param name="points">The list of points to chose from</param> /// <returns>The point.</returns> private Point GetClosestPoint(Unit unit, LinkedList<Point> points) { Point closestPoint = new Point(0, 0); double closestDistance = Double.MaxValue; Point unitLocation = new Point((int)unit.x, (int)unit.y); foreach (Point p in points) { double currentDistance = Util.GetHypoteneuseLength(p, unitLocation); if (currentDistance < closestDistance) { closestPoint = p; closestDistance = currentDistance; } } return closestPoint; }
public void QueueUnit(Unit unit) { if (!this.AlreadyInQueue(unit)) { this.unitList.AddLast(unit); // Console.WriteLine("StackTrace: '{0}'\n target={1}", Environment.StackTrace, unit.multiplayerData.moveTarget); } }
/// <summary> /// Gets the point that is furthest away of a collcetion from a unit. /// </summary> /// <param name="unit">The unit.</param> /// <param name="points">The list of points to chose from</param> /// <returns>The point.</returns> private Point GetFarthestPoint(Unit unit, LinkedList<Point> points) { Point farthestPoint = new Point(0, 0); double farthestDistance = 0; Point unitLocation = new Point((int)unit.x, (int)unit.y); foreach (Point p in points) { double currentDistance = Util.GetHypoteneuseLength(p, unitLocation); if (currentDistance > farthestDistance) { farthestPoint = p; farthestDistance = currentDistance; } } return farthestPoint; }
public UnitProcess(Unit unit, Point target) { this.unit = unit; this.target = target; }
/// <summary> /// Sets the target to attack /// </summary> /// <param name="unitToAttack"></param> public void AttackUnit(Unit unitToAttack) { this.buildingToDestroy = null; this.unitToDefend = null; this.unitToStalk = unitToAttack; }
public void CreateUnit(Unit.Type type) { ProductionUnit newUnit = null; switch (type) { case Unit.Type.Engineer: if (this.type == Type.Fortress) { newUnit = new ProductionUnit(100f, 5.0, type); productionQueue.AddLast(newUnit); } break; case Unit.Type.Melee: if (this.type == Type.Barracks) { newUnit = new ProductionUnit(100f, 5.0, type); productionQueue.AddLast(newUnit); } break; case Unit.Type.HeavyMelee: if (this.type == Type.Factory) { newUnit = new ProductionUnit(100f, 5.0, type); productionQueue.AddLast(newUnit); } break; case Unit.Type.Fast: if (this.type == Type.Barracks) { newUnit = new ProductionUnit(100f, 5.0, type); productionQueue.AddLast(newUnit); } break; case Unit.Type.Ranged: if (this.type == Type.Barracks) { newUnit = new ProductionUnit(100f, 5.0, type); productionQueue.AddLast(newUnit); } break; case Unit.Type.HeavyRanged: if (this.type == Type.Factory) { newUnit = new ProductionUnit(100f, 5.0, type); productionQueue.AddLast(newUnit); } break; default: break; } }
/// <summary> /// Sets the target to defend /// </summary> /// <param name="unitToDefend"></param> public void Defend(Unit unitToDefend) { this.buildingToDestroy = null; this.unitToStalk = null; this.unitToDefend = unitToDefend; }
/// <summary> /// Sets the target to defenc /// </summary> /// <param name="unitToDefend"></param> public void Defend(Unit unitToDefend) { this.unitToStalk = null; this.unitToDefend = unitToDefend; }
/// <summary> /// Set's the new Job for the unit /// </summary> /// <param name="newJob"></param> public void SetJob(Unit.Job newJob) { if (this.job != newJob) { // Console.WriteLine("Unit's Job updated to + " + newJob); this.job = newJob; } }
public HealthBar(Unit unit) { texture = Game1.GetInstance().Content.Load<Texture2D>("Misc/solid"); this.unit = unit; this.type = Type.Unit; }
public AggroEvent(Unit from, Damageable to, Boolean received) { this.from = from; this.to = to; this.received = received; }
/// <summary> /// Gets the point that is furthest away of a collcetion from a unit. /// </summary> /// <param name="unit">The unit.</param> /// <param name="points">The list of points to chose from</param> /// <returns>The point.</returns> private Point GetFarthestPoint(Unit unit, CustomArrayList<Point> points) { Point farthestPoint = new Point(0, 0); double farthestDistance = 0; Point unitLocation = new Point((int)unit.x, (int)unit.y); for (int i = 0; i < points.Count(); i++) { Point p = points.ElementAt(i); double currentDistance = Util.GetHypoteneuseLength(p, unitLocation); if (currentDistance > farthestDistance) { farthestPoint = p; farthestDistance = currentDistance; } } return farthestPoint; }
public UnitMultiplayerData(Unit unit, Boolean isLocal) : base(isLocal) { this.unit = unit; }