Exemplo n.º 1
0
    private static void TagResponseUnwrapper(TagActorResponse tar)
    {
        GameObject actorConcerned = Actors.allActors[tar.actorId];
        //Make the send message threadsafe
        SendMessageContext context = new SendMessageContext(actorConcerned, "TagUntag", tar, SendMessageOptions.RequireReceiver);

        SendMessageHelper.RegisterSendMessage(context);
    }
Exemplo n.º 2
0
    public void TagUntag(TagActorResponse tar)
    {
        if (tar.toTag)
        {
            visualRepresentation = Instantiate(visualRepresentationPrefab);

            visualRepresentation.transform.position = transform.position + Offset; //With a offset so that it is directly above

            visualRepresentation.transform.parent = transform;                     //Who's the daddy?

            numTagged++;                                                           //Increment number of actors tagged
        }

        else
        {
            numTagged--;                   //Decrement number of actors tagged
            Destroy(visualRepresentation); //Destroy the representation
        }
    }
Exemplo n.º 3
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;
        }
    }