Пример #1
0
        public override void SendMessage(IGameMessage _IGameMessage, GameMessageImportance _Importance)
        {
            NetOutgoingMessage om = netServer.CreateMessage();
            om.Write((byte)_IGameMessage.MessageType);
            _IGameMessage.Encode(om);

            netServer.SendToAll(om, _Importance == GameMessageImportance.VeryImportant ? NetDeliveryMethod.ReliableOrdered : NetDeliveryMethod.Unreliable); // ReliableUnordered
        }
Пример #2
0
        public void SendMessageOrdered(IGameMessage gameMessage)
        {
            NetOutgoingMessage om = client.CreateMessage();
            om.Write((byte) gameMessage.MessageType);
            gameMessage.Encode(om);

            client.SendMessage(om, NetDeliveryMethod.ReliableOrdered);
        }
        public void SendMessage(IGameMessage gameMessage)
        {
            NetOutgoingMessage om = this.netServer.CreateMessage();
            om.Write((byte)gameMessage.MessageType);
            gameMessage.Encode(om);

            this.netServer.SendToAll(om, NetDeliveryMethod.ReliableUnordered);
        }
Пример #4
0
 public virtual void addEvent(IGameMessage _IGameMessage, GameMessageImportance _GameMessageImportance)
 {
     Event var_Event = new Event(_IGameMessage, _GameMessageImportance);
     if (this.LastIndex < this.LastIndexMax)
     {
         this.EventList[this.LastIndex] = var_Event;
         this.LastIndex += 1;
     }
 }
Пример #5
0
 public override void Message(IGameMessage msg)
 {
     SoundMessage sound = msg as SoundMessage;
     if (sound != null)
     {
         sounds.Add(sound.SoundName);
         if (sound.Playing) Engine.Instance.SoundSystem.PlaySfx(sound.SoundName);
         else Engine.Instance.SoundSystem.StopSfx(sound.SoundName);
     }
 }
Пример #6
0
 public override void Message(IGameMessage msg)
 {
     StateMessage statemsg = msg as StateMessage;
     if (statemsg != null)
     {
         if (states.ContainsKey(statemsg.StateName))
         {
             currentState = statemsg.StateName;
             states[currentState].Initialize(Parent);
             StateFrames = 0;
         }
     }
 }
Пример #7
0
 public void SendMessage(IGameMessage gameMessage)
 {
     try
     {
         foreach (var s in sessions)
         {
             s.Value.SendMessage(gameMessage);
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex.ToString());
     }
 }
Пример #8
0
 public override void SendMessageToClient(IGameMessage _IGameMessage, Client _Client)
 {
     NetOutgoingMessage om = netServer.CreateMessage();
     om.Write((byte)_IGameMessage.MessageType);
     _IGameMessage.Encode(om);
     foreach (NetConnection connection in this.netServer.Connections)
     {
         if (connection.RemoteEndPoint == _Client.IPEndPoint)
         {
             this.netServer.SendMessage(om, connection, NetDeliveryMethod.ReliableOrdered); // ReliableUnordered // Unreliable
             break;
         }
     }
 }
Пример #9
0
        public void SendMessage(IGameMessage gameMessage)
        {
            try
            {
                NetOutgoingMessage om = server.CreateMessage();
                om.Write((byte) gameMessage.MessageType);
                gameMessage.Encode(om);

                Connection.SendMessage(om, NetDeliveryMethod.ReliableUnordered, 0);
            }
            catch (Exception ex)
            {
                Logger.Error(ex.ToString());
            }
        }
Пример #10
0
        public void HandleChatTalkMessage(IGameMessage msg)
        {
            ChatTalkMessage message = (ChatTalkMessage) msg;

            if (message.Message.Length > 1 && message.Message[0] == '/')
            {
                Logger.Info("[" + username + "] issued command " + message.Message);
                ChatService.HandleCommand(this, server, message);
                return;
            }

            Logger.Info("[" + username + "]: " + message.Message);

            server.SendMessage(new ChatTalkMessage("[" + username + "]: " + message.Message));
        }
