コード例 #1
0
ファイル: Cell.cs プロジェクト: mgood7123/Bullet-Time
        public void AddCover(NodeCoverPoint cover)
        {
            if (covers == null)
            {
                covers = new HashSet <NodeCoverPoint>();
            }

            covers.Add(cover);
        }
コード例 #2
0
        public void AddCover(NodeCoverTemp coverInfo)
        {
            Cover cover = new Cover(coverInfo.positionV3, coverInfo.connection.positionV3, coverInfo.connectionType, coverInfo.normal);

            Vector3 agentNormalPoint = coverInfo.normal * properties.radius;

            foreach (var coverPoint in coverInfo.points)
            {
                Vector3        pointPlusAgentOffset = coverPoint.positionV3 + agentNormalPoint;
                HashSet <Cell> nearbyCells          = new HashSet <Cell>();

                foreach (var edge in coverPoint.edges)
                {
                    CellContentData data = new CellContentData(edge);
                    foreach (var cell in _cells)
                    {
                        if (cell.Contains(data))
                        {
                            nearbyCells.Add(cell);
                        }
                    }
                }

                float   closestSqrDistance = float.MaxValue;
                Cell    closestCell        = null;
                Vector3 closestPoint       = Vector3.zero;

                foreach (var cell in nearbyCells)
                {
                    bool    isOutside;
                    Vector3 currentPoint;
                    cell.GetClosestPointToCell(pointPlusAgentOffset, out currentPoint, out isOutside);

                    float curSqrDistance = SomeMath.SqrDistance(pointPlusAgentOffset, currentPoint);
                    if (curSqrDistance < closestSqrDistance)
                    {
                        closestCell        = cell;
                        closestPoint       = currentPoint;
                        closestSqrDistance = curSqrDistance;
                    }
                }

                if (closestCell == null)
                {
                    //Debuger3.AddDot(coverPoint.positionV3, Color.red);
                    continue;
                }

                NodeCoverPoint coverNode = new NodeCoverPoint(coverPoint.positionV3, closestPoint, closestCell, cover);
                cover.AddCoverPoint(coverNode);
            }

            covers.Add(cover);
        }
コード例 #3
0
 public void DeserializeCovers()
 {
     foreach (var cover in serializedGraph.serializedCovers)
     {
         Cover newCover = new Cover(cover.left, cover.right, cover.coverType, cover.normal);
         foreach (var point in cover.coverPoints)
         {
             NodeCoverPoint newCoverPoint = new NodeCoverPoint(point.position, point.cellPosition, cellPool[point.cell], newCover);
             newCover.AddCoverPoint(newCoverPoint);
         }
         targetGraph.covers.Add(newCover);
         covers.Add(newCover);
     }
 }
コード例 #4
0
 public SerializedCoverPoint(NodeCoverPoint point, int cell)
 {
     position     = point.positionV3;
     cellPosition = point.cellPos;
     this.cell    = cell;
 }