コード例 #1
0
        public void RemoveUnit(LiveUnit u)
        {
            Units.Remove(u);
            //... additional code to clear it from the ui

            //... check for game over (HasLost)
        }
コード例 #2
0
 /// <summary>
 /// Applies any registered buffs to the unit.<para></para>Additional funcationality is present in the overridden methods.
 /// </summary>
 virtual internal void ApplyTo(LiveUnit u)
 {
     if (appliedBuffs.Count > 0)//skips if no buffs applied
     {
         foreach (Buff b in appliedBuffs)
         {
             u.StackBuff(b);
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// Returns true if the ability will be applied to the unit
        /// </summary>
        internal bool DoesAffect(LiveUnit u)
        {
            if (u.ContainsBuffType(BuffType.IsImmortal))
            {
                return(false);
            }
            OwnerPlayer targets = validTargetMask & u.OwnerPlayer;

            return(targets == u.OwnerPlayer);
        }
コード例 #4
0
        /// <summary> Moves the grid position with a center at the x/y co-ordinate to the stored target position<para></para><para></para>
        /// SetTarget must be called first, or an exception will be thrown.
        /// </summary>
        public override void ApplyTo(int x, int y)
        {
            //first, apply the teleportation buff to valid units within the coordinates
            base.ApplyTo(x, y);

            //exception will be thrown if targetx&y are not set first in SetTarget
            if (targetX < 0 || targetY < 0)
            {
                throw new Exception();
            }

            //store existing state of grid at target location
            Grid temp = Grid.mainGrid.GetRegion(x, y, Radius);

            //update the position of any units that should be moved.
            for (int i = 0; i < temp.height; i++)
            {
                for (int j = 0; j < temp.width; j++)
                {
                    LiveUnit u          = temp.Get(i, j);
                    LiveUnit targetDest = Grid.mainGrid.Get(x + targetX - Radius + 1 + i, y + targetY - Radius + 1 + j);
                    if (u != null && DoesAffect(u) && targetDest == null)
                    {
                        //stack teleports
                        if (u.ContainsBuffType(BuffType.OnTeleportApplyBuff))
                        {
                            Buff inQuestion = u.FirstBuffOfType(BuffType.OnTeleportApplyBuff);
                            Buff toCreate   = new Buff((BuffType)inQuestion.Strength, 1, inQuestion.DoesStack, 1);
                            toCreate.Title = inQuestion.Title.Substring(1);
                            u.StackBuff(toCreate);
                        }


                        //Move the UI
                        u.sprite.xInd = targetX - Radius + 1 + i;
                        u.sprite.yInd = targetY - Radius + 1 + j;
                        u.sprite.MoveTo(((targetX - Radius + 1 + i) * 63) + 6 + UI.UIGrid.margin, ((targetY - Radius + 1 + j) * 63) - 21 + UI.UIGrid.margin);
                        u.sprite.MoveSubUI();

                        //set corresponding position on target to u
                        Grid.mainGrid.Set(targetX - Radius + 1 + i, targetY - Radius + 1 + j, u);
                        //clear old position
                        Grid.mainGrid.Set(x - Radius + 1 + i, y - Radius + 1 + j, null);
                    }
                }
            }

            //clear target
            targetX = -1;
            targetY = -1;
        }
コード例 #5
0
 /// <summary>
 /// Damages and applies any registered buffs to the unit paramater.
 /// </summary>
 override internal void ApplyTo(LiveUnit u)
 {
     if (DoesAffect(u))
     {
         int insdamage = damage;
         base.ApplyTo(u);
         Random Crit = new Random();
         if (Crit.Next(100) <= Managers.UnitManager.Manager.activeUnit.critChance)
         {
             insdamage = (int)((damage * Managers.UnitManager.Manager.activeUnit.critDamage) / 100);
         }
         u.ApplyDamage(insdamage);
     }
 }
コード例 #6
0
 /// <summary>
 /// Apply damage to a unit's health.  If the position is null, nothing happens.  Throws IndexOutOfRangeException when the target location is OOB
 /// </summary>
 /// <param name="x">X position of the unit to damage</param>
 /// <param name="y">Y position of the unit to damage</param>
 /// <param name="damage">How much damage to deal to the target unit's health</param>
 public void DamageUnit(int x, int y, int damage)
 {
     if (Utils.InRange(0, this.width - 1, x) && Utils.InRange(0, this.height - 1, y))
     {
         LiveUnit thisUnit = this.Get(x, y);
         if (thisUnit != null)
         {
             thisUnit.ApplyDamage(damage);
         }
     }
     else
     {
         throw new IndexOutOfRangeException("Target position out of bounds");
     }
 }
コード例 #7
0
        public TokenUnit(LiveUnit creator, OwnerPlayer owner, int health = 9999) : base(health, owner)
        {
            this.creator = creator;

            ownerPlayer = (creator == null? OwnerPlayer.None : creator.ownerPlayer);

            MovesLeft   = 0;
            hasAttacked = true;
            hasMoved    = true;

            //NOTE: logic does not support tokens owned by multiple players. can't see why we'd need them, so DON'T MAKE THEM!
            if (ownerPlayer != OwnerPlayer.None)
            {
                GetOwner().AddUnit(this);
            }
        }
コード例 #8
0
 /// <summary>
 /// Place a unit in the grid.  Overrides other units that might be at this position.
 /// Throws IndexOutOfRangeException when the specefied location is OOB
 /// </summary>
 /// <param name="xPos">X position to insert the unit at</param>
 /// <param name="yPos">Y position to insert the unit at</param>
 /// <param name="unit">Unit to insert at this position</param>
 public void Set(int xPos, int yPos, LiveUnit unit)
 {
     grid[yPos, xPos] = unit;
 }
コード例 #9
0
 public void AddUnit(LiveUnit u)
 {
     Units.Add(u);
     //... additional code to hook it up to the ui
 }