本文整理汇总了C#中NetState类的典型用法代码示例。如果您正苦于以下问题:C# NetState类的具体用法?C# NetState怎么用?C# NetState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetState类属于命名空间,在下文中一共展示了NetState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CharServerConnected
/// <summary>
///
/// </summary>
/// <param name="netState"></param>
/// <param name="packetReader"></param>
internal static void CharServerConnected( NetState netState, PacketReader packetReader )
{
// 错误 不可能有创建
if ( netState.ExtendData is CharServerExtendData == true )
return;
else
netState.ExtendData = null;
if ( packetReader.Size < 6/*( 6 + 0 )*/ )
return;
// 不检查网络是否活动
netState.IsCheckActivity = false;
string l_strWorldPassword = packetReader.ReadStringSafe();
if ( l_strWorldPassword == Program.ConfigInfo.WorldPassword )
{
CharServerExtendData l_ExtendData = new CharServerExtendData();
l_ExtendData.IsLoggedIn = true;
netState.ExtendData = l_ExtendData;
}
}
示例2: OnSerializeNetworkView
public void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
{
Vector3 pos = observedTransform.position;
Quaternion rot = observedTransform.rotation;
if(stream.isWriting) {
stream.Serialize(ref pos);
stream.Serialize(ref rot);
}
else{
stream.Serialize(ref pos);
stream.Serialize(ref rot);
reciever.serverPos = pos;
reciever.serverRot = rot;
reciever.lerpToTarget();
for( int i = serverStateBuffer.Length - 1; i >= 1;i--){
serverStateBuffer[i] = serverStateBuffer[i-1];
}
serverStateBuffer[0] = new NetState();
serverStateBuffer[0].setState((float)info.timestamp, pos, rot);
}
}
示例3: LoginServerConnectFromCharServer
/// <summary>
///
/// </summary>
/// <param name="netState"></param>
/// <param name="packetReader"></param>
internal static void LoginServerConnectFromCharServer( NetState netState, PacketReader packetReader )
{
// 错误 不可能有创建
if ( netState.ExtendData is CharServerExtendData == true )
return;
else
netState.ExtendData = null;
if ( packetReader.Size < 14/*6 + 8 + ?*/ )
return;
// 不检查网络是否活动
netState.IsCheckActivity = false;
long l_iCharGUID = packetReader.ReadUInt32();
long l_iCharPort = packetReader.ReadUInt32();
string l_strLoginPassword = packetReader.ReadStringSafe();
if ( l_strLoginPassword == Program.ConfigInfo.LoginPassword )
{
CharServerExtendData l_ExtendData = new CharServerExtendData();
l_ExtendData.IsLoggedIn = true;
l_ExtendData.CharGUID = l_iCharGUID;
l_ExtendData.CharHost = netState.NetAddress.ToString();
l_ExtendData.CharPort = l_iCharPort;
netState.ExtendData = l_ExtendData;
Program.CharServerList.Add(l_ExtendData);
l_ExtendData.ConnectToCharServer( l_ExtendData.CharHost, l_ExtendData.CharPort );
}
}
示例4: OnSerializeNetworkView
void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
{
Vector3 pos = observedRigidbody.position;
Quaternion rot = observedRigidbody.rotation;
float vel = observedRigidbody.velocity.magnitude;
if(stream.isWriting)
{
stream.Serialize(ref pos);
stream.Serialize(ref rot);
stream.Serialize(ref vel);
}
else
{
stream.Serialize(ref pos);
stream.Serialize(ref rot);
stream.Serialize(ref vel);
receiver.serverPosition = pos;
receiver.serverRotation = rot;
receiver.serverVelocity = vel;
receiver.lerpToTarget();
for(int i = serverStateBuffer.Length - 1; i >= 1; i--)
{
serverStateBuffer[i] = serverStateBuffer[i-1];
}
serverStateBuffer[0] = new NetState(info.timestamp, pos, rot);
}
}
示例5: OnResponse
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
switch ( info.ButtonID )
{
case 0:{ break; }
}
}
示例6: Update
// Update is called once per frame
void Update()
{
// if((Network.player == reciever.getOwner()) || (Network.isServer)){
// return;
// }
if(Network.isServer){
clientPing = 0;
}
else{
clientPing = (Network.GetAveragePing(Network.connections[0]) / 100) + pingMargin;
}
float interpolationTime = (float)Network.time - clientPing;
if(serverStateBuffer[0] == null) {
serverStateBuffer[0] = new NetState();
serverStateBuffer[0].setState(0, transform.position, transform.rotation);
}
if(serverStateBuffer[0].timestamp > interpolationTime){
for(int i = 0;i < serverStateBuffer.Length;i++){
if(serverStateBuffer[i] == null){
continue;
}
if(serverStateBuffer[i].timestamp <= interpolationTime || i == serverStateBuffer.Length - 1){
NetState bestTarget = serverStateBuffer[Mathf.Max(i-1, 0)];
NetState bestStart = serverStateBuffer[i];
float timediff = bestTarget.timestamp - bestStart.timestamp;
float lerpTime = 0.0f;
if(timediff > 0.0001){
lerpTime = ((interpolationTime - bestStart.timestamp) / timediff);
}
transform.position = Vector3.Lerp(bestStart.pos,
bestTarget.pos,
lerpTime);
transform.rotation = Quaternion.Slerp(bestStart.rot,
bestTarget.rot,
lerpTime);
return;
}
}
}
else{
NetState latest = serverStateBuffer[0];
transform.position = Vector3.Lerp(transform.position, latest.pos, 0.5f);
transform.rotation = Quaternion.Slerp(transform.rotation, latest.rot, 0.5f);
}
}
示例7: OnResponse
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
if ( m_Stone.Deleted )
return;
string currency = "";
string[] tr = new string[ 1 ];
foreach( TextRelay t in info.TextEntries )
tr[ t.EntryID ] = t.Text;
if ( tr[ 0 ] != null )
currency = tr[ 0 ];
m_Stone.Currency = currency;
if ( info.ButtonID == 0 )
{
from.SendMessage( "Closed." );
}
if ( info.ButtonID == 1 )
{
from.SendGump( new VendorGump( new VSShopper( from, m_Stone ), m_Stone ) );
}
if ( info.ButtonID == 2 )
{
from.SendGump( new TokenVendorStoneAddItemGump( from, m_Stone ) );
}
if ( info.ButtonID == 3 )
{
if ( m_Stone.AccessLevel == AccessLevel.Administrator )
m_Stone.AccessLevel = AccessLevel.Player;
else if ( m_Stone.AccessLevel == AccessLevel.Seer )
m_Stone.AccessLevel = AccessLevel.Administrator;
else if ( m_Stone.AccessLevel == AccessLevel.GameMaster )
m_Stone.AccessLevel = AccessLevel.Seer;
else if ( m_Stone.AccessLevel == AccessLevel.Counselor )
m_Stone.AccessLevel = AccessLevel.GameMaster;
else if ( m_Stone.AccessLevel == AccessLevel.Player )
m_Stone.AccessLevel = AccessLevel.Counselor;
from.SendGump( new StaffVendorGump( from, m_Stone ) );
}
if ( info.ButtonID == 4 )
{
if ( m_Stone.EditMode )
m_Stone.EditMode = false;
else
m_Stone.EditMode = true;
from.SendGump( new StaffVendorGump( from, m_Stone ) );
}
}
示例8: NetState_InitializeNetState
/// <summary>
///
/// </summary>
/// <param name="newNetState"></param>
internal static void NetState_InitializeNetState( NetState newNetState )
{
if ( newNetState != null && newNetState.EncoderSeed == null && newNetState.ExtendData == null )
{
// 初始化客户端加密的数据种子
newNetState.EncoderSeed = m_CryptTableBuffers.AcquireBuffer();
Buffer.BlockCopy( ROSECrypt.Instance().CryptTableBuffer, 0, newNetState.EncoderSeed, 0, ROSECrypt.Instance().CryptTableBuffer.Length );
LoginServerExtendData l_ExtendData = new LoginServerExtendData();
newNetState.ExtendData = l_ExtendData;
}
else
Debug.WriteLine( "ProcessNet.NetState_InitializeNetState(...) - newNetState != null && newNetState.Seed == null && newNetState.ExtendData == null error!" );
}
示例9: OnResponse
public override void OnResponse( NetState sender, RelayInfo info )
{
int button = info.ButtonID;
switch ( button )
{
case 1:
{
if ( temp > m_Post.MinRange )
temp -= 1;
else
sender.Mobile.SendMessage( "You cant lower this value any further." );
m_Post.HomeRange = temp;
sender.Mobile.CloseGump( typeof( HitchGump ) );
sender.Mobile.SendGump( new HitchGump( m_Post ) );
break;
}
case 2:
{
if ( temp < m_Post.MaxRange )
temp += 1;
else
sender.Mobile.SendMessage( "You cant raise this value any further." );
m_Post.HomeRange = temp;
sender.Mobile.CloseGump( typeof( HitchGump ) );
sender.Mobile.SendGump( new HitchGump( m_Post ) );
break;
}
case 3:
{
if ( temp > 5 )
temp = 5;
if ( temp < 0 )
temp = 0;
m_Post.HomeRange = temp;
m_Post.Controlled.RangeHome = m_Post.HomeRange;
sender.Mobile.CloseGump( typeof( HitchGump ) );
break;
}
}
}
示例10: OnResponse
public override void OnResponse( NetState sender, RelayInfo info )
{
switch ( info.ButtonID )
{
case 1: // #1 Site's Url
{
sender.LaunchBrowser( "http://11.freebb.com/?freebb=legends" );
break;
}
case 2: // #2 Site's url
{
sender.LaunchBrowser( "http://www.gamesites200.com/ultimaonline/vote.php?id=4432" );
break;
}
case 3: // #3 Site's url
{
sender.LaunchBrowser( "http://11.freebb.com/viewtopic.php?t=26&freebb=legends" );
break;
}
}
}
示例11: CharServerAction
/// <summary>
///
/// </summary>
/// <param name="netState"></param>
/// <param name="packetReader"></param>
internal static void CharServerAction( NetState netState, PacketReader packetReader )
{
CharServerExtendData l_ExtendData = netState.ExtendData as CharServerExtendData;
if ( l_ExtendData == null )
{
Debug.WriteLine( "CharPacketHandlers.LoginAction(...) - l_ExtendData == null error!" );
return;
}
if ( l_ExtendData.IsLoggedIn == false )
{
Debug.WriteLine( "CharPacketHandlers.LoginAction(...) - l_ExtendData.m_bIsLoggedIn == false error!" );
return;
}
if ( packetReader.Size < 7/*6 + 1 + ?*/ )
{
Debug.WriteLine( "CharPacketHandlers.LoginAction(...) - packetReader.Size < 7 error!" );
return;
}
byte l_Action = packetReader.ReadByte();
switch ( l_Action )
{
case 1: // Disconnect Character
uint l_iAccountGuid = packetReader.ReadUInt32();
CharServer_Action01( netState, l_iAccountGuid );
break;
default:
break;
}
}
示例12: OnCancel
public override void OnCancel(NetState state)
{
base.OnCancel(state);
if (m_From is PlayerMobile)
((PlayerMobile)m_From).HasMenu = false;
}
示例13: OnReadTest2
public void OnReadTest2(NetState netstate, TestPackageReader pakcage)
{
if (pakcage.IsTouchRead)
IsTouchPackageReader = true;
}
示例14: OnResponse
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
switch ( info.ButtonID )
{
case 0: //Case uses the ActionIDs defined above. Case 0 defines the actions for the button with the action id 0
{
//Cancel
from.SendMessage( "Enjoy your new vinyard." );
break;
}
}
}
示例15: OnResponse
public override void OnResponse(NetState state, RelayInfo info)
{
Mobile from = state.Mobile;
BaseCreature creature = null;
TextRelay trMessageText = info.GetTextEntry((int)Buttons.MessageEntry);
if (info.ButtonID == (int)Buttons.Close)
return;
if (info.ButtonID != (int)Buttons.SetCreature && !CheckCreature(from))
{
from.SendMessage("No Mobile Assigned");
from.SendGump(new BCCGump(from, trMessageText.Text));
return;
}
else if (info.ButtonID != (int)Buttons.SetCreature)
creature = BCC.CreatureList[from];
switch (info.ButtonID)
{
default: return;
case (int)Buttons.SendMessage:
if (trMessageText.Text.Length >= 1)
creature.Say(trMessageText.Text);
from.SendGump(new BCCGump(from, ""));
return;
case (int)Buttons.ToggleFrozen:
creature.Frozen = !creature.Frozen;
break;
case (int)Buttons.ToggleHidden:
creature.Hidden = !creature.Hidden;
break;
case (int)Buttons.SetCreature:
from.SendMessage("Click on the BaseCreature to Assign.");
from.Target = new BCC.CMAssignTarget();
return;
case (int)Buttons.Teleport:
creature.PublicOverheadMessage(MessageType.Spell, creature.SpeechHue, true, "Rel Por", false);
from.Target = new BCC.TeleportTarget();
break;
case (int)Buttons.GoTo:
from.MoveToWorld(creature.Location, creature.Map);
break;
}
from.SendGump(new BCCGump(from, trMessageText.Text));
}