Пример #11
0
        public void HandleUpdatePlayerStateMessage(IGameMessage msg)
        {
            UpdatePlayerStateMessage message = (UpdatePlayerStateMessage) msg;

            var timeDelay = (float) (NetTime.Now - connection.GetLocalTime(message.MessageTime));

            player.EnableSmoothing = true;

            if (player.LastUpdateTime < message.MessageTime)
            {
                player.SimulationState.Position = message.Position += message.Velocity*timeDelay;
                player.SimulationState.Velocity = message.Velocity;
                player.SimulationState.Rotation = message.Rotation;

                player.LastUpdateTime = message.MessageTime;
            }
        }
Пример #12
0
        private void HandleUpdatePlayerStateMessage(IGameMessage msg)
        {
            /* var message = new UpdatePlayerStateMessage(im);

             var timeDelay = (float)(NetTime.Now - im.SenderConnection.GetLocalTime(message.MessageTime));

             Player player = this.playerManager.GetPlayer(message.Id)
                             ??
                             this.playerManager.AddPlayer(
                                 message.Id, message.Position, message.Velocity, message.Rotation, false);

             player.EnableSmoothing = true;

             if (player.LastUpdateTime < message.MessageTime)
             {
                 player.SimulationState.Position = message.Position += message.Velocity * timeDelay;
                 player.SimulationState.Velocity = message.Velocity;
                 player.SimulationState.Rotation = message.Rotation;

                 player.LastUpdateTime = message.MessageTime;
             }*/
        }
Пример #13
0
 private void HandleUpdatePlayerStateMessage(IGameMessage msg)
 {
     /* var message = new UpdatePlayerStateMessage(im);
      *
      * var timeDelay = (float)(NetTime.Now - im.SenderConnection.GetLocalTime(message.MessageTime));
      *
      * Player player = this.playerManager.GetPlayer(message.Id)
      *               ??
      *               this.playerManager.AddPlayer(
      *                   message.Id, message.Position, message.Velocity, message.Rotation, false);
      *
      * player.EnableSmoothing = true;
      *
      * if (player.LastUpdateTime < message.MessageTime)
      * {
      *   player.SimulationState.Position = message.Position += message.Velocity * timeDelay;
      *   player.SimulationState.Velocity = message.Velocity;
      *   player.SimulationState.Rotation = message.Rotation;
      *
      *   player.LastUpdateTime = message.MessageTime;
      * }*/
 }
Пример #14
0
        /// <summary>
        /// 解码从服务器收到的消息(暂时不做加密和解密处理),协议格式:total(4) + seqId(4) + uniqueMessageId(4) + errorCode(4) +  body
        /// </summary>
        /// <param name="byteBuf"></param>
        /// <returns></returns>
        public IGameMessage DecodeGameMessage(ByteBuf byteBuf)
        {
            int total           = byteBuf.ReadInt();
            int seqId           = byteBuf.ReadInt();
            int messageUniqueId = byteBuf.ReadInt();
            int errorCode       = byteBuf.ReadInt();

            byte[] body = null;
            if (errorCode == 0)
            {
                int bodyLen = byteBuf.ReadableBytes();
                body = new byte[bodyLen];
                byteBuf.ReadBytes(body);
            }
            IGameMessage gameMessage = this.NewGameMessage(messageUniqueId);

            if (gameMessage != null)
            {
                gameMessage.DecodeBody(body);
            }
            return(gameMessage);
        }
Пример #15
0
        /// <summary>
        /// 编码客户端向服务器发送的请求消息,暂不加密,格式:total(4) + seqId(4)+ messageUniqueId(4) + body
        /// </summary>
        /// <param name="gameMessage"></param>
        public byte[] EncodeGameMessage(IGameMessage gameMessage)
        {
            seqid++;
            gameMessage.GetMessageHeader().SeqId = seqid;
            int total = 12;

            byte[] body = gameMessage.EncodeBody();
            if (body != null)
            {
                total += body.Length;
            }
            ByteBuf byteBuf = new ByteBuf(total);

            byteBuf.WriteInt(total);
            byteBuf.WriteInt(gameMessage.GetMessageHeader().SeqId);
            byteBuf.WriteInt(gameMessage.GetMessageUniqueId());
            if (body != null)
            {
                byteBuf.WriteBytes(body);
            }
            byte[] msg = byteBuf.ToArray();
            return(msg);
        }
