protected override void OnDrop(DragEventArgs e)
        {
            if (e.Effects == DragDropEffects.Move)
            {
                if (e.Data.GetDataPresent("Object"))
                {
                    Unit unit = (Unit)e.Data.GetData("Object");
                    Box  box  = _map.ChooseBox(e.GetPosition(_mapCanvas));

                    if (unit.Type == TypeEntite.ASTRONEF && Astronef.EstPosable(box.Case))
                    {
                        _game.PoserBase(_player, box.Case);
                        _player.Spaceships[0] = (Spaceship)unit;
                        _player.Spaceships[0].Land(_mapCanvas, box);
                        _unitList.RemoveUnit();
                    }
                    else if (unit.Type != TypeEntite.ASTRONEF)
                    {
                        if (unit.Landed)
                        {
                            if (unit.Unite.SeDeplacer(_map.ChooseBox(e.GetPosition(_mapCanvas)).Case, unit.BoxHMI.Case))
                            {
                                unit.Move(_mapCanvas, _map.ChooseBox(e.GetPosition(_mapCanvas)));
                            }
                        }
                        else
                        {
                            Astronef   astronef   = (Astronef)_player.Spaceships[0].Unite;
                            TypeEntite typeEntite = (TypeEntite)e.Data.GetData("TypeEntite");
                            if (astronef.PeutSortir(_map.ChooseBox(e.GetPosition(_mapCanvas)).Case, typeEntite))
                            {
                                unit.Land(_mapCanvas, _map.ChooseBox(e.GetPosition(_mapCanvas)));
                                _player.Spaceships[0].Reserve.UseUnit(unit);
                            }
                        }
                    }
                }
            }
            DeleteGhostUnit();
            e.Handled = true;
        }
Exemple #2
0
 public void UseUnit(Unit unit)
 {
     _reserve.RemoveUnit();
     _reserveAstronef.Utilise(unit.Type);
 }