Esempio n. 1
0
        public void registerGraphics(
            MyGridWorld.MyGraphicsPrototype empty_g,
            MyGridWorld.MyGraphicsPrototype obstacle_g,
            MyGridWorld.MyGraphicsPrototype agent_g,
            MyGridWorld.MyGraphicsPrototype doorOpened_g,
            MyGridWorld.MyGraphicsPrototype doorClosed_g,
            MyGridWorld.MyGraphicsPrototype doorControl_g,
            MyGridWorld.MyGraphicsPrototype doorControlOff_g,
            MyGridWorld.MyGraphicsPrototype lightsControl_g,
            MyGridWorld.MyGraphicsPrototype lightsControlOff_g,
            MyGridWorld.MyGraphicsPrototype lightsOff_g,
            MyGridWorld.MyGraphicsPrototype lightsOn_g)
        {
            Agent.Graphics = agent_g;

            // register all tales' graphics
            for (int j = 0; j < m_height; j++)
            {
                for (int i = 0; i < m_width; i++)
                {
                    if (Tiles[i, j].IsObstacle)
                    {
                        Tiles[i, j].Graphics = empty_g;
                    }
                    else
                    {
                        Tiles[i, j].Graphics = obstacle_g;
                    }
                }
            }

            // all static objects
            MyStaticObject tmp;

            for (int i = 0; i < StaticObjects.Length; i++)
            {
                tmp = StaticObjects[i];
                if (tmp is DoorControl)
                {
                    //tmp.graphics = doorControl_g;
                    ((AbstractTwoStateObject)tmp).UpdateGraphics(doorControl_g, doorControlOff_g);
                }
                else if (tmp is LightsControl)
                {
                    //tmp.graphics = lightsControl_g;
                    ((AbstractTwoStateObject)tmp).UpdateGraphics(lightsControl_g, lightsControlOff_g);
                }
                else if (tmp is MyDoor)
                {
                    ((AbstractTwoStateObject)tmp).UpdateGraphics(doorOpened_g, doorClosed_g);
                }
                else if (tmp is Lights)
                {
                    ((AbstractTwoStateObject)tmp).UpdateGraphics(lightsOn_g, lightsOff_g);
                }
            }
        }
Esempio n. 2
0
 public void UpdateGraphics(MyGridWorld.MyGraphicsPrototype off_g, MyGridWorld.MyGraphicsPrototype on_g)
 {
     this.OnGraphics  = on_g;
     this.OffGraphics = off_g;
     if (this.IsOn())
     {
         this.Graphics = on_g;
     }
     else
     {
         this.Graphics = off_g;
     }
 }