Пример #16
0
        public void SendMessage(IGameMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            var handledComponentTypes = new HashSet <Type>();

            foreach (var component in Components.GetSorted())
            {
                var componentType = component.GetType();

                if (handledComponentTypes.Contains(componentType))
                {
                    continue;
                }

                component.ReceiveMessage(message);

                handledComponentTypes.Add(componentType);
            }
        }
        public override void ReceiveMessage(IGameMessage msg)
        {
            switch (msg.EventId)
            {
            case (int)MessageId.NearbyEntityQueuedForDeath:
            {
                CatchNearbyEntityDying(msg.AsNearbyEntityQueuedForDeath());
                break;
            }

            case (int)MessageId.NetworkReinitialize:
            {
                Reset();
                break;
            }

            case (int)MessageId.FrameBegin:
            {
                Update();
                break;
            }
            }
        }
Пример #18
0
        public override void Message(IGameMessage msg)
        {
            if (msg is DamageMessage && flashing == 0)
            {
                if (Engine.Instance.Invincible && Parent.Name == "Player")
                {
                    return;
                }

                DamageMessage damage = (DamageMessage)msg;

                Health -= damage.Damage;

                Hit      = true;
                flashing = flashtime;
            }
            else if (msg is HealMessage)
            {
                HealMessage heal = (HealMessage)msg;

                Health += heal.Health;
            }
        }
Пример #19
0
        public override void ReceiveMessage(IGameMessage msg)
        {
            switch (msg.EventId)
            {
            case (int)MessageId.TookDamageLostHealth:
            {
                var dmg = msg.AsTookDamangeLostHealth();
                _health -= dmg.Damage;
                CheckForDeath();

                break;
            }

            case (int)MessageId.EatHealedHealth:
            {
                var hp = msg.AsEatHealed();
                _health += hp.HealedAmount;
                CheckForDeath();

                break;
            }
            }
        }
        public override void ReceiveMessage(IGameMessage msg)
        {
            // TODO : handle ForcedMovement in Transform,
            // TODO : handle ForcedMovement movement over time in a separate component
            switch (msg.EventId)
            {
            case (int)MessageId.FrameBegin:
            {
                OnUpdate();
                break;
            }

            case (int)MessageId.BeginMovePath:
            {
                OnBeginMovePath(msg.AsBeginMovePath());
                break;
            }

            case (int)MessageId.Move:
            {
                OnMove(msg.AsMove());
                break;
            }

            case (int)MessageId.NewPlayerFollowTarget:
            {
                OnNewFollowPlayer(msg.AsNewPlayerFollowTarget());
                break;
            }

            case (int)MessageId.SyncLocalsToGlobals:
            {
                SyncLocalsToGlobals(Parent.AssertGetClientPosition());
                break;
            }
            }
        }
Пример #21
0
        /// <summary>
        /// Send an IGameMessage message to all connected clients except sender of the message.
        /// </summary>
        /// <param name="Message">Message to be send.</param>
        public void SendMessage(IGameMessage Message)
        {
            try
            {
                List <NetConnection> AllConnections = this.m_networkClass.m_netServer.Connections;
                AllConnections.Remove(this.netConnection);

                if (AllConnections.Count > 0)
                {
                    NetOutgoingMessage netOutgoingMessage = this.m_networkClass.m_netServer.CreateMessage();

                    netOutgoingMessage.Write((byte)Message.MessageType);
                    Message.EncodeMessage(netOutgoingMessage);

                    this.m_networkClass.m_netServer.SendMessage(netOutgoingMessage, AllConnections, NetDeliveryMethod.ReliableOrdered, 0);
                }
            }
            catch (Exception e)
            {
                Log.HandleEmptyMessage();
                Log.HandleLog(LOGMessageTypes.Error, e.ToString());
                Log.HandleEmptyMessage();
            }
        }
Пример #22
0
        public void Handle(IGameMessage @event, IReactionScope scope)
        {
            if (@event is DeckDepletedEvent)
            {
                Handle(@event as DeckDepletedEvent);
                return;
            }

            if (@event is IAttackEffect)
            {
                HandleAttack(@event as IAttackEffect, scope);
            }

            Hand.Handle(@event, scope);

            if (@event.GetAvailableResponses().Count() == 1)
            {
                @event.GetDefaultResponse().Execute();
            }
            else
            {
                _controller.HandleGameEvent(@event, scope).Execute();
            }
        }
Пример #23
0
 public override void Message(IGameMessage msg)
 {
 }
