Beispiel #1
0
        private void HandleReceivedMessage(object sender, ServerLinkMessageEvent message)
        {
            switch (message.MessageType)
            {
                case MessageType.MsgWorld:
                    Console.WriteLine("Loading map...");

                    MsgWorldPacket worldPacket = (MsgWorldPacket)message.MessageData;

                    LoadMap(worldPacket.Map);

                    Console.WriteLine(String.Format("Map \"{0}\" loaded.", WorldName));

                    break;

                case MessageType.MsgDeath:
                    MsgDeathPacket deathPacket = (MsgDeathPacket)message.MessageData;

                    Player killee = PlayerManager.GetPlayerBySlot(deathPacket.Slot);
                    Player killer = PlayerManager.GetPlayerBySlot(deathPacket.Killer);

                    if (killee == null || killer == null)
                        return;

                    ConsoleMessageLine consoleMessage;

                    if (killer == PlayerManager.LocalPlayer)
                    {
                        consoleMessage =
                            new ConsoleMessageLine(
                                "You killed ", Color.White,
                                killee.Callsign, ProtocolHelpers.TeamTypeToColor(killer.Team));
                    }
                    else
                    {
                        consoleMessage =
                            new ConsoleMessageLine(
                                killee.Callsign, ProtocolHelpers.TeamTypeToColor(killee.Team),
                                " was killed by ", Color.White,
                                killer.Callsign, ProtocolHelpers.TeamTypeToColor(killer.Team));
                    }

                    Console.WriteLine(consoleMessage);

                    break;

                default:
                    break;
            }
        }
Beispiel #2
0
 public void WriteLine(ConsoleMessageLine consoleMessage)
 {
     lines.AddFirst(consoleMessage);
 }
Beispiel #3
0
        public virtual Single DrawLine(GameTime gameTime, ConsoleMessageLine line, Vector2 position)
        {
            // decrement our intial position
            Vector2 messageSize = consoleFont.MeasureString("ABC!");
            position.Y -= messageSize.Y / 2; // nuclex's truetype font importer measures from the baseline

            foreach (ConsoleMessagePart part in line.Parts)
            {
                // TODO break lines/words to span across multiple lines if necessary
                spriteBatch.DrawString(consoleFont,
                                       part.Message,
                                       position,
                                       part.Color, 0,
                                       Vector2.Zero,
                                       1, SpriteEffects.None, 1);

                position.X += consoleFont.MeasureString(part.Message).X;
            }

            return messageSize.Y;
        }
Beispiel #4
0
        public virtual Single DrawPrompt(GameTime gameTime, Vector2 position)
        {
            ConsoleMessageLine promptLine = new ConsoleMessageLine();

            // blink prompt
            if (currentBlinkTime > PromptBlinkRate)
            {
                promptBlinking = !promptBlinking;
                currentBlinkTime -= PromptBlinkRate;
            }
            
            if (promptBlinking && PromptActive)
                promptLine.Parts.AddLast(new ConsoleMessagePart(PromptPrefix.Message, Color.Black));
            else
                promptLine.Parts.AddLast(PromptPrefix);

            promptLine.Parts.AddLast(new ConsoleMessagePart(currentPromptInput == null ? "" : currentPromptInput,
                                                            Color.White));

            DrawCursor(gameTime, position);

            return DrawLine(gameTime, promptLine, position);
        }
Beispiel #5
0
        public override void Die(Player killer)
        {
            // send out the death packet right away
            NetOutgoingMessage deathMessage = World.ServerLink.CreateMessage();

            MsgDeathPacket deathPacket = new MsgDeathPacket(killer.Slot);

            deathMessage.Write((Byte)deathPacket.MsgType);
            deathPacket.Write(deathMessage);

            World.ServerLink.SendMessage(deathMessage, NetDeliveryMethod.ReliableOrdered, 0);

            // write to console that you were killed
            ConsoleMessageLine consoleMessage;

            if (killer != this)
            {
                consoleMessage =
                    new ConsoleMessageLine(
                        "You were killed by ", Color.White,
                        killer.Callsign, ProtocolHelpers.TeamTypeToColor(killer.Team));
            }
            else
            {
                consoleMessage = new ConsoleMessageLine("You blew yourself up!", Color.White);
            }

            World.Console.WriteLine(consoleMessage);

            base.Die(killer);
        }