public AnimatedItemEffectView(AnimatedItemEffect effect)
            : base(effect)
        {
            m_Animated = true;
            IResourceProvider provider = ServiceRegistry.GetService <IResourceProvider>();

            m_AnimData = provider.GetResource <EffectData>(Effect.ItemID);
        }
Beispiel #2
0
        public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 position, MouseOverList objectList)
        {
            if (GameObject.IsDisposed)
            {
                return(false);
            }
            AnimatedItemEffect effect = (AnimatedItemEffect)GameObject;

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

            Bounds.X  = Texture.Width / 2 - 22 - (int)effect.Offset.X;
            Bounds.Y  = Texture.Height - 44 + (int)(effect.Offset.Z - effect.Offset.Y);
            HueVector = RenderExtentions.GetHueVector(GameObject.Hue);

            return(base.Draw(spriteBatch, position, objectList));
        }
Beispiel #3
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);
            }
        }
Beispiel #4
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);
        }
Beispiel #5
0
        public override bool Draw(Batcher2D batcher, Vector3 position, MouseOverList objectList)
        {
            if (GameObject.IsDisposed)
            {
                return(false);
            }
            AnimatedItemEffect effect = (AnimatedItemEffect)GameObject;

            if (effect.AnimationGraphic == Graphic.INVALID)
            {
                return(false);
            }

            Hue hue = effect.Hue;

            if (effect.Source is Item i)
            {
                if (Engine.Profile.Current.FieldsType == 1 && StaticFilters.IsField(effect.AnimationGraphic))
                {
                    effect.AnimIndex = 0;
                }
                else if (Engine.Profile.Current.FieldsType == 2)
                {
                    if (StaticFilters.IsFireField(effect.Graphic))
                    {
                        effect.AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0020;
                    }
                    else if (StaticFilters.IsParalyzeField(effect.Graphic))
                    {
                        effect.AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0058;
                    }
                    else if (StaticFilters.IsEnergyField(effect.Graphic))
                    {
                        effect.AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0070;
                    }
                    else if (StaticFilters.IsPoisonField(effect.Graphic))
                    {
                        effect.AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0044;
                    }
                    else if (StaticFilters.IsWallOfStone(effect.Graphic))
                    {
                        effect.AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x038A;
                    }
                }
                else if (i.IsHidden)
                {
                    hue = 0x038E;
                }
            }

            if ((effect.AnimationGraphic != _displayedGraphic || Texture == null || Texture.IsDisposed) && effect.AnimationGraphic != Graphic.INVALID)
            {
                _displayedGraphic = effect.AnimationGraphic;
                Texture           = FileManager.Art.GetTexture(effect.AnimationGraphic);
                Bounds            = new Rectangle((Texture.Width >> 1) - 22, Texture.Height - 44, Texture.Width, Texture.Height);
            }

            Bounds.X = (Texture.Width >> 1) - 22 - (int)effect.Offset.X;
            Bounds.Y = Texture.Height - 44 + (int)(effect.Offset.Z - effect.Offset.Y);

            StaticTiles data = FileManager.TileData.StaticData[_displayedGraphic];

            bool isPartial     = data.IsPartialHue;
            bool isTransparent = data.IsTranslucent;

            if (Engine.Profile.Current.NoColorObjectsOutOfRange && GameObject.Distance > World.ViewRange)
            {
                HueVector = new Vector3(0x038E, 1, HueVector.Z);
            }
            else
            {
                HueVector = ShaderHuesTraslator.GetHueVector(hue, isPartial, isTransparent ? .5f : 0, false);
            }

            switch (effect.Blend)
            {
            case GraphicEffectBlendMode.Multiply:
                batcher.SetBlendState(_multiplyBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.Screen:
            case GraphicEffectBlendMode.ScreenMore:
                batcher.SetBlendState(_screenBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.ScreenLess:
                batcher.SetBlendState(_screenLessBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.NormalHalfTransparent:
                batcher.SetBlendState(_normalHalfBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.ShadowBlue:
                batcher.SetBlendState(_shadowBlueBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            default:
                base.Draw(batcher, position, objectList);
                break;
            }

            Engine.DebugInfo.EffectsRendered++;

            return(true);
        }
Beispiel #6
0
 public AnimatedEffectView(AnimatedItemEffect effect) : base(effect)
 {
 }
Beispiel #7
0
 public AnimatedItemEffectView(AnimatedItemEffect effect)
     : base(effect)
 {
     _animated = true;
     _animData = Provider.GetResource <EffectData>(Effect.ItemID);
 }
Beispiel #8
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);
        }
        public override bool Draw(SpriteBatch3D spriteBatch, Vector3 position, MouseOverList objectList)
        {
            if (GameObject.IsDisposed)
            {
                return(false);
            }
            AnimatedItemEffect effect = (AnimatedItemEffect)GameObject;

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

            Bounds.X = (Texture.Width >> 1) - 22 - (int)effect.Offset.X;
            Bounds.Y = Texture.Height - 44 + (int)(effect.Offset.Z - effect.Offset.Y);

            ulong flags = TileData.StaticData[_displayedGraphic].Flags;


            bool isPartial     = TileData.IsPartialHue(flags);
            bool isTransparent = TileData.IsTransparent(flags);

            HueVector = ShaderHuesTraslator.GetHueVector(effect.Hue, isPartial, isTransparent ? .5f : 0, false);

            switch (effect.Blend)
            {
            case GraphicEffectBlendMode.Multiply:
                spriteBatch.SetBlendState(_multiplyBlendState.Value);
                base.Draw(spriteBatch, position, objectList);
                spriteBatch.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.Screen:
            case GraphicEffectBlendMode.ScreenMore:
                spriteBatch.SetBlendState(_screenBlendState.Value);
                base.Draw(spriteBatch, position, objectList);
                spriteBatch.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.ScreenLess:
                spriteBatch.SetBlendState(_screenLessBlendState.Value);
                base.Draw(spriteBatch, position, objectList);
                spriteBatch.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.NormalHalfTransparent:
                spriteBatch.SetBlendState(_normalHalfBlendState.Value);
                base.Draw(spriteBatch, position, objectList);
                spriteBatch.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.ShadowBlue:
                spriteBatch.SetBlendState(_shadowBlueBlendState.Value);
                base.Draw(spriteBatch, position, objectList);
                spriteBatch.SetBlendState(null);
                break;

            default:
                base.Draw(spriteBatch, position, objectList);
                break;
            }


            return(true);
        }
Beispiel #10
0
 public AnimatedItemEffectView(AnimatedItemEffect effect)
     : base(effect)
 {
     m_Animated = true;
     m_AnimData = AnimData.GetAnimData(Effect.ItemID & 0x3fff);
 }