protected override void IA(List <Unite> unitsOnMap) { if (!isAtRange) { if (Outil.DistanceUnites(Outil.GetJoueur(Client.id).champion, this) <= 600) { isAtRange = true; } } if (isAtRange) { if (!timer.IsRunning) { timer.Start(); } if (timer.Elapsed.Seconds < 1) { color = Color.Red; } if (timer.Elapsed.Seconds > 1 && timer.Elapsed.Seconds < 8) { if (IsCastable(0)) { for (int i = 0; i < spellsUpdate.Count; i++) { if (spellsUpdate[i].idSort == 45) { spellsUpdate.RemoveAt(i); } } ((NovaDeFeu)spells[0]).Positions.Clear(); Cast(spells[0], Vector2.Zero, null); ObjectifListe.Clear(); color = Color.White; } uniteAttacked = null; } else { spellsUpdate.Clear(); uniteAttacked = Outil.GetJoueur(Client.id).champion; if (timer.Elapsed.Seconds > 11) { timer.Reset(); } } } }
public void Suivre(Unite unite) { List <Unite> liste = new List <Unite> { }; double distance = Outil.DistanceUnites(this, unite); bool ok = distance > Portee * Map.TailleTiles.X; if (ok) { foreach (Unite u in Map.unites) { if (Outil.DistanceUnites(this, u) <= 1 * Map.TailleTiles.X) { if (u != unite && u != this) { liste.Add(u); } } } suivreactuel = 0; List <Noeud> chemin = PathFinding.TrouverChemin(PositionTile, unite.PositionTile, Map.Taille, liste, Map.unitesStatic, false); if (chemin != null) { ObjectifListe = chemin; ObjectifListe.RemoveAt(0); } else { ObjectifListe.Clear(); body.LinearVelocity = Vector2.Zero; } } else { suivreactuel++; } }
public virtual void Deplacer() { if (ObjectifListe.Count > 0) { // Bug, je sais pas pourquoi // body.Position = ConvertUnits.ToSimUnits(new Vector2((float)Math.Round(ConvertUnits.ToDisplayUnits(body.Position.X)), (float)Math.Round(ConvertUnits.ToDisplayUnits(body.Position.Y) ))); // HAUT GAUCHE if (PositionTile.X > ObjectifListe[0].Position.X && PositionTile.Y > ObjectifListe[0].Position.Y) { body.LinearVelocity = new Vector2(-Vitesse / 1.41f, -Vitesse / 1.41f) * Map.gametime.ElapsedGameTime.Milliseconds; FlipH = true; if (direction != Direction.HautGauche || Animation.Count == 0) { Animation = packAnimation.HautDroite(); } direction = Direction.HautGauche; } // HAUT DROITE else if (PositionTile.X < ObjectifListe[0].Position.X && PositionTile.Y > ObjectifListe[0].Position.Y) { body.LinearVelocity = new Vector2(Vitesse / 1.41f, -Vitesse / 1.41f) * Map.gametime.ElapsedGameTime.Milliseconds; FlipH = false; if (direction != Direction.HautDroite || Animation.Count == 0) { Animation = packAnimation.HautDroite(); } direction = Direction.HautDroite; } // BAS DROITE else if (PositionTile.X < ObjectifListe[0].Position.X && PositionTile.Y < ObjectifListe[0].Position.Y) { body.LinearVelocity = new Vector2(Vitesse / 1.41f, Vitesse / 1.41f) * Map.gametime.ElapsedGameTime.Milliseconds; FlipH = false; if (direction != Direction.BasDroite || Animation.Count == 0) { Animation = packAnimation.BasDroite(); } direction = Direction.BasDroite; } // BAS GAUCHE else if (PositionTile.X > ObjectifListe[0].Position.X && PositionTile.Y < ObjectifListe[0].Position.Y) { body.LinearVelocity = new Vector2(-Vitesse / 1.41f, Vitesse / 1.41f) * Map.gametime.ElapsedGameTime.Milliseconds; FlipH = true; if (direction != Direction.BasGauche || Animation.Count == 0) { Animation = packAnimation.BasDroite(); } direction = Direction.BasGauche; } // GAUCHE else if (PositionTile.X > ObjectifListe[0].Position.X) { body.LinearVelocity = new Vector2(-Vitesse, 0) * Map.gametime.ElapsedGameTime.Milliseconds; FlipH = true; if (direction != Direction.Gauche || Animation.Count == 0) { Animation = packAnimation.Droite(); } direction = Direction.Gauche; } // DROITE else if (PositionTile.X < ObjectifListe[0].Position.X) { body.LinearVelocity = new Vector2(Vitesse, 0) * Map.gametime.ElapsedGameTime.Milliseconds; FlipH = false; if (direction != Direction.Droite || Animation.Count == 0) { Animation = packAnimation.Droite(); } direction = Direction.Droite; } // HAUT else if (PositionTile.Y > ObjectifListe[0].Position.Y) { body.LinearVelocity = new Vector2(0, -Vitesse) * Map.gametime.ElapsedGameTime.Milliseconds; FlipH = false; if (direction != Direction.Haut || Animation.Count == 0) { Animation = packAnimation.Haut(); } direction = Direction.Haut; } // BAS else if (PositionTile.Y < ObjectifListe[0].Position.Y) { body.LinearVelocity = new Vector2(0, Vitesse) * Map.gametime.ElapsedGameTime.Milliseconds; FlipH = false; if (direction != Direction.Bas || Animation.Count == 0) { Animation = packAnimation.Bas(); } direction = Direction.Bas; } else { ObjectifListe.RemoveAt(0); } } else { body.LinearVelocity *= 0.01f; } }
public virtual void Attaquer(Unite unite) { float calcul = Outil.DistanceUnites(this, unite) - (26 * (unite.largeurPhysique + this.largeurPhysique) / 2); if (calcul >= Portee * Map.TailleTiles.X) { Suivre(unite); } else { if (CanAttack) { if (!uniteAttacked.isInvisible) { OlduniteAttacked = uniteAttacked; ObjectifListe.Clear(); body.LinearVelocity = Vector2.Zero; // Fait regarder l'unité vers l'unité attaqué if (Animation.Count == 0) { FlipH = false; float angle = Outil.AngleUnites(this, unite); if (angle >= Math.PI / 4 && angle <= 3 * Math.PI / 4) { direction = Direction.Haut; } else if (angle >= -3 * Math.PI / 4 && angle <= -Math.PI / 4) { direction = Direction.Bas; } else if (angle >= -Math.PI / 4 && angle <= Math.PI / 4) { direction = Direction.Gauche; FlipH = true; } else { direction = Direction.Droite; } } if (Map.gametime.TotalGameTime.TotalMilliseconds - LastAttack > Vitesse_Attaque * 1000) // Si le cooldown est fini { LastAttack = (float)Map.gametime.TotalGameTime.TotalMilliseconds; // On met à jour "l'heure de la dernière attaque" // projectile if (IsRanged) // Si l'unité attaque à distance, on creer un projectile, sinon on attaque direct { Projectile = new Projectile(this, uniteAttacked); } else { if (Dommages - unite.Defense <= 0) // Si armure > Dommages , degats = 1 { // On ne prend en compte les degats que si on est en local autrement ils sont effectués via le serveur unite.Vie -= 1; } else { unite.Vie -= Dommages - unite.Defense; } } // son effetUniteAttaque.Play(); // Fait regarder l'unité vers l'unité attaqué et l'anime AnimationCurrent = AnimationLimite; FlipH = false; float angle = Outil.AngleUnites(this, unite); if (angle >= Math.PI / 4 && angle <= 3 * Math.PI / 4) { direction = Direction.Haut; Animation = packAnimation.AttaquerHaut(); } else if (angle >= -3 * Math.PI / 4 && angle <= -Math.PI / 4) { direction = Direction.Bas; Animation = packAnimation.AttaquerBas(); } else if (angle >= -Math.PI / 4 && angle <= Math.PI / 4) { direction = Direction.Gauche; FlipH = true; Animation = packAnimation.AttaquerDroite(); } else { direction = Direction.Droite; Animation = packAnimation.AttaquerDroite(); } } } } } }