示例#1
0
        // Initialize the Core :D
        public static void InitCore(CallBackLog l, CallBackEvent e)
        {
            // Can't run this more than once
            if (inited)
            {
                return;
            }

            // We need to be able to Log stuff
            if (l == null)
            {
                return;
            }
            if (e == null)
            {
                return;
            }

            Log   = l;
            Event = e;

            Log(LogType.System, "BoogieBot.dll Initializing...");

            // Initialize everything
            try
            {
                if (!File.Exists(Environment.CurrentDirectory + "/" + BoogieCore.BoogieBotConfigFileName))
                {
                    throw new FileNotFoundException("Configuration file not found.", BoogieCore.BoogieBotConfigFileName);
                }

                configFile = new IniReader(Environment.CurrentDirectory + "/boogiebot.ini");

                // NOTE: Set any OS specific variables so things can be done differently later, ie. Windows or Linux, etc.
                OperatingSystem os = Environment.OSVersion;
                switch (os.Platform)
                {
                case PlatformID.Win32Windows:
                    Log(LogType.System, "> Operating System: Windows");
                    break;

                case PlatformID.Win32NT:
                    Log(LogType.System, "> Operating System: Windows NT");
                    break;

                case PlatformID.Unix:
                    Log(LogType.System, "> Operating System: Unix");
                    break;
                }
                Log(LogType.System, "> OS Version: {0}.{1}  (Build: {2})  ({3})", os.Version.Major, os.Version.Minor, os.Version.Build, os.ServicePack);

                // Find WoW's Folder
                wowPath = BoogieCore.getWowPath();
                Log(LogType.System, "> WowPath: {0}", wowPath);

                // Find WoW's Version
                wowVersion = BoogieCore.getWoWVersion();
                Log(LogType.System, "> WoW Version: World of Warcraft {0}.{1}.{2}.{3} ({4}) Found!  Emulating this version.", wowVersion.major, wowVersion.minor, wowVersion.update, wowVersion.build, BoogieCore.WowTypeString);


                world  = new World();
                player = new Player();

                //areaTable = new AreaTable();
                //mapTable = new MapTable();
            }
            catch (Exception ex)
            {
                // Bot Start up Failed. Log why, and rethrow the exception.
                Log(LogType.System, ex.Message);
                Log(LogType.System, ex.StackTrace);

                throw new Exception("BoogieBot.dll Init Failure.", ex);
            }

            inited = true;
            Log(LogType.System, "BoogieBot.dll Initialized.");
        }