Exemplo n.º 1
0
        private void UpdateCameraBoundaries()
        {
            TopLeftPosition  = Vector2.Transform(new Vector2(0, 0), Matrix.Invert(transform));
            TopRightPosition =
                Vector2.Transform(new Vector2(viewPort.Width, 0), Matrix.Invert(transform));
            BottomLeftPosition  = Vector2.Transform(new Vector2(0, viewPort.Height), Matrix.Invert(transform));
            BottomRightPosition =
                Vector2.Transform(new Vector2(viewPort.Width, viewPort.Height), Matrix.Invert(transform));

            _topLeft     = CellSpacePartition.GetTopLeftPartition(TopLeftPosition);
            _topRight    = CellSpacePartition.GetTopRightPartition(TopRightPosition);
            _bottomLeft  = CellSpacePartition.GetBottomLeftPartition(BottomLeftPosition);
            _bottomRight = CellSpacePartition.GetBottomRightPartition(BottomRightPosition);
        }
Exemplo n.º 2
0
        public void UpdateDynamicCellPartition(GameTime gameTime)
        {
            if (EntityWithinBounds(CellSpacePartition.GetCenterPartition(Camera.Instance.center)))
            {
                AddCellToUpdate(CellSpacePartition.GetCenterPartition(Camera.Instance.center));

                //cellSpacePartition.dynamicCells[CellSpacePartition.GetCenterPartition(Camera.Instance.center)].Update(gameTime);
            }

            if (EntityWithinBounds(CellSpacePartition.GetTopLeftPartition(Camera.Instance.center)))
            {
                AddCellToUpdate(CellSpacePartition.GetTopLeftPartition(Camera.Instance.center));
                //cellSpacePartition.dynamicCells[CellSpacePartition.GetTopLeftPartition(Camera.Instance.center)].Update(gameTime);
            }

            if (EntityWithinBounds(CellSpacePartition.GetTopPartition(Camera.Instance.center)))
            {
                AddCellToUpdate(CellSpacePartition.GetTopPartition(Camera.Instance.center));
                //cellSpacePartition.dynamicCells[CellSpacePartition.GetTopPartition(Camera.Instance.center)].Update(gameTime);
            }

            if (EntityWithinBounds(CellSpacePartition.GetTopRightPartition(Camera.Instance.center)))
            {
                AddCellToUpdate(CellSpacePartition.GetTopRightPartition(Camera.Instance.center));
                //cellSpacePartition.dynamicCells[CellSpacePartition.GetTopRightPartition(Camera.Instance.center)].Update(gameTime);
            }

            if (EntityWithinBounds(CellSpacePartition.GetRightPartition(Camera.Instance.center)))
            {
                AddCellToUpdate(CellSpacePartition.GetRightPartition(Camera.Instance.center));
                //cellSpacePartition.dynamicCells[CellSpacePartition.GetRightPartition(Camera.Instance.center)].Update(gameTime);
            }

            if (EntityWithinBounds(CellSpacePartition.GetLeftPartition(Camera.Instance.center)))
            {
                AddCellToUpdate(CellSpacePartition.GetLeftPartition(Camera.Instance.center));
                //cellSpacePartition.dynamicCells[CellSpacePartition.GetLeftPartition(Camera.Instance.center)].Update(gameTime);
            }

            if (EntityWithinBounds(CellSpacePartition.GetBottomLeftPartition(Camera.Instance.center)))
            {
                AddCellToUpdate(CellSpacePartition.GetBottomLeftPartition(Camera.Instance.center));
                //cellSpacePartition.dynamicCells[CellSpacePartition.GetBottomLeftPartition(Camera.Instance.center)].Update(gameTime);
            }

            if (EntityWithinBounds(CellSpacePartition.GetBottomPartition(Camera.Instance.center)))
            {
                AddCellToUpdate(CellSpacePartition.GetBottomPartition(Camera.Instance.center));
                //cellSpacePartition.dynamicCells[CellSpacePartition.GetBottomPartition(Camera.Instance.center)].Update(gameTime);
            }

            if (EntityWithinBounds(CellSpacePartition.GetBottomRightPartition(Camera.Instance.center)))
            {
                AddCellToUpdate(CellSpacePartition.GetBottomRightPartition(Camera.Instance.center));
                //cellSpacePartition.dynamicCells[CellSpacePartition.GetBottomRightPartition(Camera.Instance.center)].Update(gameTime);
            }

            for (int i = 0; i < _partitionsToUpdate.Count; i++)
            {
                cellSpacePartition.dynamicCells[_partitionsToUpdate[i]].Update(gameTime);
            }

            // clear the partitions after every update
            _partitionsToUpdate.Clear();
        }