コード例 #1
0
    public void OnGetElevatorStatusUpdateResponse(UpdateElevatorStatusResponse response)
    {
        if (response.resultCode == ResultCode.Succeeded)
        {
            elevatorData.status = response.curStatus;

            if (response.curStatus == ElevatorStatus.Opened)
            {
                // Assume that every passenger goes out in instant, now we need to close it.
                SendUpdateElevatorStatusRequest(ElevatorStatus.Closing);
            }
            UpdateUI();
        }
    }
コード例 #2
0
    void HandleGetElevatorStatusUpdateRequest(UpdateElevatorStatusRequest request)
    {
        if (elevatorData.status == ElevatorStatus.Arrived && request.newStatus == ElevatorStatus.Opening)
        {
            elevatorData.status = ElevatorStatus.Opening;
            // Send both update status and update response to GUI
            UpdateElevatorStatusResponse updateStatusRepsonse = new UpdateElevatorStatusResponse(ResultCode.Succeeded, elevatorData.status);
            SendUpdateElevatorStatusResponse(updateStatusRepsonse);

            UpdateElevatorResponse updateElevatorResponse = new UpdateElevatorResponse(elevatorData, 0);
            SendUpdateElevatorResponse(updateElevatorResponse);
        }

        if (elevatorData.status == ElevatorStatus.Opening && request.newStatus == ElevatorStatus.Opened)
        {
            elevatorData.status = ElevatorStatus.Opened;
            UpdateElevatorStatusResponse response = new UpdateElevatorStatusResponse(ResultCode.Succeeded, elevatorData.status);
            SendUpdateElevatorStatusResponse(response);
        }

        if (elevatorData.status == ElevatorStatus.Opened && request.newStatus == ElevatorStatus.Closing)
        {
            elevatorData.status = ElevatorStatus.Closing;
            UpdateElevatorStatusResponse updateStatusResponse = new UpdateElevatorStatusResponse(ResultCode.Succeeded, elevatorData.status);
            SendUpdateElevatorStatusResponse(updateStatusResponse);

            UpdateElevatorResponse updateElevatorResponse = new UpdateElevatorResponse(elevatorData, 0);
            SendUpdateElevatorResponse(updateElevatorResponse);
        }

        if (elevatorData.status == ElevatorStatus.Closing && request.newStatus == ElevatorStatus.Closed)
        {
            elevatorData.status = ElevatorStatus.Closed;
            UpdateElevatorStatusResponse updateStatusResponse = new UpdateElevatorStatusResponse(ResultCode.Succeeded, elevatorData.status);
            SendUpdateElevatorStatusResponse(updateStatusResponse);

            UpdateElevator();
        }
    }
コード例 #3
0
 void SendUpdateElevatorStatusResponse(UpdateElevatorStatusResponse response)
 {
     elevatorController?.OnGetElevatorStatusUpdateResponse(response);
     Logger.Log(logTagRes, "SendElevatorStatusUpdateResponse " + JsonUtility.ToJson(response));
 }