예제 #1
0
        public static FloorTile getTileByIndex(FloorPlan fp, string index)
        {
            string[] outPoint1 = Regex.Split(index, "_");

            return(fp.getTile(
                       System.Convert.ToInt32(outPoint1[0]),
                       System.Convert.ToInt32(outPoint1[1])));
        }
예제 #2
0
        public static FloorTile getTileByIndex(FloorPlan fp, string index)
        {
            string[] outPoint1 = Regex.Split(index, "_");

            return fp.getTile(
                System.Convert.ToInt32(outPoint1[0]),
                System.Convert.ToInt32(outPoint1[1]));
        }
예제 #3
0
파일: FloorTile.cs 프로젝트: tkram01/see3po
        public void ResetWalkableNeighbors()
        {
            FloorTile tile1 = m_floorPlan.getTile(this.m_location.X - 1, this.m_location.Y);

            if ((tile1 != null) && (tile1.Iswalkable()))
            {
                m_neighbours.Add(tile1);
            }
            tile1 = m_floorPlan.getTile(this.m_location.X + 1, this.m_location.Y);
            if ((tile1 != null) && (tile1.Iswalkable()))
            {
                m_neighbours.Add(tile1);
            }
            tile1 = m_floorPlan.getTile(this.m_location.X, this.m_location.Y - 1);
            if ((tile1 != null) && (tile1.Iswalkable()))
            {
                m_neighbours.Add(tile1);
            }
            tile1 = m_floorPlan.getTile(this.m_location.X, this.m_location.Y + 1);
            if ((tile1 != null) && (tile1.Iswalkable()))
            {
                m_neighbours.Add(tile1);
            }
        }
예제 #4
0
        public void buildGraph()
        {
            // Add some vertices to the graph
            for (int i = 0; i < fp.getXTileNum(); i++)
            {
                for (int j = 0; j < fp.getYTileNum(); j++)
                {
                    if (fp.getWalkableValue(i, j) == 0)
                    {
                        graph.AddVertex(fp.getTile(i, j).Position.X + "_" + fp.getTile(i, j).Position.Y);
                        //m_parent.PostMessage(fp.getTile(i, j).Position.X + "_" + fp.getTile(i, j).Position.Y);
                    }

                    if (fp.getTile(i, j).endPoint)
                    {
                        this.targetPoint = i + "_" + j;
                    }
                }
            }

            edges     = new List <Edge <string> >();
            neighbors = new List <FloorTile>();

            for (int i = 0; i < fp.getXTileNum(); i++)
            {
                for (int j = i; j < fp.getYTileNum(); j++)
                {
                    if (fp.getWalkableValue(i, j) == 0)
                    {
                        neighbors = fp.getTile(i, j).getNeighbours();

                        //m_parent.PostMessage(neighbors.Count);
                        for (int k = 0; k < neighbors.Count; k++)
                        {
                            Edge <string> myedge = new Edge <string>(
                                fp.getTile(i, j).Position.X + "_" + fp.getTile(i, j).Position.Y,
                                neighbors[k].Position.X + "_" + neighbors[k].Position.Y);
                            edges.Add(myedge);
                            graph.AddEdge(myedge);
                            edgeCost.Add(myedge, 7 - fp.getTile(i, j).openness(5));
                        }
                    }
                }
            }
        }