using System;
using Server;
using Server.Mobiles;
using Server.Network;
namespace Server.Costum
{
public class King
{
public static Mobile TheKing = null;
private const string m_Title = "[King]";
private static TimeSpan m_Delay = TimeSpan.FromSeconds(1.0); //Gecikme payi *Teorik olarak sadece birkez çalisiyor, server açildiginda girdiginiz süre kadar sonra ilk seçim yapilir, bundan sonra asagidaki interval etkileyici roldedir*
private static TimeSpan m_Interval = TimeSpan.FromMinutes(15.0); //Seçim araligi
/// <summary>
/// Her interval kadar sürede bir kral seçimi yapilir
/// </summary>
public static void Initialize()
{
Timer.DelayCall(m_Delay, m_Interval, new TimerCallback(SelectKingCallback));
}
private static void SelectKingCallback()
{
try
{
Console.WriteLine("Kral seçimleri basladi");
RemoveOldKing();
SelectNewKing();
}
catch
{
Console.WriteLine("Kral seçimlerinde bir hata olustu");
}
finally
{
AnnounceNewKing();
}
}
/// <summary>
/// Eski kral silinir
/// </summary>
/// <returns></returns>
private static void RemoveOldKing()
{
if (TheKing != null)
TheKing.Title = null;
}
/// <summary>
/// Online oyuncular arasindan yeni bir kral seçilir
/// </summary>
/// <returns></returns>
private static Mobile SelectNewKing()
{
Mobile m_Candidate = null;
if (NetState.Instances.Count >= 10)
{
foreach (NetState n in NetState.Instances)
{
if (n.Mobile != null)
{
m_Candidate = n.Mobile;
if (TheKing == null)
{
TheKing = m_Candidate;
continue;
}
if (m_Candidate.Title == m_Title)
{
m_Candidate.Title = null;
}
if (m_Candidate.NetState != null && m_Candidate.Kills > TheKing.Kills)
{
TheKing = m_Candidate;
}
}
}
}
return m_Candidate;
}
/// <summary>
/// Seçilen krali anons eder
/// </summary>
private static void AnnounceNewKing()
{
if (TheKing != null)
{
Console.WriteLine("Krallik seçimi bitti, kral = {0}", TheKing.Name);
World.Broadcast(1153, false, "Yeni kral seçildi, [{0}]", TheKing.Name);
TheKing.Title = m_Title;
DoEffect();
}
else
{
World.Broadcast(1153, false, "Yeni bir kral seçilemedi...");
Console.WriteLine("Yeni bir kral seçilemedi");
}
}
private static void DoEffect()
{
Effects.SendMovingParticles(new Entity(Serial.Zero, new Point3D(TheKing.X - 6, TheKing.Y - 6, TheKing.Z + 15), TheKing.Map), TheKing, 0x36D4, 7, 0, false, true, 1160, 0, 9502, 1, 0, (EffectLayer)255, 0x100);
Effects.SendMovingParticles(new Entity(Serial.Zero, new Point3D(TheKing.X - 4, TheKing.Y - 6, TheKing.Z + 15), TheKing.Map), TheKing, 0x36D4, 7, 0, false, true, 1160, 0, 9502, 1, 0, (EffectLayer)255, 0x100);
Effects.SendMovingParticles(new Entity(Serial.Zero, new Point3D(TheKing.X - 6, TheKing.Y - 4, TheKing.Z + 15), TheKing.Map), TheKing, 0x36D4, 7, 0, false, true, 1160, 0, 9502, 1, 0, (EffectLayer)255, 0x100);
}
}
}
Total votes: 0
Ultima Online 1 gün önce
Sunucular 3 gün önce
Sunucular 3 gün önce
Ultima Online 2 hafta önce
Counter-Strike 2 hafta önce
Sunucular 1 ay önce
Sunucular 1 ay önce
Ultima Online 1 ay önce
Sunucular 1 ay önce
Sohbet & Geyik 1 ay önce
Sunucular 1 ay önce
Ultima Online 1 ay önce
Ultima Online 2 ay önce
2024-10-31 22:47
2024-10-14 17:45
2024-09-26 14:21
2024-07-08 22:50
2024-07-08 22:34
2024-06-19 22:05
2024-06-01 02:19
2024-05-31 21:17
Yorumlar (0)