using System;
using Server.Gumps;
using Server.Items;
using Server.Network;
using.server.mobiles;
namespace Server.Gumps
{
public class GameTeamSelector : Gump
{
private CTFGame m_Game;
private int m_TeamSize;
public GameTeamSelector( CTFGame game ) : this( game, game.TeamSize )
{
}
public GameTeamSelector( CTFGame game, int teamSize ) : base( 50, 50 )
{
m_Game = game;
m_TeamSize = teamSize;
Closable = false;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 250, 220, 5054 );
AddBackground( 10, 10, 230, 200, 3000 );
AddPage( 1 );
AddLabel( 20, 20, 0, "Select a team:" );
for (int i=0;i<m_Game.Teams.Count;i++)
{
CTFTeam team = (CTFTeam)m_Game.Teams[i];
if ( team.ActiveMemberCount < m_TeamSize )
{
AddButton( 20, 60 + i*20, 4005, 4006, i+1, GumpButtonType.Reply, 0 );
AddLabel( 55, 60 + i*20, 0, "Join Team " + team.Name );
}
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
from.CloseGump( typeof( GameTeamSelector ) );
if ( m_Game.Deleted )
return;
CTFTeam team = m_Game.GetTeam( info.ButtonID - 1 );
if ( team != null && team.ActiveMemberCount < m_TeamSize )
{
bool freeze = from.Frozen;
from.Kill();
if ( from.Corpse != null && !from.Corpse.Deleted )
from.Corpse.Delete();
from.Location = team.Home;
from.Map = team.Map;
from.Resurrect();
from.Frozen = freeze;
m_Game.SwitchTeams( from, team );
from.SendMessage( "You have joined team {0}!", team.Name );
}
else
{
from.SendMessage( "That team is full, please try again." );
from.SendGump( new GameTeamSelector( m_Game ) );
}
}
}
public class GameJoinGump : Gump
{
private CTFGame m_Game;
public GameJoinGump( CTFGame game, string gameName ) : base( 20, 30 )
{
m_Game = game;
AddPage( 0 );
AddBackground( 0, 0, 550, 220, 5054 );
AddBackground( 10, 10, 530, 200, 3000 );
AddPage( 1 );
AddLabel( 20, 20, 0, String.Format( "Welcome to {0}!", gameName ) );
//AddLabel( 20, 60, 0, "Let it be known to all who join the the melee that lays within, you will not" );
AddLabel( 20, 60, 0, "Enter the game with caution! ll non-bless/non-newbied items will be lost!" );
AddLabel( 20, 80, 0, "All pets will be lost! Bank your items before joining, supplies" );
AddLabel( 20, 100, 0, "will be provided. Enjoy!" );
AddLabel( 55, 180, 0, "Cancel" );
AddButton( 20, 180, 4005, 4006, 0, GumpButtonType.Reply, 0 );
AddLabel( 165, 180, 0, "Okay, Join!" );
AddButton( 130, 180, 4005, 4006, 1, GumpButtonType.Reply, 0 );
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
from.CloseGump( typeof( GameTeamSelector ) );
if ( m_Game.Deleted )
return;
CTFTeam team = m_Game.GetTeam( info.ButtonID - 1 );
if ( team != null && team.ActiveMemberCount < m_TeamSize )
{
bool freeze = from.Frozen;
if ( from.Backpack != null )
{
if( from.FindItemOnLayer( Layer.TwoHanded) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.TwoHanded) );
if( from.FindItemOnLayer( Layer.Shoes) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.Shoes) );
if( from.FindItemOnLayer( Layer.Pants) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.Pants) );
if( from.FindItemOnLayer( Layer.Shirt) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.Shirt) );
if( from.FindItemOnLayer( Layer.Helm) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.Helm) );
if( from.FindItemOnLayer( Layer.Gloves) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.Gloves) );
if( from.FindItemOnLayer( Layer.Ring) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.Ring) );
if( from.FindItemOnLayer( Layer.Neck) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.Neck) );
if( from.FindItemOnLayer( Layer.OneHanded) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.OneHanded) );
if( from.FindItemOnLayer( Layer.Waist) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.Waist) );
if( from.FindItemOnLayer( Layer.InnerTorso) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.InnerTorso) );
if( from.FindItemOnLayer( Layer.Bracelet) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.Bracelet) );
if( from.FindItemOnLayer( Layer.MiddleTorso) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.MiddleTorso) );
if( from.FindItemOnLayer( Layer.Earrings) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.Earrings) );
if( from.FindItemOnLayer( Layer.Arms) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.Arms) );
if( from.FindItemOnLayer( Layer.Cloak) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.Cloak) );
if( from.FindItemOnLayer( Layer.OuterTorso) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.OuterTorso) );
if( from.FindItemOnLayer( Layer.OuterLegs) != null )
from.Backpack.DropItem( from.FindItemOnLayer( Layer.OuterLegs) );
from.Backpack.Movable = true;
from.BankBox.AddItem( from.Backpack );
Backpack pack = new Backpack();
pack.Movable = false;
from.AddItem( pack );
}
//check if they are mounted and dismount them
IMount mount = from.Mount;
if ( mount != null )
mount.Rider = null;
from.Location = team.Home;
from.Map = team.Map;
from.Frozen = freeze;
m_Game.SwitchTeams( from, team );
from.SendMessage( "You have joined team {0}!", team.Name );
}
else
{
from.SendMessage( "That team is full, please try again." );
from.SendGump( new GameTeamSelector( m_Game ) );
}
}
}