Пример #1
0
        public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 position, MouseOverList objectList)
        {
            if (GameObject.IsDisposed)
            {
                return(false);
            }
            MovingEffect effect = (MovingEffect)GameObject;

            position.X += effect.Offset.X;
            position.Y += effect.Offset.Y + effect.Offset.Z;



            if (effect.AnimationGraphic != _displayedGraphic || Texture == null || Texture.IsDisposed)
            {
                _displayedGraphic = effect.AnimationGraphic;
                Texture           = Art.GetStaticTexture(effect.AnimationGraphic);
                Bounds            = new Rectangle(0, 0, Texture.Width, Texture.Height);
                //Bounds = new Rectangle(Texture.Width / 2 - 22, Texture.Height - 44, Texture.Width, Texture.Height);
            }

            //Bounds.X = (int)-effect.Offset.X;
            //Bounds.Y = (int)(effect.Offset.Z - effect.Offset.Y);

            //Bounds.X = -(int) ((effect.Offset.X - effect.Offset.Y) * 22);
            //Bounds.Y = (int) ((effect.Offset.Z * 4 /*- effect.Position.Z * 4*/ ) ) - (int) ((effect.Offset.X + effect.Offset.Y) * 22);
            Rotation  = effect.AngleToTarget;
            HueVector = RenderExtentions.GetHueVector(GameObject.Hue);

            return(base.Draw(spriteBatch, position, objectList));
        }
Пример #2
0
        public override bool Draw(Batcher2D batcher, Vector3 position, MouseOverList list)
        {
            if (GameObject.IsDisposed)
            {
                return(false);
            }
            MovingEffect effect = (MovingEffect)GameObject;

            if (effect.AnimationGraphic != _displayedGraphic || Texture == null || Texture.IsDisposed)
            {
                _displayedGraphic = effect.AnimationGraphic;
                Texture           = FileManager.Art.GetTexture(effect.AnimationGraphic);
                Bounds            = new Rectangle(0, 0, Texture.Width, Texture.Height);
            }

            Bounds.X = (int)-effect.Offset.X;
            Bounds.Y = (int)(effect.Offset.Z - effect.Offset.Y);
            Rotation = effect.AngleToTarget;
            if (Engine.Profile.Current.NoColorObjectsOutOfRange && GameObject.Distance > World.ViewRange)
            {
                HueVector = new Vector3(0x038E, 1, HueVector.Z);
            }
            else
            {
                HueVector = ShaderHuesTraslator.GetHueVector(GameObject.Hue);
            }
            Engine.DebugInfo.EffectsRendered++;
            return(base.Draw(batcher, position, list));
        }
Пример #3
0
 public MovingEffectView(MovingEffect effect)
     : base(effect)
 {
     _animated = TileData.ItemData[Effect.ItemID & FileManager.ItemIDMask].IsAnimation;
     if (_animated)
     {
         _animData = Provider.GetResource <EffectData>(Effect.ItemID);
         _animated = _animData.FrameCount > 0;
     }
 }
Пример #4
0
 public MovingEffectView(MovingEffect effect)
     : base(effect)
 {
     m_Animated = TileData.ItemData[Effect.ItemID & FileManager.ItemIDMask].IsAnimation;
     if (m_Animated)
     {
         IResourceProvider provider = ServiceRegistry.GetService <IResourceProvider>();
         m_AnimData = provider.GetResource <EffectData>(Effect.ItemID);
         m_Animated = m_AnimData.FrameCount > 0;
     }
 }
Пример #5
0
 public MovingEffectView(MovingEffect effect)
     : base(effect)
 {
     m_Animated = true;
     m_Animated = UltimaData.TileData.ItemData[Effect.ItemID & 0x3fff].IsAnimation;
     if (m_Animated)
     {
         m_AnimData = AnimData.GetAnimData(Effect.ItemID & 0x3fff);
         m_Animated = m_AnimData.FrameCount > 0;
     }
 }
