Ejemplo n.º 1
0
        private static void AddMagicSprite(MagicSprite sprite, int spriteIndex = -1)
        {
            if (sprite != null)
            {
                if (MaxMagicUnit > 0 && _magicSprites.Count >= MaxMagicUnit)
                {
                    switch (sprite.BelongMagic.MoveKind)
                    {
                    case 13:
                    case 20:
                    case 21:
                    case 23:
                        //Can or must skip those
                        break;

                    default:
                        //Restrict max magic sprites for performence
                        return;
                    }
                }

                sprite.Index = spriteIndex == -1 ? _maigicSpriteIndex++ : spriteIndex;

                _magicSprites.AddLast(sprite);

                if (sprite.BelongMagic.Solid > 0)
                {
                    _solideMagicSprites.AddLast(sprite);
                }
            }
        }
Ejemplo n.º 2
0
        private static void AddFollowCharacterMagicSprite(Character user, Magic magic, Vector2 origin, bool destroyOnEnd, Character target)
        {
            if (magic.MoveKind == 13)
            {
                if (target != null && user.Kind == (int)Character.CharacterKind.Player && target.IsFighterFriend)
                {
                    user = target;
                }
                var sprite = GetFixedPositionMagicSprite(user, magic, origin, destroyOnEnd);
                switch (magic.SpecialKind)
                {
                case 1:
                    user.Life += (magic.Effect == 0 ? user.Attack : magic.Effect) + magic.EffectExt;
                    AddMagicSprite(sprite);
                    break;

                case 2:
                    user.Thew += (magic.Effect == 0 ? user.Attack : magic.Effect) + magic.EffectExt;
                    AddMagicSprite(sprite);
                    break;

                default:
                {
                    MagicSprite spriteInEffect = null;
                    foreach (var item in user.MagicSpritesInEffect)
                    {
                        if (item.BelongMagic.Name == magic.Name)
                        {
                            spriteInEffect = item;
                        }
                    }
                    if (spriteInEffect != null && spriteInEffect.IsLive)
                    {
                        spriteInEffect.ResetPlay();
                    }
                    else
                    {
                        user.MagicSpritesInEffect.AddLast(sprite);
                        AddMagicSprite(sprite);
                    }
                }
                break;
                }
            }
            else if (magic.MoveKind == 23)
            {
                if (Globals.TheGame.TimeStoperMagicSprite == null)
                {
                    var sprite = GetFixedPositionMagicSprite(user, magic, origin, destroyOnEnd);
                    Globals.TheGame.TimeStoperMagicSprite = sprite;
                    AddMagicSprite(sprite);
                }
            }
        }
Ejemplo n.º 3
0
        private static MagicSprite GetThrowMagicSprite(Character user, Magic magic, Vector2 origin, Vector2 destination, bool destroyOnEnd)
        {
            var sprite = new MagicSprite(magic,
                                         user,
                                         origin,
                                         magic.Speed * Globals.MagicBasespeed,
                                         Vector2.Zero,
                                         destroyOnEnd);
            var path = new LinkedList <Vector2>();

            path.AddLast(origin);
            var distance = Vector2.Distance(origin, destination);
            var count    = (int)distance / 64;

            if (count < 4)
            {
                count = 4;
            }
            var halfCount  = count / 2;
            var pathUnit   = (destination - origin) / count;
            var offset     = new Vector2[count - 1];
            var offsetUnit = distance / count;

            for (var i = 0; i < count - 1; i++)
            {
                if (i < halfCount - 1)
                {
                    offset[i] = new Vector2(0, -(i + 1) * offsetUnit);
                }
                else
                {
                    offset[i] = new Vector2(0, -(count - i + 1) * offsetUnit);
                }
            }
            for (var i = 0; i < count - 1; i++)
            {
                path.AddLast(origin + (i + 1) * pathUnit + offset[i]);
            }
            path.AddLast(destination);
            sprite.SetPath(path);
            return(sprite);
        }
Ejemplo n.º 4
0
 public WorkItem(float leftMilliseconds, MagicSprite theSprite)
 {
     LeftMilliseconds = leftMilliseconds;
     TheSprite        = theSprite;
 }