상속: OnCollisionChangedListener, Aggroable, Damageable
예제 #1
0
 public DamageEvent(Projectile by, Unit target)
 {
     this.by = by;
     this.target = target;
     this.usedModifier = this.GetModifier();
     this.damageDone = by.baseDamage * this.usedModifier;
 }
예제 #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;
 }
예제 #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;
 }
예제 #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;
     }
 }
예제 #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;
        }
예제 #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;
         }
     }
 }
예제 #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; }
 }
예제 #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));
 }
예제 #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;
 }
예제 #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;
 }
예제 #11
0
파일: Unit.cs 프로젝트: R3coil/RTS_XNA_v2
 private Boolean isUnitDead(Unit unit)
 {
     if (unit != null && unit.isDead)
     {
         unit = null;
         return true;
     }
     return false;
 }
예제 #12
0
파일: Unit.cs 프로젝트: R3coil/RTS_XNA_v2
 /// <summary>
 /// Sets the target to attack
 /// </summary>
 /// <param name="unitToAttack"></param>
 public void Attack(Unit unitToAttack)
 {
     this.unitToDefend = null;
     this.unitToStalk = unitToAttack;
 }
예제 #13
0
 public void QueueUnit(Unit unit)
 {
     this.unitList.AddLast(unit);
 }
예제 #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;
 }
예제 #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);
     }
 }
예제 #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;
 }
예제 #17
0
 public UnitProcess(Unit unit, Point target)
 {
     this.unit = unit;
     this.target = target;
 }
예제 #18
0
파일: Unit.cs 프로젝트: Wotuu/RTS_XNA_v2
 /// <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;
 }
예제 #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;
            }
        }
예제 #20
0
파일: Unit.cs 프로젝트: Wotuu/RTS_XNA_v2
 /// <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;
 }
예제 #21
0
파일: Unit.cs 프로젝트: R3coil/RTS_XNA_v2
 /// <summary>
 /// Sets the target to defenc
 /// </summary>
 /// <param name="unitToDefend"></param>
 public void Defend(Unit unitToDefend)
 {
     this.unitToStalk = null;
     this.unitToDefend = unitToDefend;
 }
예제 #22
0
파일: Unit.cs 프로젝트: Wotuu/RTS_XNA_v2
 /// <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;
     }
 }
예제 #23
0
 public HealthBar(Unit unit)
 {
     texture = Game1.GetInstance().Content.Load<Texture2D>("Misc/solid");
     this.unit = unit;
     this.type = Type.Unit;
 }
예제 #24
0
 public AggroEvent(Unit from, Damageable to, Boolean received)
 {
     this.from = from;
     this.to = to;
     this.received = received;
 }
예제 #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;
 }
예제 #26
0
 public UnitMultiplayerData(Unit unit, Boolean isLocal)
     : base(isLocal)
 {
     this.unit = unit;
 }