コード例 #1
0
        public void LoadContent()
        {
            // position the regions such that the camera is below and right of the center of regions[0]
            Vector3 offset = sim.UI.Camera.Position - new Vector3(drawDist * 1.5f);

            cameraRightOfCenter = true;
            cameraBelowCenter   = true;

            // build the weather region areas
            for (int z = 0; z < 2; z++)
            {
                for (int x = 0; x < 2; x++)
                {
                    regions[z * 2 + x] = new WeatherRegion(new Rectangle((int)offset.X + x * drawDist * 2, (int)offset.Z + z * drawDist * 2, drawDist * 2, 2 * drawDist));
                }
            }

            // connect the weather regions to each other
            regions[0].AdjacentH = regions[1];
            regions[0].AdjacentV = regions[2];
            regions[1].AdjacentH = regions[0];
            regions[1].AdjacentV = regions[3];
            regions[2].AdjacentH = regions[3];
            regions[2].AdjacentV = regions[0];
            regions[3].AdjacentH = regions[2];
            regions[3].AdjacentV = regions[1];

            currentRegion = regions[0];
        }
コード例 #2
0
        private void CheckRegionChange()
        {
            if (camera.Position.X > currentRegion.Base.Right)
            {
                // the camera crossed the current region's right edge, so it is now left of the
                // horizontally adjacent region's center
                cameraRightOfCenter = false;
                currentRegion       = currentRegion.AdjacentH;
            }
            else if (camera.Position.X < currentRegion.Base.X)
            {
                // the camera crossed the current region's left edge, so it is now right of the
                // horizontally adjacent region's center
                cameraRightOfCenter = true;
                currentRegion       = currentRegion.AdjacentH;
            }

            if (camera.Position.Z > currentRegion.Base.Bottom)
            {
                // the camera crossed the current region's bottom edge, so it is now above the
                // vertically adjacent region's center
                cameraBelowCenter = false;
                currentRegion     = currentRegion.AdjacentV;
            }
            else if (camera.Position.Z < currentRegion.Base.Y)
            {
                // the camera crossed the current region's top edge, so it is now below the
                // vertically adjacent region's center
                cameraBelowCenter = true;
                currentRegion     = currentRegion.AdjacentV;
            }
        }
コード例 #3
0
        public void LoadContent()
        {
            // position the regions such that the camera is below and right of the center of regions[0]
            Vector3 offset = sim.UI.Camera.Position - new Vector3(drawDist * 1.5f);
            cameraRightOfCenter = true;
            cameraBelowCenter = true;

            // build the weather region areas
            for (int z = 0; z < 2; z++)
                for (int x = 0; x < 2; x++)
                    regions[z * 2 + x] = new WeatherRegion(new Rectangle((int)offset.X + x * drawDist * 2, (int)offset.Z + z * drawDist * 2, drawDist * 2, 2 * drawDist));

            // connect the weather regions to each other
            regions[0].AdjacentH = regions[1];
            regions[0].AdjacentV = regions[2];
            regions[1].AdjacentH = regions[0];
            regions[1].AdjacentV = regions[3];
            regions[2].AdjacentH = regions[3];
            regions[2].AdjacentV = regions[0];
            regions[3].AdjacentH = regions[2];
            regions[3].AdjacentV = regions[1];

            currentRegion = regions[0];
        }
コード例 #4
0
        private void CheckRegionChange()
        {
            if (camera.Position.X > currentRegion.Base.Right)
            {
                // the camera crossed the current region's right edge, so it is now left of the
                // horizontally adjacent region's center
                cameraRightOfCenter = false;
                currentRegion = currentRegion.AdjacentH;
            }
            else if (camera.Position.X < currentRegion.Base.X)
            {
                // the camera crossed the current region's left edge, so it is now right of the
                // horizontally adjacent region's center
                cameraRightOfCenter = true;
                currentRegion = currentRegion.AdjacentH;
            }

            if (camera.Position.Z > currentRegion.Base.Bottom)
            {
                // the camera crossed the current region's bottom edge, so it is now above the
                // vertically adjacent region's center
                cameraBelowCenter = false;
                currentRegion = currentRegion.AdjacentV;
            }
            else if (camera.Position.Z < currentRegion.Base.Y)
            {
                // the camera crossed the current region's top edge, so it is now below the
                // vertically adjacent region's center
                cameraBelowCenter = true;
                currentRegion = currentRegion.AdjacentV;
            }
        }