public override void Land(Canvas canvas, Box boxIHM) { base.Land(canvas, boxIHM); Astronef a = (Astronef)Unite; a.Position = boxIHM.Case; }
public Spaceship(Unite unite, MapHMI map) : base(unite) { MapHMI = map; Astronef u = (Astronef)Unite; _reserve = new SpaceshipReserve(u.Reserve, this); GhostImage = new Image() { Source = new BitmapImage(new Uri(Environment.CurrentDirectory + "\\src\\files\\images\\sprites\\astronef.png")), Height = Height, Width = Width, }; }
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; }
protected override void OnDragOver(DragEventArgs e) { DrawGhostUnit(e); if (_player.Spaceships.Count == 0) { _ghostImage.Opacity = Astronef.EstPosable(_map.ChooseBox(e.GetPosition(_mapCanvas)).Case) ? 1 : 0.5; } else { Unit unit = (Unit)e.Data.GetData("Object"); if (unit.Landed) { _ghostImage.Opacity = unit.Unite.SeDeplacer(_map.ChooseBox(e.GetPosition(_mapCanvas)).Case, unit.BoxHMI.Case) ? 1 : 0.5; } else { Astronef astronef = (Astronef)_player.Spaceships[0].Unite; TypeEntite typeEntite = (TypeEntite)e.Data.GetData("TypeEntite"); _ghostImage.Opacity = astronef.PeutSortir(_map.ChooseBox(e.GetPosition(_mapCanvas)).Case, typeEntite) ? 1 : 0.5; } } e.Handled = true; }