Ejemplo n.º 1
0
        private static void HandleMessage(byte[] data)
        {
            Color color;
            var   buffer = new PacketBuffer();

            buffer.AddBytes(data);
            buffer.GetInteger();
            var colorCode = buffer.GetInteger();

            switch (colorCode)
            {
            case (int)MessageColors.Warning:
                color = Color.DarkRed;
                break;

            case (int)MessageColors.Notification:
                color = Color.DarkGoldenrod;
                break;

            case (int)MessageColors.Minor:
                color = Color.DarkOliveGreen;
                break;

            case (int)MessageColors.Announcement:
                color = Color.SkyBlue;
                break;

            default:
                color = Color.DarkGray;
                break;
            }

            InterfaceGUI.AddChats(buffer.GetString(), color);
        }
Ejemplo n.º 2
0
 private static void EdgeWarning()
 {
     if (messageTime + 1000 >= Game1.Tick)
     {
         return;
     }
     messageTime = Game1.Tick;
     InterfaceGUI.AddChats("We shouldn't go beyond the edge of the mapped galaxy.", Color.DarkGoldenrod);
 }
Ejemplo n.º 3
0
        private static void HandleItems(byte[] data)
        {
            InterfaceGUI.AddChats(@"Item dictionary downloaded.", Color.DarkOliveGreen);
            var buffer = new PacketBuffer();

            buffer.AddBytes(data);
            buffer.GetInteger();
            GameLogic.Items = buffer.GetList <Item>();
            buffer.Dispose();
        }
Ejemplo n.º 4
0
        public void SendRegister()
        {
            InterfaceGUI.AddChats("Registering new user...", Color.DarkOliveGreen);
            var buffer = new PacketBuffer();

            buffer.AddInteger((int)CRegister);
            buffer.AddString(Globals.registerUsername);
            buffer.AddString(Globals.registerPassword);
            SendData(buffer.ToArray());
            buffer.Dispose();
        }
Ejemplo n.º 5
0
        public void SendLogin()
        {
            InterfaceGUI.AddChats("Logging in...", Color.DarkOliveGreen);
            var buffer = new PacketBuffer();

            buffer.AddInteger((int)CLogin);
            buffer.AddString(Globals.loginUsername);
            buffer.AddString(Globals.loginPassword);
            SendData(buffer.ToArray());
            buffer.Dispose();
        }
Ejemplo n.º 6
0
        private void GoodRegister(byte[] data)
        {
            var buffer = new PacketBuffer();

            buffer.AddBytes(data);
            buffer.GetInteger();
            GameLogic.PlayerIndex = buffer.GetInteger(); // Index on server side
            buffer.Dispose();
            ctcp.SendLogin();
            MenuManager.Clear(2);
            InterfaceGUI.AddChats(@"Registration successful.", Color.DarkOliveGreen);
        }
Ejemplo n.º 7
0
        private static void HandleGalaxy(byte[] data)
        {
            InterfaceGUI.AddChats(@"Galaxy downloaded.", Color.DarkOliveGreen);
            var buffer = new PacketBuffer();

            buffer.AddBytes(data);
            buffer.GetInteger();
            GameLogic.Galaxy = buffer.GetList <Star>();
            GameLogic.CollectPlanets();
            InterfaceGUI.PopulateMap();
            buffer.Dispose();
        }
Ejemplo n.º 8
0
        private static void GetStaticPulse(byte[] data)
        {
            InterfaceGUI.AddChats(@"Existing connections downloaded.", Color.DarkOliveGreen);
            // Someone new connected so this is all the data we don't need updating every 100ms
            var buffer = new PacketBuffer();

            buffer.AddBytes(data);
            buffer.GetInteger();
            var numPlayers = buffer.GetInteger();

            for (var i = 0; i != numPlayers; i++)
            {
                var index = buffer.GetInteger();
                Types.Player[index].Name = buffer.GetString();
            }
            buffer.Dispose();
        }
