예제 #1
0
            public override void Execute()
            {
                // shares kernels with GridWorld, so the parameter taleObstacle is not needed
                MyGraphicsPrototype taleEmpty    = Owner.m_tale_empty;
                MyGraphicsPrototype taleObstacle = Owner.m_tale_o;

                m_drawTalesKernel.SetupExecution(Owner.VISIBLE_WIDTH * Owner.VISIBLE_HEIGHT);
                m_drawTalesKernel.Run(Owner.Visual, Owner.VISIBLE_WIDTH, Owner.VISIBLE_HEIGHT,
                                      Owner.MapTales, Owner.SX, Owner.SY,
                                      taleEmpty.Bitmap, taleObstacle.Bitmap, taleEmpty.PixelSize);

                MyGraphicsPrototype toDraw;
                int2 pos;

                for (int i = 0; i < Owner.m_currentState.Length; i++)
                {
                    pos    = ToPixelCoords(i);
                    toDraw = Owner.m_allGraphicsPrototypes[Owner.m_currentState[i]];

                    m_drawFreeObjKernel.SetupExecution(toDraw.PixelSize.x * toDraw.PixelSize.y);
                    m_drawFreeObjKernel.Run(Owner.Visual, Owner.VISIBLE_WIDTH, Owner.VISIBLE_HEIGHT, toDraw.Bitmap,
                                            pos, toDraw.PixelSize);
                }
            }
예제 #2
0
            public override void Execute()
            {
                // draw the visible area of the map (empty and obstacle tales)
                MyGraphicsPrototype taleEmpty    = Owner.m_tale_empty_g;
                MyGraphicsPrototype taleObstacle = Owner.m_tale_obstacle_g;

                m_drawTalesKernel.SetupExecution(Owner.VISIBLE_WIDTH * Owner.VISIBLE_HEIGHT);
                m_drawTalesKernel.Run(Owner.Visual, Owner.VISIBLE_WIDTH, Owner.VISIBLE_HEIGHT,
                                      Owner.MapTales, Owner.World.GetWidth(), Owner.World.GetHeight(),
                                      taleEmpty.Bitmap, taleObstacle.Bitmap, taleEmpty.PixelSize);

                // draw static objects
                MyStaticObject[] objects = Owner.World.GetStaticObjects();
                for (int i = 0; i < objects.Length; i++)
                {
                    MyStaticObject o = objects[i];

                    m_drawObjKernel.SetupExecution(o.Graphics.PixelSize.x * o.Graphics.PixelSize.y);

                    m_drawObjKernel.Run(Owner.Visual, Owner.RES,
                                        Owner.VISIBLE_WIDTH, Owner.VISIBLE_HEIGHT,
                                        o.Graphics.Bitmap, o.GetPosition(), o.Graphics.PixelSize);
                }

                // draw the agent
                MyMovingObject      agent   = Owner.World.GetAgent();
                MyGraphicsPrototype agent_g = agent.Graphics;

                m_agentPosition.x = agent.GetPosition().x *Owner.RES;
                m_agentPosition.y = (agent.GetPosition().y + 1) * Owner.RES - 1;

                if (!Owner.ShowInEgocentricView)
                {
                    this.DrawEgocentric();
                }

                if (Owner.UpdateTask.ContinuousMovement && Owner.m_performingMovement)
                {
                    switch (Owner.LastAction)
                    {
                    case AGENT_ACTIONS.LEFT:
                    {
                        m_agentPosition.x += Owner.m_movementCooldown;
                        break;
                    }

                    case AGENT_ACTIONS.RIGHT:
                    {
                        m_agentPosition.x -= Owner.m_movementCooldown;
                        break;
                    }

                    case AGENT_ACTIONS.UP:
                    {
                        m_agentPosition.y -= Owner.m_movementCooldown;
                        break;
                    }

                    case AGENT_ACTIONS.DOWN:
                    {
                        m_agentPosition.y += Owner.m_movementCooldown;
                        break;
                    }
                    }

                    m_drawFreeObjKernel.SetupExecution(agent_g.PixelSize.x * agent_g.PixelSize.y);
                    m_drawFreeObjKernel.Run(Owner.Visual, Owner.VISIBLE_WIDTH, Owner.VISIBLE_HEIGHT, agent_g.Bitmap,
                                            m_agentPosition, agent_g.PixelSize);
                }
                else
                {
                    m_drawObjKernel.SetupExecution(agent_g.PixelSize.x * agent_g.PixelSize.y);
                    m_drawObjKernel.Run(Owner.Visual, Owner.RES,
                                        Owner.VISIBLE_WIDTH, Owner.VISIBLE_HEIGHT,
                                        agent_g.Bitmap, agent.GetPosition(), agent_g.PixelSize);
                }

                if (Owner.ShowInEgocentricView)
                {
                    this.DrawEgocentric();
                }
            }
