/* * Cette méthode permet de vérifié si il reste des entités */ public static bool EstCreable(TypeEntite t) { bool temp = false; switch (t) { case TypeEntite.TANK: if (tank >= 1) { temp = true; } break; case TypeEntite.CRABE: if (crabe >= 1) { temp = true; } break; case TypeEntite.PONTON: if (ponton >= 1) { temp = true; } break; default: throw new Exception("Unité inconnue au battaillon (Réserve)"); } return(temp); }
/// <summary> /// Méthode permettant de crée une unité (coté reserve) a partie de la réserve si elle est disponible /// </summary> /// <param name="t"> Type de l'unité a crée</param> public void Utilise(TypeEntite t) { if (EstCreable(t)) { switch (t) { case TypeEntite.TANK: tank--; break; case TypeEntite.CRABE: crabe--; break; case TypeEntite.PONDEUSE: pondeuse--; break; case TypeEntite.BARGE: barge--; break; case TypeEntite.VEDETTE: vedette--; break; case TypeEntite.GROS_TAS: gros_tas--; break; default: throw new Exception("Unité inconnue au battaillon (RéserveAstronef)"); } } }
/// <summary> /// Permet de sortir l'unité de l'astronef /// </summary> /// <param name="c">Unité sur la quelle se trouvera l'unité</param> /// <param name="t">Type de l'unité a sortir</param> public void SortirUnité(Case c, TypeEntite t) { if (PeutSortir(c, t)) { Unite u = FabriqueUnite.CreeUnite(t, c, this.Joueur) as Unite; this.Joueur.Carte.AjouterUnite(u, c); } }
public bool EstCreable(TypeEntite t) { bool temp = false; switch (t) { case TypeEntite.TANK: if (tank >= 1) { temp = true; } break; case TypeEntite.CRABE: if (crabe >= 1) { temp = true; } break; case TypeEntite.PONDEUSE: if (pondeuse >= 1) { temp = true; } break; case TypeEntite.BARGE: if (barge >= 1) { temp = true; } break; case TypeEntite.VEDETTE: if (vedette >= 1) { temp = true; } break; case TypeEntite.GROS_TAS: if (gros_tas >= 1) { temp = true; } break; //default: //throw new Exception("Unité inconnue au battaillon (RéserveAstronef)"); } return(temp); }
private void Build() { foreach (var type in Enum.GetValues(typeof(TypeEntite))) { int n = 0; TypeEntite t = (TypeEntite)type; while (n < _reserveAstronef.NombreUnite(t)) { _reserve.AddUnit(UnitFactory.BuildUnitHMI(t, null, _spaceship.Unite.Joueur)); n++; } } }
/// <summary> /// Permet de vérifier si l'unité est encore disponible /// Permet de vérifier si l'unité est sortable de l'astronef (si elle est déplacable sur la case) /// </summary> /// <param name="c">Case sur laquelle le joueur essaye de sortir l'unité</param> /// <param name="t">Type de l'unité</param> /// <returns>True si l'unité est sortable faux sinon</returns> public bool PeutSortir(Case c, TypeEntite t) { bool res = false; if (depart.EstCreable(t)) { Unite e = FabriqueUnite.CreeUnite(t, this.Position, this.Joueur) as Unite; if (e.SeDeplacer(c, this.Position)) { res = true; } } return(res); }
//------------------------------------------------------------- private void FillListeChildsType(CTypeEntiteOrganisationnelle tpEO, List <CEntiteOrganisationnelle> lst) { if (TypeEntite.Equals(tpEO)) { lst.Add(this); } else { foreach (CEntiteOrganisationnelle eo in EntiteFilles) { eo.FillListeChildsType(tpEO, lst); } } }
public int NombreUnite(TypeEntite type) { switch (type) { case TypeEntite.BARGE: return(Barge); case TypeEntite.CRABE: return(Crabe); case TypeEntite.PONDEUSE: return(Pondeuse); case TypeEntite.VEDETTE: return(Vedette); case TypeEntite.TANK: return(Tank); case TypeEntite.GROS_TAS: return(GrosTas); default: return(0); } }
/* * Fonction permettant de crée une unité à un joueur * Son type et sa position son passé en paramètre */ public static IEntite CreeUnite(TypeEntite type, Case position, Joueur j) { IEntite unit; switch (type) { case TypeEntite.ASTRONEF: unit = new Astronef(position, j); break; case TypeEntite.BARGE: unit = new Barge(position, j); break; case TypeEntite.TANK: unit = new Tank(position, j); break; case TypeEntite.CRABE: unit = new Crabe(position, j); break; case TypeEntite.GROS_TAS: unit = new Gros_Tas(position, j); break; case TypeEntite.PONDEUSE: unit = new Pondeuse(position, j); break; case TypeEntite.TOURELLE: unit = new Tourelle(position, j); break; case TypeEntite.VEDETTE: unit = new Vedette(position, j); break; default: throw new Exception("Unité inconnue au battaillon"); } return(unit); }
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; }
/// <summary> /// Méthode permettant de crée une unité (coté reserve) a partie de la réserve si elle est disponible /// </summary> /// <param name="t"> Type de l'unité a crée</param> public static void Utilise(TypeEntite t) { if (EstCreable(t)) { switch (t) { case TypeEntite.TANK: tank -= 1; break; case TypeEntite.CRABE: crabe -= 1; break; case TypeEntite.PONTON: ponton -= 1; break; default: throw new Exception("Unité inconnue au battaillon (Réserve)"); } } }
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; }
public static Unit BuildUnitHMI(TypeEntite type, Case position, Joueur j) { Unit unit = null; switch (type) { case TypeEntite.ASTRONEF: unit = new Spaceship((Unite)FabriqueUnite.CreeUnite(type, position, j), _map); unit.Image = new Image() { Source = new BitmapImage(fileLoader.GetUri("astronef.png")), }; break; case TypeEntite.BARGE: unit = new BargeHMI((Unite)FabriqueUnite.CreeUnite(type, position, j)); unit.Image = new Image() { Source = new BitmapImage(fileLoader.GetUri("barge.png")) }; break; case TypeEntite.TANK: unit = new TankHMI((Unite)FabriqueUnite.CreeUnite(type, position, j)); unit.Image = new Image() { Source = new BitmapImage(fileLoader.GetUri("tank.png")) }; break; case TypeEntite.CRABE: unit = new Crab((Unite)FabriqueUnite.CreeUnite(type, position, j)); unit.Image = new Image() { Source = new BitmapImage(fileLoader.GetUri("Crab3.png")) }; break; case TypeEntite.GROS_TAS: unit = new T99((Unite)FabriqueUnite.CreeUnite(type, position, j)); unit.Image = new Image() { Source = new BitmapImage(fileLoader.GetUri("big_tank.png")) }; break; case TypeEntite.PONDEUSE: unit = new WeatherLayerHMI((Unite)FabriqueUnite.CreeUnite(type, position, j)); unit.Image = new Image() { Source = new BitmapImage(fileLoader.GetUri("weather_layer.png")) }; break; case TypeEntite.VEDETTE: unit = new Speedboat((Unite)FabriqueUnite.CreeUnite(type, position, j)); unit.Image = new Image() { Source = new BitmapImage(fileLoader.GetUri("boat.png")), }; break; } unit.Image.Height = unit.Height; unit.Image.Width = unit.Width; unit.AddHandler(); return(unit); }