Ejemplo n.º 1
0
        public ChatInterface()
        {
            base.initialize(10000);
            MainView = new View(GeeUI.GeeUI.RootView) { Width = 290, Height = 200, X = 10, Y = 500 - 240 };
            ChatEntryField = new TextFieldView(MainView, new Vector2(0, 180), AssetManager.GetFont("Console")) { Width = 290, Height = 20, MultiLine = false, AutoWrap = false};
            ChatLogField = new TextFieldView(MainView, new Vector2(0, 95), AssetManager.GetFont("Console"))
                               {Width = 290, Height = 75, Editable = false, MultiLine = true};
            ChatEntryField.OnEnterPressed += (sender, e) =>
                                                 {
                                                     string text = ChatEntryField.Text;
                                                     ChatEntryField.ClearText();
                                                     HideChatEntry();

                                                     if (text == "") return;
                                                     Packet1CSGameEvent pack = new Packet1CSGameEvent(GameServer.GameEvents.Player_Chat, false, text);
                                                     Main.clientNetworkManager.SendPacket(pack);

                                                 };
            HideChatEntry();
        }
Ejemplo n.º 2
0
        public static void ConsoleInit()
        {
            ConsoleManager.AddConVar("player_name", "Your name in a server", "Player_" + Main.R.Next(0, 1000), l =>
            {
                if (Main.clientNetworkManager.IsConnected())
                {
                    Packet1CSGameEvent packet = new Packet1CSGameEvent(GameServer.GameEvents.Player_Change_Name, l);
                    Main.clientNetworkManager.SendPacket(packet);
                }
            });

            ConsoleManager.AddConVar("player_team", "Choose a team", "0", ls =>
            {
                if (Main.clientNetworkManager.IsConnected())
                {
                    Packet1CSGameEvent packet = new Packet1CSGameEvent(GameServer.GameEvents.Player_Choose_Team, Convert.ToByte(ls));
                    Main.clientNetworkManager.SendPacket(packet);
                }
            });
        }
Ejemplo n.º 3
0
        public static void ConsoleInit()
        {
            ConsoleManager.AddConCommand("showchat", "Show the chat window", () =>
            {
                if (!InterfaceManager.blocking && Main.clientNetworkManager.NetClient != null)
                {
                    ShowChatEntry();
                }
            });
            ConsoleManager.AddConCommand("hidechat", "Hide the chat window", HideChatEntry);

            ConsoleManager.AddConCommandArgs("say", "Say something", ls =>
            {
                Packet1CSGameEvent pack = new Packet1CSGameEvent(GameServer.GameEvents.Player_Chat, false, ls[0]);
                Main.clientNetworkManager.SendPacket(pack);
            }, 1);
        }
