Exemple #1
0
    public static void Handle(TopographyResponse tr)
    {
        switch (tr.topographyType)
        {
        case "RING":
            List <Vector3> positions = RingGenerator.Create(tr.orderedActorIds.Count);

            for (int i = 0; i < tr.orderedActorIds.Count; i++)
            {
                //This hack because of some random GetComponentFastPath error
                GameObject         actorConcerned = Actors.allActors[tr.orderedActorIds[i]];
                SendMessageContext context        = new SendMessageContext(actorConcerned, "MoveToAPosition", positions[i], SendMessageOptions.RequireReceiver);
                SendMessageHelper.RegisterSendMessage(context);
            }
            break;

        default:
            Debug.LogError("Unknown Topography type response received. Doing nothing.");
            break;
        }
    }
Exemple #2
0
    public static void HandleResponseReceived(string jsonResponse)
    {
        requestResponseBalance = true; //Just got a response to our request

        Debug.Log("Debugger sent us " + jsonResponse);
        QueryResponse currResponse = (JsonUtility.FromJson <QueryResponse>(jsonResponse));

        switch (currResponse.responseType)
        {
        case "ACTION_RESPONSE":
            //Debug.Log("Received an action response");
            ActionResponse curr = (JsonUtility.FromJson <ActionResponse>(jsonResponse));



            //One ActionResponse includes a list of events for one atomic step
            List <ActorEvent> tempList1 = new List <ActorEvent>();
            foreach (string ev in curr.events)
            {
                tempList1.Add(EventUnwrapper(ev));
            }
            if (tempList1.Count > 0)
            {
                int stepNum = curr.stepNum;

                Trace.visualizationToDispatcherIndexMapper.Add(Trace.allEvents.Count, stepNum);     //stepNum may be -1 for invalid dispatcher steps

                Trace.allEvents.Add(tempList1);
            }
            foreach (State st in curr.states)
            {
                StateUnwrapper(st);
            }

            break;

        case "TOPOGRAPHY_RESPONSE":
            TopographyResponse tr = (JsonUtility.FromJson <TopographyResponse>(jsonResponse));
            //One TopographyResponse includes the type and ordered list of actors, which need to be unwrapped
            TopographyUnwrapper(tr);
            break;

        case "TAG_RESPONSE":
            TagActorResponse tar = (JsonUtility.FromJson <TagActorResponse>(jsonResponse));
            TagResponseUnwrapper(tar);
            break;

        case "TAG_REACHED_RESPONSE":
            TagReachedResponse trr = (JsonUtility.FromJson <TagReachedResponse>(jsonResponse));
            TagReachedResponseUnwrapper(trr);
            break;

        case "EOT_RESPONSE":
            EOTResponseUnwrapper();
            break;

        case "SUPPRESS_ACTOR_RESPONSE":
            SuppressActorResponse sar = JsonUtility.FromJson <SuppressActorResponse>(jsonResponse);
            SuppressResponseUnwrapper(sar);
            break;

        case "STEP_RESPONSE":

            StepResponse sr = (JsonUtility.FromJson <StepResponse>(jsonResponse));

            int id = sr.stepNum;     //Store the StepNum

            Debug.Log("Received response of step " + (id + 1));

            List <ActorEvent> listOfEvents = new List <ActorEvent>();   //This list consists of the net difference we need to do

            //Unwrap specific parts in the same way
            foreach (string ev in sr.events)
            {
                Trace.stepEvents.Add(EventUnwrapper(ev));     //Send these events to a special list
            }
            //State unwrapping is done later as the actors at prior stepNum are not the same as current stepNum
            //StateUnwrapping done in TraceImplement

            //Send message to Reevaluate log- newer logs need to be deleted
            SendMessageContext context = new SendMessageContext(VisualizationHandler.logHead, "ReevaluateList", id + 1, SendMessageOptions.RequireReceiver);
            SendMessageHelper.RegisterSendMessage(context);                                                         //state at n -1 is sent
            break;


        default:
            Debug.LogError("Unable to resolve to a particular class");
            break;
        }
    }
Exemple #3
0
 private static void TopographyUnwrapper(TopographyResponse tr)
 {
     VisualizationHandler.Handle(tr);
 }