void RecvSkillStartCasting_ToUser(IIPSocket conn, BitStream r)
        {
            var skillType = r.ReadEnum<SkillType>();
            var castTime = r.ReadUShort();

            GameplayScreen.SkillCastProgressBar.StartCasting(skillType, castTime);
        }
        void RecvSkillUse(IIPSocket conn, BitStream r)
        {
            var casterEntityIndex = r.ReadMapEntityIndex();
            var hasTarget = r.ReadBool();
            MapEntityIndex? targetEntityIndex = null;
            if (hasTarget)
                targetEntityIndex = r.ReadMapEntityIndex();
            var skillType = r.ReadEnum<SkillType>();

            var casterEntity = _objGrabber.GetDynamicEntity<CharacterEntity>(casterEntityIndex);
            CharacterEntity targetEntity = null;
            if (targetEntityIndex.HasValue)
                targetEntity = _objGrabber.GetDynamicEntity<CharacterEntity>(targetEntityIndex.Value);

            if (casterEntity == null)
                return;

            // Get the SkillInfo for the skill being used
            var skillInfo = _objGrabber.GetSkillInfo(skillType);
            if (skillInfo == null)
                return;

            // If an ActionDisplay is available for this skill, display it
            if (skillInfo.CastActionDisplay.HasValue)
            {
                var ad = ActionDisplayScripts.ActionDisplays[skillInfo.CastActionDisplay.Value];
                if (ad != null)
                    ad.Execute(Map, casterEntity, targetEntity);
            }
        }
        void RecvSkillSetKnownAll(IIPSocket conn, BitStream r)
        {
            var count = r.ReadByte();
            var knownSkills = new List<SkillType>(count);

            // Read the known skills list
            for (var i = 0; i < count; i++)
            {
                var value = r.ReadEnum<SkillType>();
                knownSkills.Add(value);
            }

            Debug.Assert(knownSkills.Count == count);
            Debug.Assert(knownSkills.All(EnumHelper<SkillType>.IsDefined), "One or more known skills were unknown...");

            // Set the known skills
            UserInfo.KnownSkills.SetValues(knownSkills);
        }
        void RecvSkillStartCasting_ToMap(IIPSocket conn, BitStream r)
        {
            var casterEntityIndex = r.ReadMapEntityIndex();
            var skillType = r.ReadEnum<SkillType>();

            // Get the SkillInfo for the skill being used
            var skillInfo = _objGrabber.GetSkillInfo(skillType);
            if (skillInfo == null)
                return;

            // Get the entity
            var casterEntity = _objGrabber.GetDynamicEntity<Character>(casterEntityIndex);
            if (casterEntity == null)
                return;

            // If an ActionDisplay is available for this skill, display it
            if (skillInfo.StartCastingActionDisplay.HasValue)
            {
                var ad = ActionDisplayScripts.ActionDisplays[skillInfo.StartCastingActionDisplay.Value];
                if (ad != null)
                {
                    casterEntity.IsCastingSkill = true;
                    ad.Execute(Map, casterEntity, null);
                }
            }
        }
        void RecvUseSkill(IIPSocket conn, BitStream r)
        {
            SkillType skillType;
            MapEntityIndex? targetIndex = null;

            // Get the SkillType to use
            try
            {
                skillType = r.ReadEnum<SkillType>();
            }
            catch (InvalidCastException)
            {
                const string errmsg = "Failed to read SkillType from stream.";
                if (log.IsWarnEnabled)
                    log.Warn(errmsg);
                Debug.Fail(errmsg);
                r.ReadBool();
                return;
            }

            // Check for a target
            var hasTarget = r.ReadBool();
            if (hasTarget)
                targetIndex = r.ReadMapEntityIndex();

            // Get the user
            User user;
            if ((user = TryGetUser(conn)) != null)
            {
                // Check that they know the skill
                if (!user.KnownSkills.Knows(skillType))
                    user.Send(GameMessage.SkillNotKnown, ServerMessageType.GUIChat);
                else
                {
                    // Use the skill
                    user.UseSkill(skillType, GetTargetCharacter(user, targetIndex));
                }
            }
        }
