本文整理汇总了C#中BaseEvent类的典型用法代码示例。如果您正苦于以下问题:C# BaseEvent类的具体用法?C# BaseEvent怎么用?C# BaseEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BaseEvent类属于命名空间,在下文中一共展示了BaseEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnExtensionResponse
//------------------------------------------------------------------------------------
/**
* Handle responses from server side Extension.
*/
public void OnExtensionResponse(BaseEvent evt)
{
string cmd = (string)evt.Params["cmd"];
SFSObject dataObject = (SFSObject)evt.Params["params"];
switch ( cmd ) {
case "start":
StartGame(dataObject.GetInt("t"),
dataObject.GetInt("p1i"),
dataObject.GetInt("p2i"),
dataObject.GetUtfString("p1n"),
dataObject.GetUtfString("p2n")
);
break;
case "stop":
UserLeft();
break;
case "move":
MoveReceived(dataObject.GetInt("t"), dataObject.GetInt("x"), dataObject.GetInt("y"));
break;
case "win":
ShowWinner(cmd, (int)dataObject.GetInt("w"));
break;
case "tie":
ShowWinner(cmd, -1);
break;
}
}
示例2: OnUserVariableUpdate
// When user variable is updated on any client, then this callback is being received
// This is where most of the magic happens
private void OnUserVariableUpdate(BaseEvent e)
{
SFSUser user = e.Params.GetSFSUser();
if (user == smartfox.MySelf) return;
if (!remotePlayers.ContainsKey(user)) return;
ArrayList changedVars = e.Params.GetChangedVars();
// Check if the remote user changed his position or rotation
if (changedVars.Contains("x") || changedVars.Contains("y") || changedVars.Contains("z") || changedVars.Contains("rot"))
{
// Move the character to a new position...
Vector3 pos = new Vector3((float)user.GetVariable("x").GetDoubleValue(), 1, (float)user.GetVariable("z").GetDoubleValue());
Quaternion quat = Quaternion.Euler(0, (float)user.GetVariable("rot").GetDoubleValue(), 0);
SimpleRemoteInterpolation interp = remotePlayers[user].GetComponent<SimpleRemoteInterpolation>();
interp.SetTransform(pos, quat, true);
}
// Remote client got new name?
if (changedVars.Contains("name"))
{
remotePlayers[user].GetComponentInChildren<TextMesh>().text = user.Name;
}
}
示例3: OnExtensionResponse
private void OnExtensionResponse(BaseEvent evt)
{
try
{
String ResponseType = (string)evt.Params["cmd"];
Debug.Log("Received Response: " + ResponseType);
ISFSObject ObjectIn = (SFSObject)evt.Params["params"];
if(ResponseType == "CharacterList")
{
for(int i = 0; i < ObjectIn.GetUtfStringArray("NameList").Length; i++)
{
float posY = 200 - (50 + (80 * i));
//Debug.Log(posY);
CharacterPanel.Add((GameObject)Instantiate(Resources.Load("UI/CharacterPanel", typeof(GameObject))));
CharacterPanel[i].GetComponent<RectTransform>().parent = this.CharacterListPanel.GetComponent<RectTransform>();
CharacterPanel[i].GetComponent<RectTransform>().localPosition = new Vector3(0, posY, 0);
CharacterPanel[i].GetComponentInChildren<Text>().text = ObjectIn.GetUtfStringArray("NameList")[i];
GameObject aCP = CharacterPanel[i];
CharacterPanel[i].GetComponent<Button>().onClick.AddListener(() => CharacterPanel_Clicked(aCP));
}
}
}
catch(Exception e)
{
Debug.Log("Exception handling response: " + e.Message + " >>> " + e.StackTrace);
}
}
示例4: OnConnection
void OnConnection(BaseEvent evt)
{
bool connectionSuccess = (bool)evt.Params["success"];
Debug.Log("OnConn:" + connectionSuccess);
if (connectionSuccess)
{
SFSObject loginData = new SFSObject();
loginData.PutUtfString("username", usernameField.value);
loginData.PutUtfString("password", passwordField.value);
sfs.Send(new Sfs2X.Requests.LoginRequest("", "", "MainZone", loginData));
connectionWindow.SetActive(false);
loggingWindow.SetActive(true);
}
else
{
sfs = Connection.Instance().Reset();
SetupListeners();
loginWindow.SetActive(true);
connectionWindow.SetActive(false);
}
}
示例5: OnLogin
public void OnLogin(BaseEvent evt)
{
Debug.Log("Logged in successfully");
// We either create the Game Room or join it if it exists already
smartFox.Send(new JoinRoomRequest("The Game"));
}
示例6: OnConnection
void OnConnection(BaseEvent e)
{
if ((bool)e.Params ["success"]) {
Debug.Log ("Successfully Connected!");
UnityEngine.UI.Text connectionMessage = GameObject.Find ("ConnectionMessage").GetComponent<UnityEngine.UI.Text> ();
connectionMessage.text = "Connection Successful! \nSelect a player...";
GameObject tetrisButton = GameObject.Find ("Tetris");
GameObject breakoutButton = GameObject.Find ("Breakout");
GameObject platformButton = GameObject.Find ("Platformer");
GameObject connectionButton = GameObject.Find ("Connect");
GameObject observerButton = GameObject.Find ("Observer");
GameObject textField = GameObject.Find ("ServerIPInputField");
tetrisButton.GetComponent<UnityEngine.UI.Image> ().enabled = true;
breakoutButton.GetComponent<UnityEngine.UI.Image> ().enabled = true;
platformButton.GetComponent<UnityEngine.UI.Image> ().enabled = true;
observerButton.GetComponent<UnityEngine.UI.Image> ().enabled = true;
sfs.Send(new LoginRequest(Username, "", ZoneName));
}
else{
UnityEngine.UI.Text connectionMessage = GameObject.Find ("ConnectionMessage").GetComponent<UnityEngine.UI.Text> ();
connectionMessage.text = "Connection failed.";
Debug.Log ("Connection Failed");
}
}
示例7: OnConnectionLost
public void OnConnectionLost(BaseEvent evt)
{
Debug.LogError ("Lost server connection, reconnecting..");
// Reset all internal states so we kick back to login screen
server.RemoveAllEventListeners ();
Application.LoadLevel ("Connector");
}
示例8: OnUserEnterRoom
private void OnUserEnterRoom(BaseEvent e)
{
User user = e.Params.GetUser();
print("OnUserEnterRoom : " + user.Name);
OnUserEnteredRoom(user);
}
示例9: OnUserVariablesUpdate
private void OnUserVariablesUpdate(BaseEvent evt)
{
ArrayList changedVars = (ArrayList)evt.Params["changedVars"];
SFSUser user = (SFSUser)evt.Params["user"];
Debug.Log(user.Id);
if(!users.ContainsKey(user.Id))
{
Debug.LogWarning("Got variable update for an user that is not in the users list.");
return;
}
if (changedVars.Contains("x") || changedVars.Contains("y") || changedVars.Contains("z"))
{
GameObject playerGo = user.Properties["GameObject"] as GameObject;
Vector3 newPosition = new Vector3();
newPosition.x = (float)user.GetVariable("x").GetDoubleValue();
newPosition.y = (float)user.GetVariable("y").GetDoubleValue();
newPosition.z = (float)user.GetVariable("z").GetDoubleValue();
playerGo.transform.position = newPosition;
}
}
示例10: OnConnectionLost
public void OnConnectionLost(BaseEvent evt)
{
Debug.Log("OnConnectionLost");
isLoggedIn = false;
currentActiveRoom = null;
UnregisterSFSSceneCallbacks();
}
示例11: getActivableEvents
public BaseEvent[] getActivableEvents()
{
int counter=0;
if (associatedPart != null)
{
foreach (PartModule pm in associatedPart.GetComponents<PartModule>())
{
foreach (BaseEvent mEvent in pm.Events)
{
if (mEvent.guiActive & mEvent.active) counter++;
}
}
BaseEvent[] events = new BaseEvent[counter];
counter = 0;
foreach (PartModule pm in associatedPart.GetComponents<PartModule>())
{
foreach (BaseEvent mEvent in pm.Events)
{
if (mEvent.guiActive & mEvent.active)
{
events[counter] = mEvent;
counter++;
}
}
}
return events;
}
else return new BaseEvent[0];
}
示例12: OnUserEnterRoom
void OnUserEnterRoom(BaseEvent e)
{
Debug.Log ("User Enter Room");
SmartfoxUtil.CheckParam (e.Params);
SFSUser user = (SFSUser)e.Params ["user"];
CreateRemotePlayer (user,Vector3.zero);
}
示例13: OnLogout
protected override void OnLogout(BaseEvent e)
{
base.OnLogout(e);
chat.roomList.Clear();
chat.zoneMode = 0;
}
示例14: OnConnectionLost
/// <summary>
/// When connection is lost we load the login scene
/// </summary>
private void OnConnectionLost(BaseEvent evt)
{
UnsubscribeDelegates();
Screen.lockCursor = false;
Screen.showCursor = true;
Application.LoadLevel("Authorization");
}
示例15: GetStreamName
private string GetStreamName(BaseEvent @event)
{
var id = @event.AggregateRootId.ToString();//.Replace('-','_'); // Category name baseras på senaste dashen i streamname, därför kan inte ID:t innehålla en dash.
var aggregateType = @event.AggregateRootType.Name;
return $"{aggregateType}-{id}";
}