Inheritance: OnCollisionChangedListener, Aggroable, Damageable
Esempio n. 1
0
 public DamageEvent(Projectile by, Unit target)
 {
     this.by = by;
     this.target = target;
     this.usedModifier = this.GetModifier();
     this.damageDone = by.baseDamage * this.usedModifier;
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 public ProductionUnit(float maxHealth, double productionDuration, Unit.Type type)
 {
     this.currentHealth = 0;
     this.maxHealth = maxHealth;
     this.productionDuration = productionDuration;
     this.productionProgress = 0;
     this.type = type;
 }
Esempio n. 4
0
 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;
     }
 }
Esempio n. 5
0
        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;
        }
Esempio n. 6
0
 /// <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;
         }
     }
 }
Esempio n. 7
0
 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; }
 }
Esempio n. 8
0
 /// <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));
 }
Esempio n. 9
0
 public ObjectProcess(Object obj, Point target)
 {
     if (obj is Unit)
     {
         unit = (Unit)obj;
         building = null;
     }
     else
     {
         building = (Building)obj;
         unit = null;
     }
     this.target = target;
 }
Esempio n. 10
0
 /// <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;
 }
Esempio n. 11
0
 private Boolean isUnitDead(Unit unit)
 {
     if (unit != null && unit.isDead)
     {
         unit = null;
         return true;
     }
     return false;
 }
Esempio n. 12
0
 /// <summary>
 /// Sets the target to attack
 /// </summary>
 /// <param name="unitToAttack"></param>
 public void Attack(Unit unitToAttack)
 {
     this.unitToDefend = null;
     this.unitToStalk = unitToAttack;
 }
Esempio n. 13
0
 public void QueueUnit(Unit unit)
 {
     this.unitList.AddLast(unit);
 }
Esempio n. 14
0
 /// <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;
 }
Esempio n. 15
0
 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);
     }
 }
Esempio n. 16
0
 /// <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;
 }
Esempio n. 17
0
 public UnitProcess(Unit unit, Point target)
 {
     this.unit = unit;
     this.target = target;
 }
Esempio n. 18
0
 /// <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;
 }
Esempio n. 19
0
        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;
            }
        }
Esempio n. 20
0
 /// <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;
 }
Esempio n. 21
0
 /// <summary>
 /// Sets the target to defenc
 /// </summary>
 /// <param name="unitToDefend"></param>
 public void Defend(Unit unitToDefend)
 {
     this.unitToStalk = null;
     this.unitToDefend = unitToDefend;
 }
Esempio n. 22
0
 /// <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;
     }
 }
Esempio n. 23
0
 public HealthBar(Unit unit)
 {
     texture = Game1.GetInstance().Content.Load<Texture2D>("Misc/solid");
     this.unit = unit;
     this.type = Type.Unit;
 }
Esempio n. 24
0
 public AggroEvent(Unit from, Damageable to, Boolean received)
 {
     this.from = from;
     this.to = to;
     this.received = received;
 }
Esempio n. 25
0
 /// <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;
 }
Esempio n. 26
0
 public UnitMultiplayerData(Unit unit, Boolean isLocal)
     : base(isLocal)
 {
     this.unit = unit;
 }