示例#1
0
    public static void Handle(ActorCreated currEvent)
    {
        GameObject go;

        if (currEvent.resourceId == "" || currEvent.resourceId == null)
        {
            go = Instantiate(modelDictionary["Cube"]); //If type is not set, we want a cube
        }
        else
        {
            go = Instantiate(modelDictionary[currEvent.resourceId]);
        }

        go.transform.name = currEvent.actorId;

        go.transform.parent = TraceImplement.rootOfActors.transform;//Add it to the root G.O.

        //Add this to the dictionary
        Actors.allActors.Add(currEvent.actorId, go);
        if (sysActorNames.Any(go.transform.name.Contains))
        {
            go.transform.position = new Vector3(Random.Range(3.5f, 4.5f), 1f, Random.Range(-2.5f, -3.5f)); //A separate area->Marked in the inspector
        }
        else
        {
            go.transform.position = new Vector3(Random.Range(0f, 3.5f), Random.Range(1.25f, 1.9f), Random.Range(-1.5f, 1.5f));
            if (logCreateForEvent)
            {
                //Create a Log of it
                Log newLog = new Log(0, "Actor created : " + currEvent.actorId);
                Handle(newLog);
            }
        }
        Actors.allActors[currEvent.actorId].GetComponent <ActorFunctionality>().MomentaryOutline(Color.magenta, outlineTime / 2);
    }
示例#2
0
文件: Init.cs 项目: ZyFlux/Projects
    // Use this for initialization
    void Start()
    {
        if (isActive)
        {
            ActorCreated      deadLetters = new ActorCreated("deadLetters", "Postkasten"); //Initiallization of initial actor
            List <ActorEvent> tempList    = new List <ActorEvent>();                       //Make a temporary list to hold this
            tempList.Add(deadLetters);
            Trace.allEvents.Add(tempList);

            Debug.Log("About to start the Network Interface..");
            AsynchronousClient.StartClient();
        }
    }
示例#3
0
    private static ActorEvent EventUnwrapper(string line)
    {
        ActorEvent ev = (JsonUtility.FromJson <ActorEvent>(line)); //Read into the event parent class

        //Now assign a specific class
        switch (ev.eventType) //Go through all possible event types
        {
        case "ACTOR_CREATED":
            ActorCreated specificActorCreatedEvent = (JsonUtility.FromJson <ActorCreated>(line));
            ev = specificActorCreatedEvent;
            break;

        case "MESSAGE_SENT":
            MessageSent specificMessageSentEvent = (JsonUtility.FromJson <MessageSent>(line));
            ev = specificMessageSentEvent;
            break;

        case "MESSAGE_RECEIVED":
            MessageReceived specificMessageReceivedEvent = (JsonUtility.FromJson <MessageReceived>(line));
            ev = specificMessageReceivedEvent;
            break;

        case "ACTOR_DESTROYED":
            ActorDestroyed specificActorDestroyedEvent = (JsonUtility.FromJson <ActorDestroyed>(line));
            ev = specificActorDestroyedEvent;
            break;

        case "LOG":
            Debug.Log("Log received");
            Log newLog = (JsonUtility.FromJson <Log>(line));
            ev = newLog;
            break;

        case "MESSAGE_DROPPED":
            MessageDropped specificMessageDroppedEvent = (JsonUtility.FromJson <MessageDropped>(line));
            ev = specificMessageDroppedEvent;
            break;

        default:
            //We don't know what this event is
            Debug.LogError("Unknown event encountered in JSON");
            break;
        }
        return(ev);
    }
示例#4
0
    public static void Handle(ActorCreated currEvent)
    {
        GameObject go;

        if (currEvent.resourceId == "" || currEvent.resourceId == null)
        {
            go = Instantiate(VisualizationHandler.modelDictionary["Cube"]); //If type is not set, we want a cube
        }
        else
        {
            go = Instantiate(VisualizationHandler.modelDictionary[currEvent.resourceId]);
        }

        go.transform.name = currEvent.actorId;

        go.transform.parent = TraceImplement.rootOfActors.transform;//Add it to the root G.O.

        //Add this to the dictionary
        Actors.allActors.Add(currEvent.actorId, go);
        if (VisualizationHandler.sysActorNames.Any(go.transform.name.Contains))                            //System actors are different
        {
            go.transform.position = new Vector3(Random.Range(3.5f, 4.5f), 1f, Random.Range(-2.5f, -3.5f)); //A separate area->Marked in the inspector
        }
        else
        {
            go.transform.position = new Vector3(Random.Range(0f, 3.5f), Random.Range(1.25f, 1.9f), Random.Range(-1.5f, 1.5f));
            if (logCreateForEvent)
            {
                //Create a Log of it
                Log newLog = new Log(0, "Actor created : " + currEvent.actorId);
                VisualizationHandler.Handle(newLog);
            }
        }
        SuppressActorResponse sar     = new SuppressActorResponse(go.transform.name, true);
        SendMessageContext    context = new SendMessageContext(go, "SuppressOnOff", sar, SendMessageOptions.RequireReceiver);

        SendMessageHelper.RegisterSendMessage(context);
    }
示例#5
0
        /// <summary>
        /// Event invoker for the <see cref="ActorCreated"/> event.
        /// </summary>
        /// <param name="actor">Actor.</param>
        protected virtual void OnActorCreated(IActor actor)
        {
            var args = new ActorEventArgs(actor);

            ActorCreated?.Invoke(this, args);
        }
示例#6
0
 //-------------------Outlining functions
 public static void Outline(ActorCreated currEvent)
 {
     //Currently called from the Handler function
 }