Ejemplo n.º 1
0
        /// <summary>
        /// 删除指定精灵
        /// </summary>
        ///
        /// <param name="sprite"></param>
        /// <returns></returns>
        public bool Remove(ISprite sprite)
        {
            if (sprite == null)
            {
                return(false);
            }
            if (sprites == null)
            {
                return(false);
            }
            bool removed = false;

            for (int i = size; i > 0; i--)
            {
                if (sprite.Equals(sprites[i - 1]))
                {
                    removed = true;
                    size--;
                    sprites[i - 1] = sprites[size];
                    sprites[size]  = null;
                    if (size == 0)
                    {
                        sprites = new ISprite[0];
                    }
                    else
                    {
                        CompressCapacity(2);
                    }
                    return(removed);
                }
            }
            return(removed);
        }
Ejemplo n.º 2
0
        public void CheckHit(Bullet bullet, ISprite sprite)
        {
            if (sprite.Equals(Owner))
                return;

            if (!(sprite is Living))
                return;

            var livingSprite = sprite as Living;
            HandleHit(bullet, livingSprite);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 检查指定精灵是否存在
 /// </summary>
 ///
 /// <param name="sprite"></param>
 /// <returns></returns>
 public bool Contains(ISprite sprite)
 {
     if (sprite == null)
     {
         return(false);
     }
     if (sprites == null)
     {
         return(false);
     }
     for (int i = 0; i < size; i++)
     {
         if (sprites[i] != null && sprite.Equals(sprites[i]))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 4
0
 public override void Update()
 {
     timer -= GameObjectManager.Instance.CurrentGameTime.ElapsedGameTime.TotalSeconds;
     if (timer >= TimerUtil.Zero)
     {
         if (currentSprite.Equals(oldSprite))
         {
             currentSprite = newSprite;
         }
         else
         {
             currentSprite = oldSprite;
         }
     }
     else
     {
         RemoveTransitionState();
     }
     base.Update();
 }