private void Start() { Connect(); hubConnection.On <string>("OutsideLog", (msg) => Debug.Log($"Outside Log: {msg}")); hubConnection.On <int, float>("SetDirection", (id, direction) => { platforms[id].SetDirection(direction); onUserActions.Invoke(); }); hubConnection.On("StopGame", () => onGameStop.Invoke()); hubConnection.On("PauseGame", () => onGamePaused.Invoke()); hubConnection.On("StartGame", () => onGameStart.Invoke()); hubConnection.On <string>("SetID", id => onConnection.Invoke($"{settings.phoneURL}#{id}")); hubConnection.On("PlayerJoin", () => onPlayerJoin.Invoke()); hubConnection.On("PlayerLeft", () => { Debug.Log("Player left"); ++needPlayers; if (needPlayers == 2) { onGameStop.Invoke(); } else { onGamePaused.Invoke(); } }); hubConnection.SendAsync("ConnectTV"); }
void _myHubClient_ConnectionEvent(bool obj) { if (ConnectionEvent != null) { ConnectionEvent.Invoke(obj); } }
public void OnReceivePairConfirm(TCPConnection connection, string pairedId, string lockedId) { ConnectionsDisplayer.DisplayedConnectionHandle handle = null; if (ConnectionsDisplayer.Instance) { handle = ConnectionsDisplayer.Instance.GetConnectionHandle(connection); } bool paired = pairedId != "0"; //string "0" means the device is unpaired now if (pairedId == SystemInfo.deviceUniqueIdentifier) { Haze.Logger.Log("Paired to " + connection); connection.paired = true; if (handle != null) { handle.display.Available = true; } //Give an update to the VideosDisplayer if (VideosDisplayer.Instance) { VideosDisplayer.Instance.OnPairConnection(connection); } if (VideosDisplayer0ld.Instance) { VideosDisplayer0ld.Instance.OnPairConnection(connection); } } else { if (connection.paired) { connection.paired = false; Haze.Logger.Log("Unpaired from " + connection); } Haze.Logger.LogWarning("Setting available to " + !paired + " for connection " + connection); if (handle != null) { handle.display.Available = !paired; } } connection.lockedId = lockedId; //Update all device displays if (ConnectionsDisplayer.Instance) { foreach (ConnectionsDisplayer.DisplayedConnectionHandle h in ConnectionsDisplayer.Instance.Handles) { h.display.UpdateDisplay(); } } lastConnectedDevice = connection; onConnected.Invoke(connection); }
public void OnNewConnection(TCPConnection connection) { Haze.Logger.Log(connection + " has been added as an option"); if (ConnectionsDisplayer.Instance) { ConnectionsDisplayer.Instance.AddConnection(connection); if (ConnectionsDisplayer.Instance.Handles.Count == 1) { onFirstConnection.Invoke(); } } onConnectionFound.Invoke(connection); }
/// <summary> /// Stops the connection from sending and receing data. /// </summary> public virtual void StopConnection() { if (IsActive) { connectionStopped.Invoke(this); gameObject.name = "Connection(Stopped)"; CancelInvoke("CheckForData"); client.Close(); client = null; if (usePDUBundles) { CancelInvoke("SendBundle"); } } }
void _hubConnection_StateChanged(StateChange obj) { if (this.State == ConnectionState.Connected) { if (ConnectionEvent != null) { ConnectionEvent.Invoke(true); } } else { if (ConnectionEvent != null) { ConnectionEvent.Invoke(false); } } HubClientEvents.Log.ClientEvents("_hubConnection_StateChanged New State:" + _hubConnection.State + " " + _hubConnection.ConnectionId); }
/// <summary> /// Start the socket sending and receiving on the DIS network /// </summary> public virtual void StartConnection() { connectionStarted.Invoke(this); gameObject.name = "Connection(Started)"; CreateSocket(); if (pduFactory == null) { Debug.LogWarning("No DecoderFactory assigned, I can not decode DIS data without one. I will create a default factory."); pduFactory = gameObject.AddComponent <DecodeFactory>(); } InvokeRepeating("CheckForData", 0, receivePollFrequency); // Start sending bundles? if (usePDUBundles) { InvokeRepeating("SendBundle", bundleSendFrequency, bundleSendFrequency); } }
public ConnectionEvent OnConnMatch;// = new ConnectionEvent(); public void OnConnection(GameObject otherProtein) { collidingProtein = otherProtein; //Disable the fuducial object DisableFuducialObject(); //Spawn proteins on the tabletop SpawnProteins(); PlayAnimation(); //object.OnConnMatch += handler; public void handler(GameObject protein1, GameObject protein2){} Debug.Log("invoking callback"); OnConnMatch.Invoke(this.gameObject, otherProtein); //Spawn connection line if (otherProtein.GetComponent <FuducialObjects>() != null && gameObject.name != "protein_9_I(Clone)") { SpawnConnectionLine(otherProtein.GetComponent <FuducialObjects>().matchTargetPosition); } else if (gameObject.name != "protein_9_I(Clone)") { SpawnConnectionLine(otherProtein.transform.position); //If it is a root protein } //Spawn the second root protein after P3 has connected if (otherProtein.name == "protein_3_I(Clone)") { GameObject.FindGameObjectWithTag("Root").transform.position = new Vector3(4.83f, 0f, -23.16f); } //Protein 9 special if (gameObject.name == "protein_9_I(Clone)") { foreach (var marker in markers) { marker.SetActive(false); } SpawnConnectionLine(new Vector3(5, 0, -15)); SpawnConnectionLine(new Vector3(-3, 0, -7)); SpawnConnectionLine(new Vector3(13, 0, -7)); StartCoroutine(PlayBacteriaBurst()); } foreach (var marker in markers) { if (marker.GetComponent <Markers>().shownOnConnection) { marker.SetActive(true); } } //Do stuff when protien 7 & 8 have connected if (Markers.p7Connected && Markers.p8Connected) { //Play punching animation GameObject protein6 = GameObject.Find("protein_6_V"); protein6.GetComponent <Animator>().SetTrigger("playPunch"); GameObject membrane = GameObject.Find("Membrane"); membrane.GetComponent <Animator>().SetTrigger("playDestruction"); proteinToSpawn = proteinToSpawn3; SpawnProteins(); } if (Markers.p9Connected) { GameObject membrane = GameObject.Find("Membrane"); membrane.GetComponent <Animator>().SetTrigger("playDestructionSecond"); } }
public void OnClientDisconnect(NetworkConnection conn) { onClientDisconnect.Invoke(conn); }
private void OnConnection() { ConnectionEvent?.Invoke(this, new EventArgs()); }