Exemplo n.º 1
0
 private void RemoveMoleFromPen(MoleControl mole)
 {
     if (mole != null)
     {
         _molepen.Children.Remove(mole);
         _molemap.Remove(mole.MoleName);
     }
 }
Exemplo n.º 2
0
        private async Task <MoleControl> CreateMoleAsync(KubePod pod)
        {
            try
            {
                MoleControl moleControl = null;
                await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    moleControl = new MoleControl();
                    _molemap.Add(pod.Name, moleControl);
                    moleControl.MoleName = pod.Name;
                    moleControl.Height   = moleControl.Width = MOLE_SIZE;
                    var init             = _movementEngine.InitializeMole(MOLE_SPEED);
                    var vm = new MoleViewModel(init.Item1, init.Item2, _moleService, _adminService)
                    {
                        CurrentChar = "-", MoleName = pod.Name, Phase = pod.Phase
                    };
                    moleControl.DataContext = vm;
                    Moles.Add(vm);
                    var property    = nameof(vm.DisplayAlignment);
                    Binding binding = new Binding()
                    {
                        Path = new PropertyPath(property)
                    };
                    moleControl.SetBinding(MoleControl.DisplayAlignmentProperty, binding);

                    moleControl.Init(_width, _height);
                    moleControl.MoleTapped += async(s, e) =>
                    {
                        Debug.WriteLine($"MOLE TAPPED {e.MoleName}");
                        await DeletePodAsync(e.Mole);
                        _lastKill = DateTime.Now;
                    };

                    _molepen.Children.Add(moleControl);
                });

                await _semaphore.WaitAsync();

                Debug.WriteLine($"+++Create mole {pod.Name}");
                return(moleControl);
            }
            finally
            {
                _semaphore.Release();
            }
        }
Exemplo n.º 3
0
 // Update ()
 void Update()
 {
     // waits till the game is done
     if (TimerControl.gameEnded && totalHits == 0) {
         scoreUpdate = true;
     }
     else {
         scoreUpdate = false;
     }
     // cycles through all the child objects, in this instance, all
     // the mole objects and counts how many EACH of them has been hit
     // this determines your score
     if (scoreUpdate) {
         foreach (Transform child in transform) {
             moleControl = child.gameObject.GetComponent<MoleControl>();
             totalHits += moleControl.numHits;
         }
         scoreUpdate = false;
     }
 }