using System;
using System.Collections;
using Server.Items;
using Server.Mobiles;
using Server.Gumps;
using Server.Network;
namespace Server.Items
{
public class CustomMoongate : Item
{
private AccessLevel m_AccessLevel = (AccessLevel)3;//4 = Admin, 3 = Seer, 2 = Gm etc
private ArrayList m_Destinations = new ArrayList();
private ArrayList m_DestX = new ArrayList();
private ArrayList m_DestY = new ArrayList();
private ArrayList m_DestZ = new ArrayList();
private ArrayList m_DestMaps = new ArrayList();
[Constructable]
public CustomMoongate() : base( 3948 )//moongate
{
Movable = false;
Light = LightType.Circle225;
}
public CustomMoongate( Serial serial ) : base( serial )
{
}
public override bool OnMoveOver( Mobile m )
{
if ( m_Destinations.Count > 0 )
{
m.SendGump( new CustomMoongateGump( m, this,false ));
}
else
{
m.SendMessage("The moongate doesn't appear to go anywhere...");
if ( m.AccessLevel >= m_AccessLevel )
m.SendMessage("Double-Click this to configure it");
}
return true;
}
public override void OnDoubleClick( Mobile from )
{
if ( from.AccessLevel >= m_AccessLevel )
from.SendGump(new CustomMoongateGump(from, this,true));
else
{
if ( m_Destinations.Count > 0 )
{
if ( Utility.InRange( this.Location, from.Location, 1 ) )
from.SendGump( new CustomMoongateGump( from, this, false ));
else
from.SendMessage("That is too far away");
}
else
from.SendMessage("The moongate doesn't appear to go anywhere...");
}
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
writer.Write( (int)m_Destinations.Count );
for ( int i = 0; i < m_Destinations.Count; ++i )
{
writer.Write( (string)m_Destinations[i] );
writer.Write( (int)m_DestX[i] );
writer.Write( (int)m_DestY[i] );
writer.Write( (int)m_DestZ[i] );
writer.Write( (int)m_DestMaps[i] );
}
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
int count = reader.ReadInt();
for ( int i = 0; i < count; ++i )
{
m_Destinations.Add( reader.ReadString() );
m_DestX.Add( reader.ReadInt() );
m_DestY.Add( reader.ReadInt() );
m_DestZ.Add( reader.ReadInt() );
m_DestMaps.Add( reader.ReadInt() );
}
break;
}
}
}
private class CustomMoongateGump : Gump
{
private CustomMoongate m_Gate;
private bool EditMode;
public void AddTextField( int x, int y, int width, int height, int index )
{
AddBackground( x - 2, y - 2, width + 4, height + 4, 0x2486 );
AddTextEntry( x + 2, y + 2, width - 4, height - 4, 0, index, "" );
}
public CustomMoongateGump( Mobile from, CustomMoongate gate, bool editmode ) : base( 100,50 )
{
EditMode = editmode;
from.CloseGump( typeof( CustomMoongateGump ) );
PlayerMobile pm = from as PlayerMobile;
m_Gate = gate;
int width = 248;
if ( EditMode == true )
width = 435;
else
Effects.PlaySound( from.Location, from.Map, 0x20E );
int height = 224;
if ( m_Gate.m_Destinations.Count > 3 )
height = ((m_Gate.m_Destinations.Count*32)+95);//350;//Varies for no. Entries
AddBackground( 0, 0, width, height, 2600 );
if ( EditMode == true )
AddLabel( (width/2)-128, 16, 33, "Nokta Ekleme Modu" );
else
AddLabel( (width/2)-80, 16, 33, "Gideceğiniz yeri seçin" );
AddPage( 1 );
if ( EditMode == true )
{
AddButton( 128, 48, 4029, 4031, 11, GumpButtonType.Reply, 0 );// Add Destination
AddLabel(160, 48, 33, "Yeni Gidilecek Noktayı Ekle" );
AddTextField( 128, 96, 150, 20, 1 );
AddLabel(128, 72, 33, "Mapin Adı" );
AddTextField( 128, 144, 150, 20, 0 );
AddLabel(128, 120, 33, "Noktanın Adı" );
AddTextField( 148, 168, 80, 20, 2 );
AddLabel(128, 168, 33, "X" );
AddTextField( 248, 168, 80, 20, 3 );
AddLabel(228, 168, 33, "Y" );
AddTextField( 348, 168, 60, 20, 4 );
AddLabel(328, 168, 33, "Z" );
}
for ( int i = 0; i < m_Gate.m_Destinations.Count; ++i )
{
AddLabel( 48, (32*i)+40, 33, (string)m_Gate.m_Destinations[i] );
if ( EditMode == true )
AddButton( 16, (32*i)+40, 4017, 4019, i+12, GumpButtonType.Reply, 0 );//Del Destination
else
AddButton( 16, (32*i)+40, 4005, 4007, i+1, GumpButtonType.Reply, 0 );//Teleport
}
AddPage( 0 );
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
string name = "";
Point3D dest = new Point3D( 0, 0, 0 );
string map = "";
int m_Map = 0;
int x = 0;
int y = 0;
int z = 0;
foreach( TextRelay tr in info.TextEntries )
{
switch ( tr.EntryID )
{
case 0: //Name
{
if ( tr.Text != null )
{
if ( tr.Text != "" )
{
name = tr.Text;
}
}
break;
}
case 1://Map
{
if ( tr.Text != null )
{
if ( tr.Text != "" )
{
map = tr.Text;
}
}
break;
}
case 2://X
{
if ( tr.Text != null )
{
if ( tr.Text != "" )
{
x = int.Parse(tr.Text);
}
}
break;
}
case 3://Y
{
if ( tr.Text != null )
{
if ( tr.Text != "" )
{
y = int.Parse(tr.Text);
}
}
break;
}
case 4://Z
{
if ( tr.Text != null )
{
if ( tr.Text != "" )
{
z = int.Parse(tr.Text);//Convert to Int
}
}
break;
}
}
}
if ( info.ButtonID == 0 )
{
}
else if ( info.ButtonID >= 1 && info.ButtonID <= 10 )
{//Go
if ( Utility.InRange( m_Gate.Location, from.Location, 2 ) )
{
dest = new Point3D(((int)m_Gate.m_DestX[info.ButtonID-1]), ((int)m_Gate.m_DestY[info.ButtonID-1]), ((int)m_Gate.m_DestZ[info.ButtonID-1]) );
m_Map = (int)m_Gate.m_DestMaps[info.ButtonID-1];
Map mp = Map.Internal;
if ( dest == Point3D.Zero )
dest = from.Location;
if ( m_Map == 0 )
mp = Map.Felucca;
else if ( m_Map == 1 )
mp = Map.Trammel;
else if ( m_Map == 2 )
mp = Map.Ilshenar;
else if ( m_Map == 3 )
mp = Map.Malas;
if ( m_Map == 0 )
{
from.Location = dest;
}
else
{//Swap comments inside brackets if beta36
//from.Location = dest;
//from.Map = (Map)mp;
from.MoveToWorld( dest, (Map)mp );
}
Effects.PlaySound( from.Location, from.Map, 0x1FE );
}
else
from.SendMessage("You are too far away");
}
else if ( info.ButtonID == 11 )
{//ADD
if ( m_Gate.m_Destinations.Count <= 14 )//Change to max. entries, more than about 15 will be offscreen to some players
{
if ( ( ( x != 0 ) || ( y != 0 ) ) && ( name != "" ) )
{
if ( map == "felucca" || map == "Felucca" )
m_Gate.m_DestMaps.Add( 0 );
else if ( map == "trammel" || map == "Trammel" )
m_Gate.m_DestMaps.Add( 1 );
else if ( map == "ilshenar" || map == "Ilshenar" )
m_Gate.m_DestMaps.Add( 2 );
else if ( map == "malas" || map == "Malas" )
m_Gate.m_DestMaps.Add( 3 );
else
{
if ( m_Gate.Map == Map.Felucca )
m_Gate.m_DestMaps.Add( 0 );
else if ( m_Gate.Map == Map.Trammel )
m_Gate.m_DestMaps.Add( 1 );
else if ( m_Gate.Map == Map.Ilshenar )
m_Gate.m_DestMaps.Add( 2 );
else if ( m_Gate.Map == Map.Malas )
m_Gate.m_DestMaps.Add( 3 );
}
m_Gate.m_DestX.Add( x );
m_Gate.m_DestY.Add( y );
m_Gate.m_DestZ.Add( z );
m_Gate.m_Destinations.Add( name );
from.SendMessage("Nokta Eklendi");
}
else
from.SendMessage("Lütfen (x,y,z'leri) veya Map adı , Nokta adı yazıp tekrar deneyin!!!");
}
else
from.SendMessage("Birşey ekleyemezsiniz.Çünkü gate doldu!");
from.SendGump( new CustomMoongateGump( from, m_Gate,true ));
}
else if ( info.ButtonID >= 12 && info.ButtonID <= 21 )
{//DEL
m_Gate.m_DestMaps.RemoveAt( info.ButtonID-12 );
m_Gate.m_DestX.RemoveAt( info.ButtonID-12 );
m_Gate.m_DestY.RemoveAt( info.ButtonID-12 );
m_Gate.m_DestZ.RemoveAt( info.ButtonID-12 );
m_Gate.m_Destinations.RemoveAt( info.ButtonID-12 );
from.SendMessage("Nokta silindi");
from.SendGump( new CustomMoongateGump( from, m_Gate,true ));
}
}
}
}
}
Total votes: 0
Ultima Online 1 gün önce
Sunucular 2 gün önce
Sunucular 2 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)