Esempio n. 1
0
        public void go(Queue <SimEvent> queue)
        {
            queue.Enqueue(new SimEvent(EventType.Initialize, time, EventTarg.Elevator, "INIT", SimObject.floor.first));
            ElevatorCar ec = new ElevatorCar(SimConsts.points[(int)SimConsts.point.E1f], null, queue);

            queue.Enqueue(new SimEvent(EventType.Spawn, time, EventTarg.Elevator, ec.Name, SimObject.floor.first));
            while (time < 50 || Person.Count > 0)
            {
                Person p = Person.Create(null, time);
                if (p != null)
                {
                    queue.Enqueue(new SimEvent(EventType.Spawn, time, EventTarg.Person, p.Name, p.Fl));
                    if (p.Fl == SimObject.floor.first)
                    {
                        fl1.AddLast(p);
                    }
                    else
                    {
                        fl2.AddLast(p);
                    }
                }
                foreach (Person pe in fl1)
                {
                    pe.SimThink(this);
                    if (pe.needRemoval)
                    {
                        pe.needRemoval = false;
                        remove.AddLast(pe);
                    }
                }

                foreach (Person pe in remove)
                {
                    fl1.Remove(pe);
                }
                remove.Clear();

                foreach (Person pe in fl2)
                {
                    pe.SimThink(this);
                    if (pe.needRemoval)
                    {
                        pe.needRemoval = false;
                        remove.AddLast(pe);
                    }
                }

                foreach (Person pe in remove)
                {
                    fl2.Remove(pe);
                }
                remove.Clear();

                ec.SimThink(this);
                ++time;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //person = new Person("Bob", Vector2.Zero, Content.Load<Texture2D>("Person"));
            personTexture   = Content.Load <Texture2D>("Person");
            elevatorTexture = Content.Load <Texture2D>("ColorBox");
            bg      = new Background(Content.Load <Texture2D>("Background"));
            elevate = new ElevatorCar(SimConsts.points[(int)SimConsts.point.E1f], elevatorTexture, simOut);
            Console.WriteLine("Height: {0}", GraphicsDevice.Viewport.Height);
            Console.WriteLine("Width: {0}", GraphicsDevice.Viewport.Width);
            // TODO: use this.Content to load your game content here
        }
Esempio n. 3
0
        private void process(SimEvent se)
        {
            switch (se.eType)
            {
            case EventType.Initialize:
                updates = 0;
                break;

            case EventType.Spawn:
                if (se.eTarg == EventTarg.Person)
                {
                    if (se.flr == SimObject.floor.first)
                    {
                        Person p = new Person(SimConsts.points[(int)SimConsts.point.PS1], personTexture, se.flr);
                        p.Name   = se.targName;
                        p.Target = SimConsts.points[(int)SimConsts.point.PQ1];
                        SimThings.AddLast(p);
                    }
                    else
                    {
                        Person p = new Person(SimConsts.points[(int)SimConsts.point.PS2], personTexture, se.flr);
                        p.Name   = se.targName;
                        p.Target = SimConsts.points[(int)SimConsts.point.PQ2];
                        SimThings.AddLast(p);
                    }
                }
                else
                {
                    elevate      = new ElevatorCar(SimConsts.points[(int)SimConsts.point.E1f], elevatorTexture, simOut);
                    elevate.Name = se.targName;
                    SimThings.AddLast(elevate);
                }
                break;

            case EventType.Seek:
                foreach (SimObject so in SimThings)
                {
                    if (so.Name == se.targName)
                    {
                        so.Fl = se.flr;
                        so.ChangeMode(SimObject.AIMode.Seek);
                    }
                }
                break;

            case EventType.Load:
                foreach (SimObject so in SimThings)
                {
                    if (so.Name == se.targName)
                    {
                        so.Fl = se.flr;
                        so.ChangeMode(SimObject.AIMode.Load);
                    }
                }
                break;

            case EventType.Unload:
                foreach (SimObject so in SimThings)
                {
                    if (so.Name == se.targName)
                    {
                        so.Fl = se.flr;
                        so.ChangeMode(SimObject.AIMode.Unload);
                    }
                }
                break;

            case EventType.Terminate:
                if (se.eTarg == EventTarg.Elevator)
                {
                    //MessageBox.Show("End of simulation", "End of simulation", new string[] { "OK" });
                    this.Exit();
                }
                SimObject kill = null;
                foreach (SimObject so in SimThings)
                {
                    if (so.Name == se.targName)
                    {
                        kill = so;
                    }
                }

                SimThings.Remove(kill);
                kill = null;

                break;

            default:
                break;
            }
        }