Ejemplo n.º 4
0
        public void Start()
        {
            InputManager.BindKey(() =>
            {
                if (InterfaceManager.blocking) return;
                _leftPressed = true;
                SendMovementFlags();
            }, Keys.A);

            InputManager.BindKey(() =>
            {
                if (InterfaceManager.blocking) return;
                _rightPressed = true;
                SendMovementFlags();
            }, Keys.D);

            InputManager.BindMouse(() =>
                                       {
                                           short angle = (short)((float)PlayerAimAngle).RToD();
                                           if (angle != PlayerAimAngle)
                                               SendMovementFlags();
                                       }, MouseButton.Movement, true, true);

            InputManager.BindKey(() =>
                                     {
                                         _leftPressed = false;

                                         SendMovementFlags();
                                     }, Keys.A, true, false);

            InputManager.BindKey(() =>
                                     {
                                         _rightPressed = false;
                                         SendMovementFlags();
                                     }, Keys.D, true, false);

            InputManager.BindKey(() =>
            {
                if (InterfaceManager.blocking) return;
                _jumpPressed = true;
                SendMovementFlags();
            }, Keys.W, true);

            InputManager.BindKey(() =>
                                     {
                                         _jumpPressed = false;
                                         SendMovementFlags();
                                     }, Keys.W, false, false);

            InputManager.BindKey(() =>
            {
                if (InterfaceManager.blocking) return;
                short blockID = GameWorld.GetBlockAt(PlayerEntity.GetEntityTile().X, PlayerEntity.GetEntityTile().Y).ID;
                if (blockID == 6)
                {
                    Packet1CSGameEvent pack = new Packet1CSGameEvent(GameServer.GameEvents.Player_KeyPress, 's', (bool)true);
                    Main.clientNetworkManager.SendPacket(pack);
                }
            }, Keys.S, true);
            // Duplicate was present

            InputManager.BindMouse(() =>
            {
                if (InterfaceManager.blocking || InputManager.GetMousePos().Y <= 50) return;
                _attackPressed = true;
                SendMovementFlags();
            }, MouseButton.Left);

            InputManager.BindMouse(() =>
                                       {
                                           _attackPressed = false;
                                           SendMovementFlags();
                                       }, MouseButton.Left, false);

            InputManager.BindMouse(() =>
            {
                if (InterfaceManager.blocking || InputManager.GetMousePos().Y <= 50) return;
                Item i = Inventory.GetPlayerItemInHand();
                if (i == null) return;
                Vector2 aim = PlayerEntity.GetBlockAimingAt();
                Packet1CSGameEvent pack = new Packet1CSGameEvent(GameServer.GameEvents.Player_Use_Item, (short)aim.X, (short)aim.Y);
                Main.clientNetworkManager.SendPacket(pack);
            }, MouseButton.Right);

            InputManager.BindKey(() =>
                                     {
                                         if (InterfaceManager.blocking) return;
                                         Packet1CSGameEvent p = new Packet1CSGameEvent(GameServer.GameEvents.Player_Drop_Item);
                                         Main.clientNetworkManager.SendPacket(p);
                                     }, Keys.F);

            InputManager.BindKey(() =>
            {
                _sprinting = true;
                SendMovementFlags();
            }, Keys.LeftShift);

            InputManager.BindKey(() =>
            {
                _sprinting = false;
                SendMovementFlags();
            }, Keys.LeftShift, true, false);

            InputManager.BindKey(() =>
            {
                if (InterfaceManager.blocking) return;
                Vector2 aim = PlayerEntity.GetBlockAimingAt();
                short id = GameWorld.GetBlockAt(aim.X, aim.Y).ID;
                if (id != 0)
                {
                    Packet1CSGameEvent p = new Packet1CSGameEvent(GameServer.GameEvents.Player_Use_Block, (short)aim.X, (short)aim.Y);
                    Main.clientNetworkManager.SendPacket(p);
                }
            }, Keys.E, false);

            InputManager.BindKey(() =>
            {
                if (InterfaceManager.blocking) return;
                if (PlayerEntity.PClass is PlayerClassDestroyer == false)
                    return;

                PlayerClassDestroyer c = (PlayerClassDestroyer)PlayerEntity.PClass;
                Vector2 aim = PlayerEntity.GetBlockAimingAt();
                short id = GameWorld.GetBlockAt(aim.X, aim.Y).ID;

                if(c.BlockInHand != 0)
                {
                    Packet1CSGameEvent p = new Packet1CSGameEvent(GameServer.GameEvents.Player_Place_Block);
                    Main.clientNetworkManager.SendPacket(p);
                    return;
                }
                if (id != 0) {
                    Packet1CSGameEvent p = new Packet1CSGameEvent(GameServer.GameEvents.Player_Pickup_Block, (short)aim.X, (short)aim.Y);
                    Main.clientNetworkManager.SendPacket(p);
                }
            }, Keys.Q);

            InputManager.BindMouse(() =>
            {
                if (InterfaceManager.blocking) return;
                return;
            }, MouseButton.Middle);
        }
Ejemplo n.º 5
0
 public static void SendMessageToAll(string message)
 {
     Packet1CSGameEvent pack = new Packet1CSGameEvent(GameEvents.Player_Chat, (byte)0, false, message);
     ServerNetworkManager.SendPacket(pack);
 }
Ejemplo n.º 6
0
        public void BlockPressed(int i)
        {
            int b = i + 3;
            CurSelected = b;
            GameWorld.ThePlayer.Inventory.PlayerInventorySelected = b;
            Packet p = new Packet1CSGameEvent(GameServer.GameEvents.Player_Inventory_Selection_Change, (byte)b);
            Main.clientNetworkManager.SendPacket(p);

            for (int j = 0; j < 9; j++)
            {
                _buttons[j].NinePatchNormal = GeeUI.GeeUI.NinePatchBtnDefault;
            }
            _buttons[i].NinePatchNormal = GeeUI.GeeUI.NinePatchBtnClicked;
        }