Пример #1
0
        public Vector2 HandleCustomEffects(Vector2 motionVector, ISprite sprite)
        {
            Point cell = Helper.VPointToCell(sprite.Center);

            int colIndex = GetCellIndex(cell);

            if (colIndex == 2)
            {
                if (sprite.GetType() == typeof(AnimatedSprite))
                {
                    ((AnimatedSprite)sprite).CurrentAnimation.FramesPerSecond = 3;
                }
                return(motionVector * .5f);
            }
            if (colIndex == 3)
            {
                if (sprite.GetType() == typeof(AnimatedSprite))
                {
                    ((AnimatedSprite)sprite).CurrentAnimation.FramesPerSecond = 10;
                }
                return(motionVector * 1.5f);
            }
            if (sprite.GetType() == typeof(AnimatedSprite))
            {
                ((AnimatedSprite)sprite).CurrentAnimation.FramesPerSecond = 7;
            }
            return(motionVector);
        }
Пример #2
0
 /// <summary>
 /// 删除所有指定类
 /// </summary>
 ///
 /// <param name="clazz"></param>
 /// <returns></returns>
 public void Remove(Type clazz)
 {
     if (clazz == null)
     {
         return;
     }
     for (int i = size; i > 0; i--)
     {
         ISprite sprite = (ISprite)sprites[i - 1];
         Type    cls    = sprite.GetType();
         if (clazz == null || clazz == cls || clazz.IsInstanceOfType(sprite) ||
             clazz.Equals(cls))
         {
             size--;
             sprites[i - 1] = sprites[size];
             sprites[size]  = null;
             if (size == 0)
             {
                 sprites = new ISprite[0];
             }
             else
             {
                 CompressCapacity(2);
             }
         }
     }
 }
Пример #3
0
        /// <summary>
        /// 返回所有指定类产生的精灵
        /// </summary>
        ///
        /// <param name="clazz"></param>
        /// <returns></returns>
        public List <ISprite> GetSprites(
            Type clazz)
        {
            if (clazz == null)
            {
                return(null);
            }
            List <ISprite> l = new List <ISprite>(size);

            for (int i = size; i > 0; i--)
            {
                ISprite sprite = (ISprite)sprites[i - 1];
                Type    cls    = sprite.GetType();
                if (clazz == null || clazz == cls || clazz.IsInstanceOfType(sprite) ||
                    clazz.Equals(cls))
                {
                    l.Add(sprite);
                }
            }
            return(l);
        }
Пример #4
0
 public static DungeonEnum ToDungeonEnum(this ISprite dungeon)
 {
     if (DungeonEnum.DownWall.GetName().Contains(dungeon.GetType().Name))
     {
         return(GetWallEnum((Wall)dungeon));
     }
     if (DungeonEnum.DownOpenDoor.GetName().Contains(dungeon.GetType().Name))
     {
         return(GetOpenDoorEnum((OpenDoor)dungeon));
     }
     if (DungeonEnum.DownLockedDoor.GetName().Contains(dungeon.GetType().Name))
     {
         return(GetLockedDoorEnum((LockedDoor)dungeon));
     }
     if (DungeonEnum.DownShutDoor.GetName().Contains(dungeon.GetType().Name))
     {
         return(GetShutDoorEnum((ShutDoor)dungeon));
     }
     if (DungeonEnum.DownBombedOpening.GetName().Contains(dungeon.GetType().Name))
     {
         return(GetBombedOpeningEnum((BombedOpening)dungeon));
     }
     return(dungeon.GetType().Name.ToDungeonEnum());
 }