예제 #3
0
            public override void Execute()
            {
                // load bitmaps and pas them to the game objects
                int offset = 0;
                CudaDeviceVariable <float> devBitmaps = Owner.Bitmaps.GetDevice(Owner);

                Bitmap bitmap = Owner.m_bitmapTable[Owner.TEXTURE_SET + "taleObstacle.png"];

                Owner.m_tale_obstacle_g = new MyGraphicsPrototype()
                {
                    PixelSize = new int2(bitmap.Width, bitmap.Height),
                    Bitmap    = devBitmaps.DevicePointer + devBitmaps.TypeSize * offset,
                };
                offset += FillWithChannelFromBitmap(bitmap, 0, Owner.Bitmaps.Host, offset);

                bitmap = Owner.m_bitmapTable[Owner.TEXTURE_SET + "taleEmpty.png"];
                Owner.m_tale_empty_g = new MyGraphicsPrototype()
                {
                    PixelSize = new int2(bitmap.Width, bitmap.Height),
                    Bitmap    = devBitmaps.DevicePointer + devBitmaps.TypeSize * offset,
                };
                offset += FillWithChannelFromBitmap(bitmap, 0, Owner.Bitmaps.Host, offset);

                bitmap          = Owner.m_bitmapTable[Owner.TEXTURE_SET + "agent.png"];
                Owner.m_agent_g = new MyGraphicsPrototype()
                {
                    PixelSize = new int2(bitmap.Width, bitmap.Height),
                    Bitmap    = devBitmaps.DevicePointer + devBitmaps.TypeSize * offset,
                };
                offset += FillWithChannelFromBitmap(bitmap, 0, Owner.Bitmaps.Host, offset);

                bitmap = Owner.m_bitmapTable[Owner.TEXTURE_SET + "doorOpened.png"];
                MyGraphicsPrototype doorOpened_g = new MyGraphicsPrototype()
                {
                    PixelSize = new int2(bitmap.Width, bitmap.Height),
                    Bitmap    = devBitmaps.DevicePointer + devBitmaps.TypeSize * offset,
                };

                offset += FillWithChannelFromBitmap(bitmap, 0, Owner.Bitmaps.Host, offset);

                bitmap = Owner.m_bitmapTable[Owner.TEXTURE_SET + "doorClosed.png"];
                MyGraphicsPrototype doorClosed_g = new MyGraphicsPrototype()
                {
                    PixelSize = new int2(bitmap.Width, bitmap.Height),
                    Bitmap    = devBitmaps.DevicePointer + devBitmaps.TypeSize * offset,
                };

                offset += FillWithChannelFromBitmap(bitmap, 0, Owner.Bitmaps.Host, offset);

                bitmap = Owner.m_bitmapTable[Owner.TEXTURE_SET + "doorControl.png"];
                MyGraphicsPrototype doorControl_g = new MyGraphicsPrototype()
                {
                    PixelSize = new int2(bitmap.Width, bitmap.Height),
                    Bitmap    = devBitmaps.DevicePointer + devBitmaps.TypeSize * offset,
                };

                offset += FillWithChannelFromBitmap(bitmap, 0, Owner.Bitmaps.Host, offset);

                bitmap = Owner.m_bitmapTable[Owner.TEXTURE_SET + "doorControlOff.png"];
                MyGraphicsPrototype doorControlOff_g = new MyGraphicsPrototype()
                {
                    PixelSize = new int2(bitmap.Width, bitmap.Height),
                    Bitmap    = devBitmaps.DevicePointer + devBitmaps.TypeSize * offset,
                };

                offset += FillWithChannelFromBitmap(bitmap, 0, Owner.Bitmaps.Host, offset);

                bitmap = Owner.m_bitmapTable[Owner.TEXTURE_SET + "lightsControl.png"];
                MyGraphicsPrototype lightsControl_g = new MyGraphicsPrototype()
                {
                    PixelSize = new int2(bitmap.Width, bitmap.Height),
                    Bitmap    = devBitmaps.DevicePointer + devBitmaps.TypeSize * offset,
                };

                offset += FillWithChannelFromBitmap(bitmap, 0, Owner.Bitmaps.Host, offset);

                bitmap = Owner.m_bitmapTable[Owner.TEXTURE_SET + "lightsControlOff.png"];
                MyGraphicsPrototype lightsControlOff_g = new MyGraphicsPrototype()
                {
                    PixelSize = new int2(bitmap.Width, bitmap.Height),
                    Bitmap    = devBitmaps.DevicePointer + devBitmaps.TypeSize * offset,
                };

                offset += FillWithChannelFromBitmap(bitmap, 0, Owner.Bitmaps.Host, offset);


                bitmap = Owner.m_bitmapTable[Owner.TEXTURE_SET + "lightsOn.png"];
                MyGraphicsPrototype lightsOn_g = new MyGraphicsPrototype()
                {
                    PixelSize = new int2(bitmap.Width, bitmap.Height),
                    Bitmap    = devBitmaps.DevicePointer + devBitmaps.TypeSize * offset,
                };

                offset += FillWithChannelFromBitmap(bitmap, 0, Owner.Bitmaps.Host, offset);

                bitmap = Owner.m_bitmapTable[Owner.TEXTURE_SET + "lightsOff.png"];
                MyGraphicsPrototype lightsOff_g = new MyGraphicsPrototype()
                {
                    PixelSize = new int2(bitmap.Width, bitmap.Height),
                    Bitmap    = devBitmaps.DevicePointer + devBitmaps.TypeSize * offset,
                };

                offset += FillWithChannelFromBitmap(bitmap, 0, Owner.Bitmaps.Host, offset);

                // parse the map and instantiate all parts of the world
                Owner.World.registerGraphics(
                    Owner.m_tale_empty_g, Owner.m_tale_obstacle_g, Owner.m_agent_g,
                    doorOpened_g, doorClosed_g, doorControl_g, doorControlOff_g,
                    lightsControl_g, lightsControlOff_g, lightsOff_g, lightsOn_g);

                Owner.AgentPosX.Host[0] = Owner.World.GetAgent().GetPosition().x;
                Owner.AgentPosY.Host[0] = Owner.World.GetAgent().GetPosition().y;

                Owner.AgentPosX.SafeCopyToDevice();
                Owner.AgentPosY.SafeCopyToDevice();
                Owner.Bitmaps.SafeCopyToDevice();
                Array.Copy(Owner.World.GetArray(), Owner.MapTales.Host, Owner.MapTales.Count);
                Owner.MapTales.SafeCopyToDevice();

                Owner.PublishWorldSize();
            }