Esempio n. 1
0
        //Returns an ItemData object detailing what is currently being stored in a characters inventory slot
        public static ItemData GetInventorySlot(string CharacterName, int InventorySlot)
        {
            //Create a new ItemData object to store all the data about the characters inventory slot
            ItemData InventoryItem = new ItemData();

            //Define/execute some new queries/commands for extracting all info about the item in the characters target inventory slot, store it all in the InventoryItem object
            string ItemNumberQuery = "SELECT ItemSlot" + InventorySlot + "ItemNumber FROM inventories WHERE CharacterName='" + CharacterName + "'";

            InventoryItem.ItemNumber = CommandManager.ExecuteScalar(ItemNumberQuery, "Fetching ItemNumber value from " + CharacterName + "s InventorySlot #" + InventorySlot);
            string ItemIDQuery = "SELECT ItemSlot" + InventorySlot + "ItemID FROM inventories WHERE CharacterName='" + CharacterName + "'";

            InventoryItem.ItemID = CommandManager.ExecuteScalar(ItemIDQuery, "Fetching ItemID value from " + CharacterName + "s InventorySlot #" + InventorySlot);

            //Lastly use the item info database to find out what slot this item belongs in when being equipped, the store it in and return the final InventoryItem object
            InventoryItem.ItemEquipmentSlot = ItemInfoDatabase.GetItemSlot(InventoryItem.ItemNumber);
            return(InventoryItem);
        }
Esempio n. 2
0
        private bool StartServer(string ServerIP)
        {
            //Display a message to the console indicating the server is not being started
            MessageLog.Print("Starting server on " + ServerIP);

            //Before connecting to the server we need to load the connection settings from the .xml config file, start by loading the file into memory
            XmlDocument ConnectionSettings = new XmlDocument();

            ConnectionSettings.Load("SQLConnectionSettings.xml");

            //Extract all the required values from the file and store each of their into their own variables
            int    NetworkPort        = Convert.ToInt32(ConnectionSettings.DocumentElement.SelectSingleNode("/root/NetworkPort").InnerText);
            string WindowsServiceName = ConnectionSettings.DocumentElement.SelectSingleNode("/root/WindowsServiceName").InnerText;
            string Username           = ConnectionSettings.DocumentElement.SelectSingleNode("/root/Username").InnerText;
            string Password           = ConnectionSettings.DocumentElement.SelectSingleNode("/root/Password").InnerText;

            //Load all the existing game items from the exported text file
            ItemInfoDatabase.LoadItemList("Content/MasterItemList.txt");
            ItemManager.InitializeItemManager();

            //Start listening for new network client connections
            ConnectionManager.Initialize(ServerIP);

            //Open a new window for rendering so we can see whats going on while the server is up
            ApplicationWindow = new Window("Swaelo Server 2.0", new Int2(1024, 768), WindowMode.Windowed); // new Int2(1700, 100), WindowMode.Windowed);
            LogicLoop         = new GameLoop(ApplicationWindow);

            //Load in the contents needed for the scene to run
            ContentArchive Content;

            using (var Stream = typeof(Program).Assembly.GetManifestResourceStream("Server.Content.ServerContents.contentarchive"))
                Content = ContentArchive.Load(Stream);

            //Initialize the game world simulation
            World = new GameWorld(LogicLoop, Content);

            return(true);
        }