本文整理汇总了C#中NetState类的典型用法代码示例。如果您正苦于以下问题:C# NetState类的具体用法?C# NetState怎么用?C# NetState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetState类属于命名空间,在下文中一共展示了NetState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:30,代码来源:WorldPacketHandlers.cs
示例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);
}
}
开发者ID:chrisscherer,项目名称:ISGame,代码行数:25,代码来源:Predictor.cs
示例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 );
}
}
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:39,代码来源:LoginPacketHandlers.cs
示例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);
}
}
开发者ID:rdemaeye,项目名称:mergePractice,代码行数:31,代码来源:Predictor.cs
示例5: OnResponse
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
switch ( info.ButtonID )
{
case 0:{ break; }
}
}
开发者ID:greeduomacro,项目名称:DimensionsNewAge,代码行数:8,代码来源:QuestGiver.cs
示例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);
}
}
开发者ID:chrisscherer,项目名称:ISGame,代码行数:55,代码来源:Predictor.cs
示例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 ) );
}
}
开发者ID:Ziden,项目名称:ServUO-EC-Test-Fork,代码行数:52,代码来源:Token+Vendor+Stone.cs
示例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!" );
}
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:18,代码来源:ProcessNet.cs
示例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;
}
}
}
开发者ID:justdanofficial,项目名称:khaeros,代码行数:42,代码来源:StablePost.cs
示例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;
}
}
}
开发者ID:cynricthehun,项目名称:UOLegends,代码行数:21,代码来源:Webstone.cs
示例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;
}
}
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:42,代码来源:WorldPacketHandlers.cs
示例12: OnCancel
public override void OnCancel(NetState state)
{
base.OnCancel(state);
if (m_From is PlayerMobile)
((PlayerMobile)m_From).HasMenu = false;
}
开发者ID:Godkong,项目名称:Origins,代码行数:7,代码来源:Moongate.cs
示例13: OnReadTest2
public void OnReadTest2(NetState netstate, TestPackageReader pakcage)
{
if (pakcage.IsTouchRead)
IsTouchPackageReader = true;
}
开发者ID:RainsSoft,项目名称:DogSE,代码行数:5,代码来源:CraetePacketReaderTest.cs
示例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;
}
}
}
开发者ID:justdanofficial,项目名称:khaeros,代码行数:15,代码来源:VinyardGroundAddonDeed.cs
示例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));
}
开发者ID:kamronbatman,项目名称:Defiance-AOS-Pre-2012,代码行数:47,代码来源:BCC.cs
示例16: OnResponse
public override void OnResponse( NetState state, RelayInfo info )
{
if ( info.ButtonID == 1 )
m_Gate.EndConfirmation( m_From );
}
开发者ID:Godkong,项目名称:Origins,代码行数:5,代码来源:Moongate.cs
示例17: OnResponse
public override void OnResponse( NetState state, RelayInfo info )
{
base.OnResponse( state, info );
if( info.ButtonID >= 1 && info.ButtonID <= 8 )
state.Mobile.SendGump( new WeaponStoneGump(state.Mobile, m_Stone, info.ButtonID ) );
else if( info.ButtonID != 0 )
{
if( m_Stone.UseLimit )
{
bool foundName = false;
foreach( WeaponStone.WeaponStoneEntry nameEntry in m_Stone.m_alNameList )
{
if( nameEntry.m_sName == state.Mobile.Account.ToString() )
{
foundName = true;
if( nameEntry.m_iCount < m_iAmountToGive )
nameEntry.m_iCount++;
else
{
state.Mobile.SendMessage( "You may not take anymore items from this stone." );
return;
}
}
}
if( !foundName )
m_Stone.m_alNameList.Add( new WeaponStone.WeaponStoneEntry( state.Mobile.Account.ToString(), 1 ) );
}
ItemEntry entry = (ItemEntry)m_MainTable[info.ButtonID-999];
Item item = (Item) Activator.CreateInstance( entry.m_Type );
if( item.Stackable )
item.Amount = m_iStackableAmount;
state.Mobile.AddToBackpack( item );
state.Mobile.SendMessage( "The {0} has been placed into your packpack.", entry.m_sName );
state.Mobile.SendGump( new WeaponStoneGump(state.Mobile, m_Stone, m_iPos ) );
}
}
开发者ID:kamronbatman,项目名称:Defiance-AOS-Pre-2012,代码行数:42,代码来源:WeaponStone.cs
示例18: RunTaskNetStateDisconnect
private void RunTaskNetStateDisconnect(NetState netState)
{
m_netStateManager.InternalRemoveNetState(netState.Serial);
// 通知业务逻辑有客户端连接上来可以做一些初始化
// 或者判断是否允许本次连接
var tempEV = NetStateDisconnect;
if (tempEV != null)
{
var arg = new NetStateDisconnectEventArgs
{
NetState = netState,
};
tempEV(this, arg);
}
netState.ExitWorld();
netState.Dispose();
}
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:19,代码来源:WorldBase.cs
示例19: OnSocketConnect
/// <summary>
/// 触发Socket的连接事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnSocketConnect(object sender, SocketConnectEventArgs<NetState> e)
{
if (WhiteList.IsEnable)
{
var ip = e.Session.RemoteOnlyIP;
if (!WhiteList.Contains(ip))
{
e.AllowConnection = false;
return;
}
}
var netState = new NetState(e.Session, this);
e.Session.Data = netState;
// 网络连接会涉及到一些业务逻辑操作,因此需要把它加到任务队列里进行处理
// 如果不考虑业务逻辑的处理,则可以不放到任务队列,节约一下处理时间
mainTask.AppentdTask(RunTaskNetStateConnect, netState);
}
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:23,代码来源:WorldBase.cs
示例20: OnReadTest
public void OnReadTest(NetState netstate, PacketReader reader)
{
IsTouchOnReadTest = true;
}
开发者ID:RainsSoft,项目名称:DogSE,代码行数:4,代码来源:CraetePacketReaderTest.cs
注:本文中的NetState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论