示例#1
0
        private void OnStartup(object sender, StartupEventArgs ev)
        {
            var cd = AppDomain.CurrentDomain;

            cd.UnhandledException += GlobalUnhandledExceptionHandler;
            System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.High;
            if (File.Exists(Environment.CurrentDirectory + "/TCCupdater.exe"))
            {
                File.Delete(Environment.CurrentDirectory + "/TCCupdater.exe");
            }
            UpdateManager.CheckAppVersion();
            UpdateManager.CheckDatabaseVersion();



            TeraSniffer.Instance.Enabled = true;
            WindowManager.Init();
            LoadSettings();
            PacketRouter.Init();

            TeraSniffer.Instance.NewConnection += (srv) => SkillManager.Clear();
            TeraSniffer.Instance.EndConnection += () => SkillManager.Clear();

            var LoadThread = new Thread(new ThreadStart(() =>
            {
                SkillsDatabase.Load();
                Console.WriteLine("Skills loaded.");
                BroochesDatabase.SetBroochesIcons();
                Console.WriteLine("Set brooches icons");
                MonsterDatabase.Populate();
                Console.WriteLine("Monsters loaded");
                AbnormalityDatabase.Load();
                Console.WriteLine("Abnormalities loaded");
                WindowManager.CooldownWindow.LoadingDone();
            }));

            SessionManager.CurrentPlayer.Class = Class.None;

            WindowManager.ShowWindow(WindowManager.CooldownWindow);
            LoadThread.Start();
            //Debug();
        }
        private void OnStartup(object sender, StartupEventArgs ev)
        {
            var cd = AppDomain.CurrentDomain;

            cd.UnhandledException += GlobalUnhandledExceptionHandler;
            Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
            if (File.Exists(Environment.CurrentDirectory + "/TCCupdater.exe"))
            {
                File.Delete(Environment.CurrentDirectory + "/TCCupdater.exe");
            }
            UpdateManager.CheckAppVersion();
            UpdateManager.CheckDatabaseVersion();

            SkillsDatabase.Load();
            //ItemSkillsDatabase.SetBroochesIcons();
            SettingsManager.LoadWindowSettings();
            SettingsManager.LoadSettings();
            WindowManager.Init();
            WindowManager.Settings = new SettingsWindow()
            {
                Name = "Settings"
            };
            FocusManager.FocusTimer.Start();
            TwitchConnector.Instance.Init();
            PacketProcessor.Init();

            TeraSniffer.Instance.NewConnection += (srv) =>
            {
                SkillManager.Clear();
                WindowManager.TrayIcon.Icon = WindowManager.ConnectedIcon;
                ChatWindowViewModel.Instance.AddTccMessage($"Connected to {srv.Name}.");
            };
            TeraSniffer.Instance.EndConnection += () =>
            {
                ChatWindowViewModel.Instance.AddTccMessage("Disconnected from the server.");
                GroupWindowViewModel.Instance.ClearAllAbnormalities();
                BuffBarWindowViewModel.Instance.Player.ClearAbnormalities();
                EntitiesManager.ClearNPC();

                SkillManager.Clear();
                WindowManager.TrayIcon.Icon = WindowManager.DefaultIcon;
                Proxy.CloseConnection();
            };

            SessionManager.CurrentPlayer.Class = Class.None;
            SessionManager.CurrentPlayer.Name  = "player";

            TeraSniffer.Instance.Enabled = true;
            TimeManager.Instance.SetServerTimeZone(SettingsManager.LastRegion);

            var v   = Assembly.GetExecutingAssembly().GetName().Version;
            var ver = $"TCC v{v.Major}.{v.Minor}.{v.Build}";

            ChatWindowViewModel.Instance.AddTccMessage(ver);

            if (!Debug)
            {
                return;
            }
            SessionManager.CurrentPlayer = new Player(1, "Foglio");
            CooldownWindowViewModel.Instance.LoadSkills(Utils.ClassEnumToString(Class.Warrior).ToLower() + "-skills.xml", Class.Warrior);

            for (uint i = 0; i < 1; i++)
            {
                var u = new User(GroupWindowViewModel.Instance.GetDispatcher());
                u.Name      = "Test_Dps" + i;
                u.PlayerId  = i;
                u.Online    = true;
                u.UserClass = Class.Warrior;


                GroupWindowViewModel.Instance.AddOrUpdateMember(u);
            }
            for (uint i = 0; i < 2; i++)
            {
                var u = new User(GroupWindowViewModel.Instance.GetDispatcher());
                u.Name      = "Test_Healer" + i;
                u.PlayerId  = i + 10;
                u.Online    = true;
                u.UserClass = Class.Elementalist;
                if (i == 1)
                {
                    u.Alive = false;
                }
                if (i == 0)
                {
                    u.Name = "Foglio";
                }

                GroupWindowViewModel.Instance.AddOrUpdateMember(u);
            }
            for (uint i = 0; i < 4; i++)
            {
                var u = new User(GroupWindowViewModel.Instance.GetDispatcher());
                u.Name      = "Test_Tank" + i;
                u.PlayerId  = i + 100;
                u.Online    = true;
                u.UserClass = Class.Lancer;
                GroupWindowViewModel.Instance.AddOrUpdateMember(u);
            }
            //foreach (var user in GroupWindowViewModel.Instance.Members)
            //{
            //    user.AddOrRefreshBuff(new Abnormality(4611, true, true, false, AbnormalityType.Buff),60*100*60,1);
            //    user.AddOrRefreshBuff(new Abnormality(46126, true, true, false, AbnormalityType.Buff),60*100*60,1);
            //    user.AddOrRefreshDebuff(new Abnormality(89308100, true, false, false, AbnormalityType.DOT),60*100*60,5);
            //    user.AddOrRefreshDebuff(new Abnormality(89308101, true, false, false, AbnormalityType.DOT),60*100*60,5);

            //}
            //GroupWindowViewModel.Instance.StartRoll();
            //GroupWindowViewModel.Instance.SetReadyStatus(new ReadyPartyMember());
        }