Example #1
0
        private bool IsVisible(int apx, int apy, MyStaticObject so)
        {
            int dx = Math.Abs(so.GetPosition().x - apx);
            int dy = Math.Abs(so.GetPosition().y - apy);

            return(dx <= pars.ViewLimit && dy <= pars.ViewLimit);
        }
        private bool IsVisible(int apx, int apy, MyStaticObject so)
        {
            int dx = Math.Abs(so.GetPosition().x - apx);
            int dy = Math.Abs(so.GetPosition().y - apy);

            return dx <= pars.ViewLimit && dy <= pars.ViewLimit;
        }
Example #3
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();
                }
            }