Пример #1
0
        public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type,
                                                             params object[] list)
        {
            ComponentReplyMessage reply = base.RecieveMessage(sender, type, list);

            if (sender == this) //Don't listen to our own messages!
                return ComponentReplyMessage.Empty;

            switch (type)
            {
                case ComponentMessageType.CheckSpriteClick:
                    reply = new ComponentReplyMessage(ComponentMessageType.SpriteWasClicked,
                                                      WasClicked((PointF)list[0]), DrawDepth);
                    break;
                case ComponentMessageType.GetAABB:
                    reply = new ComponentReplyMessage(ComponentMessageType.CurrentAABB, AABB);
                    break;
                case ComponentMessageType.GetSprite:
                    reply = new ComponentReplyMessage(ComponentMessageType.CurrentSprite, sprite.GetCurrentSprite());
                    break;
                case ComponentMessageType.SetDrawDepth:
                    SetDrawDepth((DrawDepth)list[0]);
                    break;
                case ComponentMessageType.SlaveAttach:
                    SetMaster(Owner.EntityManager.GetEntity((int)list[0]));
                    break;
                case ComponentMessageType.ItemUnEquipped:
                case ComponentMessageType.Dropped:
                    UnsetMaster();
                    break;
                case ComponentMessageType.MoveDirection:
                    switch ((Direction)list[0])
                    {
                        case Direction.North:
                            sprite.Direction = Direction.North;
                            break;
                        case Direction.South:
                            sprite.Direction = Direction.South;
                            break;
                        case Direction.East:
                            sprite.Direction = Direction.East;
                            break;
                        case Direction.West:
                            sprite.Direction = Direction.West;
                            break;
                        case Direction.NorthEast:
                            sprite.Direction = Direction.NorthEast;
                            break;
                        case Direction.NorthWest:
                            sprite.Direction = Direction.NorthWest;
                            break;
                        case Direction.SouthEast:
                            sprite.Direction = Direction.SouthEast;
                            break;
                        case Direction.SouthWest:
                            sprite.Direction = Direction.SouthWest;
                            break;
                    }
                    break;
                case ComponentMessageType.EntitySaidSomething:
                    ChatChannel channel;
                    if (Enum.TryParse(list[0].ToString(), true, out channel))
                    {
                        string text = list[1].ToString();

                        if (channel == ChatChannel.Ingame || channel == ChatChannel.Player ||
                            channel == ChatChannel.Radio)
                        {
                            (_speechBubble ?? (_speechBubble = new SpeechBubble(Owner.Name + Owner.Uid))).SetText(text);
                        }
                    }
                    break;
            }

            return reply;
        }
