コード例 #1
0
        public void RefreshSubTiles()
        {
            this.m_passableFlag  &= 0xF0;
            this.m_pathFinderCost = 0;

            for (int i = 0; i < this.m_gameObjects.Size(); i++)
            {
                LogicGameObject gameObject = this.m_gameObjects[i];

                this.m_pathFinderCost = LogicMath.Max(this.m_pathFinderCost, gameObject.PathFinderCost());

                if (!gameObject.IsPassable())
                {
                    int width  = gameObject.GetWidthInTiles();
                    int height = gameObject.GetWidthInTiles();

                    if (width == 1 || height == 1)
                    {
                        this.m_passableFlag |= 0xF;
                    }
                    else
                    {
                        int edge = gameObject.PassableSubtilesAtEdge();

                        int startX = 2 * (this.m_tileX - gameObject.GetTileX());
                        int startY = 2 * (this.m_tileY - gameObject.GetTileY());
                        int endX   = 2 * width - edge;
                        int endY   = 2 * height - edge;

                        for (int j = 0; j < 2; j++)
                        {
                            int offset = j;
                            int x      = startX + j;

                            for (int k = 0; k < 2; k++)
                            {
                                int y = startY + k;

                                if (y < endY && x < endX && x >= edge && y >= edge)
                                {
                                    this.m_passableFlag |= (byte)(1 << offset);
                                }

                                offset += 2;
                            }
                        }
                    }
                }
            }
        }