private void AttackCreep(Creep _creep) { // pythagorean to find hypoteneus distance double hypDistance = GetDistanceToCreep(_creep); // is in range to attack? if (hypDistance <= MyWeapon.Range) { // attack! _creep.Hurt(MyWeapon.Damage); // check for kill condition if (_creep.HitPoints <= 0) { //System.Diagnostics.Debug.Print("Creep hitpoints: " + _creep.HitPoints); MyCanvas.Dispatcher.Invoke(_creep.Killed); } // trigger cooldown state MyWeapon.Reload(); // switch image to 'attack' Thread t1 = new Thread(new ThreadStart( delegate() { MyCanvas.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate() { MyCanvas.Dispatcher.Invoke(new Action(() => DrawTower(pathImage_attack))); })); Thread.Sleep(TimeSpan.FromMilliseconds(attackAnimationLength)); MyCanvas.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate() { MyCanvas.Dispatcher.Invoke(new Action(() => DrawTower(pathImage))); })); })); t1.Start(); } }