Пример #1
0
 public override void Added(Entity e)
 {
     if (e.Tag == "mainTilemap") {
         mainTilemap = m_tilemapMapper.Get(e);
         canvasTransform = e.GetComponent<Transform>();
         mainValidate = e.GetComponent<TilemapValidate>();
     }
     else if (e.Tag == "singlesTilemap")
     {
         singlesTilemap = m_tilemapMapper.Get(e);
     }
     else if (e.Tag == "roadTilemap") {
         roadTilemap = m_tilemapMapper.Get(e);
     }
     else if (e.Tag == "wallTilemap") {
         wallTilemap = m_tilemapMapper.Get(e);
     }
 }
Пример #2
0
 private void limitCameraPosition(Transform p_camTransform)
 {
     Entity mainTilemap = World.TagManager.GetEntity("mainTilemap");
     if (mainTilemap != null)
     {
         Tilemap tilemap = mainTilemap.GetComponent<Tilemap>();
         if (tilemap != null)
         {
             float camX = -p_camTransform.position.X / p_camTransform.scale;
             float camY = -p_camTransform.position.Y / p_camTransform.scale;
             float maxWidth = (float)tilemap.getColumns() * 32;
             float maxHeight = (float)tilemap.getRows() * 32;
             float canvasWidth = (float)m_canvasWindow.Width / p_camTransform.scale;
             float canvasHeight = (float)m_canvasWindow.Height / p_camTransform.scale;
             float camCenterX = camX + canvasWidth / 2.0f;
             float camCenterY = camY + canvasHeight / 2.0f;
             if (camCenterX > maxWidth)
             {
                 p_camTransform.position.X = -(maxWidth - canvasWidth / 2.0f) * p_camTransform.scale;
             }
             else if (camCenterX < 0)
             {
                 p_camTransform.position.X = (canvasWidth / 2.0f) * p_camTransform.scale;
             }
             if (camCenterY > maxHeight)
             {
                 p_camTransform.position.Y = -(maxHeight - canvasHeight / 2.0f) * p_camTransform.scale;
             }
             else if (camCenterY < 0)
             {
                 p_camTransform.position.Y = (canvasHeight / 2.0f) * p_camTransform.scale;
             }
         }
     }
 }
Пример #3
0
        protected override void Begin()
        {
            m_graphicsDevice.SetRenderTarget(m_canvasRender);
            m_graphicsDevice.Clear(Color.LightGray);

            Matrix cameraMatrix = Matrix.Identity;
            Entity camera = world.TagManager.GetEntity("mainCamera");
            if (camera != null)
            {
                m_camTransform = camera.GetComponent<Transform>();
                if (m_camTransform != null)
                {
                    cameraMatrix = m_camTransform.getMatrix();
                }
            }

            m_spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend,
                SamplerState.PointClamp, null, null, null, cameraMatrix);
        }