Ejemplo n.º 9
0
        public static void Navigate(bool initial = false)
        {
            if (!Navigating)
            {
                return;
            }
            var start     = new Vector2(Types.Player[PlayerIndex].X, Types.Player[PlayerIndex].Y);
            var direction = Vector2.Normalize(start - Destination);

            distance = Vector2.Distance(start, Destination);
            if (navAngle == -1 && distance < 750)
            {
                Navigating = false;
                InterfaceGUI.AddChats(@"Too close to engage autonavigation", Color.BurlyWood);
            }
            if (navTimer + 1000 <= Game1.Tick)
            {
                navTimer = Game1.Tick;
                navAngle = (float)Math.Atan2(direction.Y, direction.X) - MathHelper.ToRadians(90);
                if (navAngle < 0)
                {
                    navAngle += (float)Math.PI * 2;
                }
                else if (navAngle > (float)Math.PI * 2)
                {
                    navAngle -= (float)Math.PI * 2;
                }
            }
            Globals.DirUp = true;
            if (Math.Abs(Types.Player[PlayerIndex].Rotation - navAngle) <= .05F)
            {
                Types.Player[PlayerIndex].Rotation = navAngle;
            }
            else
            {
                Rotate(Math.Abs(Types.Player[PlayerIndex].Rotation - navAngle) >= 3.14 ? 1 : 0);
            }

            if (distance >= 150)
            {
                return;
            }
            Navigating = false;
            InterfaceGUI.AddChats(@"We've reached our destination", Color.BurlyWood);
        }
Ejemplo n.º 10
0
        public static void Aerology()
        {
            if (GameLogic.selectedPlanet == "")
            {
                return;
            }
            var PLANET = GameLogic.Planets.FirstOrDefault(p => p.Id == GameLogic.selectedPlanet);
            var P      = Types.Player[GameLogic.PlayerIndex];

            if (P.X < PLANET.X + 500 && P.X > PLANET.X - 500 && P.Y < PLANET.Y + 500 && P.Y > PLANET.Y - 500)
            {
                Console.WriteLine("Aerology");
            }
            else
            {
                InterfaceGUI.AddChats("You are too far away to interact with " + PLANET.Name + ".", Color.DarkGoldenrod);
            }
        }
Ejemplo n.º 11
0
        private static void DownloadData(byte[] data)
        {
            var buffer = new PacketBuffer();

            buffer.AddBytes(data);
            buffer.GetInteger();
            GameLogic.PlayerIndex = buffer.GetInteger(); // Index on server side
            var suppress = buffer.GetInteger();
            var i        = GameLogic.PlayerIndex;

            Types.Player[i] = new User
            {
                Id          = buffer.GetString(),
                Name        = buffer.GetString(),
                X           = buffer.GetFloat(),
                Y           = buffer.GetFloat(),
                Rotation    = buffer.GetFloat(),
                Health      = buffer.GetInteger(),
                MaxHealth   = buffer.GetInteger(),
                Shield      = buffer.GetInteger(),
                MaxShield   = buffer.GetInteger(),
                Rank        = buffer.GetString(),
                Credits     = buffer.GetInteger(),
                Exp         = buffer.GetInteger(),
                Level       = buffer.GetInteger(),
                Weap1Charge = buffer.GetInteger(),
                Weap2Charge = buffer.GetInteger(),
                Weap3Charge = buffer.GetInteger(),
                Weap4Charge = buffer.GetInteger(),
                Weap5Charge = buffer.GetInteger(),
                Inventory   = buffer.GetList <Inventory>()
            };
            buffer.Dispose();
            if (suppress == 1)
            {
                return;
            }
            MenuManager.Clear(1);
            Globals.graphicsChange = Globals.Fullscreen;
            InterfaceGUI.AddChats(@"User data downloaded.", Color.DarkOliveGreen);
        }
Ejemplo n.º 12
0
        public static void Trade()
        {
            if (GameLogic.selectedPlanet == "")
            {
                return;
            }
            var PLANET = GameLogic.Planets.FirstOrDefault(p => p.Id == GameLogic.selectedPlanet);
            var P      = Types.Player[GameLogic.PlayerIndex];

            if (P.X < PLANET.X + 500 && P.X > PLANET.X - 500 && P.Y < PLANET.Y + 500 && P.Y > PLANET.Y - 500)
            {
                Globals.inventoryMode = 2;
                Game1.IGUI.pInv       = false;
                Game1.IGUI.PopulateInventory();
                MenuManager.ChangeMenu(MenuManager.Menu.Inventory);
            }
            else
            {
                InterfaceGUI.AddChats("You are too far away to interact with " + PLANET.Name + ".", Color.DarkGoldenrod);
            }
        }