Пример #24
0
        public static Block GameMessageToBlock(IGameMessage m)
        {
            if (m == null)
            {
                return(null);
            }

            if (m is PlayerEventMessage)
            {
                if (m.IsMuted)
                {
                    return(null);
                }
                var b    = new GameMessageBlock(m);
                var p    = new Paragraph();
                var prun = new Run(m.From + " ");
                prun.Foreground = m.From.Color.CacheToBrush();
                prun.FontWeight = FontWeights.Bold;
                p.Inlines.Add(prun);

                var chatRun = MergeArgsv2(m.Message, m.Arguments);
                chatRun.Foreground = new SolidColorBrush(m.From.Color);
                //chatRun.FontWeight = FontWeights.Bold;
                p.Inlines.Add(chatRun);

                b.Blocks.Add(p);

                return(b);
            }
            else if (m is ChatMessage)
            {
                if (m.IsMuted)
                {
                    return(null);
                }

                var p = new Paragraph();
                var b = new GameMessageBlock(m);

                var inline = new Span();

                inline.Foreground = m.From.Color.CacheToBrush();
                var chatRun = new Run("<" + m.From + "> ");
                chatRun.Foreground = m.From.Color.CacheToBrush();
                chatRun.FontWeight = FontWeights.Bold;
                inline.Inlines.Add(chatRun);

                inline.Inlines.Add(MergeArgsv2(m.Message, m.Arguments));

                p.Inlines.Add(inline);

                b.Blocks.Add(p);

                return(b);
            }
            else if (m is WarningMessage)
            {
                if (m.IsMuted)
                {
                    return(null);
                }

                var b = new GameMessageBlock(m);
                b.Background  = Brushes.LightGray;
                b.Padding     = new Thickness(5);
                b.BorderBrush = Brushes.LightGray;
                b.Foreground  = m.From.Color.CacheToBrush();
                var par = new Paragraph(MergeArgsv2(m.Message, m.Arguments));
                par.Margin = new Thickness(0);
                b.Blocks.Add(par);
                //var block = new BlockUIContainer();
                //var border = new Border()
                //{
                //    CornerRadius = new CornerRadius(4),
                //    BorderBrush = Brushes.Gray,
                //    BorderThickness = new Thickness(1),
                //    Padding = new Thickness(5),
                //    Background = Brushes.LightGray,
                //};
                //var tb = new TextBlock(MergeArgsv2(m.Message, m.Arguments));
                //tb.Foreground = m.From.Color.CacheToBrush();
                //tb.TextWrapping = TextWrapping.Wrap;

                //border.Child = tb;
                //block.Child = border;

                //b.Blocks.Add(block);

                //var hiddenText = new Paragraph(MergeArgsv2(m.Message, m.Arguments));
                //hiddenText.Foreground = Brushes.Transparent;
                //hiddenText.FontSize = 0.1;
                //hiddenText.Margin = new Thickness(0);
                //b.Blocks.Add(hiddenText);

                return(b);
            }
            else if (m is SystemMessage)
            {
                if (m.IsMuted)
                {
                    return(null);
                }

                var p       = new Paragraph();
                var b       = new GameMessageBlock(m);
                var chatRun = MergeArgsv2(m.Message, m.Arguments);
                chatRun.Foreground = m.From.Color.CacheToBrush();
                p.Inlines.Add(chatRun);
                b.Blocks.Add(p);
                return(b);
            }
            else if (m is NotifyMessage)
            {
                if (m.IsMuted)
                {
                    return(null);
                }

                var p       = new Paragraph();
                var b       = new GameMessageBlock(m);
                var chatRun = MergeArgsv2(m.Message, m.Arguments);
                chatRun.Foreground = m.From.Color.CacheToBrush();
                b.Blocks.Add(p);
                p.Inlines.Add(chatRun);
                return(b);
            }
            else if (m is TurnMessage)
            {
                if (m.IsMuted)
                {
                    return(null);
                }

                var brush = m.From.Color.CacheToBrush();

                var p = new Paragraph();
                var b = new GameMessageBlock(m);
                b.TextAlignment = TextAlignment.Center;
                b.Margin        = new Thickness(2);

                p.Inlines.Add(
                    new Line
                {
                    X1 = 0,
                    X2 = 40,
                    Y1 = -4,
                    Y2 = -4,
                    StrokeThickness = 2,
                    Stroke          = brush
                });

                var chatRun = new Run(string.Format(m.Message, m.Arguments));
                chatRun.Foreground = brush;
                chatRun.FontWeight = FontWeights.Bold;
                p.Inlines.Add(chatRun);

                var prun = new Run(" " + (m as TurnMessage).TurnPlayer + " ");
                prun.Foreground = (m as TurnMessage).TurnPlayer.Color.CacheToBrush();
                prun.FontWeight = FontWeights.Bold;
                p.Inlines.Add(prun);

                p.Inlines.Add(
                    new Line
                {
                    X1 = 0,
                    X2 = 40,
                    Y1 = -4,
                    Y2 = -4,
                    StrokeThickness = 2,
                    Stroke          = brush
                });

                b.Blocks.Add(p);

                //if (((Paragraph)output.Document.Blocks.LastBlock).Inlines.Count == 0)
                //    output.Document.Blocks.Remove(output.Document.Blocks.LastBlock);

                return(b);

                //output.Document.Blocks.Add(new Paragraph { Margin = new Thickness() });
            }
            else if (m is DebugMessage)
            {
                if (m.IsMuted)
                {
                    return(null);
                }
                var p       = new Paragraph();
                var b       = new GameMessageBlock(m);
                var chatRun = MergeArgsv2(m.Message, m.Arguments);
                chatRun.Foreground = m.From.Color.CacheToBrush();
                p.Inlines.Add(chatRun);
                b.Blocks.Add(p);
                return(b);
            }
            else if (m is NotifyBarMessage)
            {
                if (m.IsMuted)
                {
                    return(null);
                }
                var p       = new Paragraph();
                var b       = new GameMessageBlock(m);
                var chatRun = MergeArgsv2(m.Message, m.Arguments);
                chatRun.Foreground = (m as NotifyBarMessage).MessageColor.CacheToBrush();
                p.Inlines.Add(chatRun);
                b.Blocks.Add(p);
                return(b);
            }
            return(null);
        }
