Example #1
0
        public override void HandleMessage(Message message)
        {
            switch (message.Event)
            {
                case "entity:resurrected":
                    {
                        Guid entityId;
                        bool parseResult = Guid.TryParse(message.Payload.entity.ToString(), out entityId);
                        if (!parseResult) return;
                        Creature creature = Entity.GetCreature(entityId);
                        creature.Status = CreatureStatus.Spawn;
                    }
                    break;

                case "entity:dead":
                    {
                        Guid entityId;
                        bool parseResult = Guid.TryParse(message.Payload.entity.ToString(), out entityId);
                        if (!parseResult) return;
                        Creature creature = Entity.GetCreature(entityId);
                        creature.Status = CreatureStatus.Dead;
                    }
                    break;
            }
        }
Example #2
0
        public override void HandleMessage(Message message)
        {
            switch (message.Event)
            {
                case "message":
                    {
                        Chat.ShowMessage(message.Payload.text.ToString(), message.Payload.sender.ToString(), "", Chat.GetColorForChannel(Chat.Channel.All));
                    }
                    break;

                case "emote":
                    {
                        Creature sender = Game.Zone.Agents.FirstOrDefault(a => a.Name.Equals(message.Payload.sender.ToString()));

                        if (sender != null)
                        {
                            CreatureAnimation animation;
                            if (Enum.TryParse(message.Payload.action.ToString(), true, out animation))
                            {
                                sender.PerformAnimation(animation);
                            }
                            else
                            {
                                List<string> args;
                                string command = Chat.ParseCommand(message.Payload.action.ToString(), out args);
                                switch (command)
                                {
                                    case "fame":
                                        if (args.Count == 1)
                                        {
                                            uint rank;
                                            if (uint.TryParse(args.First(), out rank))
                                            {
                                                sender.PerformFameEmote(rank);
                                            }
                                        }
                                        break;

                                    default:
                                        Chat.ShowMessage(string.Format("unknown command: {0}", command));
                                        break;
                                }
                            }
                        }
                    }
                    break;
            }
        }
