コード例 #1
0
ファイル: WorkerRole.cs プロジェクト: KseniiaKen/MAS
        private void onAddContainerMessage(Message message)
        {
            AddContainerMessage acm = (AddContainerMessage)message;

            Trace.TraceInformation("Added containter. Type: {0}; Id: {1}.", acm.containerType, acm.containerId);

            ContainersCore container = null;
            switch(acm.containerType)
            {
                case Enums.ContainerType.Home:
                    container = new Home(acm.containerId, acm.area, acm.dencity);
                    break;
                case Enums.ContainerType.Hospital:
                    container = new Hospital(acm.containerId, acm.area, acm.dencity);
                    break;
                case Enums.ContainerType.Mall:
                    container = new Mall(acm.containerId, acm.area, acm.dencity);
                    break;
                case Enums.ContainerType.Nursery:
                    container = new Nursery(acm.containerId, acm.area, acm.dencity);
                    break;
                case Enums.ContainerType.Office:
                    container = new Office(acm.containerId, acm.area, acm.dencity);
                    break;
                case Enums.ContainerType.School:
                    container = new School(acm.containerId, acm.area, acm.dencity);
                    break;
                case Enums.ContainerType.University:
                    container = new University(acm.containerId, acm.area, acm.dencity);
                    break;
            }

            if (container != null)
            {
                if (!Containers.Instance.ContainsKey(container.Id))
                {
                    Containers.Instance.Add(container.Id, container);
                }

                foreach (AddAgentMessage aam in acm.agentData)
                {
                    this.onAddAgentMessage(aam, container);
                }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: KseniiaKen/MAS
        private static void fillContainers() 
        {
            Home home = new Home(0, 50, 12);
            Containers.Instance.Add(0, home); //Containers.Instance — глобальная коллекция, содержащая контейнеры.

            Hospital hospital = new Hospital(1, 237, 19);
            Containers.Instance.Add(1, hospital);

            Mall mall = new Mall(2, 578, 90);
            Containers.Instance.Add(2, mall);

            Office office = new Office(3, 236, 20);
            Containers.Instance.Add(3, office);

            University university = new University(4, 300, 25);
            Containers.Instance.Add(4, university);

            School school = new School(5, 250, 30);
            Containers.Instance.Add(5, school);

            Nursery nursery = new Nursery(6, 60, 23);
            Containers.Instance.Add(6, nursery);

        }