本文整理汇总了C#中SFSObject.Put方法的典型用法代码示例。如果您正苦于以下问题:C# SFSObject.Put方法的具体用法?C# SFSObject.Put怎么用?C# SFSObject.Put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFSObject
的用法示例。
在下文中一共展示了SFSObject.Put方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendAnimationMessage
void SendAnimationMessage(string message)
{
SmartFoxClient client = NetworkController.GetClient();
SFSObject data = new SFSObject();
data.Put("_cmd", "a"); //We put _cmd = "a" here to know that this object contains animation message
data.Put("mes", message);
client.SendObject(data);
}
示例2: SendDamage
void SendDamage(int damage)
{
SmartFoxClient client = NetworkController.GetClient();
SFSObject data = new SFSObject();
data.Put("_cmd", "d"); //We put _cmd = "d" to identify the message as a damage message
data.Put("amount", damage); //how much damage was dealt
client.SendObject(data);
}
示例3: ForceRemotePlayerToSendTransform
void ForceRemotePlayerToSendTransform(User user)
{
SmartFoxClient client = NetworkController.GetClient();
SFSObject data = new SFSObject();
data.Put("_cmd", "f"); //We put _cmd = "f" here to know that this object contains "force send transform" demand
data.Put("to_uid", user.GetId()); // Who this message is for
client.SendObject(data);
}
示例4: DoSend
// Send transform to all other users
public void DoSend()
{
SmartFoxClient client = NetworkController.GetClient();
SFSObject data = new SFSObject();
data.Put("_cmd", "t"); //We put _cmd = "t" here to know that this object contains transform sync data.
data.Put("x", this.position.x);
data.Put("y", this.position.y);
data.Put("z", this.position.z);
data.Put("rx", this.rotation.x);
data.Put("ry", this.rotation.y);
data.Put("rz", this.rotation.z);
data.Put("w", this.rotation.w);
// We send data using SendObject method here. To optimize this you can use SendXtMessage method with custum formatted method
// Also an extension on the server side could decide which users really need to receive the transform
client.SendObject(data);
}
示例5: OnDamage
public void OnDamage(int damage)
{
//Only hurt the player if the damage dealt is greater than their defense
if(damage > mDefense) {
mHealth = mHealth - (damage-mDefense);
}
healthLabel = "HEALTH: " + mHealth;
//If the player is dead then destroy the object and notify other players
if(mHealth <= 0) {
SmartFoxClient client = NetworkController.GetClient();
SFSObject data = new SFSObject();
data.Put("_cmd", "k"); //We put _cmd = "k" for a killed message
client.SendObject(data);
Destroy(this.gameObject);
}
}
示例6: test
private void test()
{
//test
SFSObject monparam = new SFSObject();
monparam.Put("n", "monparam");
monparam.Put("t", "b");
monparam.PutBool("v", false);
SFSObject monparam2 = new SFSObject();
monparam2.Put("n", "monparam2");
monparam2.Put("t", "b");
monparam2.PutBool("v", true);
SFSObject monparam3 = new SFSObject();
monparam3.Put("n", "monparam3");
monparam3.Put("t", "mi");
monparam3.Put("v", "5");
monparam3.PutNumber("m", 1);
SFSObject monaction = new SFSObject();
monaction.Put("n", "monaction");
monaction.Put("0", monparam);
monaction.Put("1", monparam2);
monaction.Put("2", monparam3);
SFSObject monparam4 = new SFSObject();
monparam4.Put("n", "monparam4");
monparam4.Put("t", "b");
monparam4.PutBool("v", false);
SFSObject monparam5 = new SFSObject();
monparam5.Put("n", "monparam5");
monparam5.Put("t", "mi");
monparam5.Put("v", "16");
monparam5.PutNumber("m", -6);
SFSObject monaction2 = new SFSObject();
monaction2.Put("n", "monaction2");
monaction2.Put("0", monparam4);
monaction2.Put("1", monparam5);
SFSObject monparam6 = new SFSObject();
monparam6.Put("n", "monparam6");
monparam6.Put("t", "b");
monparam6.PutBool("v", true);
SFSObject monparam7 = new SFSObject();
monparam7.Put("n", "monparam7");
monparam7.Put("t", "mi");
monparam7.Put("v", "55");
monparam7.PutNumber("m", -7);
SFSObject monparam8 = new SFSObject();
monparam8.Put("n", "monparam8");
monparam8.Put("t", "b");
monparam8.PutBool("v", false);
SFSObject monparam9 = new SFSObject();
monparam9.Put("n", "monparam9");
monparam9.Put("t", "mi");
monparam9.Put("v", "300");
monparam9.PutNumber("m", 0);
SFSObject monaction3 = new SFSObject();
monaction3.Put("n", "monaction3");
monaction3.Put("0", monparam6);
monaction3.Put("1", monparam7);
monaction3.Put("2", monparam8);
monaction3.Put("3", monparam9);
SFSObject monactionhierarchy = new SFSObject();
monactionhierarchy.Put("0", monaction);
monactionhierarchy.Put("2", monaction2);
monactionhierarchy.Put("1", monaction3);
SFSObject monactionlibrary = new SFSObject();
SFSObject maliste = new SFSObject();
maliste.Put("h", monactionhierarchy);
maliste.Put("l", monactionlibrary);
ReceiveActionList(maliste);
}