Пример #6
0
        public static void SendMovingParticles(IEntity from, IEntity to, int itemID, int speed, int duration, bool fixedDirection, bool explodes, int hue, int renderMode, int effect, int explodeEffect, int explodeSound, EffectLayer layer, int unknown)
        {
            if (from is Mobile)
            {
                ((Mobile)from).ProcessDelta();
            }

            if (to is Mobile)
            {
                ((Mobile)to).ProcessDelta();
            }

            Map map = from.Map;

            if (map != null)
            {
                Packet particles = null, regular = null;

                IPooledEnumerable eable = map.GetClientsInRange(from.Location);

                foreach (NetState state in eable)
                {
                    state.Mobile.ProcessDelta();

                    if (SendParticlesTo(state))
                    {
                        if (particles == null)
                        {
                            particles = new MovingParticleEffect(from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, layer, unknown);
                        }

                        state.Send(particles);
                    }
                    else if (itemID > 1)
                    {
                        if (regular == null)
                        {
                            regular = new MovingEffect(from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode);
                        }

                        state.Send(regular);
                    }
                }

                eable.Free();
            }

            //SendPacket( from.Location, from.Map, new MovingParticleEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, unknown ) );
        }
Пример #7
0
        public static void SendMovingParticles(IEntity from, IEntity to, int itemID, int speed, int duration, bool fixedDirection, bool explodes, int hue, int renderMode, int effect, int explodeEffect, int explodeSound, EffectLayer layer, int unknown)
        {
            if ((from is Mobile))
            {
                ((Mobile)from).ProcessDelta();
            }
            if ((to is Mobile))
            {
                ((Mobile)to).ProcessDelta();
            }
            Map map1 = from.Map;

            if (map1 == null)
            {
                return;
            }
            Packet            packet1     = null;
            Packet            packet2     = null;
            IPooledEnumerable enumerable1 = map1.GetClientsInRange(from.Location);

            foreach (NetState state1 in enumerable1)
            {
                state1.Mobile.ProcessDelta();
                if (Effects.SendParticlesTo(state1))
                {
                    if (packet1 == null)
                    {
                        packet1 = new MovingParticleEffect(from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, layer, unknown);
                    }
                    state1.Send(packet1);
                    continue;
                }
                if (itemID > 1)
                {
                    if (packet2 == null)
                    {
                        packet2 = new MovingEffect(from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode);
                    }
                    state1.Send(packet2);
                }
            }
            enumerable1.Free();
        }
Пример #8
0
        public override bool Draw(Batcher2D batcher, Vector3 position, MouseOverList list)
        {
            if (GameObject.IsDisposed)
            {
                return(false);
            }
            MovingEffect effect = (MovingEffect)GameObject;

            if (effect.AnimationGraphic != _displayedGraphic || Texture == null || Texture.IsDisposed)
            {
                _displayedGraphic = effect.AnimationGraphic;
                Texture           = Art.GetStaticTexture(effect.AnimationGraphic);
                Bounds            = new Rectangle(0, 0, Texture.Width, Texture.Height);
            }

            Bounds.X  = (int)-effect.Offset.X;
            Bounds.Y  = (int)(effect.Offset.Z - effect.Offset.Y);
            Rotation  = effect.AngleToTarget;
            HueVector = ShaderHuesTraslator.GetHueVector(GameObject.Hue);

            return(base.Draw(batcher, position, list));
        }
Пример #9
0
        public static void Add(GraphicEffectPacket packet)
        {
            bool hasHueData   = (packet as GraphicEffectHuedPacket != null);
            bool hasParticles = (packet as GraphicEffectExtendedPacket != null); // we don't yet handle these.

            if (hasParticles)
            {
                Core.Diagnostics.Logger.Warn("Unhandled particles in an effects packet.");
            }

            AEffect effect = null;
            int     hue    = hasHueData ? ((GraphicEffectHuedPacket)packet).Hue : 0;
            int     blend  = hasHueData ? (int)((GraphicEffectHuedPacket)packet).BlendMode : 0;

            switch (packet.EffectType)
            {
            case GraphicEffectType.Moving:
                if (packet.ItemID <= 0)
                {
                    return;
                }
                effect = new MovingEffect(m_Model.Map, packet.SourceSerial, packet.TargetSerial,
                                          packet.SourceX, packet.SourceY, packet.SourceZ,
                                          packet.TargetX, packet.TargetY, packet.TargetZ,
                                          packet.ItemID, hue);
                effect.BlendMode = blend;
                if (packet.DoesExplode)
                {
                    effect.Children.Add(new AnimatedItemEffect(m_Model.Map, packet.TargetSerial,
                                                               packet.TargetX, packet.TargetY, packet.TargetZ,
                                                               0x36cb, hue, 9));
                }
                break;

            case GraphicEffectType.Lightning:
                effect = new LightningEffect(m_Model.Map, packet.SourceSerial,
                                             packet.SourceX, packet.SourceY, packet.SourceZ, hue);
                break;

            case GraphicEffectType.FixedXYZ:
                if (packet.ItemID <= 0)
                {
                    return;
                }
                effect = new AnimatedItemEffect(m_Model.Map,
                                                packet.SourceX, packet.SourceY, packet.SourceZ,
                                                packet.ItemID, hue, packet.Duration);
                effect.BlendMode = blend;
                break;

            case GraphicEffectType.FixedFrom:
                if (packet.ItemID <= 0)
                {
                    return;
                }
                effect = new AnimatedItemEffect(m_Model.Map, packet.SourceSerial,
                                                packet.SourceX, packet.SourceY, packet.SourceZ,
                                                packet.ItemID, hue, packet.Duration);
                effect.BlendMode = blend;
                break;

            case GraphicEffectType.ScreenFade:
                Core.Diagnostics.Logger.Warn("Unhandled screen fade effect.");
                break;

            default:
                Core.Diagnostics.Logger.Warn("Unhandled effect.");
                return;
            }

            if (effect != null)
            {
                Add(effect);
            }
        }
