本文整理汇总了C#中GameServer类的典型用法代码示例。如果您正苦于以下问题:C# GameServer类的具体用法?C# GameServer怎么用?C# GameServer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GameServer类属于命名空间,在下文中一共展示了GameServer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnitBase
public UnitBase(GameServer _server, Player player)
: base(_server, player)
{
EntityType = Entity.EntityType.Unit;
UnitType = UnitTypes.Default;
EntityToAttack = null;
Speed = .01f;
Range = 50;
AttackDelay = 100;
AttackRechargeTime = 1000;
SupplyUsage = 1;
RangedUnit = false;
StandardAttackDamage = 1;
StandardAttackElement = Entity.DamageElement.Normal;
State = UnitState.Agro;
allowMovement = false;
_moveXCompleted = false;
_moveYCompleted = false;
attackTimer = new Stopwatch();
attackTimer.Reset();
attackTimer.Stop();
rechargeTimer = new Stopwatch();
rechargeTimer.Restart();
updatedMovePositionTimer = new Stopwatch();
updatedMovePositionTimer.Start();
}
示例2: Main
public static void Main()
{
server = new GameServer(9958);
server.Ennable();
Console.ReadKey();
}
示例3: Main
static void Main(string[] args)
{
var settings = ReadSettings(Program.Location + "Settings.xml");
Console.WriteLine("Name: " + settings.Name);
Console.WriteLine("Port: " + settings.Port);
Console.WriteLine("Player Limit: " + settings.MaxPlayers);
Console.WriteLine("Starting...");
ServerInstance = new GameServer(settings.Port, settings.Name, settings.Gamemode);
ServerInstance.PasswordProtected = settings.PasswordProtected;
ServerInstance.Password = settings.Password;
ServerInstance.AnnounceSelf = settings.Announce;
ServerInstance.MasterServer = settings.MasterServer;
ServerInstance.MaxPlayers = settings.MaxPlayers;
ServerInstance.AllowDisplayNames = settings.AllowDisplayNames;
ServerInstance.Start(settings.Filterscripts);
Console.WriteLine("Started! Waiting for connections.");
while (true)
{
ServerInstance.Tick();
System.Threading.Thread.Sleep(10); // Reducing CPU Usage (Win7 from average 15 % to 0-1 %, Linux from 100 % to 0-2 %)
}
}
示例4: Main
static void Main(string[] args)
{
var settings = ReadSettings(Program.Location + "Settings.xml");
Console.WriteLine("Name: " + settings.Name);
Console.WriteLine("Port: " + settings.Port);
Console.WriteLine("Player Limit: " + settings.MaxPlayers);
Console.WriteLine("Starting...");
ServerInstance = new GameServer(settings.Port, settings.Name, settings.Gamemode);
ServerInstance.PasswordProtected = settings.PasswordProtected;
ServerInstance.Password = settings.Password;
ServerInstance.AnnounceSelf = settings.Announce;
ServerInstance.MasterServer = settings.MasterServer;
ServerInstance.MaxPlayers = settings.MaxPlayers;
ServerInstance.Start(settings.Filterscripts);
Console.WriteLine("Started! Waiting for connections.");
while (true)
{
ServerInstance.Tick();
}
}
示例5: IsMatch
public bool IsMatch(GameServer server)
{
if (server.IsConnected == _isConnected)
return true;
else
return false;
}
示例6: NetworkMultiplayer
public NetworkMultiplayer(bool createServer = false)
: base(GameModes.Network)
{
if(createServer)
GameServer = new GameServer();
//read network on each update
Game.Instance.OnUpdate += ReadNetwork;
//server config
NetPeerConfiguration config = new NetPeerConfiguration("tank");
config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
//server creation
Client = new NetClient(config);
Client.Start();
if (!createServer)
{
//check whether the user has a known server
ListMenu serverMenu = new ListMenu("Do you want to connect to a given IP (if yes, enter in console)?", "tank.Code.YESORNOCHOOSENOW", ConnectionMethodSelectionCallback);
Scene.Add(serverMenu);
}
else//we know that a local server must exist
Client.DiscoverLocalPeers(14242);
//register handler for receiving data
OnClientData += IncomingHandler;
//are we client, or are we dancer?
if(!createServer)
Console.WriteLine("client");
}
示例7: Initialize
public override void Initialize(GameServer server)
{
base.Initialize(server);
_queryCount = 1;
_queryResultCache = Hashtable.Synchronized(new Hashtable());
_server.MessageReceived += new MessageReceivedEventHandler(this.MessageReceived);
}
示例8: RegisterResult
/// <summary>
/// Sends the result of server register
/// </summary>
/// <param name="server"></param>
/// <param name="result">0 = success; 1 = duplicated index</param>
public void RegisterResult(GameServer server, ushort result)
{
AG.RegisterResult registerResult = new AG.RegisterResult();
registerResult.Result = result;
registerResult.CreateChecksum();
GameManager.Instance.Send(server, PacketManager.ToArray(registerResult));
}
示例9: GameServerMultiplayer
public GameServerMultiplayer(GameServerSettings settings)
{
server = new GameServer<IServerPlayPacket, IClientPlayPacket>(
serverPort, IPAddress.Parse(GameClientMultiplayer.multicastAddress));
server.OnReceiveClientPacket += OnReceiveClientPacket;
this.settings = settings;
connectedPlayers = new Dictionary<int, Player>();
}
示例10: GameManager
public GameManager(RealmCore rCore)
{
RCore = rCore;
Server = new GameServer();
Server.ClientDisconnected += Server_ClientDisconnected;
Server.NewClientConntected += Server_NewClientConntected;
Server.NewDataReceived += Server_NewDataReceived;
Server.NewDataSended += Server_NewDataSended;
Server.Started += Server_Started;
Server.Stoped += Server_Stoped;
}
示例11: Initialize
protected override void Initialize()
{
if (AppSettings.Default.EnableServer)
{
GameServer server = new GameServer(new MapGenerator().Generate(30, 16), AppSettings.Default.ListenPort);
server.Start();
}
ApplyGraphicsSettings();
base.Initialize();
}
示例12: MessageReceived
private void MessageReceived(GameServer server, IProtocol message)
{
if ((ProtocolDef)message.ProtocolId == ProtocolDef.g2e_exesql_def)
{
g2e_exesql protocol = message as g2e_exesql;
bool success = ((FSEyeResult)protocol.nRetCode == FSEyeResult.fseye_success);
bool done = ((FSEyeResult)protocol.nRetCode != FSEyeResult.mydb_more_result);
UpdateQueryResultCache(protocol.nSessionID, protocol.szResult, done, success);
}
}
示例13: LLApiServer
public LLApiServer(GameServer gameServer, int port, ushort maxConnections, ushort maxMessages)
{
GameServer = gameServer;
Port = port;
MaxConnections = maxConnections;
MaxMessages = maxMessages;
isConnected = false;
Config = new ConnectionConfig();
int ReliableChannelId = Config.AddChannel(QosType.Reliable);
int NonReliableChannelId = Config.AddChannel(QosType.Unreliable);
Topology = new HostTopology(Config, MaxConnections);
}
示例14: Query
protected FS2RoleDataInfo Query(GameServer server, int roleId)
{
FS2RoleDataInfo roleInfo = null;
ArrayList paramList = new ArrayList();
paramList.Add(roleId);
string selectedFiled = string.Format("{0},{1},{2},{3},{4}",
FS2TableString.RolesfirstFieldMoney,FS2TableString.RolesfirstFieldMoneyInBox,
FS2TableString.RolesfirstFieldItemList,FS2TableString.RolesfirstFieldRoleName,
FS2TableString.RolesfirstFieldId);
string sqlCmdText = string.Format("SELECT {0} FROM {1} WHERE {2}='?';" ,selectedFiled,
FS2TableString.RolesfirstTableName, FS2TableString.RolesfirstFieldId);
SqlCommand cmd = new SqlCommand(sqlCmdText, paramList.ToArray());
if (!server.IsConnected)
{
LabelOpMsg.Visible = true;
LabelOpMsg.Text = StringDef.NoConnectionAlert;
return null;
}
SqlResult result = WebUtil.QueryGameServerDb(CurrentUser.Id,server,cmd);
if (result != null && result.Success)
{
result.SetFieldType(new SqlDataType[]{
SqlDataType.UInt32,
SqlDataType.UInt32,
SqlDataType.Blob,
SqlDataType.String,
SqlDataType.Int32
});
object[] record;
byte[] itemData;
roleInfo = new FS2RoleDataInfo();
while ((record = result.ReadRecord())!=null)
{
if (record != null)
{
roleInfo.Money = (uint)record[0];
roleInfo.MoneyInBox = (uint)record[1];
itemData = (byte[])record[2];
if (itemData != null)
{
roleInfo.ItemList = FS2ItemDataInfo.Parse(itemData);
//if (info != null) ItemList.Add(info);
}
roleInfo.RoleName = record[3] as string;
roleInfo.RoleId = (int)record[4];
}
}
//RenderView(roleInfo);
}
return roleInfo;
}
示例15: ProjectileBase
public ProjectileBase(GameServer _server, Player player, Vector2f startPosition, EntityBase target, float dmg, Entity.DamageElement element, float speed = 1)
: base(_server, player)
{
EntityType = Entity.EntityType.Projectile;
Start = startPosition;
Target = target;
Position = Start;
BoundsSize = new Vector2f(5, 5);
Damage = dmg;
Element = element;
Speed = speed;
RemoveOnNoHealth = false;
}