Пример #2
0
        public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type,
                                                             params object[] list)
        {
            ComponentReplyMessage reply = base.RecieveMessage(sender, type, list);

            if (sender == this) //Don't listen to our own messages!
            {
                return(ComponentReplyMessage.Empty);
            }

            switch (type)
            {
            case ComponentMessageType.CheckSpriteClick:
                reply = new ComponentReplyMessage(ComponentMessageType.SpriteWasClicked,
                                                  WasClicked((PointF)list[0]), DrawDepth);
                break;

            case ComponentMessageType.GetAABB:
                reply = new ComponentReplyMessage(ComponentMessageType.CurrentAABB, AABB);
                break;

            case ComponentMessageType.GetSprite:
                reply = new ComponentReplyMessage(ComponentMessageType.CurrentSprite, sprite.GetCurrentSprite());
                break;

            case ComponentMessageType.SetDrawDepth:
                SetDrawDepth((DrawDepth)list[0]);
                break;

            case ComponentMessageType.SlaveAttach:
                SetMaster(Owner.EntityManager.GetEntity((int)list[0]));
                break;

            case ComponentMessageType.ItemUnEquipped:
            case ComponentMessageType.Dropped:
                UnsetMaster();
                break;

            case ComponentMessageType.MoveDirection:
                switch ((Direction)list[0])
                {
                case Direction.North:
                    sprite.Direction = Direction.North;
                    break;

                case Direction.South:
                    sprite.Direction = Direction.South;
                    break;

                case Direction.East:
                    sprite.Direction = Direction.East;
                    break;

                case Direction.West:
                    sprite.Direction = Direction.West;
                    break;

                case Direction.NorthEast:
                    sprite.Direction = Direction.NorthEast;
                    break;

                case Direction.NorthWest:
                    sprite.Direction = Direction.NorthWest;
                    break;

                case Direction.SouthEast:
                    sprite.Direction = Direction.SouthEast;
                    break;

                case Direction.SouthWest:
                    sprite.Direction = Direction.SouthWest;
                    break;
                }
                break;

            case ComponentMessageType.EntitySaidSomething:
                ChatChannel channel;
                if (Enum.TryParse(list[0].ToString(), true, out channel))
                {
                    string text = list[1].ToString();

                    if (channel == ChatChannel.Ingame || channel == ChatChannel.Player ||
                        channel == ChatChannel.Radio)
                    {
                        (_speechBubble ?? (_speechBubble = new SpeechBubble(Owner.Name + Owner.Uid))).SetText(text);
                    }
                }
                break;
            }

            return(reply);
        }
        public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type,
                                                             params object[] list)
        {
            ComponentReplyMessage reply = base.RecieveMessage(sender, type, list);

            if (sender == this) //Don't listen to our own messages!
            {
                return(ComponentReplyMessage.Empty);
            }

            switch (type)
            {
            case ComponentMessageType.MoveDirection:
                switch ((Direction)list[0])
                {
                case Direction.North:
                    SetSpriteByKey(_basename + "_back");
                    flip = false;
                    break;

                case Direction.South:
                    SetSpriteByKey(_basename + "_front");
                    flip = false;
                    break;

                case Direction.East:
                    SetSpriteByKey(_basename + "_side");
                    flip = true;
                    break;

                case Direction.West:
                    SetSpriteByKey(_basename + "_side");
                    flip = false;
                    break;

                case Direction.NorthEast:
                    SetSpriteByKey(_basename + "_back");
                    flip = false;
                    break;

                case Direction.NorthWest:
                    SetSpriteByKey(_basename + "_back");
                    flip = false;
                    break;

                case Direction.SouthEast:
                    SetSpriteByKey(_basename + "_front");
                    flip = false;
                    break;

                case Direction.SouthWest:
                    SetSpriteByKey(_basename + "_front");
                    flip = false;
                    break;
                }
                break;

            case ComponentMessageType.Die:
                SetSpriteByKey(_basename + "_incap_dead");
                flip = false;
                break;

            case ComponentMessageType.EntitySaidSomething:
                ChatChannel channel;
                if (Enum.TryParse(list[0].ToString(), true, out channel))
                {
                    string text = list[1].ToString();

                    if (channel == ChatChannel.Ingame || channel == ChatChannel.Player ||
                        channel == ChatChannel.Radio)
                    {
                        (_speechBubble ?? (_speechBubble = new SpeechBubble(Owner.Name + Owner.Uid))).SetText(text);
                    }
                }
                break;
            }

            return(reply);
        }
Пример #4
0
        public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type,
                                                             params object[] list)
        {
            ComponentReplyMessage reply = base.RecieveMessage(sender, type, list);

            if (sender == this) //Don't listen to our own messages!
                return ComponentReplyMessage.Empty;

            switch (type)
            {
                case ComponentMessageType.MoveDirection:
                    switch ((Direction) list[0])
                    {
                        case Direction.North:
                            SetSpriteByKey(_basename + "_back");
                            flip = false;
                            break;
                        case Direction.South:
                            SetSpriteByKey(_basename + "_front");
                            flip = false;
                            break;
                        case Direction.East:
                            SetSpriteByKey(_basename + "_side");
                            flip = true;
                            break;
                        case Direction.West:
                            SetSpriteByKey(_basename + "_side");
                            flip = false;
                            break;
                        case Direction.NorthEast:
                            SetSpriteByKey(_basename + "_back");
                            flip = false;
                            break;
                        case Direction.NorthWest:
                            SetSpriteByKey(_basename + "_back");
                            flip = false;
                            break;
                        case Direction.SouthEast:
                            SetSpriteByKey(_basename + "_front");
                            flip = false;
                            break;
                        case Direction.SouthWest:
                            SetSpriteByKey(_basename + "_front");
                            flip = false;
                            break;
                    }
                    break;
                case ComponentMessageType.Die:
                    SetSpriteByKey(_basename + "_incap_dead");
                    flip = false;
                    break;
                case ComponentMessageType.EntitySaidSomething:
                    ChatChannel channel;
                    if (Enum.TryParse(list[0].ToString(), true, out channel))
                    {
                        string text = list[1].ToString();

                        if (channel == ChatChannel.Ingame || channel == ChatChannel.Player ||
                            channel == ChatChannel.Radio)
                        {
                            (_speechBubble ?? (_speechBubble = new SpeechBubble(Owner.Name + Owner.Uid))).SetText(text);
                        }
                    }
                    break;
            }

            return reply;
        }