示例#6
0
        void RecvRemoveStatusEffect(IIPSocket conn, BitStream r)
        {
            var statusEffectType = r.ReadEnum<StatusEffectType>();

            GameplayScreen.StatusEffectsForm.RemoveStatusEffect(statusEffectType);
            GameplayScreen.AppendToChatOutput(string.Format("Removed status effect {0}.", statusEffectType));
        }
        void RecvEmote(IIPSocket conn, BitStream r)
        {
            var mapEntityIndex = r.ReadMapEntityIndex();
            var emoticon = r.ReadEnum<Emoticon>();

            var entity = Map.GetDynamicEntity(mapEntityIndex);
            if (entity == null)
                return;

            EmoticonDisplayManager.Instance.Add(entity, emoticon, GetTime());
        }
        void RecvRaiseStat(IIPSocket conn, BitStream r)
        {
            StatType statType;

            // Get the StatType
            try
            {
                statType = r.ReadEnum<StatType>();
            }
            catch (InvalidCastException)
            {
                const string errorMsg = "Received invaild StatType on connection `{0}`.";
                Debug.Fail(string.Format(errorMsg, conn));
                if (log.IsWarnEnabled)
                    log.WarnFormat(errorMsg, conn);
                return;
            }

            // Get the User
            User user;
            if ((user = TryGetUser(conn)) == null)
                return;

            // Raise the user's stat
            user.RaiseStat(statType);
        }
        void RecvAddStatusEffect(IIPSocket conn, BitStream r)
        {
            var statusEffectType = r.ReadEnum<StatusEffectType>();
            var power = r.ReadUShort();
            var secsLeft = r.ReadUShort();

            var param = new string[] {User.Name, statusEffectType.ToString(), power.ToString()};
            var message = GameMessageCollection.CurrentLanguage.GetMessage(GameMessage.CombatStatusEffectGained, param);

            GameplayScreen.StatusEffectsForm.AddStatusEffect(statusEffectType, power, secsLeft);
            GameplayScreen.AppendToChatOutput(message);
        }
示例#10
0
        void RecvCreateAccount(IIPSocket conn, BitStream r)
        {
            var successful = r.ReadBool();
            var errorMessage = string.Empty;

            if (!successful)
            {
                var failureGameMessage = r.ReadEnum<GameMessage>();
                errorMessage = GameMessageCollection.CurrentLanguage.GetMessage(failureGameMessage);
            }

            if (ReceivedCreateAccount != null)
                ReceivedCreateAccount.Raise(conn, new CreateAccountEventArgs(successful, errorMessage));
        }
示例#11
0
        void RecvUpdateEquipmentSlot(IIPSocket conn, BitStream r)
        {
            var slot = r.ReadEnum<EquipmentSlot>();
            var hasValue = r.ReadBool();

            if (hasValue)
            {
                var graphic = r.ReadGrhIndex();
                UserInfo.Equipped.SetSlot(slot, graphic);
            }
            else
                UserInfo.Equipped.ClearSlot(slot);
        }
示例#12
0
        /// <summary>
        /// Reads the data from the server related to the user guild information. This should only be used by the client.
        /// </summary>
        /// <param name="bitStream">The <see cref="BitStream"/> containing the data.</param>
        public void Read(BitStream bitStream)
        {
            var id = bitStream.ReadEnum<GuildInfoMessages>();
            switch (id)
            {
                case GuildInfoMessages.SetGuild:
                    ReadSetGuild(bitStream);
                    return;

                case GuildInfoMessages.AddMember:
                    ReadAddMember(bitStream);
                    return;

                case GuildInfoMessages.RemoveMember:
                    ReadRemoveMember(bitStream);
                    return;

                case GuildInfoMessages.AddOnlineMember:
                    ReadAddOnlineMember(bitStream);
                    return;

                case GuildInfoMessages.RemoveOnlineMember:
                    ReadRemoveOnlineMember(bitStream);
                    return;

                case GuildInfoMessages.UpdateRank:
                    ReadUpdateRank(bitStream);
                    return;

                case GuildInfoMessages.UpdateNameTag:
                    ReadUpdateNameTag(bitStream);
                    return;

                default:
                    const string errmsg = "Unknown GuildInfoMessages value `{0}`. Could not parse!";
                    var err = string.Format(errmsg, id);
                    log.Fatal(err);
                    Debug.Fail(err);
                    return;
            }
        }
示例#13
0
        /// <summary>
        /// Reads the data from the server related to the user group information. This should only be used by the client.
        /// </summary>
        /// <param name="bs">The <see cref="BitStream"/> containing the data.</param>
        public void Read(BitStream bs)
        {
            var id = bs.ReadEnum<GroupInfoMessages>();
            switch (id)
            {
                case GroupInfoMessages.AddMember:
                    ReadAddMember(bs);
                    break;

                case GroupInfoMessages.RemoveMember:
                    ReadRemoveMember(bs);
                    break;

                case GroupInfoMessages.SetGroup:
                    ReadSetGroup(bs);
                    break;

                default:
                    const string errmsg = "Unknown GroupInfoMessages value `{0}`. Could not parse!";
                    var err = string.Format(errmsg, id);
                    log.Fatal(err);
                    Debug.Fail(err);
                    return;
            }
        }
