예제 #1
0
        /// <summary>
        /// Действия при выборе игрового бокса
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PlBoxVM_BoxSelected(object sender, EventArgs e)
        {
            PlayBoxViewModel newSelectedBox = sender as PlayBoxViewModel;

            MovementInField = true;

            if (SelectedBox == null)
            {
                SelectedBox = newSelectedBox;
                OnBoxSelected();

                if (MovementInField)
                {
                    if (newSelectedBox.IsPlayerPresent)
                    {
                        LocalHighlightPositions();
                    }
                    else
                    {
                        SelectedBox = null;
                    }
                }
            }
            else
            {
                if (newSelectedBox.IsPlayerPresent)
                {
                    if (newSelectedBox != SelectedBox)
                    {
                        PlayerViewModel plNSB = newSelectedBox.WithdrawPlayer();
                        PlayerViewModel plSB  = SelectedBox.WithdrawPlayer();
                        newSelectedBox.SetPlayer(plSB);
                        SelectedBox.SetPlayer(plNSB);
                        ResetHighlight();
                        SelectedBox = null;
                    }
                }
                else
                {
                    PlayerViewModel plSB = SelectedBox.WithdrawPlayer();
                    newSelectedBox.SetPlayer(plSB);
                    ResetHighlight();
                    SelectedBox = null;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Инициализация боксов и расстановка по схеме
        /// </summary>
        private void InitPLayBoxVMs()
        {
            IScheme scheme = _schemes.GetScheme(SelectedScheme);

            foreach (ILocationPosition locPos in scheme)
            {
                PlayBoxViewModel plBoxVM = new PlayBoxViewModel(locPos);
                plBoxVM.BoxSelected      += PlBoxVM_BoxSelected;
                plBoxVM.PreRemovalPlayer += PlBoxVM_PreRemovalPlayer;
                _playBoxVMs.Add(plBoxVM);
            }

            if (_players.Count > 0)
            {
                foreach (PlayerViewModel plVM in _players)
                {
                    _playBoxVMs[plVM.CurrentLocNumber - 1].SetPlayer(plVM);
                }
            }
        }