예제 #1
0
 private void btnSettings_Click(object sender, RoutedEventArgs e)
 {
     PlayerContainer.Visibility = Visibility.Collapsed;
     SettingsControl.Visibility = Visibility.Visible;
     SettingsControl.Update();
 }
예제 #2
0
        public void Init(IGameManager manager, PlayerViewModel model)
        {
            this._manager = manager ?? throw new ArgumentNullException("manager is null");
            this._manager.PlayerColorChanged += _manager_PlayerColorChanged;

            this.viewModel = model ?? throw new ArgumentNullException("Player model is null");
            this.viewModel.PropertyChanged += ViewModel_PropertyChanged;

            LifeControl.Init(viewModel, true);
            UpdateCustomType();

            cmdLife1.Init(new PlayerViewModel()
            {
                LifeTotal = viewModel.CmdEnemy1
            }, false);
            cmdLife2.Init(new PlayerViewModel()
            {
                LifeTotal = viewModel.CmdEnemy2
            }, false);
            cmdLife3.Init(new PlayerViewModel()
            {
                LifeTotal = viewModel.CmdEnemy3
            }, false);


            ToprtAngle.Angle = 0;
            //rtPanelOptions.Angle = 0;

            borderLife1.Visibility = cmdLife1.Visibility = Visibility.Collapsed;
            borderLife2.Visibility = cmdLife2.Visibility = Visibility.Collapsed;
            borderLife3.Visibility = cmdLife3.Visibility = Visibility.Collapsed;

            SettingsControl.Init(this.viewModel, this, OnCloseSettings);

            var cmd = 1;

            foreach (var id in _manager.ActivePlayers())
            {
                if (id == viewModel.ID)
                {
                    continue;
                }
                if (id == PlayerID.Unknown)
                {
                    continue;
                }

                CommanderButtonMapping[id] = cmd;

                switch (cmd)
                {
                case 1:
                    cmdLife1.Visibility = Visibility.Visible;
                    break;

                case 2:
                    cmdLife2.Visibility = Visibility.Visible;
                    break;

                case 3:
                    cmdLife3.Visibility = Visibility.Visible;
                    break;

                default:
                    break;
                }
                cmd++;
            }

            cmdLife1.LifeChanged += CmdLife_LifeChanged;
            cmdLife2.LifeChanged += CmdLife_LifeChanged;
            cmdLife3.LifeChanged += CmdLife_LifeChanged;

            this.LifeControl.LifeChangeHistory += LifeControl_LifeChanged;

            this.DataContext = viewModel;
        }