Exemplo n.º 1
0
 public AddContainerMessage(Guid senderId, Enums.ContainerType containerType, int id, double area, double dencity) : base(senderId, MessageType.AddContainer)
 {
     this.containerId   = id;
     this.containerType = containerType;
     this.area          = area;
     this.dencity       = dencity;
 }
Exemplo n.º 2
0
        //private void infectOtherAgent(int sourceAgentId)
        //{
        //    if (this.agents.Count < 2)
        //    {
        //        Trace.TraceInformation("Warning: too litle agents");
        //        return;
        //    }
        //    // Random:
        //    // int idx = random.Next(0, this.agents.Count - 1);

        //    ContainersCore currentContainer = this.agentLocations[sourceAgentId];
        //    if (currentContainer == null)
        //    {
        //        Trace.TraceInformation("Warning: no current container for {0}", sourceAgentId);
        //        return;
        //    }

        //    if (currentContainer is Home)
        //    {
        //        // Trace.TraceInformation("Current container for {0} is Home", sourceAgentId);
        //        return;
        //    }

        //    if (currentContainer.AgentCount < 2)
        //    {
        //        Trace.TraceInformation("Warning: noone in container for {0}", sourceAgentId);
        //        return;
        //    }

        //    int destAgentId = sourceAgentId;
        //    while (destAgentId == sourceAgentId)
        //    {
        //        destAgentId = currentContainer.GetRandomAgent();
        //    }

        //    Guid clientId = this.agents[destAgentId];
        //    var msg0 = new Message(MessageTransportSystem.Instance.Id, MessageType.Infect);
        //    msg0.data = destAgentId.ToString();
        //    //Trace.TraceInformation("Infecting: {0} -> {1}", sourceAgentId, destAgentId);
        //    MessageTransportSystem.Instance.SendMessage(msg0, clientId);
        //}

        private void gotoContainer(AddAgentMessage amsg, Enums.ContainerType containerType)
        {
            //if (agentId == 2)
            //    Trace.TraceInformation("Go: {0} to {1} ; Time: {2}", agentId, containerId, GlobalTime.realTime);

            List <ContainersCore> containersWithType = Containers.Instance.Values.Where((c) => c.ContainerType == containerType).ToList();

            if (containersWithType.Count == 0)
            {
                Trace.TraceWarning("Warning: Container with type {0} not found", containerType);
                return;
            }

            int            idx          = GlobalAgentDescriptorTable.random.Next(0, containersWithType.Count - 1);
            ContainersCore container    = containersWithType[idx];
            ContainersCore oldContainer = this.agentLocations[amsg.agentId];

            amsg.containerId = container.Id;

            Guid workerId = this.containers2workers[container.Id];

            // MessageTransportSystem.Instance.SendMessage(amsg, workerId);
            this.addAgentMessages[workerId].Add(amsg);

            agentLocations[amsg.agentId] = container;
        }
Exemplo n.º 3
0
 //заполнение параметров контейнера
 protected ContainersCore(Enums.ContainerType containerType, int id, double area, double dencity)
 {
     this.containerType = containerType;
     this.area          = area;
     this.dencity       = dencity;
     this.id            = id;
 }
Exemplo n.º 4
0
 //заполнение параметров контейнера
 protected ContainersCore(Enums.ContainerType containerType, int id, double area, double dencity)
 {
     this.containerType = containerType;
     this.area = area;
     this.dencity = dencity;
     this.id = id;
 }
Exemplo n.º 5
0
 public void AddToGoto(AbstractPerson agent, Enums.ContainerType containerType)
 {
     lock (gotoAgents)
     {
         gotoAgents.Add(agent);
         gotoContainers.Add(containerType);
     }
 }
Exemplo n.º 6
0
 public SectionConfig(string name, Enums.ContainerType containerType)
     : base()
 {
     this.ContainerType    = containerType;
     base.Name             = name;
     this.IsFixed          = false;
     this.IsFullScreen     = false;
     this.CreateBackButton = false;
     this.BackButtonText   = null;
 }
Exemplo n.º 7
0
        public override void Move()
        {
            if (this.healthState == Enums.HealthState.Dead)
            {
                return;
            }

            Enums.ContainerType resOfContainerToGo = containerToGo();
            if (this.currentContainerType != resOfContainerToGo)
            {
                // Trace.TraceInformation("Moved to {0}", resOfContainerToGo);
                MessageTransfer.Instance.AddToGoto(this, resOfContainerToGo);
                currentContainerType = resOfContainerToGo;
            }
        }