Example #3
0
        public override void HandleMessage(Message message)
        {
            PlayerCharacter groupLeader;
            Party party;
            switch (message.Event)
            {
                case "update":
                    {
                        try
                        {
                            bool newParty = false;
                            groupLeader = Entity.GetEntity<Player>(Guid.Parse(message.Payload.leader.ToString())).Character;
                            party = Game.Zone.Parties.FirstOrDefault(x => x.Leader == groupLeader);
                            if (party == null)
                            {
                                party = new Party(groupLeader);
                                newParty = true;
                            }

                            AddMembersToParty(party, message.Payload.members);
                            AddOrRemoveInvites(party, message.Payload.invited);
                            GenerateJoinRequests(groupLeader, message.Payload.invited);

                            if (newParty)
                                Game.Zone.AddParty(party);
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                    break;

                case "remove":
                    {
                        //party.RemoveMember();
                    }
                    break;

                case "map:change":
                    break;
            }
        }
Example #4
0
        public override void HandleMessage(Message message)
        {
            switch (message.Event)
            {
                case "update":
                    {
                        PlayerCharacter character = Entity.GetEntity<Player>(Guid.Parse(message.Payload.entity.ToString())).Character;
                        if (character == Game.Player.Character) return;

                        float x = float.Parse(message.Payload.goal.x.ToString());
                        float y = float.Parse(message.Payload.goal.y.ToString());
                        short plane = short.Parse(message.Payload.position.plane.ToString());

                        character.Transformation.SetGoal(x, y, plane);
                        character.Transformation.SpeedModifier = float.Parse(message.Payload.velocity.ToString());
                        character.Transformation.MovementType = (MovementType)byte.Parse(message.Payload.move_type.ToString());
                    }
                    break;
            }
        }
Example #5
0
 public abstract void HandleMessage(Message message);
Example #6
0
            public void HandleMessage(Message message)
            {
                if (!message.Topic.Equals("phoenix")) Console.WriteLine("StoC: Topic: {0}, Event: {1}", message.Topic, message.Event);

                Channel channel = All.FirstOrDefault(c => message.Topic.StartsWith(c.Topic + ":"));
                if (channel != null) channel.HandleMessage(message);
            }
Example #7
0
        public override void HandleMessage(Message message)
        {
            switch (message.Event)
            {
                case "phx_reply":
                    {
                        if (!message.Payload.status.ToString().Equals("ok")) return;

                        switch (message.Ref)
                        {
                            case MAP_CHANGE_REF:
                                {
                                    var area = (Area)Enum.Parse(typeof(Area), message.Payload.response.map.ToString());

                                    Networking.ChangeArea(area, Game.Player.Character.Name);
                                }
                                break;
                        }
                    }
                    break;
                case "initial":
                    {
                        Guid myId = Entity.Entities.Values.OfType<Player>().First(p => p.Character == Game.Player.Character).Id;

                        foreach (JProperty a in message.Payload.attributes.Values<JProperty>())
                        {
                            Entity.UpdateEntity(myId, a.Name, a.Value);
                        }

                        Game.ChangeMap(DefinitionConverter.ToMap(Area), zone =>
                                {
                                    zone.IsExplorable = !IsOutpost;

                                    Entity.Players.ForEach(p => zone.AddAgent(p.Character));
                                });
                    }
                    break;
                case "add":
                    {
                        Guid id = Guid.Parse(message.Payload.entity.ToString());

                        foreach (JProperty a in message.Payload.attributes.Values<JProperty>())
                        {
                            Entity.UpdateEntity(id, a.Name, a.Value);
                        }
                    }
                    break;
                case "change":
                    {
                        Guid id = Guid.Parse(message.Payload.entity.ToString());

                        foreach (JProperty a in message.Payload.added.Values<JProperty>())
                        {
                            Entity.UpdateEntity(id, a.Name, a.Value);
                        }

                        foreach (JProperty a in message.Payload.changed.Values<JProperty>())
                        {
                            Entity.UpdateEntity(id, a.Name, a.Value);
                        }
                    }
                    break;
                case "remove":
                    {
                        Entity.RemoveEntity(Guid.Parse(message.Payload.entity.ToString()));
                    }
                    break;
            }
        }
Example #8
0
        public override void HandleMessage(Message message)
        {
            switch (message.Event)
            {
                case "initial":
                    {
                        string hSkills = message.Payload.Value<string>("unlocked_skills");
                        byte[] avSkills = Enumerable.Range(0, hSkills.Length)
                                                    .Select(x => Convert.ToByte(hSkills.Substring(x, 1), 16))
                                                    .Reverse().ToArray();

                        Game.Player.Abilities.ClearAvailableSkills();

                        for (int i = 0; i < avSkills.Length; i++)
                        {
                            for (int j = 0; j < 4; j++)
                            {
                                if (((1 << j) & avSkills[i]) > 0)
                                {
                                    Game.Player.Abilities.AddAvailableSkill((Skill)(4 * i + j + 1));
                                }
                            }
                        }

                        for (int i = 0; i < 8; i++)
                        {
                            Game.Player.Character.SkillBar.SetSkill((uint)i, (Skill)message.Payload.skillbar[i]);
                        }
                    }
                    break;

                case "skillbar:ok":
                    {
                        for (int i = 0; i < 8; i++)
                        {
                            Game.Player.Character.SkillBar.SetSkill((uint)i, (Skill)message.Payload.skillbar[i]);
                        }
                    }
                    break;

                case "cast:start":
                    {
                        PlayerCharacter character = Entity.GetEntity<Player>(Guid.Parse(message.Payload.entity.ToString())).Character;

                        uint castTime = uint.Parse(message.Payload.cast_time.ToString());
                        var skill = (Skill)uint.Parse(message.Payload.skill.ToString());

                        character.CastSkill(skill, castTime * 0.001F, character);
                    }
                    break;

                case "cast:end":
                    {
                        PlayerCharacter character = Entity.GetEntity<Player>(Guid.Parse(message.Payload.entity.ToString())).Character;

                        uint rechargeTime = uint.Parse(message.Payload.recharge_time.ToString());
                        uint slot = uint.Parse(message.Payload.slot.ToString());

                        if (Game.Player.Character == character)
                        {
                            character.SkillBar.RechargeStart(slot, rechargeTime / 1000);
                        }
                    }
                    break;

                case "recharge:end":
                    {
                        PlayerCharacter character = Entity.GetEntity<Player>(Guid.Parse(message.Payload.entity.ToString())).Character;
                        character.SkillBar.RechargeEnd(uint.Parse(message.Payload.slot.ToString()));
                    }
                    break;

                case "cast:instantly":
                    {
                        PlayerCharacter character = Entity.GetEntity<Player>(Guid.Parse(message.Payload.entity.ToString())).Character;

                        uint rechargeTime = uint.Parse(message.Payload.recharge_time.ToString());
                        var skill = (Skill)uint.Parse(message.Payload.skill.ToString());
                        uint slot = uint.Parse(message.Payload.slot.ToString());

                        character.CastInstant(skill, character);

                        if (Game.Player.Character == character)
                        {
                            character.SkillBar.RechargeStart(slot, rechargeTime / 1000);
                        }
                    }
                    break;

                case "cast:error":
                    {
                        Game.Player.Character.SkillBar.RechargedVisual(uint.Parse(message.Payload.slot.ToString()));
                    }
                    break;
            }
        }
Example #9
0
        public void Send(Message message)
        {
            if (!message.Topic.Equals("phoenix")) Console.WriteLine("CtoS: Topic: {0}, Event: {1}", message.Topic, message.Event);

            _webSocket.Send(message.ToString());
        }