Пример #25
0
 public void Handle(IGameMessage message, IActionScope turnScope)
 {
 }
Пример #26
0
 private void HandleChatTalkMessage(IGameMessage msg)
 {
     ChatTalkMessage message = (ChatTalkMessage) msg;
     Entry.UserInterace.Chat.Log(message.Message);
 }
Пример #27
0
 public void Handle(IGameMessage @event, IReactionScope scope)
 {
     this.OfType <IHandleExternalEvents>().ForEach(card => card.Handle(@event, scope));
 }
Пример #28
0
 public GameMessageBlock(IGameMessage mess)
 {
     Message = mess;
 }
Пример #29
0
 public void Handle(IGameMessage @event)
 {
     RouteToNewSagas(@event);
     RouteToExistingSagas(@event);
 }
 public static EatHealedHealthMessage AsEatHealed(this IGameMessage msg) =>
 AssertCast <EatHealedHealthMessage>(msg, MessageId.EatHealedHealth);
Пример #31
0
 public virtual void SendMessageToClient(IGameMessage _IGameMessage, Client _Client)
 {
 }
Пример #32
0
 public Event(IGameMessage _IGameMessage, GameMessageImportance _GameMessageImportance)
 {
     this.IGameMessage = _IGameMessage;
     this.Importance = _GameMessageImportance;
 }
Пример #33
0
 public void addEvent(IGameMessage _IGameMessage)
 {
     this.addEvent(_IGameMessage, GameMessageImportance.UnImportant);
 }
Пример #34
0
        //TODO: Position des Objektes fehlt natürich noch ;D
        private void sendMessageToClientsInRange(IGameMessage _IGameMessage, GameMessageImportance _GameMessageImportance)
        {
            int var_Range = 500;

            foreach (Client var_Client in this.serverClients)
            {
                if (var_Client.PlayerObject != null)
                {
                    int var_Distance = (int) Math.Sqrt(Math.Pow(var_Client.PlayerObject.Position.X, 2) + Math.Pow(var_Client.PlayerObject.Position.Y, 2));
                    if (var_Distance <= var_Range)
                    {
                        this.SendMessageToClient(_IGameMessage, var_Client);
                    }
                }
            }
        }
