Пример #1
0
        public override void SetUp()
        {
            storage = new TemporaryNativeStorage("realm-benchmark");
            storage.DeleteDirectory(string.Empty);

            realm = new RealmAccess(storage, "client");

            realm.Run(r =>
            {
                realm.Write(c => c.Add(TestResources.CreateTestBeatmapSetInfo(rulesets: new[] { new OsuRuleset().RulesetInfo })));
            });

            updateThread = new UpdateThread(() => { }, null);
            updateThread.Start();
        }
Пример #2
0
        public void Init(LaunchState state, InitialiseSettings settings)
        {
            LaunchState = state;
            Settings    = settings;
            ActiveWorld = new World();

            Settings.Context.MakeCurrent(null);
            SystemManager.LoadSystems(new CoreSystemLoader());
            EntityManager.RegisterSystem(Renderer);

            SystemManager.InitialiseSystems(EntityManager, EventManager, ResourceManager, ActiveWorld);

            UpdateThread.Start();
            RenderThread.Start();
        }
Пример #3
0
 public static void Check()
 {
     Process[] UcsOpen = Process.GetProcessesByName("UCS.exe");
     if (UcsOpen.Length != 0)
     {
         foreach (var Process in Process.GetProcessesByName("UCS.exe"))
         {
             Process.Kill();
         }
         UpdateThread.Start();
     }
     else if (UcsOpen.Length == 0)
     {
         UpdateThread.Start();
     }
 }
