Ejemplo n.º 1
0
    private void AnalyzerMapItemOwner(Cell cell, MapTile tile)
    {
        int     size        = GetCellSize(cell.size);
        Vector3 center      = new Vector3(cell.x + size / 2, 1f, cell.z + size / 2) + Vector3.up * 100f;
        Vector3 halfExtents = new Vector3(size / 2, 1f, size / 2);
        Vector3 direction   = Vector3.down;

        RaycastHit hit;

        if (Physics.BoxCast(center, halfExtents, direction, out hit))
        {
            PoteniallyVisibleSetItem pvsItem = hit.collider.GetComponent <PoteniallyVisibleSetItem>();
            if (pvsItem != null)
            {
                if (pvsItem.size != cell.size)
                {
                    //Debug.LogWarning(string.Format("AnalyzerMapItemOwner PVSItem size{0} is not equal cell size{1}.", pvsItem.size, cell.size));
                    return;
                }
                if (pvsItem.ownerCellIdList.IndexOf(cell.Id) >= 0)
                {
                    //Debug.LogWarning(string.Format("AnalyzerMapItemOwner duplicate ownerCellId{0}.", cell.Id));
                    return;
                }
                pvsItem.ownerCellIdList.Add(cell.Id);
            }
        }
    }
Ejemplo n.º 2
0
 private void ClearAllMapItemOwner()
 {
     for (int i = 0; i < poteniallyVisibleSetItemList.Count; i++)
     {
         PoteniallyVisibleSetItem pvsItem = poteniallyVisibleSetItemList[i];
         pvsItem.ownerCellIdList.Clear();
     }
 }
Ejemplo n.º 3
0
 private void ShowAllMapItem()
 {
     for (int i = 0; i < poteniallyVisibleSetItemList.Count; i++)
     {
         PoteniallyVisibleSetItem pvsItem = poteniallyVisibleSetItemList[i];
         pvsItem.gameObject.SetActive(true);
     }
 }
Ejemplo n.º 4
0
 private void ShowSpecifiedMapItem(MapItemSize size)
 {
     for (int i = 0; i < poteniallyVisibleSetItemList.Count; i++)
     {
         PoteniallyVisibleSetItem pvsItem = poteniallyVisibleSetItemList[i];
         if (pvsItem.size == size)
         {
             pvsItem.gameObject.SetActive(true);
         }
     }
 }
Ejemplo n.º 5
0
 private XmlElement CalculateCellPVS(Cell cell, Portal portal, XmlDocument xml)
 {
     for (int k = 0; k < portal.rayStartPointList.Count; k++)
     {
         Vector3    origin     = portal.rayStartPointList[k];
         XmlElement xmlElement = xml.CreateElement("cell");
         for (int i = 0; i < cell.rayEndPointList.Count; i++)
         {
             for (int j = 0; j < verticalSize.Count; j++)
             {
                 float      height    = verticalSize[j];
                 Vector3    start     = origin + Vector3.up * height;
                 Vector3    end       = cell.rayEndPointList[i] + Vector3.up * height;
                 Vector3    direction = (end - start).normalized;
                 float      distance  = Vector3.Distance(end, start);
                 RaycastHit hitInfo;
                 if (Physics.Raycast(start, direction, out hitInfo, distance))
                 {
                     PoteniallyVisibleSetItem pvsItem = hitInfo.collider.GetComponent <PoteniallyVisibleSetItem>();
                     if (pvsItem != null)
                     {
                         if (pvsItem.size != cell.size)
                         {
                             //Debug.LogWarning(string.Format("CalculateMapPVS PVSItem size{0} is not equal cell size{1}.", pvsItem.size, cell.size));
                             continue;
                         }
                         else if (pvsItem.occlusionType != MapItemOcclusionType.Occluder)
                         {
                             //Debug.LogWarning(string.Format("CalculateMapPVS PVSItem occlusionType{0} is not equal Occluder.", pvsItem.occlusionType));
                             continue;
                         }
                         else if (pvsItem.ownerCellIdList.IndexOf(cell.Id) >= 0)
                         {
                             cell.isVisible = true;
                             xmlElement.SetAttribute("id", cell.Id.ToString());
                             return(xmlElement);
                         }
                     }
                 }
             }
         }
     }
     return(null);
 }
Ejemplo n.º 6
0
 private void Update()
 {
     PoteniallyVisibleSetData.Instance.Update(player);
     for (int i = 0; i < poteniallyVisibleSetItems.Length; i++)
     {
         PoteniallyVisibleSetItem pvsItem = poteniallyVisibleSetItems[i];
         bool isVisible = false;
         for (int j = 0; j < pvsItem.ownerCellIdList.Count; j++)
         {
             int cellId = pvsItem.ownerCellIdList[j];
             if (PoteniallyVisibleSetData.Instance.CheckVisible(cellId))
             {
                 isVisible = true;
                 break;
             }
         }
         pvsItem.SetVisivle(isVisible);
     }
 }