示例#1
0
        // TODO: Merging code not working 100% correctly, so each small
        // Wall is just added for now. This is not efficient at all,
        // and must be changed later.
        public void AddWall(Wall wall)
        {
            bool mergedWall = false;

            for (int i = 0; i < Walls.Count; i++)
            {
                Wall otherWall = Walls[i];

                if (otherWall.BoundingBox.Right == wall.BoundingBox.Left
                    && otherWall.BoundingBox.Width >= otherWall.BoundingBox.Height
                    && otherWall.BoundingBox.Top == wall.BoundingBox.Top)
                {
                    otherWall.BottomRightPixel = wall.BottomRightPixel;
                    mergedWall = true;
                }
                else if (otherWall.BoundingBox.Left == wall.BoundingBox.Right
                    && otherWall.BoundingBox.Width >= otherWall.BoundingBox.Height
                    && otherWall.BoundingBox.Top == wall.BoundingBox.Top)
                {
                    otherWall.TopLeftPixel = wall.TopLeftPixel;
                    mergedWall = true;
                }
                else if (otherWall.BoundingBox.Bottom == wall.BoundingBox.Top
                    && otherWall.BoundingBox.Height >= otherWall.BoundingBox.Width
                    && otherWall.BoundingBox.Left == wall.BoundingBox.Left)
                {
                    otherWall.BottomRightPixel = wall.BottomRightPixel;
                    mergedWall = true;
                }
                else if (otherWall.BoundingBox.Top == wall.BoundingBox.Bottom
                    && otherWall.BoundingBox.Height >= otherWall.BoundingBox.Width
                    && otherWall.BoundingBox.Left == wall.BoundingBox.Left)
                {
                    otherWall.TopLeftPixel = wall.TopLeftPixel;
                    mergedWall = true;
                }

                //Walls[i] = wall;

                if (mergedWall)
                {
                    Walls[i] = otherWall;
                    break;
                }
            }

            if (!mergedWall)
                Walls.Add(wall);
        }
示例#2
0
文件: Wall.cs 项目: Linusa/AI_Project
        public bool Equals(Wall wall)
        {
            if (TopLeftPixel != wall.TopLeftPixel)
                return false;

            return BottomRightPixel == wall.BottomRightPixel;
        }
示例#3
0
文件: Map.cs 项目: Linusa/AI_Project
        private void createTiles(int[] tileTypeIndices)
        {
            for (int i = 0; i < TilesDown; i++)
            {
                for (int j = 0; j < TilesAcross; j++)
                {
                    TileInfo curTileInfo = new TileInfo();
                    curTileInfo.Position = new Vector2(j * TileSize.X, i * TileSize.Y);

                    int curIdx = (i * TilesAcross) + j;
                    TileType curTileType = (TileType)tileTypeIndices[curIdx];

                    if (curTileType == TileType.Wall)
                    {
                        // Create a Wall and register it with the WallManager.
                        Wall curWall = new Wall();
                        curWall.TopLeftPixel = curTileInfo.Position;
                        curWall.BottomRightPixel = curTileInfo.Position + TileSize;
                        WallManager.Instance.AddWall(curWall);

                        curTileInfo.Type = TileType.Wall;
                    }
                    else if (curTileType == TileType.Bush)
                    {
                        Vector2 bushPos = curTileInfo.Position + TileSize / 2;
                        bushes.Add(bushPos);

                        curTileInfo.Type = TileType.Bush;
                    }
                    else
                        curTileInfo.Type = TileType.Ground;

                    mapTiles.Add(curTileInfo);
                }
            }
        }
示例#4
0
 public void RemoveWall(Wall wall)
 {
     if (Walls.Contains(wall))
         Walls.RemoveAt(Walls.FindIndex(w => w.Equals(wall)));
 }
示例#5
0
        public BoundingBox WallExtentsIn3D(Wall wall)
        {
            Vector3 minPt = new Vector3();
            minPt.X = wall.BoundingBox.Left;
            minPt.Y = wall.BoundingBox.Top;
            minPt.Z = -10.0f;

            Vector3 maxPt = new Vector3();
            maxPt.X = wall.BoundingBox.Right;
            maxPt.Y = wall.BoundingBox.Bottom;
            maxPt.Z = 10.0f;

            return new BoundingBox(minPt, maxPt);
        }