Пример #4
0
        private void window_keydown(object sender, KeyEventArgs e)
        {
            if (keydown.Contains(e.KeyCode) || e.KeyCode == Keys.NumLock || e.KeyCode == Keys.ShiftKey || e.KeyCode == Keys.Menu)
            {
                return;
            }
            else
            {
                keydown.Add(e.KeyCode);
            }

            Keys ekey = e.KeyCode;

            if (e.KeyCode == Keys.Delete)
            {
                ekey = Keys.Decimal;
            }
            else if (e.KeyCode == Keys.Insert)
            {
                ekey = Keys.NumPad0;
            }
            else if (e.KeyCode == Keys.Clear)
            {
                ekey = Keys.NumPad5;
            }

            else if (e.KeyCode == Keys.F2)
            {
                ContrastMode = !ContrastMode;
                return;
            }
            else if (e.KeyCode == Keys.F3)
            {
                if (state == States.NEWGAME && Neat.All.Count < 24)
                {
                    OpenFileDialog dialog = new OpenFileDialog();
                    dialog.Filter           = "Bot files (*.bot)|*.bot|All files (*.*)|*.*";
                    dialog.RestoreDirectory = true;

                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        List <byte> bytes = new List <byte>(File.ReadAllBytes(dialog.FileName));
                        Neat.remove(bytes, 8);

                        Neat n = Neat.decompile(bytes);
                        n.SetupGenZero();
                        n.AddKey();

                        IKey.UpdateAll();
                        Map.SetMaxPoints();

                        // Set color
                        Program.HEADS[n.Key].color = n.color.GetValueOrDefault(Entities.Head.GenerateColor());
                    }
                }
                return;
            }
            else if (e.KeyCode == Keys.F1)
            {
                if (state != States.NEWGAME)
                {
                    return;
                }
                if (ActiveKeys.Count > 0)
                {
                    new AI(ActiveKeys[ActiveKeys.Count - 1]);
                    MVP.Flash($"AI added to {HEADS[ActiveKeys[ActiveKeys.Count - 1]].DisplayKey}");
                    HEADS[ActiveKeys[ActiveKeys.Count - 1]].DisplayKey = "AI";
                }
                return;
            }
            else if (e.KeyCode == Keys.F4 && !e.Alt)
            {
                if (state == States.NEWGAME)
                {
                    if (Neat.All.Count > 0)
                    {
                        Neat toRemove = Neat.All.Last();
                        toRemove.Remove();
                        IKey.UpdateAll();
                    }
                    Map.SetMaxPoints();
                }
                return;
            }
            else if (e.KeyCode == Keys.F9 && e.Alt)
            {
                if (ActiveKeys.Count == 0 || InactiveKeys.Count == 0)
                {
                    return;
                }

                HEADS[InactiveKeys[0]].Reward(0, ActiveKeys[0]);
                HEADS[ActiveKeys[0]].Die();
                return;
            }
            else if (e.KeyCode == Keys.F10)
            {
                if (SyncUpdate)
                {
                    SyncUpdate = false;
                    UpdateThread.Stop();
                    NeuralThread.Stop();
                    StartAsyncUpdate();
                }
                else
                {
                    SyncUpdate = true;
                    UpdateThread.Start();
                    NeuralThread.Start();
                }
                return;
            }
            else if (e.KeyCode == Keys.F7)
            {
                SlowMo = true;
                return;
            }
            else if (e.KeyCode == Keys.F8)
            {
                SpeedMo = true;
                return;
            }
            else if (e.KeyCode == Keys.F11)
            {
                FullScreen = !FullScreen;
                if (FullScreen)
                {
                    Width           = Screen.PrimaryScreen.Bounds.Width;
                    FormBorderStyle = FormBorderStyle.None;
                    WindowState     = FormWindowState.Maximized;
                    Cursor.Hide();
                }
                else
                {
                    Width           = 1024;
                    Height          = 600;
                    FormBorderStyle = FormBorderStyle.Sizable;
                    WindowState     = FormWindowState.Normal;
                    Cursor.Show();
                }
                return;
            }

            else if (e.KeyCode == Keys.F12)
            {
                if (!e.Alt)
                {
                    if (map is BotArena)
                    {
                        List <byte> bytes = new List <byte>();
                        bytes.AddRange(((BotArena)map).GetGeneration());
                        foreach (Neat bot in ((BotArena)map).bots)
                        {
                            bytes.AddRange(Neat.compile(bot));
                        }

                        SaveFileDialog dialog = new SaveFileDialog();
                        dialog.Filter           = "Bot files (*.bot)|*.bot|All files (*.*)|*.*";
                        dialog.RestoreDirectory = true;

                        if (dialog.ShowDialog() == DialogResult.OK)
                        {
                            File.WriteAllBytes(dialog.FileName, bytes.ToArray());
                        }
                    }
                    else if (ActiveKeys.Count == 0)
                    {
                        Cursor.Show();
                        OpenFileDialog dialog = new OpenFileDialog();
                        dialog.Filter           = "Bot files (*.bot)|*.bot|All files (*.*)|*.*";
                        dialog.RestoreDirectory = true;

                        if (dialog.ShowDialog() == DialogResult.OK)
                        {
                            List <byte> bytes = new List <byte>(File.ReadAllBytes(dialog.FileName));

                            BotArena arena = new BotArena(BotArena.Type.MAX_POINTS);
                            arena.SetGeneration(bytes);
                            map = arena;

                            while (bytes.Count > 0)
                            {
                                arena.bots.Add(Neat.decompile(bytes));
                            }

                            arena.AddBots(false);
                            Map.StartGame();

                            Ingame = true;
                            state  = States.INGAME;
                        }
                        if (FullScreen)
                        {
                            Cursor.Hide();
                        }
                    }
                }
                else if (state == States.NEWGAME && !TutorialActive)
                {
                    if (ActiveKeys.Count != 1)
                    {
                        return;
                    }
                    TUTO           = new Tutorial(Map);
                    TutorialActive = true;
                    Map.StartGame();
                    if (SyncUpdate)
                    {
                        NeuralThread.Start();
                    }
                }
                return;
                // trigger tutorial
            }
            else if (e.KeyCode == Keys.F6)
            {
                if (ActiveKeys.Count != 0)
                {
                    return;
                }

                BotArena arena = new BotArena(7, BotArena.Type.MAX_POINTS);                 /// <   -	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-

                map = arena;
                arena.AddBots(false);
                Map.StartGame();

                Ingame = true;
                state  = States.INGAME;

                return;
                // trigger bot arena
            }
            else if (e.KeyCode == Keys.F5)
            {
                if (state != States.NEWGAME)
                {
                    return;
                }
                switch (Gamemode)
                {
                case Gamemodes.CLASSIC:
                    MVP.SetText("Red chaos");
                    Gamemode = Gamemodes.CHAOS_RED;
                    foreach (Head head in HEADS.Values)
                    {
                        head.NewColor(true);
                    }
                    break;

                case Gamemodes.CHAOS_RED:
                    MVP.SetText("Rainbow chaos");
                    Gamemode = Gamemodes.CHAOS_RAINBOW;
                    foreach (Head head in HEADS.Values)
                    {
                        head.NewColor();
                    }
                    break;

                case Gamemodes.CHAOS_RAINBOW:
                    MVP.SetText("King of the hill");
                    foreach (Head head in HEADS.Values)
                    {
                        head.NewColor(false);
                    }
                    Map.MaxOrbs = 7;
                    Gamemode    = Gamemodes.KING_OF_THE_HILL;
                    break;

                case Gamemodes.KING_OF_THE_HILL:
                    MVP.SetText("Hidden");
                    Map.MaxOrbs = 8;
                    Gamemode    = Gamemodes.HIDDEN;
                    break;

                case Gamemodes.HIDDEN:
                    MVP.SetText("Yeet Mode");
                    Gamemode       = Gamemodes.YEET_MODE;
                    Map.blastSpawn = BlastSpawn.RARE;
                    break;

                case Gamemodes.YEET_MODE:
                    MVP.SetText("Classic");
                    Map.MaxOrbs = 255;
                    Gamemode    = Gamemodes.CLASSIC;
                    break;
                }

                UpdateColors?.Invoke();
                return;
            }

            switch (state)
            {
            case States.NEWGAME:
                //add new player
                if (e.KeyCode == Keys.Enter && ActiveKeys.Count > 0)                           // (re)start game
                {
                    if (e.Shift)
                    {
                        Map.ResumeGame();
                    }
                    else
                    {
                        Map.StartGame();
                    }
                    if (SyncUpdate)
                    {
                        NeuralThread.Start();
                    }
                    Ingame = true;
                    state  = States.INGAME;
                }
                else if (e.KeyCode == Keys.Escape)                             // clear all keys
                {
                    HashSet <Neat> NeatCopy = new HashSet <Neat>(Neat.All);
                    foreach (Neat neat in NeatCopy)
                    {
                        neat.Remove();
                    }
                    HashSet <Head> HeadCopy = new HashSet <Head>(HEADS.Values);
                    foreach (Head head in HeadCopy)
                    {
                        head.Remove();
                    }
                    Map.MaxPoints = 0;
                    Leader        = Keys.None;
                }
                else if (0 <= e.KeyValue && e.KeyValue < 256)                             //add key
                {
                    lock (ActiveLock) {
                        if (ActiveKeys.Contains(ekey))
                        {
                            HEADS[ekey].Remove();
                        }
                        else
                        {
                            if (HEADSOnPause.ContainsKey(ekey))
                            {
                                HEADS.Add(ekey, new Head(HEADSOnPause[ekey]));
                            }
                            else
                            {
                                HEADS.Add(ekey, new Head(ekey));
                            }
                            ActiveKeys.Add(ekey);
                            Map.SetMaxPoints();
                        }
                    }
                    IKey.UpdateAll();
                }
                break;

            case States.INGAME:
                if (e.KeyCode == Keys.Escape)                           //pause game
                {
                    ApplicationPause();
                }
                else if (ActiveKeys.Contains(ekey))                             //default action
                {
                    HEADS[ekey].Action();
                }
                break;

            case States.PAUSED:
                if (e.KeyCode == Keys.Escape)                           // unpause
                {
                    state  = States.INGAME;
                    Ingame = true;
                    if (SyncUpdate)
                    {
                        UpdateThread.Start();
                        NeuralThread.Start();
                    }
                    else
                    {
                        StartAsyncUpdate();
                    }
                    VisualThread.Start();
                    //ForcePaused = false;
                }
                else if (e.KeyCode == Keys.Enter)                             // let players join
                {
                    HEADSOnPause.Clear();
                    foreach (KeyValuePair <Keys, Head> player in HEADS)
                    {
                        HEADSOnPause.Add(player.Key, player.Value);
                    }
                    Map.EndGame();
                    Map.Clear();
                    Map.phase = Phases.NONE;
                    state     = States.NEWGAME;
                    MVP.Show("Prepare!");
                    lock (ActiveLock) foreach (Keys key in ActiveKeys)
                        {
                            HEADS[key].v = IVector.Up;
                        }
                    Ingame = false;
                    VisualThread.Start();
                    if (SyncUpdate)
                    {
                        UpdateThread.Start();
                    }
                    else
                    {
                        StartAsyncUpdate();
                    }
                }
                break;
            }
        }
