Beispiel #1
0
        private void EditComputerAccount_Executed(object arg)
        {
            var computerAccount    = (ComputerAccount)arg;
            var newComputerAccount = new ComputerAccountViewModel(computerAccount.Clone(), computerAccount);

            newComputerAccount.Add += NewComputerAccount_Edit;
            var contentBox = new ContentBox {
                Data = newComputerAccount, Title = Resources.ComputerPlayer
            };

            Navigate?.Invoke(contentBox);
        }
Beispiel #2
0
        private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var acc = (GameAccount)sender;

            if (e.PropertyName == nameof(GameAccount.AccountType))
            {
                UpdatePlayer(acc);
            }
            else if (e.PropertyName == nameof(GameAccount.SelectedAccount))
            {
                var index = Players.IndexOf(acc);

                if (index > -1 && index < _model.Players.Length)
                {
                    _model.Players[index] = acc.SelectedAccount;
                }

                if (acc.SelectedAccount == _computerPlayers.Last())
                {
                    var account = new ComputerAccount()
                    {
                        CanBeDeleted = true
                    };

                    // Зададим ему рандомные характеристики
                    account.Randomize();

                    var newComputerAccount = new ComputerAccountViewModel(account, null);
                    newComputerAccount.Add += NewComputerAccount_Add;
                    var contentBox = new ContentBox {
                        Data = newComputerAccount, Title = Resources.NewPlayer, Cancel = _closeNewPlayer
                    };
                    Navigate?.Invoke(contentBox);
                }

                CheckUniqueAccounts();
            }
        }