/// <summary> /// Mets à jour la tour. /// </summary> protected override void DoUpdate(GameTime time) { base.DoUpdate(time); // Temps d'attente avant de respawn. if (m_respawnTimer > 0) { m_respawnTimer -= (float)time.ElapsedGameTime.TotalSeconds; return; } // Si on doit spawn une vague if (m_waveTimer <= 0) { m_waveTimer = SpawnInterval; float decay = 0; for (int i = 0; i < VirusPerWave; i++) { int iref = i; var DatacenterCandidates = GameServer.GetMap().Entities.GetEntitiesByType((this.Type & EntityType.Teams) | EntityType.Datacenter); if (DatacenterCandidates.Count > 0) { var Datacenter = DatacenterCandidates.First().Value; SpawnPosition = Datacenter.Position; } GameServer.GetScene().EventSheduler.Schedule(new Scheduler.ActionDelegate(() => { EntityVirus Virus = new EntityVirus() { Position = SpawnPosition, Type = EntityType.Virus | (this.Type & (EntityType.Team1 | EntityType.Team2)), Row = iref % RowCount, }; if (HasBossBuff) { Virus.ApplyBossBuff(); } GameServer.GetMap().Entities.Add(Virus.ID, Virus); }), decay); decay += SpawnDecay; } } // Décrémente le timer d'apparition des vagues. m_waveTimer -= (float)time.ElapsedGameTime.TotalSeconds; if (m_bossBuffTimer > 0) { m_bossBuffTimer -= (float)time.ElapsedGameTime.TotalSeconds; } }
/// <summary> /// Fait avancer ce Virus vers sa destination. /// </summary> void Travel(GameTime time) { // Si on a pas de trajectoire, on return if (m_path == null || m_path.TrajectoryUnits.Count == 0 || m_currentAgro == null) { return; } // On mets à jour la trajectoire. m_path.UpdateStep(Position, GetMoveSpeed(), time); m_path.Offset = (Row - 1) * new Vector2(0.25f, 0.25f); Vector2 nextPosition = m_path.CurrentStep; // Si on est trop près d'un sbire, on s'arrête EntityType allyVirusType = EntityTypeConverter.ToAbsolute(EntityTypeRelative.AllyVirus, Type); EntityCollection allyVirus = GameServer.GetMap().Entities.GetEntitiesByType(allyVirusType); foreach (var kvp in allyVirus) { EntityVirus entity = (EntityVirus)kvp.Value; if (entity == this || entity.Row != this.Row) { continue; } // Ce Virus est trop près, on s'arrête s'il a le même aggro et est plus proche. if (Vector2.DistanceSquared(entity.Position, Position) <= 4.0f) { if (entity.ID < this.ID) { return; } } } // on s'arrête quand on est en range d'une tour / Virus. float dstSqr = Vector2.DistanceSquared(m_path.LastPosition(), Position); float range = AttackRange * AttackRangeApproach; if (m_currentAgro.Type.HasFlag(EntityType.Checkpoint) || dstSqr > range * range) { Direction = nextPosition - Position; MoveForward(time); } }