Пример #35
0
        public override void Message(IGameMessage msg)
        {
            HitBoxMessage boxes = msg as HitBoxMessage;
            if (boxes != null)
            {
                foreach (CollisionBox box in boxes.AddBoxes)
                {
                    box.SetParent(this);
                    AddBox(box);
                }

                enabledBoxes.Clear();
                foreach (var name in boxes.EnableBoxes)
                {
                    if (!boxIDsByName.ContainsKey(name))
                    {
                        throw new GameRunException(String.Format("The {0} entity wanted to enable a hitbox named {1}, which doesn't exist.", Parent.Name, name));
                    }

                    enabledBoxes.Add(boxIDsByName[name]);
                }

                return;
            }
        }
Пример #36
0
 public Event(IGameMessage _IGameMessage, GameMessageImportance _GameMessageImportance)
 {
     this.IGameMessage = _IGameMessage;
     this.Importance   = _GameMessageImportance;
 }
 public static ForcedMovementMessage AsForcedMovement(this IGameMessage msg) =>
 AssertCast <ForcedMovementMessage>(msg, MessageId.ForcedMovement);
 public static ParticleEffectMessage AsParticleEffect(this IGameMessage msg) =>
 AssertCast <ParticleEffectMessage>(msg, MessageId.ParticleEffect);
Пример #39
0
        public override void Message(IGameMessage msg)
        {
            if (msg is DamageMessage && flashing == 0)
            {
                if (Engine.Instance.Invincible && Parent.Name == "Player") return;

                DamageMessage damage = (DamageMessage)msg;

                Health -= damage.Damage;

                Hit = true;
                flashing = flashtime;
            }
            else if (msg is HealMessage)
            {
                HealMessage heal = (HealMessage)msg;

                Health += heal.Health;
            }
        }
 public static AnimationMessage AsNewAnimation(this IGameMessage msg) =>
 AssertCast <AnimationMessage>(msg, MessageId.NewAnimation);
