Beispiel #1
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            uint argb = message.GetUInt(0);

            WorldConnection worldCon = (WorldConnection)connectionBase;
            FluidColor      color    = new FluidColor(argb);

            if (!handled)
            {
                worldCon.World.BackgroundColor = color;
            }

            BackgroundColorChangedEvent backgroundColorChangedEvent = new BackgroundColorChangedEvent()
            {
                Raw   = message,
                Color = color
            };

            connectionBase.RaiseServerEvent <BackgroundColorChangedEvent>(backgroundColorChangedEvent);
        }
Beispiel #2
0
        private void DrawFluid(SKPaintSurfaceEventArgs e)
        {
            SKImageInfo info    = e.Info;
            SKSurface   surface = e.Surface;
            SKCanvas    canvas  = surface.Canvas;
            SKPoint     center  = new SKPoint(info.Width / 2, info.Height / 2);

            // fluid
            SKPaint fluidPaint = new SKPaint
            {
                IsAntialias = true,
                Style       = SKPaintStyle.Fill,
                Color       = FluidColor.ToSKColor(),
            };

            // fluid bottom
            canvas.DrawCircle(center.X, info.Height + bottomFluidGlassCircleCenterY, bottomFluidGlassHullRadius - fluidHullPadding, fluidPaint);

            // draw live
            float livePixelsYStart = info.Height + bottomFluidGlassCircleCenterY - bottomFluidGlassHullRadius - startMarkerDistance;
            float livePixelsYEnd   = topFluidGlassCircleCenterY;

            // map real temp to pixels from marker start to end
            FixMaxMin();
            float temperatureY = Temperature.Map(MinTemperature, MaxTemperature, livePixelsYStart, livePixelsYEnd);

            // fluid top
            SKRect fluidTop = new SKRect
            {
                Top    = temperatureY,
                Left   = center.X - (topFluidGlassWidth / 2) + fluidHullPadding,
                Right  = center.X + (topFluidGlassWidth / 2) - fluidHullPadding,
                Bottom = info.Height + bottomFluidGlassCircleCenterY
            };

            canvas.DrawRect(fluidTop, fluidPaint);
        }
Beispiel #3
0
 /// <summary>
 /// Creates a label block
 /// </summary>
 /// <param name="worldCon">The world connection</param>
 /// <param name="blockId">the block ID</param>
 /// <param name="x">The x coorindate</param>
 /// <param name="y">The y coordinate</param>
 /// <param name="text">The text of the block</param>
 public LabelBlock(WorldConnection worldCon, BlockID blockId, int x, int y, string text)
     : base(worldCon, blockId, x, y, text)
 {
     Color = new FluidColor(255, 255, 255);
 }
Beispiel #4
0
 /// <summary>
 /// Creates a label block
 /// </summary>
 /// <param name="blockId">the block ID</param>
 /// <param name="x">The x coorindate</param>
 /// <param name="y">The y coordinate</param>
 /// <param name="text">The text of the block</param>
 public LabelBlock(BlockID blockId, int x, int y, string text)
     : base(blockId, x, y, text)
 {
     Color = new FluidColor(255, 255, 255);
 }
Beispiel #5
0
 /// <summary>
 /// Creates a label block
 /// </summary>
 /// <param name="blockId">the block ID</param>
 /// <param name="x">The x coorindate</param>
 /// <param name="y">The y coordinate</param>
 /// <param name="text">The text of the block</param>
 public LabelBlock(BlockID blockId, int x, int y, string text, string hexColor)
     : base(blockId, x, y, text)
 {
     Color = new FluidColor(hexColor);
 }
