public void PublicFieldValueOnImplementedInterfaceType()
        {
            string     barTestValue = "my bar";
            BarMessage message      = new BarMessage(string.Empty, barTestValue);

            AbstractConstraint baseConstraint = PublicField.Value(typeof(FooMessage), "BarField", barTestValue);

            Assert.True(baseConstraint.Eval(message), "Returned false when field was correct and field was declared in supplied type..");

            AbstractConstraint constraint = PublicField.Value(typeof(BarMessage), "BarField", barTestValue);

            Assert.False(constraint.Eval(message), "Returned true when field was correct but type was not declared on the suppleid type.");
        }
Esempio n. 2
0
        private void ProcessInput()
        {
            // Begin with processing input
            if (System.Console.KeyAvailable)
            {
                // We have input, process accordingly
                var userKey = System.Console.ReadKey();

                switch (userKey.Key)
                {
                case ConsoleKey.Enter:

                    // create test message
                    var foo = new FooMessage();
                    foo.FloatX   = 12.98f;
                    foo.IntY     = 3985;
                    foo.Name     = "This isn't not a test!";
                    foo.Birthday = DateTime.Now;
                    foo.Vector   = new Vector2 {
                        X = -9.1f, Y = 88.7f
                    };

                    // for testing, print what it is
                    Console.WriteLine("Sending to server: '" + foo.ToString() + "'");

                    // send test message to server
                    this.NetworkClient.SendToServer((int)TestMessageTypes.Foo, foo);

                    break;

                case ConsoleKey.Spacebar:

                    // create test message
                    var bar = new BarMessage();
                    bar.TimeOriginallySent = DateTime.Now;

                    // for testing, print what it is
                    Console.WriteLine("Sending to server: '" + bar.ToString() + "'");

                    // send test message to server
                    this.NetworkClient.SendToServer((int)TestMessageTypes.Bar, bar);

                    break;
                }
            }
        }
Esempio n. 3
0
    private void Beat()
    {
        lastBeatTime = Time.time;
        halfBeatCounter++;

        BeatMessage beatMessage = new BeatMessage();

        beatMessage.Sender        = gameObject;
        beatMessage.HalfBeatCount = HalfBeatCount;

        MessageBus.Instance.SendMessage(beatMessage);

        if (halfBeatCounter >= beatsPerBar * 2)
        {
            ResetBeatCounter();
            BarMessage barMessage = new BarMessage();
            barMessage.Sender = gameObject;
            MessageBus.Instance.SendMessage(barMessage);
        }
    }
        private void HandleMessages()
        {
            if (messageQueue == null)
            {
                return;
            }
            ArrayList q = (ArrayList)messageQueue.Clone();

            messageQueue.Clear();

            foreach (MDMessage msg in q)
            {
                if (msg is DebugMessage)
                {
                    if (DebugLog == null)
                    {
                        continue;
                    }

                    DebugMessage msg2 = (DebugMessage)msg;
                    DebugLog(msg2.message);
                    continue;
                }
                if (msg is NoteOnMessage)
                {
                    if (NoteOn == null)
                    {
                        continue;
                    }

                    NoteOnMessage msg2 = (NoteOnMessage)msg;
                    NoteOn(msg2.part, msg2.num, msg2.velocity);
                    continue;
                }
                if (msg is NoteOffMessage)
                {
                    if (NoteOff == null)
                    {
                        continue;
                    }

                    NoteOffMessage msg2 = (NoteOffMessage)msg;
                    NoteOff(msg2.part, msg2.num);
                    continue;
                }
                if (msg is ParamChangeMessage)
                {
                    if (ParamChange == null)
                    {
                        continue;
                    }

                    ParamChangeMessage msg2 = (ParamChangeMessage)msg;
                    ParamChange(msg2.part, msg2.param, msg2.value);
                    continue;
                }
                if (msg is BeatTickMessage)
                {
                    if (BeatTick == null)
                    {
                        continue;
                    }

                    BeatTickMessage msg2 = (BeatTickMessage)msg;
                    BeatTick(msg2.tick, msg2.beat, msg2.bar);
                    continue;
                }
                if (msg is BeatMessage)
                {
                    if (Beat == null)
                    {
                        continue;
                    }

                    BeatMessage msg2 = (BeatMessage)msg;
                    Beat(msg2.beat, msg2.bar);
                    continue;
                }
                if (msg is BarMessage)
                {
                    if (Bar == null)
                    {
                        continue;
                    }

                    BarMessage msg2 = (BarMessage)msg;
                    Bar(msg2.bar);
                    continue;
                }
                if (msg is TempoChangeMessage)
                {
                    if (TempoChange == null)
                    {
                        continue;
                    }

                    TempoChangeMessage msg2 = (TempoChangeMessage)msg;
                    TempoChange(msg2.bpm);
                    continue;
                }
                if (msg is NewMusicalSeedMessage)
                {
                    if (NewMusicalSeed == null)
                    {
                        continue;
                    }

                    NewMusicalSeedMessage msg2 = (NewMusicalSeedMessage)msg;
                    NewMusicalSeed(msg2.name);
                    continue;
                }
                if (msg is CueChangeMessage)
                {
                    if (CueChange == null)
                    {
                        continue;
                    }

                    CueChangeMessage msg2 = (CueChangeMessage)msg;
                    CueChange(msg2.cue, msg2.seedName, msg2.style);
                    continue;
                }
                if (msg is ProjectLoadMessage)
                {
                    if (ProjectLoad == null)
                    {
                        continue;
                    }

                    //ProjectLoadMessage msg2 = (ProjectLoadMessage)msg;
                    ProjectLoad();
                    continue;
                }
            }
        }
