Inheritance: OnCollisionChangedListener, Aggroable, Damageable
コード例 #1
0
ファイル: DamageEvent.cs プロジェクト: Cur10s1ty/RTS_XNA
 public DamageEvent(Projectile by, Unit target)
 {
     this.by = by;
     this.target = target;
     this.usedModifier = this.GetModifier();
     this.damageDone = by.baseDamage * this.usedModifier;
 }
コード例 #2
0
ファイル: DamageEvent.cs プロジェクト: Wotuu/RTS_XNA_v2
 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
ファイル: ProductionUnit.cs プロジェクト: R3coil/RTS_XNA_v2
 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
ファイル: MeleeStore.cs プロジェクト: R3coil/RTS_XNA_v2
 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
ファイル: HealthBar.cs プロジェクト: Wotuu/RTS_XNA_v2
        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
ファイル: Synchronizer.cs プロジェクト: Wotuu/RTS_XNA_v2
 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
ファイル: UnitSelection.cs プロジェクト: Wotuu/RTS_XNA_v2
 /// <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
ファイル: Synchronizer.cs プロジェクト: R3coil/RTS_XNA_v2
 public void QueueUnit(Unit unit)
 {
     this.unitList.AddLast(unit);
 }
コード例 #14
0
ファイル: UnitSelection.cs プロジェクト: R3coil/RTS_XNA_v2
 /// <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
ファイル: Synchronizer.cs プロジェクト: Wotuu/RTS_XNA_v2
 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
ファイル: UnitSelection.cs プロジェクト: R3coil/RTS_XNA_v2
 /// <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
ファイル: Building.cs プロジェクト: Cur10s1ty/RTS_XNA_v2
        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
ファイル: HealthBar.cs プロジェクト: forced1988/RTS_XNA
 public HealthBar(Unit unit)
 {
     texture = Game1.GetInstance().Content.Load<Texture2D>("Misc/solid");
     this.unit = unit;
     this.type = Type.Unit;
 }
コード例 #24
0
ファイル: AggroEvent.cs プロジェクト: Wotuu/RTS_XNA_v2
 public AggroEvent(Unit from, Damageable to, Boolean received)
 {
     this.from = from;
     this.to = to;
     this.received = received;
 }
コード例 #25
0
ファイル: UnitSelection.cs プロジェクト: Wotuu/RTS_XNA_v2
 /// <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;
 }