Ejemplo n.º 1
0
        private void ParseGraphicalEffects(Internal.CommunicationStream message)
        {
            var initialPosition = message.ReadPosition();
            int modifier        = message.ReadUnsignedByte();

            Appearances.AppearanceInstance effect = null;
            byte effectId = 0;

            var    fromPosition    = initialPosition;
            ushort unclampedOffset = 0;

            while (modifier != 0)
            {
                if (modifier == 1)
                {
                    unclampedOffset = message.ReadUnsignedShort();
                    int offset = unclampedOffset % 256;
                    fromPosition.x += offset % Constants.MapSizeX;
                    fromPosition.y += offset / Constants.MapSizeX;
                }

                // the effect is far away from the initial position
                while (fromPosition.x - initialPosition.x >= Constants.MapSizeX)
                {
                    fromPosition.x -= Constants.MapSizeX;
                    fromPosition.y++;
                }

                if ((unclampedOffset >= 1024 && modifier == 1) || (modifier & 3) == 0)
                {
                    effectId = message.ReadUnsignedByte();
                    int deltaX     = message.ReadSignedByte();
                    int deltaY     = message.ReadSignedByte();
                    var toPosition = new Vector3Int(fromPosition.x + deltaX, fromPosition.y + deltaY, fromPosition.z);
                    effect = AppearanceStorage.CreateMissileInstance(effectId, fromPosition, toPosition);
                }
                else if (unclampedOffset >= 768 || modifier == 3)
                {
                    effectId = message.ReadUnsignedByte();
                    effect   = AppearanceStorage.CreateEffectInstance(effectId);
                }
                else
                {
                    throw new System.NotImplementedException();
                }

                if (!effect)
                {
                    throw new System.Exception("ProtocolGame.ParseGraphicalEffects: Unknown effect: " + effectId);
                }

                WorldMapStorage.AppendEffect(fromPosition, effect);
                modifier = message.ReadUnsignedByte();
            }
        }
Ejemplo n.º 2
0
        private void ParseMissleEffect(Internal.CommunicationStream message)
        {
            var  fromPosition = message.ReadPosition();
            var  toPosition   = message.ReadPosition();
            byte missleId     = message.ReadUnsignedByte();

            var missle = AppearanceStorage.CreateMissileInstance(missleId, fromPosition, toPosition);

            if (!missle)
            {
                throw new System.Exception("ProtocolGame.ParseMissleEffect: Unknown missle id: " + missleId);
            }

            WorldMapStorage.AppendEffect(fromPosition, missle);
        }