Esempio n. 5
0
        public void _RecvHandler(ProxySocket Socket, uint Serial, NewProxy Proxy, ref MemoryStream Buffer)
        {
            Packet Packet = new Packet(Buffer.ToArray());

            try
            {
                switch ((ServerAction)Packet.Action)
                {
                    #region Location
                case ServerAction.Location:
                {
                    PlayerLocation Loc = Packet.Read <PlayerLocation>(0);
                    Clients[Serial].Aisling.Location.X  = Loc.X;
                    Clients[Serial].Aisling.Location.Y  = Loc.Y;
                    Clients[Serial].Aisling.LastRefresh = DateTime.Now;
                } break;

                    #endregion
                    #region Map Info
                case ServerAction.MapInfo:
                {
                    MapInfo Info = Packet.Read <MapInfo>(0);
                    Clients[Serial].Aisling.Location.Map = Info.MapNumber;
                    //if (Clients[Serial].Aisling.Map.Number != Info.MapNumber)
                    Clients[Serial].Aisling.Map.Entities.Clear();
                    Clients[Serial].Aisling.Map.Number = Info.MapNumber;
                    Clients[Serial].Aisling.Map.Width  = Info.TileX;
                    Clients[Serial].Aisling.Map.Height = Info.TileY;
                    new System.Threading.Thread(new System.Threading.ThreadStart(Clients[Serial].WaitForMapLoad)).Start();
                    Clients[Serial].Aisling.LastRefresh = DateTime.Now;
                } break;

                    #endregion
                    #region Animation
                case ServerAction.Animation:
                {
                    string PString = Packet.GetPacketString(Packet.Data);
                    Net.ServerStructs.Animation AnimationStruct = Packet.Read <Net.ServerStructs.Animation>(0);
                    Types.Animation             Animation       = new Types.Animation(AnimationStruct.ToWho, AnimationStruct.FromWho, AnimationStruct.Number, AnimationStruct.Speed);
                    Clients[Serial].Aisling.Map.Entities[Animation.ToWho].Animations.Add(Animation);
                    if (Clients[Serial].Aisling.Map.Entities[Animation.ToWho].Animations.Count > 30)
                    {
                        Clients[Serial].Aisling.Map.Entities[Animation.ToWho].Animations =
                            new List <Types.Animation>(
                                from var
                                in Clients[Serial].Aisling.Map.Entities[Animation.ToWho].Animations
                                where var.TimeElapsed < new TimeSpan(0, 5, 0)
                                select var
                                );
                    }
                    if (AnimationStruct.ToWho == Clients[Serial].Aisling.Serial)
                    {
                        Clients[Serial].Aisling.Animations.Add(Animation);
                    }
                    else
                    {
                        if (Clients[Serial].Aisling.Map.Entities.ContainsKey(Animation.ToWho) &&
                            Clients[Serial].Aisling.Map.Entities.ContainsKey(Animation.FromWho))
                        {
                            if (Clients[Serial].Aisling.Map.Entities[Animation.FromWho].EntityType == MapEntity.Type.Player)
                            {
                                if (Clients[Serial].Aisling.Map.Entities[Animation.ToWho].EntityType == MapEntity.Type.Monster)
                                {
                                    if (!(Clients[Serial].Aisling.Map.Entities[Animation.FromWho] as AislingEntity).Targets.Contains(Animation.ToWho))
                                    {
                                        (Clients[Serial].Aisling.Map.Entities[Animation.FromWho] as AislingEntity).Targets.Add(Animation.ToWho);
                                    }
                                }
                                foreach (MapEntity Entity in Clients[Serial].Aisling.Map.FindEntities((MapEntity MapEnt) => MapEnt.EntityType == MapEntity.Type.Monster && MapEnt.Serial == Animation.ToWho))
                                {
                                    (Entity as Monster).Animations.Add(Animation);
                                }
                                (Clients[Serial].Aisling.Map.Entities[Animation.FromWho] as AislingEntity).Targets =
                                    new List <uint>
                                    (
                                        from var in (Clients[Serial].Aisling.Map.Entities[Animation.FromWho] as AislingEntity).Targets
                                        where Clients[Serial].Aisling.Map.Entities.ContainsKey(var)
                                        select var
                                    );
                            }
                        }
                    }
                } break;

                    #endregion
                    #region Skill Slot Info
                case ServerAction.SkillSlotInfo:
                {
                    SkillSlotInfo Info = Packet.Read <SkillSlotInfo>(0);
                    if (Info.Slot <= 36)
                    {
                        Clients[Serial].Aisling.TemSkills[(int)(Info.Slot - 1)] = new SkillSlot()
                        {
                            Icon = Info.Icon,
                            Name = Info.Name
                        };
                    }
                    else if (Info.Slot <= 72)
                    {
                        Clients[Serial].Aisling.MedSkills[(int)(Info.Slot - 37)] = new SkillSlot()
                        {
                            Icon = Info.Icon,
                            Name = Info.Name
                        };
                    }
                    else if (Info.Slot <= 90)
                    {
                        Clients[Serial].Aisling.WorldSkills[(int)(Info.Slot - 73)] = new SkillSlot()
                        {
                            Icon = Info.Icon,
                            Name = Info.Name
                        };
                    }
                } break;

                    #endregion
                    #region Spell Slot Info
                case ServerAction.SpellSlotInfo:
                {
                    SpellSlotInfo Info = Packet.Read <SpellSlotInfo>(0);
                    if (Info.Slot <= 36)
                    {
                        Clients[Serial].Aisling.TemSpells[Info.Slot - 1] = new SpellSlot()
                        {
                            Lines      = Info.Lines,
                            Name       = Info.Name,
                            Prompt     = Info.Prompt,
                            TargetType = Info.TargetType
                        };
                    }
                    else if (Info.Slot <= 72)
                    {
                        Clients[Serial].Aisling.MedSpells[Info.Slot - 37] = new SpellSlot()
                        {
                            Lines      = Info.Lines,
                            Name       = Info.Name,
                            Prompt     = Info.Prompt,
                            TargetType = Info.TargetType
                        };
                    }
                    else if (Info.Slot <= 90)
                    {
                        Clients[Serial].Aisling.WorldSpells[Info.Slot - 73] = new SpellSlot()
                        {
                            Lines      = Info.Lines,
                            Name       = Info.Name,
                            Prompt     = Info.Prompt,
                            TargetType = Info.TargetType
                        };
                    }
                } break;

                    #endregion
                    #region Remove Slot
                case ServerAction.RemoveItem:
                {
                    RemoveSlot Info = Packet.Read <RemoveSlot>(0);
                    Clients[Serial].Aisling.Inventory[Info.Slot - 1] = null;
                } break;

                case ServerAction.RemoveSpell:
                {
                    RemoveSlot Info = Packet.Read <RemoveSlot>(0);
                    if (Info.Slot <= 36)
                    {
                        Clients[Serial].Aisling.TemSpells[(int)(Info.Slot - 1)] = null;
                    }
                    else if (Info.Slot <= 72)
                    {
                        Clients[Serial].Aisling.MedSpells[(int)(Info.Slot - 37)] = null;
                    }
                    else if (Info.Slot <= 90)
                    {
                        Clients[Serial].Aisling.WorldSpells[(int)(Info.Slot - 73)] = null;
                    }
                } break;

                case ServerAction.RemoveSkill:
                {
                    RemoveSlot Info = Packet.Read <RemoveSlot>(0);
                    if (Info.Slot <= 36)
                    {
                        Clients[Serial].Aisling.TemSkills[(int)(Info.Slot - 1)] = null;
                    }
                    else if (Info.Slot <= 72)
                    {
                        Clients[Serial].Aisling.MedSkills[(int)(Info.Slot - 37)] = null;
                    }
                    else if (Info.Slot <= 90)
                    {
                        Clients[Serial].Aisling.WorldSkills[(int)(Info.Slot - 73)] = null;
                    }
                } break;

                    #endregion
                    #region Spell Bar
                case ServerAction.SpellBar:
                {
                    PlayerSpellBar PlayerBar = Packet.Read <PlayerSpellBar>(0);
                    Types.SpellBar SpellBar  = new SpellBar(PlayerBar.Icon, PlayerBar.Color);
                    if (!Clients[Serial].Aisling.SpellBar.ContainsKey(PlayerBar.Icon))
                    {
                        Clients[Serial].Aisling.SpellBar.Add(PlayerBar.Icon, SpellBar);
                    }
                    if (SpellBar.Color == PlayerSpellBar.SpellIconColor.Gone)
                    {
                        Clients[Serial].Aisling.SpellBar.Remove(SpellBar.Icon);
                    }
                } break;

                    #endregion
                    #region Client Walk
                case ServerAction.ClientWalk:
                {
                    ClientSpriteWalk WalkingDirection = Packet.Read <ClientSpriteWalk>(0);
                    Clients[Serial].Aisling.Location.AbsX = WalkingDirection.X;
                    Clients[Serial].Aisling.Location.AbsY = WalkingDirection.Y;
                    switch (WalkingDirection.Direction)
                    {
                    case FaceDirection.Down:
                        Clients[Serial].Aisling.Location.AbsY++;
                        break;

                    case FaceDirection.Up:
                        Clients[Serial].Aisling.Location.AbsY--;
                        break;

                    case FaceDirection.Left:
                        Clients[Serial].Aisling.Location.AbsX--;
                        break;

                    case FaceDirection.Right:
                        Clients[Serial].Aisling.Location.AbsX++;
                        break;
                    }
                    Clients[Serial].Aisling.Location.AbsLocation = WalkingDirection.Direction;
                    Clients[Serial].Aisling.LastBattle           = DateTime.Now;
                } break;

                    #endregion
                    #region HPBar Display
                case ServerAction.DisplayHPBAR:
                {
                    HPBAR EntityBar = Packet.Read <HPBAR>(0);
                    Console.WriteLine(EntityBar.Percent);
                    if (Clients[Serial].Aisling.Map.Entities.ContainsKey(EntityBar.Serial))
                    {
                        Clients[Serial].Aisling.Map.Entities[EntityBar.Serial].HPPercent = EntityBar.Percent;
                    }
                    if (EntityBar.Serial == Clients[Serial].Aisling.Serial)
                    {
                        Clients[Serial].HPPercent = EntityBar.Percent;
                    }
                    foreach (MapEntity Entity in Clients[Serial].Aisling.Map.FindEntities((MapEntity MapEnt) => MapEnt.EntityType == MapEntity.Type.Monster && MapEnt.Serial == EntityBar.Serial))
                    {
                        try
                        {
                            if (EntityBar.Percent < 100)
                            {
                                (Entity as Monster).WasHit = true;
                            }
                            (Clients[Serial].EntityFromSerial(EntityBar.Serial) as Monster).WasPramhed = false;
                            (Clients[Serial].EntityFromSerial(EntityBar.Serial) as Monster).HPPercent  = EntityBar.Percent;
                        }
                        catch { }
                    }
                    //if we hit our target, reset hit count to zero
                    if (Clients[Serial].Aisling.testSer == EntityBar.Serial)
                    {
                        Clients[Serial].Aisling.test = 0;
                        //we hit it, so it's not pramhed
                        Clients[Serial].Aisling.Map.Entities[EntityBar.Serial].WasPramhed = false;
                    }
                } break;

                    #endregion
                    #region Adding Sprites / Monsters / Npcs / Items
                case ServerAction.AddSprites:
                {
                    AddSprites Sprites = AddSprites.FromPacket(Packet);
                    foreach (AddSprites.MonsterSprite Monster in Sprites.Monsters)
                    {
                        if (!Clients[Serial].Aisling.Map.Entities.ContainsKey(Monster.Serial))
                        {
                            Clients[Serial].Aisling.Map.Entities.Add(Monster.Serial, new Monster()
                                {
                                    Icon      = Monster.Icon,
                                    IsPet     = Monster.IsPet,
                                    HPPercent = 100,
                                    Date      = DateTime.Now,
                                    Location  = new Location()
                                    {
                                        X         = Monster.X,
                                        Y         = Monster.Y,
                                        Direction = Monster.Direction,
                                        Map       = Clients[Serial].Aisling.Location.Map
                                    },
                                    Serial = Monster.Serial
                                }
                                                                     );
                        }
                    }
                    foreach (AddSprites.NPCSprite NPC in Sprites.NPCs)
                    {
                        if (Clients[Serial].Aisling.Map.Entities.ContainsKey(NPC.Serial))
                        {
                            Clients[Serial].Aisling.Map.Entities.Remove(NPC.Serial);
                        }
                        Clients[Serial].Aisling.Map.Entities.Add(NPC.Serial, new NPC()
                            {
                                Icon     = NPC.Icon,
                                Location = new Location()
                                {
                                    X         = NPC.X,
                                    Y         = NPC.Y,
                                    Direction = NPC.Direction,
                                    Map       = Clients[Serial].Aisling.Location.Map
                                },
                                Name   = NPC.Name,
                                Serial = NPC.Serial
                            }
                                                                 );
                    }
                    foreach (AddSprites.ItemSprite Item in Sprites.Items)
                    {
                        if (Clients[Serial].Aisling.Map.Entities.ContainsKey(Item.Serial))
                        {
                            Clients[Serial].Aisling.Map.Entities.Remove(Item.Serial);
                        }
                        Clients[Serial].Aisling.Map.Entities.Add(Item.Serial, new Item()
                            {
                                Icon     = Item.Icon,
                                Location = new Location()
                                {
                                    X         = Item.X,
                                    Y         = Item.Y,
                                    Direction = (FaceDirection)FaceDirection.Up,
                                    Map       = Clients[Serial].Aisling.Location.Map,
                                },
                                Serial = Item.Serial
                            }
                                                                 );
                    }
                } break;

                    #endregion
                    #region Adding Players
                case ServerAction.AddPlayer:
                {
                    if (Packet.Data[11] == 0x00 &&
                        Packet.Data[12] == 0x00 &&
                        Packet.Data[13] == 0x00 &&
                        Packet.Data[14] == 0x00)
                    {
                        Packet.Data[13] = 0x50;
                    }
                    if (Packet[11] == 0xFF && Packet[12] == 0xFF)
                    {
                        ShowPlayerForm Info = Packet.Read <ShowPlayerForm>(0);

                        if (Packet.Data[11] == 0x00 &&
                            Packet.Data[12] == 0x00 &&
                            Packet.Data[13] == 0x00 &&
                            Packet.Data[14] == 0x00)
                        {
                            Info.Name = "icube";
                        }
                        if (!(new Location()
                            {
                                X = Info.X, Y = Info.Y
                            }.OnScreenOf(Clients[Serial].Aisling.Location)))
                        {
                            break;
                        }
                        if (Info.Serial == Clients[Serial].Aisling.Serial)
                        {
                            Clients[Serial].Aisling.Location.X = Info.X;
                            Clients[Serial].Aisling.Location.Y = Info.Y;
                        }
                        else
                        {
                            if (Clients[Serial].Aisling.Map.Entities.ContainsKey(Info.Serial))
                            {
                                Clients[Serial].Aisling.Map.Entities.Remove(Info.Serial);
                            }
                            Clients[Serial].Aisling.Map.Entities.Add(Info.Serial, new AislingEntity()
                                {
                                    LegendInfo = new LegendInfo.Entry[0],
                                    Location   = new Location()
                                    {
                                        X         = Info.X,
                                        Y         = Info.Y,
                                        Map       = Clients[Serial].Aisling.Location.Map,
                                        Direction = Info.Direction
                                    },
                                    Name         = Info.Name.value,
                                    Serial       = Info.Serial,
                                    HoverMessage = Info.HoverMessage.value
                                }
                                                                     );
                        }
                    }
                    else
                    {
                        ShowPlayer Info = null;
                        Info = Packet.Read <ShowPlayer>(0);
                        Console.WriteLine(Info.Name);
                        if (!(new Location()
                            {
                                X = Info.X, Y = Info.Y
                            }.OnScreenOf(Clients[Serial].Aisling.Location)))
                        {
                            break;
                        }
                        if (Packet.Data[11] == 0x00 &&
                            Packet.Data[12] == 0x00 &&
                            Packet.Data[13] == 0x00 &&
                            Packet.Data[14] == 0x00)
                        {
                            Info.Name = "icube";
                        }
                        if (Info.Serial == Clients[Serial].Aisling.Serial)
                        {
                            Clients[Serial].Aisling.Location.X = Info.X;
                            Clients[Serial].Aisling.Location.Y = Info.Y;
                        }
                        else
                        {
                            if (Clients[Serial].Aisling.Map.Entities.ContainsKey(Info.Serial))
                            {
                                Clients[Serial].Aisling.Map.Entities.Remove(Info.Serial);
                            }
                            Clients[Serial].Aisling.Map.Entities.Add(Info.Serial, new AislingEntity()
                                {
                                    LegendInfo = new LegendInfo.Entry[0],
                                    Location   = new Location()
                                    {
                                        X         = Info.X,
                                        Y         = Info.Y,
                                        Map       = Clients[Serial].Aisling.Location.Map,
                                        Direction = Info.Direction
                                    },
                                    Name         = Info.Name.value,
                                    Serial       = Info.Serial,
                                    HoverMessage = Info.HoverMessage.value
                                }
                                                                     );
                        }
                    }
                } break;

                    #endregion
                    #region Remove Sprite
                case ServerAction.RemoveSprite:
                {
                    uint EntitySerial = Packet.Read <RemoveSprite>(0).ID;
                    if (Clients[Serial].Aisling.Map.Entities.ContainsKey(EntitySerial))
                    {
                        Clients[Serial].Aisling.Map.Entities.Remove(EntitySerial);
                    }
                } break;

                    #endregion
                    #region Stats Updated
                case ServerAction.StatsUpdated:
                {
                    bool[] Bools = Packet.Read <StatsUpdate>(0).BitMaskValues();
                    int    Index = 3;
                    if (Bools[2])
                    {
                        StatsStructA StructA = Packet.Read <StatsStructA>(Index);
                        Clients[Serial].Aisling.Stats.STR        = StructA.STR;
                        Clients[Serial].Aisling.Stats.INT        = StructA.INT;
                        Clients[Serial].Aisling.Stats.WIS        = StructA.WIS;
                        Clients[Serial].Aisling.Stats.CON        = StructA.CON;
                        Clients[Serial].Aisling.Stats.DEX        = StructA.DEX;
                        Clients[Serial].Aisling.Stats.Points     = StructA.Points;
                        Clients[Serial].Aisling.Stats.MaxHP      = StructA.HPMax;
                        Clients[Serial].Aisling.Stats.MaxMP      = StructA.MPMax;
                        Clients[Serial].Aisling.Stats.WeightCurr = StructA.WeightCurr;
                        Clients[Serial].Aisling.Stats.WeightMax  = StructA.WeightMax;
                        Clients[Serial].Aisling.Stats.Ability    = StructA.Ability;
                        Clients[Serial].Aisling.Stats.Level      = StructA.Level;
                        Index += 28;
                    }
                    if (Bools[3])
                    {
                        StatsStructB StructB = Packet.Read <StatsStructB>(Index);
                        Clients[Serial].Aisling.Stats.CurHP = StructB.HPCurr;
                        Clients[Serial].Aisling.Stats.CurMP = StructB.MPCurr;
                        Index += 8;
                    }
                    if (Bools[4])
                    {
                        StatsStructC StructC = Packet.Read <StatsStructC>(Index);
                        Clients[Serial].Aisling.Stats.AbilityExperience = StructC.AExp;
                        Clients[Serial].Aisling.Stats.LevelExperience   = StructC.EXP;
                        Clients[Serial].Aisling.Stats.Gold        = StructC.Gold;
                        Clients[Serial].Aisling.Stats.GP          = StructC.GP;
                        Clients[Serial].Aisling.Stats.NextLevel   = StructC.NextLev;
                        Clients[Serial].Aisling.Stats.NextAbility = StructC.NextAB;
                        Index += 24;
                    }
                    if (Bools[5])
                    {
                        StatsStructD StructD = Packet.Read <StatsStructD>(Index);
                        Clients[Serial].Aisling.Stats.AC             = StructD.AC;
                        Clients[Serial].Aisling.Stats.MR             = StructD.MR;
                        Clients[Serial].Aisling.Stats.HIT            = StructD.HIT;
                        Clients[Serial].Aisling.Stats.DAM            = StructD.DAM;
                        Clients[Serial].Aisling.Stats.AttackElement  = StructD.AEle;
                        Clients[Serial].Aisling.Stats.DefenseElement = StructD.DEle;
                        Index += 13;
                    }
                }
                break;

                    #endregion
                    #region Entity Walked
                case ServerAction.EntityWalked:
                {
                    SpriteWalk EntityWalk = Packet.Read <SpriteWalk>(0);
                    ushort     XDIFF = EntityWalk.X, YDIFF = EntityWalk.Y;
                    switch (EntityWalk.Direction)
                    {
                    case FaceDirection.Down:
                        YDIFF++;
                        break;

                    case FaceDirection.Left:
                        XDIFF--;
                        break;

                    case FaceDirection.Right:
                        XDIFF++;
                        break;

                    case FaceDirection.Up:
                        YDIFF--;
                        break;
                    }
                    if (Clients[Serial].Aisling.Map.Entities.ContainsKey(EntityWalk.Serial))
                    {
                        if (Clients[Serial].Aisling.Map.Entities[EntityWalk.Serial].EntityType == MapEntity.Type.Monster)
                        {
                            (Clients[Serial].Aisling.Map.Entities[EntityWalk.Serial] as Monster).WasHit = false;
                        }
                        Clients[Serial].Aisling.Map.Entities[EntityWalk.Serial].WasHit             = false;
                        Clients[Serial].Aisling.Map.Entities[EntityWalk.Serial].Location.X         = XDIFF;
                        Clients[Serial].Aisling.Map.Entities[EntityWalk.Serial].Location.Y         = YDIFF;
                        Clients[Serial].Aisling.Map.Entities[EntityWalk.Serial].Location.Direction = EntityWalk.Direction;
                    }
                    if (Clients[Serial].AttackTargetSerial == EntityWalk.Serial)
                    {
                        Clients[Serial].Aisling.AttackLoops = 0;
                        Clients[Serial].Aisling.test2       = false;
                    }
                } break;

                    #endregion
                    #region Appendage
                case ServerAction.Appendage:
                {
                    Appendage BodyItems = Packet.Read <Appendage>(0);
                    Clients[Serial].Aisling.Body[(Aisling.SpriteBody.Appendage.Slot)BodyItems.Slot]      = new Aisling.SpriteBody.Appendage(BodyItems.Icon, BodyItems.Name);
                    Clients[Serial].Aisling.Body[(Aisling.SpriteBody.Appendage.Slot)BodyItems.Slot].Icon = BodyItems.Icon;
                } break;

                    #endregion
                    #region Entity Turned
                case ServerAction.EntityTurn:
                {
                    EntityDirection EntityDir = Packet.Read <EntityDirection>(0);
                    if (Clients[Serial].Aisling.Map.Entities.ContainsKey(EntityDir.Serial))
                    {
                        Clients[Serial].Aisling.Map.Entities[EntityDir.Serial].Location.Direction = EntityDir.FaceDirection;
                        if (Clients[Serial].Aisling.Map.Entities[EntityDir.Serial].EntityType == MapEntity.Type.Monster)
                        {
                            (Clients[Serial].Aisling.Map.Entities[EntityDir.Serial] as Monster).WasSuained = false;
                        }
                    }
                } break;

                    #endregion
                    #region Body Animation
                case ServerAction.BodyAnimation:
                {
                    SpriteAnimation EntityAnimation = Packet.Read <SpriteAnimation>(0);
                    if (Clients[Serial].Aisling.Serial == EntityAnimation.ID)
                    {
                        Clients[Serial].Aisling.AttackLanded = true;
                    }
                    else
                    {
                        Clients[Serial].Aisling.AttackLanded = false;
                    }

                    //we enganged attacking
                    if (EntityAnimation.ID == Clients[Serial].Aisling.Serial)
                    {
                        if (EntityAnimation.Animation == 1 || EntityAnimation.Animation == 129 ||
                            EntityAnimation.Animation == 139 || EntityAnimation.Animation == 132)
                        {
                            Clients[Serial].Aisling.Swings++;
                            Clients[Serial].Aisling.EngagedCombat = true;
                        }
                        else
                        {
                            Clients[Serial].Aisling.EngagedCombat = false;
                        }
                    }
                    else
                    {
                        Clients[Serial].Aisling.EngagedCombat = false;
                        if (Clients[Serial].Aisling.Map.Entities[EntityAnimation.ID].EntityType == MapEntity.Type.Player)
                        {
                            var v =
                                from var
                                in Clients[Serial].Aisling.Map.EntityList
                                where
                                var.Location.X == Clients[Serial].Aisling.Map.Entities[EntityAnimation.ID].Location.InfrontOf.X &&
                                var.Location.Y == Clients[Serial].Aisling.Map.Entities[EntityAnimation.ID].Location.InfrontOf.Y
                                select var;
                            if (v.Count() > 0)
                            {
                                foreach (var ent in v)
                                {
                                    if (!(Clients[Serial].Aisling.Map.Entities[EntityAnimation.ID] as AislingEntity).Targets.Contains(ent.Serial))
                                    {
                                        (Clients[Serial].Aisling.Map.Entities[EntityAnimation.ID] as AislingEntity).Targets.Add(ent.Serial);
                                    }
                                }
                            }
                            (Clients[Serial].Aisling.Map.Entities[EntityAnimation.ID] as AislingEntity).Targets =
                                new List <uint>
                                (
                                    from var in (Clients[Serial].Aisling.Map.Entities[EntityAnimation.ID] as AislingEntity).Targets
                                    where Clients[Serial].Aisling.Map.Entities.ContainsKey(var)
                                    select var
                                );
                        }
                    }
                } break;

                    #endregion
                    #region Sound Played
                case ServerAction.SoundPlay:
                {
                    PlaySound SoundNumber = Packet.Read <PlaySound>(0);
                    Clients[Serial].Aisling.LastSound = new Sounds()
                    {
                        Number = SoundNumber.Number
                    };
                    if (Clients[Serial].AttackTargetSerial > 0)
                    {
                        Clients[Serial].Aisling.testSer = Clients[Serial].AttackTargetSerial;
                    }
                } break;

                    #endregion
                    #region Chat Messages
                case ServerAction.Chat:
                {
                    Chat ChatMessage = Packet.Read <Chat>(0);
                    Clients[Serial].Aisling.ChatMessages.Add(new Aisling.ChatMessage(Convert.ToBoolean(ChatMessage.Type), ChatMessage.Serial, ChatMessage.Message));
                } break;

                    #endregion
                    #region Bar Messages
                case ServerAction.Bar:
                {
                    BarMessage BarMessage = Packet.Read <BarMessage>(0);
                    Clients[Serial].Aisling.BarMessages.Add(new Aisling.BarMessage((Aisling.BarMessage.MessageType)BarMessage.Type, BarMessage.Message));
                    if (BarMessage.Message.value.ToLower().StartsWith("these items are cursed"))
                    {
                        if (Clients[Serial].Aisling.Map.Entities.ContainsKey(Clients[Serial].ItemTargetSerial))
                        {
                            (Clients[Serial].Aisling.Map.Entities[Clients[Serial].ItemTargetSerial] as Item).IsBanned = true;
                        }
                    }
                } break;

                    #endregion
                    #region Group
                case ServerAction.GroupRequest:
                {
                    GroupRequest Request = Packet.Read <GroupRequest>(0);
                } break;

                    #endregion
                    #region Remove Appendage
                case ServerAction.RemoveAppendage:
                {
                    if (Clients[Serial].Aisling.Body[(Aisling.SpriteBody.Appendage.Slot)Packet[2]] != null)
                    {
                        string ItemRemoved = Clients[Serial].Aisling.Body[(Aisling.SpriteBody.Appendage.Slot)Packet[2]].Name;
                    }
                    Clients[Serial].Aisling.Body[(Aisling.SpriteBody.Appendage.Slot)Packet[2]] = null;
                } break;

                    #endregion
                default:
                {
                } break;
                }
                if (Clients[Serial].Aisling.EngagedCombat)
                {
                    Clients[Serial].Aisling.test++;
                    Clients[Serial].Aisling.EngagedCombat = false;
                }
            }
            catch { }
        }
        public void PublicFieldValueOnImplementedInterfaceType()
        {
            string barTestValue = "my bar";
            BarMessage message = new BarMessage(string.Empty, barTestValue);

            AbstractConstraint baseConstraint = PublicField.Value(typeof(FooMessage), "BarField", barTestValue);
            Assert.IsTrue(baseConstraint.Eval(message), "Returned false when field was correct and field was declared in supplied type..");

            AbstractConstraint constraint = PublicField.Value(typeof(BarMessage), "BarField", barTestValue);
            Assert.IsFalse(constraint.Eval(message), "Returned true when field was correct but type was not declared on the suppleid type.");
        }