public void ClearZoneTarget(GameObject zone) { if (ZoneObject == zone) { CameraState = CameraStateEnum.Follow; ZoneObject = null; } }
public void ShowMainMenu() { uiController.EnableMainMenuUI(true, null); uiController.DisableGameUI(); cameraState = CameraStateEnum.MenuLocation; playerCamera.mode = CameraModeEnum.MoveBehindPanTo; playerCamera.targetObject = mainMenuTransform; playerCamera.moveBehindPanToCallback = () => playerCamera.mode = CameraModeEnum.Locked; }
private void GetCameraState() { if (Input.GetAxis("Target") > 0.01f) { mCameraState = CameraStateEnum.Target; } else { mCameraState = CameraStateEnum.Behind; } }
/// <summary> /// The thread loop used to actually communicate with the camera. It will attempt to /// continually reconnect with the camera if the connection fails. /// </summary> void HikEventClient() { // Data buffer for incoming data. const int bufferSizeMax = 2048; byte[] byteBuffer = new byte[bufferSizeMax]; // Connect to a remote device. try { // set the status to unknown until connected SetDeviceStatus(CameraStatus.Unknown); // Establish the remote endpoint for the socket. IPAddress ipAddress = IPAddress.Parse(ipAddressStr); IPEndPoint remoteEP = new IPEndPoint(ipAddress, port); string authenticationStr = Base64Encode(username + ":" + password); while (!hikClientShutdown) { try { switch (cameraState) { case CameraStateEnum.Start: { // Create a TCP/IP socket. buffer = ""; sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); // Begin the connection. This will end either with an exception or a callback. sock.BeginConnect(remoteEP, new AsyncCallback(ConnectCallback), this); cameraState = CameraStateEnum.Connect; break; } case CameraStateEnum.Connect: { // Wait for connection Thread.Sleep(100); break; } case CameraStateEnum.Send: { LogMessage("Connected to camera"); // Encode the data string into a byte array. string header = "GET /ISAPI/Event/notification/alertStream HTTP/1.1\r\n" + "Authorization: Basic " + authenticationStr + "\r\n" + "Connection: keep-alive\r\n" + "\r\n"; // Send the data to start the alert stream int bytesSent = sock.Send(Encoding.ASCII.GetBytes(header)); cameraState = CameraStateEnum.Receive; lastAlertMsg = DateTime.Now; break; } case CameraStateEnum.Receive: { // Wait on the socket for data ArrayList readList = new ArrayList(); readList.Add(sock); Socket.Select(readList, null, null, 5000); if (sock.Available > 0) { // add new data to the buffer int length = sock.Receive(byteBuffer); buffer += System.Text.Encoding.UTF8.GetString(byteBuffer, 0, length); ProcessBuffer(); } // Check if too long between messages TimeSpan span = DateTime.Now - lastAlertMsg; if (span.TotalMilliseconds > 20000) { // Attempt to reconnect LogMessage(span.TotalMilliseconds.ToString() + " ms since last message. Attempt to reconnect."); sock.Shutdown(SocketShutdown.Both); sock.Close(); cameraState = CameraStateEnum.Wait; // status is unknown SetDeviceStatus(CameraStatus.Unknown); } break; } case CameraStateEnum.Wait: { Thread.Sleep(100); cameraState = CameraStateEnum.Start; break; } } } catch (SocketException se) { LogMessage("Socket exception: " + se.ToString()); if (sock.Connected) { sock.Shutdown(SocketShutdown.Both); sock.Close(); } cameraState = CameraStateEnum.Start; Thread.Sleep(100); } } // Release the socket. sock.Shutdown(SocketShutdown.Both); sock.Close(); } catch (Exception e) { LogMessage("Unexpected Exception : " + e.ToString()); } // reset the status to unknown when exiting SetDeviceStatus(CameraStatus.Unknown); }
public void SetZoneTarget(GameObject zone) { ZoneObject = zone; CameraState = CameraStateEnum.Zone; }
public CameraStateAttribute(CameraStateEnum state) { _state = state; }