Пример #10
0
        public void Add
        (
            GraphicEffectType type,
            uint source, uint target,
            ushort graphic,
            ushort hue,
            ushort srcX, ushort srcY, sbyte srcZ,
            ushort targetX, ushort targetY, sbyte targetZ,
            byte speed, int duration, bool fixedDir, bool doesExplode, bool hasparticles, GraphicEffectBlendMode blendmode
        )
        {
            if (hasparticles)
            {
                Log.Warn("Unhandled particles in an effects packet.");
            }

            GameEffect effect = null;

            if (hue != 0)
            {
                hue++;
            }

            duration *= Constants.ITEM_EFFECT_ANIMATION_DELAY;

            switch (type)
            {
            case GraphicEffectType.Moving:
                if (graphic <= 0)
                {
                    return;
                }

                if (speed == 0)
                {
                    speed++;
                }

                effect = new MovingEffect(source, target, srcX, srcY, srcZ, targetX, targetY, targetZ, graphic, hue, fixedDir, speed)
                {
                    Blend = blendmode
                };

                if (doesExplode)
                {
                    effect.AddChildEffect(new AnimatedItemEffect(target, targetX, targetY, targetZ, 0x36Cb, hue, 9, speed));
                }

                break;

            case GraphicEffectType.Lightning:
                effect = new LightningEffect(source, srcX, srcY, srcZ, hue);

                break;

            case GraphicEffectType.FixedXYZ:

                if (graphic <= 0)
                {
                    return;
                }

                effect = new AnimatedItemEffect(srcX, srcY, srcZ, graphic, hue, duration, speed)
                {
                    Blend = blendmode
                };

                break;

            case GraphicEffectType.FixedFrom:

                if (graphic <= 0)
                {
                    return;
                }

                effect = new AnimatedItemEffect(source, srcX, srcY, srcZ, graphic, hue, duration, speed)
                {
                    Blend = blendmode
                };

                break;

            case GraphicEffectType.ScreenFade:
                Log.Warn("Unhandled 'Screen Fade' effect.");

                break;

            default:
                Log.Warn("Unhandled effect.");

                return;
            }


            Add(effect);
        }
Пример #11
0
 public MovingEffectView(MovingEffect effect) : base(effect)
 {
 }