Beispiel #6
0
        protected void UpdateSpecialPattern()
        {
            _hasSpecialPattern = false;
            if (!_type || _type.IsCreature)
            {
                return;
            }

            if (_type.IsStackable)
            {
                _hasSpecialPattern = true;
                if (_data < 2)
                {
                    _specialPatternX = 0;
                    _specialPatternY = 0;
                }
                else if (_data == 2)
                {
                    _specialPatternX = 1;
                    _specialPatternY = 0;
                }
                else if (_data == 3)
                {
                    _specialPatternX = 2;
                    _specialPatternY = 0;
                }
                else if (_data == 4)
                {
                    _specialPatternX = 3;
                    _specialPatternY = 0;
                }
                else if (_data < 10)
                {
                    _specialPatternX = 0;
                    _specialPatternY = 1;
                }
                else if (_data < 25)
                {
                    _specialPatternX = 1;
                    _specialPatternY = 1;
                }
                else if (_data < 50)
                {
                    _specialPatternX = 2;
                    _specialPatternY = 1;
                }
                else
                {
                    _specialPatternX = 3;
                    _specialPatternY = 1;
                }

                _specialPatternX = _specialPatternX % (int)_type.FrameGroups[(int)Protobuf.Shared.FrameGroupType.Idle].SpriteInfo.PatternWidth;
                _specialPatternY = _specialPatternY % (int)_type.FrameGroups[(int)Protobuf.Shared.FrameGroupType.Idle].SpriteInfo.PatternHeight;
            }
            else if (_type.IsSplash || _type.IsFluidContainer)
            {
                _hasSpecialPattern = true;
                FluidColor color = FluidColor.Transparent;
                if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameNewFluids))
                {
                    switch ((FluidType)_data)
                    {
                    case FluidType.None:
                        color = FluidColor.Transparent;
                        break;

                    case FluidType.Water:
                        color = FluidColor.Blue;
                        break;

                    case FluidType.Mana:
                        color = FluidColor.Purple;
                        break;

                    case FluidType.Beer:
                        color = FluidColor.Brown;
                        break;

                    case FluidType.Oil:
                        color = FluidColor.Brown;
                        break;

                    case FluidType.Blood:
                        color = FluidColor.Red;
                        break;

                    case FluidType.Slime:
                        color = FluidColor.Green;
                        break;

                    case FluidType.Mud:
                        color = FluidColor.Brown;
                        break;

                    case FluidType.Lemonade:
                        color = FluidColor.Yellow;
                        break;

                    case FluidType.Milk:
                        color = FluidColor.White;
                        break;

                    case FluidType.Wine:
                        color = FluidColor.Purple;
                        break;

                    case FluidType.Health:
                        color = FluidColor.Red;
                        break;

                    case FluidType.Urine:
                        color = FluidColor.Yellow;
                        break;

                    case FluidType.Rum:
                        color = FluidColor.Brown;
                        break;

                    case FluidType.FruidJuice:
                        color = FluidColor.Yellow;
                        break;

                    case FluidType.CoconutMilk:
                        color = FluidColor.White;
                        break;

                    case FluidType.Tea:
                        color = FluidColor.Brown;
                        break;

                    case FluidType.Mead:
                        color = FluidColor.Brown;
                        break;

                    default:
                        color = FluidColor.Blue;
                        break;
                    }
                }
                else
                {
                    color = (FluidColor)_data;
                }

                _specialPatternX = ((int)color & 3) % (int)_type.FrameGroups[(int)Protobuf.Shared.FrameGroupType.Idle].SpriteInfo.PatternWidth;
                _specialPatternY = ((int)color >> 2) % (int)_type.FrameGroups[(int)Protobuf.Shared.FrameGroupType.Idle].SpriteInfo.PatternHeight;
            }
            else if (_type.IsHangable)
            {
                _hasSpecialPattern = true;
                if (_hang == AppearanceInstance.HookSouth)
                {
                    _specialPatternX = _type.FrameGroups[(int)Protobuf.Shared.FrameGroupType.Idle].SpriteInfo.PatternWidth >= 2 ? 1 : 0;
                    _specialPatternY = 0;
                }
                else if (_hang == AppearanceInstance.HookEast)
                {
                    _specialPatternX = _type.FrameGroups[(int)Protobuf.Shared.FrameGroupType.Idle].SpriteInfo.PatternWidth >= 3 ? 2 : 0;
                    _specialPatternY = 0;
                }
                else
                {
                    _specialPatternX = 0;
                    _specialPatternY = 0;
                }
            }
        }