示例#14
0
        void RecvEmoticon(IIPSocket conn, BitStream r)
        {
            var emoticon = r.ReadEnum<Emoticon>();

            if (!EnumHelper<Emoticon>.IsDefined(emoticon))
            {
                const string errmsg = "Attempted to use undefined emoticon `{0}`.";
                if (log.IsWarnEnabled)
                    log.WarnFormat(errmsg, emoticon);
                return;
            }

            User user;
            if ((user = TryGetUser(conn)) == null)
                return;

            user.Emote(emoticon);
        }
示例#15
0
        void RecvRemoveStatusEffect(IIPSocket conn, BitStream r)
        {
            var statusEffectType = r.ReadEnum<StatusEffectType>();

            var message = GameMessageCollection.CurrentLanguage.GetMessage(GameMessage.CombatStatusEffectWoreOff, statusEffectType.ToString());

            GameplayScreen.StatusEffectsForm.RemoveStatusEffect(statusEffectType);
            GameplayScreen.AppendToChatOutput(message);
        }
示例#16
0
        void RecvGetEquipmentItemInfo(IIPSocket conn, BitStream r)
        {
            var slot = r.ReadEnum<EquipmentSlot>();

            User user;
            if ((user = TryGetUser(conn)) != null)
                user.SendEquipmentItemStats(slot);
        }
示例#17
0
 void RecvSendEquipmentItemInfo(IIPSocket conn, BitStream r)
 {
     var slot = r.ReadEnum<EquipmentSlot>();
     GameplayScreen.EquipmentInfoRequester.ReceiveInfo(slot, r);
 }
示例#18
0
        void RecvUnequipItem(IIPSocket conn, BitStream r)
        {
            var slot = r.ReadEnum<EquipmentSlot>();

            User user;
            if ((user = TryGetUser(conn)) != null)
                user.Equipped.RemoveAt(slot);
        }
示例#19
0
        void RecvSkillSetKnown(IIPSocket conn, BitStream r)
        {
            var skillType = r.ReadEnum<SkillType>();
            var isKnown = r.ReadBool();

            if (!EnumHelper<SkillType>.IsDefined(skillType))
            {
                const string errmsg = "Invalid SkillType received: `{0}`";
                if (log.IsWarnEnabled)
                    log.WarnFormat(errmsg, skillType);
                Debug.Fail(string.Format(errmsg, skillType));
                return;
            }

            // Set the skill's known state
            UserInfo.KnownSkills.SetSkill(skillType, isKnown);
        }
示例#20
0
        /// <summary>
        /// Reads the data from the server related to the user quest information. This should only be used by the client.
        /// </summary>
        /// <param name="bs">The <see cref="BitStream"/> containing the data.</param>
        public void Read(BitStream bs)
        {
            var id = bs.ReadEnum<QuestInfoMessages>();
            switch (id)
            {
                case QuestInfoMessages.AddCompletedQuest:
                    ReadAddCompletedQuest(bs);
                    break;

                case QuestInfoMessages.AddActiveQuest:
                    ReadAddActiveQuest(bs);
                    break;

                case QuestInfoMessages.RemoveActiveQuest:
                    ReadRemoveActiveQuest(bs);
                    break;

                case QuestInfoMessages.LoadInitialValues:
                    ReadLoadInitialValues(bs);
                    break;

                default:
                    const string errmsg = "Unknown QuestInfoMessages value `{0}`. Could not parse!";
                    var err = string.Format(errmsg, id);
                    log.Fatal(err);
                    Debug.Fail(err);
                    return;
            }
        }
示例#21
0
        void RecvAddStatusEffect(IIPSocket conn, BitStream r)
        {
            var statusEffectType = r.ReadEnum<StatusEffectType>();
            var power = r.ReadUShort();
            var secsLeft = r.ReadUShort();

            GameplayScreen.StatusEffectsForm.AddStatusEffect(statusEffectType, power, secsLeft);
            GameplayScreen.AppendToChatOutput(string.Format("Added status effect {0} with power {1}.", statusEffectType, power));
        }