本文整理汇总了C#中Message.GetDouble方法的典型用法代码示例。如果您正苦于以下问题:C# Message.GetDouble方法的具体用法?C# Message.GetDouble怎么用?C# Message.GetDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message.GetDouble方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: onUnitCreate
public void onUnitCreate(Player player, Message message) {
int entityID = ++entityIndex;
int ownerID = player.Id;
String type = message.GetString(0);
double x = message.GetDouble(1);
double y = message.GetDouble(2);
Console.WriteLine("[ENGINE] " + player + ": create Unit - id=" + entityID + ", owner=" + ownerID + ", type=" + type + ", pos=" + x + "," + y);
room.Broadcast(MessageTypes.SV_UNIT_CREATE, entityID, ownerID, type, x, y);
}
示例2: onStructureCreate
public void onStructureCreate(Player player, Message message) {
int entityID = ++entityIndex;
int ownerID = player.Id;
String type = message.GetString(0);
double x = message.GetDouble(1);
double y = message.GetDouble(2);
switch(type) {
case "structure_town_center":
// Gives ownership of this town center to the first player without one
foreach(Player p in room.Players) {
if(p.townCenterID == 0) {
Console.WriteLine("[GAMEPLAY] Giving TOWN CENTER eid=" + entityID + " to " + player);
p.townCenterID = entityID;
ownerID = p.Id;
break;
}
}
break;
case "structure_altar":
// Gives ownership of this altar to the first player without one
foreach(Player p in room.Players) {
if(p.altarID == 0) {
Console.WriteLine("[GAMEPLAY] Giving ALTAR eid=" + entityID + " to " + player);
p.altarID = entityID;
ownerID = p.Id;
break;
}
}
break;
}
Console.WriteLine("[ENGINE] " + player + ": create Structure - id=" + entityID + ", owner=" + ownerID + ", type=" + type + ", pos=" + x + "," + y);
room.Broadcast(MessageTypes.SV_STRUCTURE_CREATE, entityID, ownerID, type, x, y);
}
示例3: handleGameMessage
/**
* Handles game-specific messages (messages which are sent only during the game)
*/
public void handleGameMessage(Player player, Message msg)
{
switch (msg.Type)
{
case MessageTypes.TRY_USE:
tryUseSpell(msg.GetInt(0), player);
break;
case MessageTypes.TICK:
player.onTick(msg.GetDouble(0), msg.GetString(1), msg.GetString(2));
//update sever duplication model
break;
default:
handleSpecialGameMessage(msg);
break;
}
}
示例4: MoveReceiveEvent
/// <summary>
/// Initializes a new instance of the <see cref="MoveReceiveEvent" /> class.
/// </summary>
/// <param name="message">The message.</param>
public MoveReceiveEvent(Message message)
: base(message)
{
this.UserId = message.GetInteger(0);
this.UserPosX = message.GetInteger(1);
this.UserPosY = message.GetInteger(2);
this.SpeedX = message.GetDouble(3);
this.SpeedY = message.GetDouble(4);
this.ModifierX = message.GetDouble(5);
this.ModifierY = message.GetDouble(6);
this.Horizontal = message.GetDouble(7);
this.Vertical = message.GetDouble(8);
this.Coins = message.GetInteger(9);
this.SpaceDown = message.GetBoolean(10);
}
示例5: InitReceiveEvent
/// <summary>
/// Initializes a new instance of the <see cref="InitReceiveEvent" /> class.
/// </summary>
/// <param name="message">The EE message.</param>
public InitReceiveEvent(Message message)
: base(message)
{
this.OwnerUsername = message.GetString(0);
this.WorldName = message.GetString(1);
this.Plays = message.GetInteger(2);
this.CurrentWoots = message.GetInteger(3);
this.TotalWoots = message.GetInteger(4);
this.Encryption = message.GetString(5);
this.UserId = message.GetInteger(6);
this.Face = (Smiley)message.GetInteger(7);
// Aura
this.SpawnX = message.GetInteger(9);
this.SpawnY = message.GetInteger(10);
this.ChatColor = message.GetUInt(11);
this.Username = message.GetString(12);
this.CanEdit = message.GetBoolean(13);
this.IsOwner = message.GetBoolean(14);
this.RoomWidth = message.GetInteger(15);
this.RoomHeight = message.GetInteger(16);
this.IsTutorialRoom = message.GetBoolean(17);
this.Gravity = message.GetDouble(18);
}
示例6: OnInit
/// <summary>
/// Called when [initialize].
/// </summary>
/// <param name="m">
/// The m.
/// </param>
private void OnInit(Message m)
{
// Extract data
string owner = m.GetString(0),
name = m.GetString(1),
worldKey = Tools.Derot(m.GetString(5)),
botName = m.GetString(9);
int plays = m.GetInteger(2),
woots = m.GetInteger(3),
totalWoots = m.GetInteger(4),
botId = m.GetInteger(6),
width = m.GetInteger(12),
height = m.GetInteger(13);
double botX = m.GetDouble(7), botY = m.GetDouble(8), gravityMultiplier = m.GetDouble(15);
bool isTutorialRoom = m.GetBoolean(14),
potions = m.GetBoolean(16),
hasAccess = m.GetBoolean(10),
isOwner = m.GetBoolean(11);
// Update relevant objects
this._initMessage = m;
this.Bot.Name = botName;
this.Bot.Id = botId;
this.Bot.X = botX;
this.Bot.Y = botY;
this.Bot.HasAccess = hasAccess;
// Bot.IsOwner = isOwner;
this.Bot.PlayingIn = this.Source;
this.Source.OnlineBots.Add(this.Bot);
if (this.Source.IsInitialized)
{
// You don't need to get the room data multiple times. Save time by returning.
return;
}
// Update the room data.
this.Source.Name = name;
this.Source.Owner = Tools.GetPlayer(owner, this.Source);
this.Source.Plays = plays;
this.Source.Woots = woots;
this.Source.TotalWoots = totalWoots;
this.Source.RoomKey = worldKey;
this.Source.Height = height;
this.Source.Width = width;
RoomAccessor.Width = width;
RoomAccessor.Height = height;
this.Source.PotionsAllowed = potions;
this.Source.IsTutorialRoom = isTutorialRoom;
this.Source.GravityMultiplier = gravityMultiplier;
this.Source.IsInitialized = true;
// Execute the messages that came prematurely.
foreach (Message msg in this._prematureMessages)
{
this.OnMessage(this, msg);
}
this._prematureMessages.Clear();
// Begin loading blocks.
this.LoadBlocks();
this.Source.BlocksLoaded = true;
// Begin updating physics.
this._playerPhysicsThread = new Thread(this.UpdatePhysics);
this._playerPhysicsThread.Start();
// Fire the event.
var e = new RoomEventArgs(this.Source, m);
this.Source.Pull.InitEvent(e);
}
示例7: Move
public void Move(Message m)
{
if (this.C != null)
{
this.C.Send(
"m",
m.GetDouble(1),
m.GetDouble(2),
m.GetDouble(3),
m.GetDouble(4),
m.GetDouble(5),
m.GetDouble(6),
m.GetDouble(7),
m.GetDouble(8),
m.GetInt(9),
m.GetBoolean(10),
m.GetBoolean(11));
}
}
示例8: conn_OnMessage
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void conn_OnMessage(object sender, Message e)
{
if (!ListenForPackets) return;
if (OnPacket != null)
{
Packet packet = new Packet(e.Type);
for (uint n = 0; n < e.Count; n++)
{
packet.Add(e[n]);
}
OnPacket(this, packet);
}
switch (e.Type)
{
case "init":
WorldKey = Rot13(e.GetString(5));
if (OnWorldKey != null) OnWorldKey(this, WorldKey);
MapData = Init2Array(e);
if (OnInit != null)
{
User bot = new User(e.GetString(9), e.GetInt(6));
bot.Move.Position.X = (double)e.GetInt(7);
bot.Move.Position.Y = (double)e.GetInt(8);
Dictionary<int, int> potData = Init2Pot(e);
OnInit(this,
e.GetString(0),
e.GetString(1),
e.GetString(2),
e.GetInt(3),
e.GetInt(4),
WorldKey,
bot,
e.GetBoolean(10),
e.GetBoolean(11),
e.GetInt(12),
e.GetInt(13),
e.GetBoolean(14),
e.GetDouble(15),
e.GetBoolean(16),
MapData,
potData);
}
break;
case "info":
if (OnInfo != null) OnInfo(this, e.GetString(0), e.GetString(1));
break;
case "p":
if (OnPotion != null) OnPotion(this, e.GetInt(0), e.GetInt(1), e.GetBoolean(2));
break;
case "write":
if (OnWrite != null) OnWrite(this, e.GetString(0), e.GetString(1));
break;
case "upgrade":
if (OnUpgrade != null) OnUpgrade(this);
break;
case "m":
if (OnMove != null)
{
User.Motion motion = new User.Motion();
motion.Position.X = e.GetDouble(1);
motion.Position.Y = e.GetDouble(2);
motion.Velocity.X = e.GetDouble(3);
motion.Velocity.Y = e.GetDouble(4);
motion.Acceleration.X = e.GetDouble(5);
motion.Acceleration.Y = e.GetDouble(6);
motion.KeyDown.X = e.GetDouble(7);
motion.KeyDown.Y = e.GetDouble(8);
OnMove(this, e.GetInt(0), motion, e.GetInt(9), e.GetBoolean(10), e.GetBoolean(11));
}
break;
case "add":
if (OnAdd != null || ListUsers)
{
User u = new User(e.GetString(1), e.GetInt(0));
u.SmileyID = e.GetInt(2);
u.Move.Position.X = e.GetDouble(3);
u.Move.Position.Y = e.GetDouble(4);
u.isGod = e.GetBoolean(5);
u.isMod = e.GetBoolean(6);
u.isChat = e.GetBoolean(7);
u.Coins = e.GetInt(8);
u.isFriend = e.GetBoolean(9);
u.isPurple = e.GetBoolean(10);
u.Level = e.GetInt(11);
u.isClubMember = e.GetBoolean(12);
if (OnAdd != null) OnAdd(this, u);
if (ListUsers) Manager.UserJoined(u);
}
break;
case "c":
if (OnCoin != null) OnCoin(this, e.GetInt(0), e.GetInt(1));
break;
case "k":
if (OnCrown != null) OnCrown(this, e.GetInt(0));
break;
//.........这里部分代码省略.........