Пример #12
0
        public void Add(GraphicEffectType type, Serial source, Serial target, Graphic graphic, Hue hue, Position srcPos, Position targPos, byte speed, int duration, bool fixedDir, bool doesExplode, bool hasparticles, GraphicEffectBlendMode blendmode)
        {
            if (hasparticles)
            {
                Log.Message(LogTypes.Warning, "Unhandled particles in an effects packet.");
            }
            GameEffect effect = null;

            switch (type)
            {
            case GraphicEffectType.Moving:

                if (graphic <= 0)
                {
                    return;
                }

                if (speed == 0)
                {
                    speed++;
                }

                effect = new MovingEffect(source, target, srcPos.X, srcPos.Y, srcPos.Z, targPos.X, targPos.Y, targPos.Z, graphic, hue)
                {
                    Blend = blendmode, MovingDelay = speed
                };

                if (doesExplode)
                {
                    effect.AddChildEffect(new AnimatedItemEffect(target, targPos.X, targPos.Y, targPos.Z, 0x36Cb, hue, 9));
                }

                break;

            case GraphicEffectType.Lightning:
                effect = new LightningEffect(source, srcPos.X, srcPos.Y, srcPos.Z, hue);

                break;

            case GraphicEffectType.FixedXYZ:

                if (graphic <= 0)
                {
                    return;
                }

                effect = new AnimatedItemEffect(srcPos.X, srcPos.Y, srcPos.Z, graphic, hue, duration)
                {
                    Blend = blendmode
                };

                break;

            case GraphicEffectType.FixedFrom:

                if (graphic <= 0)
                {
                    return;
                }

                effect = new AnimatedItemEffect(source, srcPos.X, srcPos.Y, srcPos.Z, graphic, hue, duration)
                {
                    Blend = blendmode
                };
                break;

            case GraphicEffectType.ScreenFade:
                Log.Message(LogTypes.Warning, "Unhandled 'Screen Fade' effect.");

                break;

            default:
                Log.Message(LogTypes.Warning, "Unhandled effect.");

                return;
            }


            Add(effect);
        }
Пример #13
0
        public void CreateEffect
        (
            GraphicEffectType type,
            uint source,
            uint target,
            ushort graphic,
            ushort hue,
            ushort srcX,
            ushort srcY,
            sbyte srcZ,
            ushort targetX,
            ushort targetY,
            sbyte targetZ,
            byte speed,
            int duration,
            bool fixedDir,
            bool doesExplode,
            bool hasparticles,
            GraphicEffectBlendMode blendmode
        )
        {
            if (hasparticles)
            {
                Log.Warn("Unhandled particles in an effects packet.");
            }

            GameEffect effect;

            if (hue != 0)
            {
                hue++;
            }

            duration *= Constants.ITEM_EFFECT_ANIMATION_DELAY;

            switch (type)
            {
            case GraphicEffectType.Moving:
                if (graphic <= 0)
                {
                    return;
                }

                // TODO: speed == 0 means run at standard frameInterval got from anim.mul?
                if (speed == 0)
                {
                    speed++;
                }

                effect = new MovingEffect
                         (
                    this,
                    source,
                    target,
                    srcX,
                    srcY,
                    srcZ,
                    targetX,
                    targetY,
                    targetZ,
                    graphic,
                    hue,
                    fixedDir,
                    duration,
                    speed
                         )
                {
                    Blend = blendmode,
                    CanCreateExplosionEffect = doesExplode
                };

                break;

            case GraphicEffectType.DragEffect:

                if (graphic <= 0)
                {
                    return;
                }

                if (speed == 0)
                {
                    speed++;
                }

                effect = new DragEffect
                         (
                    this,
                    source,
                    target,
                    srcX,
                    srcY,
                    srcZ,
                    targetX,
                    targetY,
                    targetZ,
                    graphic,
                    hue,
                    duration,
                    speed
                         )
                {
                    Blend = blendmode,
                    CanCreateExplosionEffect = doesExplode
                };

                break;

            case GraphicEffectType.Lightning:
                effect = new LightningEffect
                         (
                    this,
                    source,
                    srcX,
                    srcY,
                    srcZ,
                    hue
                         );

                break;

            case GraphicEffectType.FixedXYZ:

                if (graphic <= 0)
                {
                    return;
                }

                effect = new FixedEffect
                         (
                    this,
                    srcX,
                    srcY,
                    srcZ,
                    graphic,
                    hue,
                    duration,
                    0     //speed [use 50ms]
                         )
                {
                    Blend = blendmode
                };

                break;

            case GraphicEffectType.FixedFrom:

                if (graphic <= 0)
                {
                    return;
                }

                effect = new FixedEffect
                         (
                    this,
                    source,
                    srcX,
                    srcY,
                    srcZ,
                    graphic,
                    hue,
                    duration,
                    0     //speed [use 50ms]
                         )
                {
                    Blend = blendmode
                };

                break;

            case GraphicEffectType.ScreenFade:
                Log.Warn("Unhandled 'Screen Fade' effect.");

                return;

            default:
                Log.Warn("Unhandled effect.");

                return;
            }


            PushToBack(effect);
        }