public void Remove(DuelPlayer player) { if (player == null) { return; } int index = Array.IndexOf(m_Players, player); if (index == -1) { return; } DuelPlayer[] old = m_Players; m_Players = new DuelPlayer[old.Length - 1]; for (int i = 0; i < index; ++i) { m_Players[i] = old[i]; } for (int i = index + 1; i < old.Length; ++i) { m_Players[i - 1] = old[i]; } }
private void DelayBounce_Callback(object state) { object[] states = (object[])state; Mobile mob = (Mobile)states[0]; Container corpse = (Container)states[1]; DuelPlayer dp = null; if (mob is PlayerMobile) { dp = (mob as PlayerMobile).DuelPlayer; } m_Context.RemoveAggressions(mob); if (dp != null && !dp.Eliminated) { mob.MoveToWorld(m_Context.Arena.GetBaseStartPoint(GetTeamID(mob)), Facet); } else { m_Context.SendOutside(mob); } m_Context.Refresh(mob, corpse); DuelContext.Debuff(mob); DuelContext.CancelSpell(mob); mob.Frozen = false; if (corpse != null && !corpse.Deleted) { Timer.DelayCall(TimeSpan.FromSeconds(30), new TimerCallback(corpse.Delete)); } }
public void Remove(DuelPlayer player) { if (player == null) { return; } var index = Array.IndexOf(Players, player); if (index == -1) { return; } var old = Players; Players = new DuelPlayer[old.Length - 1]; for (var i = 0; i < index; ++i) { Players[i] = old[i]; } for (var i = index + 1; i < old.Length; ++i) { Players[i - 1] = old[i]; } }
public ParticipantGump(Mobile from, DuelContext context, Participant p) : base(50, 50) { this.m_From = from; this.m_Context = context; this.m_Participant = p; from.CloseGump(typeof(RulesetGump)); from.CloseGump(typeof(DuelContextGump)); from.CloseGump(typeof(ParticipantGump)); int count = p.Players.Length; if (count < 4) { count = 4; } this.AddPage(0); int height = 35 + 10 + 22 + 22 + 30 + 22 + 2 + (count * 22) + 2 + 30; this.AddBackground(0, 0, 300, height, 9250); this.AddBackground(10, 10, 280, height - 20, 0xDAC); this.AddButton(240, 25, 0xFB1, 0xFB3, 3, GumpButtonType.Reply, 0); //AddButton( 223, 54, 0x265A, 0x265A, 4, GumpButtonType.Reply, 0 ); this.AddHtml(35, 25, 230, 20, this.Center("Participant Setup"), false, false); int x = 35; int y = 47; this.AddHtml(x, y, 200, 20, String.Format("Team Size: {0}", p.Players.Length), false, false); y += 22; this.AddGoldenButtonLabeled(x + 20, y, 1, "Increase"); y += 22; this.AddGoldenButtonLabeled(x + 20, y, 2, "Decrease"); y += 30; this.AddHtml(35, y, 230, 20, this.Center("Players"), false, false); y += 22; for (int i = 0; i < p.Players.Length; ++i) { DuelPlayer pl = p.Players[i]; this.AddGoldenButtonLabeled(x, y, 5 + i, String.Format("{0}: {1}", 1 + i, pl == null ? "Empty" : pl.Mobile.Name)); y += 22; } }
public ParticipantGump(Mobile from, DuelContext context, Participant p) : base(50, 50) { From = from; Context = context; Participant = p; from.CloseGump <RulesetGump>(); from.CloseGump <DuelContextGump>(); from.CloseGump <ParticipantGump>(); int count = p.Players.Length; if (count < 4) { count = 4; } AddPage(0); int height = 35 + 10 + 22 + 22 + 30 + 22 + 2 + count * 22 + 2 + 30; AddBackground(0, 0, 300, height, 9250); AddBackground(10, 10, 280, height - 20, 0xDAC); AddButton(240, 25, 0xFB1, 0xFB3, 3); // AddButton( 223, 54, 0x265A, 0x265A, 4, ); AddHtml(35, 25, 230, 20, Center("Participant Setup")); int x = 35; int y = 47; AddHtml(x, y, 200, 20, $"Team Size: {p.Players.Length}"); y += 22; AddGoldenButtonLabeled(x + 20, y, 1, "Increase"); y += 22; AddGoldenButtonLabeled(x + 20, y, 2, "Decrease"); y += 30; AddHtml(35, y, 230, 20, Center("Players")); y += 22; for (int i = 0; i < p.Players.Length; ++i) { DuelPlayer pl = p.Players[i]; AddGoldenButtonLabeled(x, y, 5 + i, $"{1 + i}: {(pl == null ? "Empty" : pl.Mobile.Name)}"); y += 22; } }
public void MoveInside(DuelPlayer[] players, int index) { if (index < 0) { index = 0; } else { index %= m_Points.Points.Length; } Point3D start = GetBaseStartPoint(index); int offset = 0; Point2D[] offsets = (index < 4) ? m_EdgeOffsets : m_CornerOffsets; int[,] matrix = m_Rotate[index]; for (int i = 0; i < players.Length; ++i) { DuelPlayer pl = players[i]; if (pl == null) { continue; } Mobile mob = pl.Mobile; Point2D p; if (offset < offsets.Length) { p = offsets[offset++]; } else { p = offsets[offsets.Length - 1]; } p.X = (p.X * matrix[0, 0]) + (p.Y * matrix[0, 1]); p.Y = (p.X * matrix[1, 0]) + (p.Y * matrix[1, 1]); mob.MoveToWorld(new Point3D(start.X + p.X, start.Y + p.Y, start.Z), m_Facet); mob.Direction = mob.GetDirectionTo(m_Wall); m_Players.Add(mob); } }
public void Nullify(DuelPlayer player) { if (player == null) { return; } int index = Array.IndexOf(m_Players, player); if (index == -1) { return; } m_Players[index] = null; }
public void Resize(int count) { DuelPlayer[] old = Players; Players = new DuelPlayer[count]; if (old != null) { int ct = 0; for (int i = 0; i < old.Length; ++i) { if (old[i] != null && ct < count) { Players[ct++] = old[i]; } } } }
public void Add(Mobile player) { if (Contains(player)) { return; } for (var i = 0; i < Players.Length; ++i) { if (Players[i] == null) { Players[i] = new DuelPlayer(player, this); return; } } Resize(Players.Length + 1); Players[^ 1] = new DuelPlayer(player, this);
public void Add(Mobile player) { if (Contains(player)) { return; } for (int i = 0; i < m_Players.Length; ++i) { if (m_Players[i] == null) { m_Players[i] = new DuelPlayer(player, this); return; } } Resize(m_Players.Length + 1); m_Players[m_Players.Length - 1] = new DuelPlayer(player, this); }
public void OnEliminated(DuelPlayer player) { Participant part = player.Participant; if (!part.Eliminated) return; if (this.m_TournyType == TournyType.FreeForAll) { int rem = 0; for (int i = 0; i < part.Context.Participants.Count; ++i) { Participant check = (Participant)part.Context.Participants[i]; if (check != null && !check.Eliminated) ++rem; } TournyParticipant tp = part.TournyPart; if (tp == null) return; if (rem == 1) this.GiveAwards(tp.Players, TrophyRank.Silver, this.ComputeCashAward() / 2); else if (rem == 2) this.GiveAwards(tp.Players, TrophyRank.Bronze, this.ComputeCashAward() / 4); } }
public void Add( Mobile player ) { if ( Contains( player ) ) return; for ( int i = 0; i < m_Players.Length; ++i ) { if ( m_Players[i] == null ) { m_Players[i] = new DuelPlayer( player, this ); return; } } Resize( m_Players.Length + 1 ); m_Players[m_Players.Length - 1] = new DuelPlayer( player, this ); }
public ReadyUpGump(Mobile from, DuelContext context) : base(50, 50) { m_From = from; m_Context = context; Closable = false; AddPage(0); if (context.Rematch) { int height = 25 + 20 + 10 + 22 + 25; AddBackground(0, 0, 210, height, 9250); AddBackground(10, 10, 190, height - 20, 0xDAC); AddHtml(35, 25, 140, 20, Center("Rematch?"), false, false); AddButton(35, 55, 247, 248, 1, GumpButtonType.Reply, 0); AddButton(115, 55, 242, 241, 2, GumpButtonType.Reply, 0); } else { #region Participants AddPage(1); ArrayList parts = context.Participants; int height = 25 + 20; for (int i = 0; i < parts.Count; ++i) { Participant p = (Participant)parts[i]; height += 4; if (p.Players.Length > 1) { height += 22; } height += (p.Players.Length * 22); } height += 10 + 22 + 25; AddBackground(0, 0, 260, height, 9250); AddBackground(10, 10, 240, height - 20, 0xDAC); AddHtml(35, 25, 190, 20, Center("Participants"), false, false); int y = 20 + 25; for (int i = 0; i < parts.Count; ++i) { Participant p = (Participant)parts[i]; y += 4; int offset = 0; if (p.Players.Length > 1) { AddHtml(35, y, 176, 20, string.Format("Team #{0}", i + 1), false, false); y += 22; offset = 10; } for (int j = 0; j < p.Players.Length; ++j) { DuelPlayer pl = p.Players[j]; string name = (pl == null ? "(Empty)" : pl.Mobile.Name); AddHtml(35 + offset, y, 166, 20, name, false, false); y += 22; } } y += 8; AddHtml(35, y, 176, 20, "Continue?", false, false); y -= 2; AddButton(102, y, 247, 248, 0, GumpButtonType.Page, 2); AddButton(169, y, 242, 241, 2, GumpButtonType.Reply, 0); #endregion #region Rules AddPage(2); Ruleset ruleset = context.Ruleset; Ruleset basedef = ruleset.Base; height = 25 + 20 + 5 + 20 + 20 + 4; int changes = 0; BitArray defs; if (ruleset.Flavors.Count > 0) { defs = new BitArray(basedef.Options); for (int i = 0; i < ruleset.Flavors.Count; ++i) { defs.Or(((Ruleset)ruleset.Flavors[i]).Options); } height += ruleset.Flavors.Count * 18; } else { defs = basedef.Options; } BitArray opts = ruleset.Options; for (int i = 0; i < opts.Length; ++i) { if (defs[i] != opts[i]) { ++changes; } } height += (changes * 22); height += 10 + 22 + 25; AddBackground(0, 0, 260, height, 9250); AddBackground(10, 10, 240, height - 20, 0xDAC); AddHtml(35, 25, 190, 20, Center("Rules"), false, false); AddHtml(35, 50, 190, 20, string.Format("Set: {0}", basedef.Title), false, false); y = 70; for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18) { AddHtml(35, y, 190, 20, string.Format(" + {0}", ((Ruleset)ruleset.Flavors[i]).Title), false, false); } y += 4; if (changes > 0) { AddHtml(35, y, 190, 20, "Modifications:", false, false); y += 20; for (int i = 0; i < opts.Length; ++i) { if (defs[i] != opts[i]) { string name = ruleset.Layout.FindByIndex(i); if (name != null) // sanity { AddImage(35, y, opts[i] ? 0xD3 : 0xD2); AddHtml(60, y, 165, 22, name, false, false); } y += 22; } } } else { AddHtml(35, y, 190, 20, "Modifications: None", false, false); y += 20; } y += 8; AddHtml(35, y, 176, 20, "Continue?", false, false); y -= 2; AddButton(102, y, 247, 248, 1, GumpButtonType.Reply, 0); AddButton(169, y, 242, 241, 3, GumpButtonType.Reply, 0); #endregion } }
public void MoveInside( DuelPlayer[] players, int index ) { if ( index < 0 ) index = 0; else index %= m_Points.Points.Length; Point3D start = GetBaseStartPoint( index ); int offset = 0; Point2D[] offsets = ( index < 4 ) ? m_EdgeOffsets : m_CornerOffsets; int[,] matrix = m_Rotate[index]; for ( int i = 0; i < players.Length; ++i ) { DuelPlayer pl = players[i]; if ( pl == null ) continue; Mobile mob = pl.Mobile; Point2D p; if ( offset < offsets.Length ) p = offsets[offset++]; else p = offsets[offsets.Length - 1]; p.X = (p.X * matrix[0, 0]) + (p.Y * matrix[0, 1]); p.Y = (p.X * matrix[1, 0]) + (p.Y * matrix[1, 1]); mob.MoveToWorld( new Point3D( start.X + p.X, start.Y + p.Y, start.Z ), m_Facet ); mob.Direction = mob.GetDirectionTo( m_Wall ); m_Players.Add( mob ); if (mob is PlayerMobile) { if (Tournament.Tournament.CurrentStage != TournamentStage.Inactive) { PvPTemplates.PvPTemplates.FetchProfile(mob as PlayerMobile).ApplyDelta(true); } else { PvPTemplates.PvPTemplates.FetchProfile(mob as PlayerMobile).ApplyDelta(false); } } } }
private void Finish_Callback() { ArrayList teams = new ArrayList(); for (int i = 0; i < m_Context.Participants.Count; ++i) { KHTeamInfo teamInfo = m_Controller.TeamInfo[i % m_Controller.TeamInfo.Length]; if (teamInfo == null) { continue; } teams.Add(teamInfo); } teams.Sort(); Tournament tourny = m_Context.m_Tournament; StringBuilder sb = new StringBuilder(); if (tourny != null && tourny.TournyType == TournyType.FreeForAll) { sb.Append(m_Context.Participants.Count * tourny.PlayersPerParticipant); sb.Append("-man FFA"); } else if (tourny != null && tourny.TournyType == TournyType.RandomTeam) { sb.Append(tourny.ParticipantsPerMatch); sb.Append("-team"); } else if (tourny != null && tourny.TournyType == TournyType.RedVsBlue) { sb.Append("Red v Blue"); } else if (tourny != null) { for (int i = 0; i < tourny.ParticipantsPerMatch; ++i) { if (sb.Length > 0) { sb.Append('v'); } sb.Append(tourny.PlayersPerParticipant); } } if (m_Controller != null) { sb.Append(' ').Append(m_Controller.Title); } string title = sb.ToString(); KHTeamInfo winner = (KHTeamInfo)(teams.Count > 0 ? teams[0] : null); for (int i = 0; i < teams.Count; ++i) { TrophyRank rank = TrophyRank.Bronze; if (i == 0) { rank = TrophyRank.Gold; } else if (i == 1) { rank = TrophyRank.Silver; } KHPlayerInfo leader = ((KHTeamInfo)teams[i]).Leader; foreach (KHPlayerInfo pl in ((KHTeamInfo)teams[i]).Players.Values) { Mobile mob = pl.Player; if (mob == null) { continue; } sb = new StringBuilder(); sb.Append(title); if (pl == leader) { sb.Append(" Leader"); } if (pl.Score > 0) { sb.Append(": "); sb.Append(pl.Score.ToString("N0")); sb.Append(pl.Score == 1 ? " point" : " points"); sb.Append(", "); sb.Append(pl.Kills.ToString("N0")); sb.Append(pl.Kills == 1 ? " kill" : " kills"); if (pl.Captures > 0) { sb.Append(", "); sb.Append(pl.Captures.ToString("N0")); sb.Append(pl.Captures == 1 ? " capture" : " captures"); } } Item item = new Trophy(sb.ToString(), rank); if (pl == leader) { item.ItemID = 4810; } item.Name = String.Format("{0}, {1}", item.Name, ((KHTeamInfo)teams[i]).Name.ToLower()); if (!mob.PlaceInBackpack(item)) { mob.BankBox.DropItem(item); } int cash = pl.Score * 250; if (cash > 0) { item = new BankCheck(cash); if (!mob.PlaceInBackpack(item)) { mob.BankBox.DropItem(item); } mob.SendMessage("You have been awarded a {0} trophy and {1:N0}gp for your participation in this game.", rank.ToString().ToLower(), cash); } else { mob.SendMessage("You have been awarded a {0} trophy for your participation in this game.", rank.ToString().ToLower()); } } } for (int i = 0; i < m_Context.Participants.Count; ++i) { Participant p = m_Context.Participants[i] as Participant; if (p == null || p.Players == null) { continue; } for (int j = 0; j < p.Players.Length; ++j) { DuelPlayer dp = p.Players[j]; if (dp != null && dp.Mobile != null) { dp.Mobile.CloseGump(typeof(KHBoardGump)); dp.Mobile.SendGump(new KHBoardGump(dp.Mobile, this)); } } if (i == winner.TeamID) { continue; } if (p != null && p.Players != null) { for (int j = 0; j < p.Players.Length; ++j) { if (p.Players[j] != null) { p.Players[j].Eliminated = true; } } } } m_Context.Finish(m_Context.Participants[winner.TeamID] as Participant); }
public void MoveInside(DuelPlayer[] players, int index) { if (index < 0) { index = 0; } else { index %= m_Points.Points.Length; } Point3D start = GetBaseStartPoint(index); int offset = 0; Point2D[] offsets = (index < 4) ? m_EdgeOffsets : m_CornerOffsets; int[,] matrix = m_Rotate[index]; for (int i = 0; i < players.Length; ++i) { DuelPlayer pl = players[i]; if (pl == null) { continue; } Mobile mob = pl.Mobile; Point2D p; if (offset < offsets.Length) { p = offsets[offset++]; } else { p = offsets[offsets.Length - 1]; } p.X = (p.X * matrix[0, 0]) + (p.Y * matrix[0, 1]); p.Y = (p.X * matrix[1, 0]) + (p.Y * matrix[1, 1]); mob.MoveToWorld(new Point3D(start.X + p.X, start.Y + p.Y, start.Z), m_Facet); mob.Direction = mob.GetDirectionTo(m_Wall); m_Players.Add(mob); if (mob is PlayerMobile) { if (Tournament.Tournament.CurrentStage != TournamentStage.Inactive) { PvPTemplates.PvPTemplates.FetchProfile(mob as PlayerMobile).ApplyDelta(true); } else { PvPTemplates.PvPTemplates.FetchProfile(mob as PlayerMobile).ApplyDelta(false); } } } }
public ReadyGump(Mobile from, DuelContext context, int count) : base(50, 50) { m_From = from; m_Context = context; m_Count = count; ArrayList parts = context.Participants; int height = 25 + 20; for (int i = 0; i < parts.Count; ++i) { Participant p = (Participant)parts[i]; height += 4; if (p.Players.Length > 1) { height += 22; } height += (p.Players.Length * 22); } height += 25; Closable = false; Dragable = false; AddPage(0); AddBackground(0, 0, 260, height, 9250); AddBackground(10, 10, 240, height - 20, 0xDAC); if (count == -1) { AddHtml(35, 25, 190, 20, Center("Ready"), false, false); } else { AddHtml(35, 25, 190, 20, Center("Starting"), false, false); AddHtml(35, 25, 190, 20, "<DIV ALIGN=RIGHT>" + count.ToString(), false, false); } int y = 25 + 20; for (int i = 0; i < parts.Count; ++i) { Participant p = (Participant)parts[i]; y += 4; bool isAllReady = true; int yStore = y; int offset = 0; if (p.Players.Length > 1) { AddHtml(35 + 14, y, 176, 20, String.Format("Participant #{0}", i + 1), false, false); y += 22; offset = 10; } for (int j = 0; j < p.Players.Length; ++j) { DuelPlayer pl = p.Players[j]; if (pl != null && pl.Ready) { AddImage(35 + offset, y + 4, 0x939); } else { AddImage(35 + offset, y + 4, 0x938); isAllReady = false; } string name = (pl == null ? "(Empty)" : pl.Mobile.Name); AddHtml(35 + offset + 14, y, 166, 20, name, false, false); y += 22; } if (p.Players.Length > 1) { AddImage(35, yStore + 4, isAllReady ? 0x939 : 0x938); } } }
public void Nullify(DuelPlayer player) { if (player == null) return; int index = Array.IndexOf(this.m_Players, player); if (index == -1) return; this.m_Players[index] = null; }
public void OnEliminated(DuelPlayer player) { Participant part = player.Participant; if (!part.Eliminated) { return; } if (m_TournyType == TournyType.FreeForAll) { int rem = 0; for (int i = 0; i < part.Context.Participants.Count; ++i) { Participant check = part.Context.Participants[i]; if (check != null && !check.Eliminated) { ++rem; } } TournyParticipant tp = part.TournyPart; if (tp == null) { return; } if (rem == 1) { tp.Points += 50; GiveAwards(tp.Players, TrophyRank.Silver, ComputeCashAward() / 2); } else if (rem == 2) { tp.Points += 25; GiveAwards(tp.Players, TrophyRank.Bronze, ComputeCashAward() / 4); } } }
public void Remove(DuelPlayer player) { if (player == null) return; int index = Array.IndexOf(this.m_Players, player); if (index == -1) return; DuelPlayer[] old = this.m_Players; this.m_Players = new DuelPlayer[old.Length - 1]; for (int i = 0; i < index; ++i) this.m_Players[i] = old[i]; for (int i = index + 1; i < old.Length; ++i) this.m_Players[i - 1] = old[i]; }
public void MoveInside( DuelPlayer[] players, int index ) { if ( index < 0 ) index = 0; else index %= m_Points.Points.Length; Point3D start = GetBaseStartPoint( index ); int offset = 0; Point2D[] offsets = ( index < 4 ) ? m_EdgeOffsets : m_CornerOffsets; int[,] matrix = m_Rotate[index]; for ( int i = 0; i < players.Length; ++i ) { DuelPlayer pl = players[i]; if ( pl == null ) continue; Mobile mob = pl.Mobile; Point2D p; if ( offset < offsets.Length ) p = offsets[offset++]; else p = offsets[offsets.Length - 1]; p.X = (p.X * matrix[0, 0]) + (p.Y * matrix[0, 1]); p.Y = (p.X * matrix[1, 0]) + (p.Y * matrix[1, 1]); mob.MoveToWorld( new Point3D( start.X + p.X, start.Y + p.Y, start.Z ), m_Facet ); mob.Direction = mob.GetDirectionTo( m_Wall ); m_Players.Add( mob ); } }