Пример #5
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (null == _item)
            {
                return;
            }
            _listSampleNum     = new List <TextBox>();
            _listJudgmentReult = new List <TextBox>();
            _listStandardValue = new List <TextBox>();
            _listtextNongdu    = new List <TextBox>();

            int sampleNum = _item.SampleNum;
            int holeUse   = 0;

            // 添加布局
            for (int i = 0; i < Global.deviceHole.HmCount; ++i)
            {
                UIElement element = GenerateChannelLayout(i, String.Format("{0:D5}", sampleNum), _item.Hole[i].SampleName);
                WrapPanelChannel.Children.Add(element);
                if (_item.Hole[i].Use)
                {
                    holeUse += 1;
                    sampleNum++;
                    _listSampleNum.Add(UIUtils.GetChildObject <TextBox>(element, "sampleNum"));
                    _listJudgmentReult.Add(UIUtils.GetChildObject <TextBox>(element, "textJugmentResult"));
                    _listStandardValue.Add(UIUtils.GetChildObject <TextBox>(element, "textStandValue"));
                    _listtextNongdu.Add(UIUtils.GetChildObject <TextBox>(element, "textNongdu"));
                }
                else
                {
                    element.Visibility = System.Windows.Visibility.Collapsed;
                    _listSampleNum.Add(null);
                    _listJudgmentReult.Add(null);
                    _listStandardValue.Add(null);
                    _listtextNongdu.Add(null);
                }
            }

            if (holeUse < 4)
            {
                if (holeUse == 1)
                {
                    this.WrapPanelChannel.Width = 190;
                }
                else if (holeUse == 2)
                {
                    this.WrapPanelChannel.Width = 380;
                }
                else if (holeUse == 3)
                {
                    this.WrapPanelChannel.Width = 570;
                }
            }

            _canvases    = UIUtils.GetChildObjects <Canvas>(WrapPanelChannel, "rootCanvas");
            _listTime    = UIUtils.GetChildObjects <Label>(WrapPanelChannel, "labelTime");
            _listUA      = UIUtils.GetChildObjects <Label>(WrapPanelChannel, "labelUA");
            _listMV      = UIUtils.GetChildObjects <Label>(WrapPanelChannel, "labelMV");
            _listStage   = UIUtils.GetChildObjects <Label>(WrapPanelChannel, "labelStage");
            _listDensity = UIUtils.GetChildObjects <Label>(WrapPanelChannel, "labelDensity");

            _updateThread = new UpdateThread(this);
            _updateThread.Start();

            if (Global.typeName.Equals("dhx"))
            {
                lbTitle.Content = "电化学检测";
            }
        }