public static void ChecksHighLevels(ArrayList players, Radar.PlayerObject im) { //Чекаем, теряем ли мы хп? if (Game1.settings.sounds.PlayMeDamaged) { if (im.CurrentHealth < LastMyHP) { if (my_player_damaged.State == SoundState.Stopped) { //Нас дамажат, проигрываем эффект удара my_player_damaged.Volume = 0.3f; my_player_damaged.Pitch = Game1.random.Next(4, 6) / 10.0f; my_player_damaged.Play(); } } } LastMyHP = im.CurrentHealth; ArrayList playerToCheckDistance = new ArrayList(); bool HighLvlFinded = false; foreach (Radar.PlayerObject player in players) { if (player.Guid != im.Guid) { if (!player.IsDead & !im.IsDead) { if (Defines.IsEnemy(player.Race, im.Race)) { if (player.IsHighLvl) { playerToCheckDistance.Add(player); HighLvlFinded = true; } } } } } //Ищем ближайших высокий левелов float nearestDistance = MaxSoundDistance; foreach (Radar.PlayerObject player in players) { float currPlayer_Distance = Vector2.Distance(new Vector2(im.XPos, im.YPos), new Vector2(player.XPos, player.YPos)); if (currPlayer_Distance < nearestDistance) { nearestDistance = currPlayer_Distance; } } //Вычисляем громкость, чем ближе - тем громче float procVal = (nearestDistance / MaxSoundDistance) * 100; float limit = 70; float procents = procVal > limit ? limit : procVal; //Ограничиваем float volume = Math.Abs((100 - procents) / 666); high_lvl_rogue.Volume = volume; high_lvl.Volume = volume; low_lvl.Volume = volume; //Проигрование звуки если высокий лвл bool findedAny = false; foreach (Radar.PlayerObject player in players) { if (player.Guid != im.Guid) { if (!player.IsDead & !im.IsDead) { if (Defines.IsEnemy(player.Race, im.Race)) { if (HighLvlFinded) //Высокий уровень { //Если рога bool hasRogue = (player.Class == (byte)Defines.Classes.ROGUE | player.Class == (byte)Defines.Classes.DRUID); if (Game1.settings.sounds.PlayInvisibles & hasRogue) { if (Game1.settings.sounds.PlayInvisibles) //Если проигрывать звуки для инвизчиков { if (high_lvl_rogue.State != SoundState.Playing) { low_lvl.Stop(); high_lvl.Stop(); high_lvl_rogue.Play(); //Проигрываем звук для инвизеров } } } else { if (Game1.settings.sounds.PlayHighLvl) //Если проигрывать звуки для высоких лвл { if (high_lvl.State != SoundState.Playing) { low_lvl.Stop(); high_lvl_rogue.Stop(); high_lvl.Play(); //Проигрываем звук для высоких лвл } } } findedAny = true; break; } else if (!player.IsHighLvl) //Низкий уровень { if (Game1.settings.sounds.PlayLowLvl) //Если проигрывать звуки для низких лвл { if (low_lvl.State != SoundState.Playing & high_lvl_rogue.State != SoundState.Playing) { high_lvl.Stop(); low_lvl.Play(); //Проигрываем звук для низких лвл } findedAny = true; break; } } } } } } //Если не нашло ничего, вырубаем (кроме роги) if (!findedAny) { low_lvl.Stop(); high_lvl.Stop(); } }
public static void DrawPlayer(this SpriteBatch sb, Radar.PlayerObject player, Radar.PlayerObject im) { float RadarZoom = Game1.settings.RadarZoom; bool IsEnemy = Defines.IsEnemy(player.Race, im.Race); float XPos = (im.XPos - player.XPos) * RadarZoom + Game1.RadarWidth / 2; float YPos = (im.YPos - player.YPos) * RadarZoom + Game1.RadarHeight / 2; float Rotation = -player.Rotation; float Zoom = RadarZoom / 3.2f; Color color = Tools.GetRandomColor(Game1.random); int Size = Game1.settings.Player_Size; Texture2D class_tex = Textures.GetTextureByClass(player.Class); Texture2D arrow_tex = Textures.GetTexture("other_arrow"); //Calc destinations for textures Rectangle ClassDest = new Rectangle((int)XPos, (int)YPos, (int)(class_tex.Width * Zoom), (int)(class_tex.Height * Zoom)); Rectangle ArrowDest = new Rectangle((int)XPos, (int)YPos, (int)(arrow_tex.Width * (Zoom / 1.4f)), (int)(arrow_tex.Height * (Zoom / 1.4f))); //Рисуем линию взгляда если высокий лвл if (IsEnemy) { if (player.IsHighLvl) { sb.DrawLine(new Vector2(XPos, YPos), Game1.RadarWidth * 1.5f, (Rotation - 1.577f), Color.Red, 2); sb.DrawText(player.Name + ":" + player.Level.ToString(), new Vector2(XPos, YPos + Size), 15.0f, color); } else { float medium_lenght = (class_tex.Width / 2) + (class_tex.Height / 2); sb.DrawLine(new Vector2(XPos, YPos), (medium_lenght) * Zoom + (medium_lenght / 2), (Rotation - 1.577f), Color.Red, 2); sb.DrawText(player.Name + ":" + player.Level.ToString(), new Vector2(XPos, YPos + Size), 14.0f, Color.Red); } } else { float medium_lenght = (class_tex.Width / 2) + (class_tex.Height / 2); sb.DrawLine(new Vector2(XPos, YPos), (medium_lenght) * Zoom, (Rotation - 1.577f), Color.LightSkyBlue, 2); sb.DrawText(player.Name + ":" + player.Level.ToString(), new Vector2(XPos, YPos + Size), 14.0f, Color.Gold); } if (player.IsDead) { sb.DrawOpacityTexture(class_tex, ClassDest, 120); } else { //Draw class sb.DrawTexture(class_tex, ClassDest); //And finally arrow of sight if (IsEnemy) { sb.DrawTexture(arrow_tex, ArrowDest, Rotation, Color.Red); } else { sb.DrawTexture(arrow_tex, ArrowDest, Rotation, Color.LightSkyBlue); } } }