Пример #41
0
        public static Block GameMessageToBlock(IGameMessage m)
        {
            if (m == null)
                return null;

            if (m is PlayerEventMessage)
            {
                if (m.IsMuted) return null;
                var b = new GameMessageBlock(m);
                var p = new Paragraph();
                var prun = new Run(m.From + " ");
                prun.Foreground = m.From.Color.CacheToBrush();
                prun.FontWeight = FontWeights.Bold;
                p.Inlines.Add(prun);

                var chatRun = MergeArgsv2(m.Message, m.Arguments);
                chatRun.Foreground = new SolidColorBrush(m.From.Color);
                //chatRun.FontWeight = FontWeights.Bold;
                p.Inlines.Add(chatRun);

                b.Blocks.Add(p);

                return b;
            }
            else if (m is ChatMessage)
            {
                if (m.IsMuted) return null;

                var p = new Paragraph();
                var b = new GameMessageBlock(m);

                var inline = new Span();

                inline.Foreground = m.From.Color.CacheToBrush();
                var chatRun = new Run("<" + m.From + "> ");
                chatRun.Foreground = m.From.Color.CacheToBrush();
                chatRun.FontWeight = FontWeights.Bold;
                inline.Inlines.Add(chatRun);

                inline.Inlines.Add(MergeArgsv2(m.Message, m.Arguments));

                p.Inlines.Add(inline);

                b.Blocks.Add(p);

                return b;
            }
            else if (m is WarningMessage)
            {
                if (m.IsMuted) return null;

                var b = new GameMessageBlock(m);
                var block = new BlockUIContainer();
                var border = new Border()
                {
                    CornerRadius = new CornerRadius(4),
                    BorderBrush = Brushes.Gray,
                    BorderThickness = new Thickness(1),
                    Padding = new Thickness(5),
                    Background = Brushes.LightGray,
                };
                var tb = new TextBlock(MergeArgsv2(m.Message, m.Arguments));
                tb.Foreground = m.From.Color.CacheToBrush();
                tb.TextWrapping = TextWrapping.Wrap;

                border.Child = tb;
                block.Child = border;

                b.Blocks.Add(block);

                return b;
            }
            else if (m is SystemMessage)
            {
                if (m.IsMuted) return null;

                var p = new Paragraph();
                var b = new GameMessageBlock(m);
                var chatRun = MergeArgsv2(m.Message, m.Arguments);
                chatRun.Foreground = m.From.Color.CacheToBrush();
                p.Inlines.Add(chatRun);
                b.Blocks.Add(p);
                return b;
            }
            else if (m is NotifyMessage)
            {
                if (m.IsMuted) return null;

                var p = new Paragraph();
                var b = new GameMessageBlock(m);
                var chatRun = MergeArgsv2(m.Message, m.Arguments);
                chatRun.Foreground = m.From.Color.CacheToBrush();
                b.Blocks.Add(p);
                p.Inlines.Add(chatRun);
                return b;
            }
            else if (m is TurnMessage)
            {
                if (m.IsMuted) return null;

                var brush = m.From.Color.CacheToBrush();

                var p = new Paragraph();
                var b = new GameMessageBlock(m);
                b.TextAlignment = TextAlignment.Center;
                b.Margin = new Thickness(2);

                p.Inlines.Add(
                    new Line
                    {
                        X1 = 0,
                        X2 = 40,
                        Y1 = -4,
                        Y2 = -4,
                        StrokeThickness = 2,
                        Stroke = brush
                    });

                var chatRun = new Run(string.Format(m.Message, m.Arguments));
                chatRun.Foreground = brush;
                chatRun.FontWeight = FontWeights.Bold;
                p.Inlines.Add(chatRun);

                var prun = new Run(" " + (m as TurnMessage).TurnPlayer + " ");
                prun.Foreground = (m as TurnMessage).TurnPlayer.Color.CacheToBrush();
                prun.FontWeight = FontWeights.Bold;
                p.Inlines.Add(prun);

                p.Inlines.Add(
                    new Line
                    {
                        X1 = 0,
                        X2 = 40,
                        Y1 = -4,
                        Y2 = -4,
                        StrokeThickness = 2,
                        Stroke = brush
                    });

                b.Blocks.Add(p);

                //if (((Paragraph)output.Document.Blocks.LastBlock).Inlines.Count == 0)
                //    output.Document.Blocks.Remove(output.Document.Blocks.LastBlock);

                return b;

                //output.Document.Blocks.Add(new Paragraph { Margin = new Thickness() });
            }
            else if (m is DebugMessage)
            {
                if (m.IsMuted) return null;
                var p = new Paragraph();
                var b = new GameMessageBlock(m);
                var chatRun = MergeArgsv2(m.Message, m.Arguments);
                chatRun.Foreground = m.From.Color.CacheToBrush();
                p.Inlines.Add(chatRun);
                b.Blocks.Add(p);
                return b;
            }
            else if (m is NotifyBarMessage)
            {
                if (m.IsMuted) return null;
                var p = new Paragraph();
                var b = new GameMessageBlock(m);
                var chatRun = MergeArgsv2(m.Message, m.Arguments);
                chatRun.Foreground = (m as NotifyBarMessage).MessageColor.CacheToBrush();
                p.Inlines.Add(chatRun);
                b.Blocks.Add(p);
                return b;
            }
            return null;
        }
 public static OverheadTextMessage AsNewOverheadText(this IGameMessage msg) =>
 AssertCast <OverheadTextMessage>(msg, MessageId.NewOverheadText);
Пример #43
0
 public void Handle(IGameMessage @event, IActionScope scope)
 {
     this.ToList().OfType <IHandleInternalEvents>().ForEach(card => card.Handle(@event, scope));
 }
 public static DefinitionChangeMessage AsDefinitionChange(this IGameMessage msg) =>
 AssertCast <DefinitionChangeMessage>(msg, MessageId.DefinitionChange);
Пример #45
0
 public virtual void SendMessage(IGameMessage _IGameMessage, GameMessageImportance _Importance)
 {
 }
 public static ChatMessageMessage AsChatMessage(this IGameMessage msg) =>
 AssertCast <ChatMessageMessage>(msg, MessageId.ChatMessage);
Пример #47
0
 public void Handle(IGameMessage @event, IReactionScope scope)
 {
 }
 public static NotificationMessage AsClientRegionChange(this IGameMessage msg) =>
 AssertCast <NotificationMessage>(msg, MessageId.ClientRegionChanged);
Пример #49
0
 public GameMessageBlock(IGameMessage mess)
 {
     Message = mess;
 }
 public IEventResponse HandleGameEvent(IGameMessage @event, IReactionScope scope)
 {
     return(_ai.HandleGameEvent(@event, scope));
 }
Пример #51
0
 public bool CanHandle(IGameMessage @event)
 {
     return(true);
 }
Пример #52
0
 public override void Message(IGameMessage msg)
 {
 }
Пример #53
0
 public void Publish(IGameMessage @event)
 {
 }
Пример #54
0
 public abstract void Message(IGameMessage msg);