Example #1
0
        private void OnCloseSettings()
        {
            PlayerContainer.Visibility = Visibility.Visible;
            SettingsControl.Visibility = Visibility.Collapsed;

            LifeControl.SetLife(viewModel.LifeTotal);
            UpdateCustomType();
            UpdateCommanderDmg();
        }
Example #2
0
 private async void CmdLife_LifeChanged(object sender, LifeChangedEventArgs e)
 {
     if (!Dispatcher.HasThreadAccess)
     {
         await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { CmdLife_LifeChanged(sender, e); });
     }
     else
     {
         await LifeControl.UpdateLifeTotalAsync(e.Lifechanged *-1);
     }
 }
Example #3
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;
        }
Example #4
0
        public void Reset(Gametypes type = Gametypes.MultiPlayer)
        {
            if (type == Gametypes.Current)
            {
                type = _lastType;
            }

            _lastType = type;

            viewModel.LifeTotal  = _manager.GetLifeValue(type);
            viewModel.Energy     = 0;
            viewModel.Experience = 0;
            viewModel.Poison     = 0;
            viewModel.CmdEnemy1  = 0;
            viewModel.CmdEnemy2  = 0;
            viewModel.CmdEnemy3  = 0;

            if (type == Gametypes.Commander)
            {
                LifeControl.SetValue(Grid.RowSpanProperty, 1);
            }
            else
            {
                LifeControl.SetValue(Grid.RowSpanProperty, 2);
            }


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

            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:
                    borderLife1.Visibility = cmdLife1.Visibility = Visibility.Visible;
                    break;

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

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

                default:
                    break;
                }
                cmd++;
            }

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


            BorderCmd.Visibility = type == Gametypes.Commander ? Visibility.Visible : Visibility.Collapsed;

            LifeControl.SetLife(viewModel.LifeTotal);
            UpdateCustomType();
            UpdateCommanderDmg();
        }
Example #5
0
 public void SetBackGround(BackGroundColors color)
 {
     viewModel.Color = color;
     LifeControl.SetColor(viewModel.Color);
 }