Exemple #1
0
    //@ return:which edge is shared for build adjacent cell. Numbering shared Count other cell.
    static public int getTypeEdge(int iSharedNum)
    {
        E_CELL_SIDEEDGE eSideEdge = E_CELL_SIDEEDGE.E_EDGE_NULL;

        switch (iSharedNum)
        {
        case 1:
        {
            eSideEdge = E_CELL_SIDEEDGE.E_EDGE_01;
        }
        break;

        case 2:
        {
            eSideEdge = E_CELL_SIDEEDGE.E_EDGE_20;
        }
        break;

        case 3:
        {
            eSideEdge = E_CELL_SIDEEDGE.E_EDGE_12;
        }
        break;

        default:
        {
            Debug.Log("NOSHARED IV NAVICELL.ERROR");
        }
        break;
        }

        return((int)eSideEdge);
    }
Exemple #2
0
    public Vector3 getDirEntryToGoal(int iSeqCell)
    {
        E_CELL_SIDEEDGE cellSideEdge = getEdge_AdjCell(iSeqCell);

        if (cellSideEdge != E_CELL_SIDEEDGE.E_EDGE_NULL)
        {
            return(m_arrDirEntryToBest[(int)cellSideEdge]);
        }

        Debug.Log("Error. null_dir. NaviCell(" + m_iSeqCell + "), requestSeq(" + iSeqCell + ")/cellSideEdge(" + cellSideEdge + ")//" + UnityEngine.Random.Range(0.0f, 1000.0f));
        return(Vector3.zero);
    }
Exemple #3
0
    bool getPntsOfEdge(E_CELL_SIDEEDGE edgecell, ref Vector3 pntEdge0, ref Vector3 pntEdge1)
    {
        if (E_CELL_SIDEEDGE.E_EDGE_NULL == edgecell)
        {
            return(false);
        }

        int i0 = (int)edgecell;
        int i1 = (i0 + 1) % 3;

        pntEdge0 = m_arrv3PT[i0];
        pntEdge1 = m_arrv3PT[i1];

        return(true);
    }
Exemple #4
0
    } // public bool setLinkcompute_

    //@ Cell clear and set flag unprocessed before all mapping navigation event call.
    public void setClear_unprocessed()
    {
        for (int i = 0; i < 3; ++i)
        {
            m_arrfcosttoGoal_edge[i] = -1.0f;
        }

        m_iLevelToGoal  = NULL_LEVELFROMGOAL;
        m_eEdge_bestway = E_CELL_SIDEEDGE.E_EDGE_NULL;

        m_fcosttoGoal_ex  = CMATH.FLOAT_MAX;
        m_fcosttoGoal_cen = CMATH.FLOAT_MAX;

        m_eStatusCell = E_CELL_STATUS.CELL_STATUS_ROAD;

        m_bUseWaytoPortal = false;

        m_iLevelBlockroadToGoal = 0;
    }
Exemple #5
0
    // ÇÔ¼ö:InitializeNaviCell()
    //@ Process °¢ ³×ºñ¼¿µéÀÇ ÃʱâÈ­ ÀÛ¾÷
    //@ Set all properties unprocessed and set NULL.
    public void InitializeNaviCell()
    {
        m_iSeqCell = NULL_CELL;

        for (int i = 0; i < 3; ++i)
        {
            m_arriAdjCells[i]        = NULL_CELL;
            m_arrfcosttoGoal_edge[i] = -1.0f;
        }

        m_iLevelToGoal  = NULL_LEVELFROMGOAL;
        m_eEdge_bestway = E_CELL_SIDEEDGE.E_EDGE_NULL;

        m_fcosttoGoal_ex  = CMATH.FLOAT_MAX;
        m_fcosttoGoal_cen = CMATH.FLOAT_MAX;

        m_tri_linker  = null;
        m_eStatusCell = E_CELL_STATUS.CELL_STATUS_ROAD;

        m_bUseWaytoPortal = false;
    }
Exemple #6
0
    }         // public void setLinkAllAdjs_simulate

    //@ Calculate cost from GOAL. Function arguments gives from Parent Cell.    //ÇöÀç ¼¿ÀÇ °ñ ºñ¿ëÀ» °è»ê ºÎ¸ð ¼¿ÀÇ ÀÎÀÚ°ªÀ¸·Î °è»êÇÑ´Ù
    bool setLinkcomputeCell(int iLevelFromGoal,
                            int iSeqCellParent,
                            float fCostFromGoal,
                            int iCntAncestorIsBlockroad)
    {
        //@ already computed more shorter condition.    //
        if ((m_iLevelToGoal + LEVELNAVI_SIMILAR) < iLevelFromGoal)
        {
            return(false);
        }

        //@ Already compute way to go already. // ÀÌ¹Ì ¸ñÇ¥Á¡À¸·Î °¡´Â ÁöÁ¡ÀÌ ¿äû ¼¿°ú µ¿ÀÏÇÏ°Ô ±¸¼º‰ç´ÂÁö ¿©ºÎ
        if (E_CELL_SIDEEDGE.E_EDGE_NULL != m_eEdge_bestway &&
            iLevelFromGoal == m_iLevelToGoal &&
            m_arriAdjCells[(int)m_eEdge_bestway] == iSeqCellParent)
        {
            return(false);
        }

        //@ compute blockroad weight level.
        switch (m_eStatusCell)
        {
        case E_CELL_STATUS.CELL_STATUS_BLOCK:
        {
            iLevelFromGoal = DFLT_LV_BLOCKTYPE;

            m_iLevelBlockroadToGoal = iCntAncestorIsBlockroad + 1;

            if (m_iLevelToGoal != NULL_LEVELFROMGOAL)
            {
                return(false);
            }
        }
        break;

        case E_CELL_STATUS.CELL_STATUS_BLOCKROAD:
        {
            if (0 == iCntAncestorIsBlockroad)
            {
                iLevelFromGoal = iLevelFromGoal + m_iLevelWeight_BlockRoad;
            }

            //if (m_iLevelToGoal != NULL_LEVELFROMGOAL)
            //{
            //    return false;
            //}

            m_iLevelBlockroadToGoal = iCntAncestorIsBlockroad + 1;
        }         // case E_CELL_STATUS.CELL_STATUS_BLOCKROAD:
        break;

        default:
        {
            m_iLevelBlockroadToGoal = iCntAncestorIsBlockroad;
        }         // default:
        break;
        } // switch (m_eStatusCell)

        //@ select 1 edge as shortest way to goal in 3 of edge.
        //@ if different value is bigger than LEVELNAVI_SIMILAR, give to current level as absolute level value.
        int iEdgeBestWay = (int)E_CELL_SIDEEDGE.E_EDGE_NULL;

        for (int iE = 0; iE < 3; ++iE)
        {
            if (iSeqCellParent == m_arriAdjCells[iE])
            {
                if (m_iLevelToGoal > iLevelFromGoal + LEVELNAVI_SIMILAR)
                {
                    iEdgeBestWay = iE;
                    break;
                }
                else
                {
                    if (m_fcosttoGoal_ex > fCostFromGoal)
                    {
                        iEdgeBestWay = iE;
                        break;
                    }
                }
            }
        } // for(int iE=0; iE<3; ++iE)

        bool bShorterCostOfPreviousAlready = ((int)E_CELL_SIDEEDGE.E_EDGE_NULL == iEdgeBestWay);

        if (true == bShorterCostOfPreviousAlready)
        {
            return(false);
        }

        //@ set each entry edge to goal edge dir.
        Vector3 v3PosEdgeGoal = m_arrv3MddlEdge[iEdgeBestWay];

        for (int iE = 0; iE < 3; ++iE)
        {
            if (iEdgeBestWay == iE)
            {
                continue;
            }

            //@ ÃßÈÄ ÃÖÀûÈ­ °í·Á
            m_arrDirEntryToBest[iE] = (v3PosEdgeGoal - m_arrv3MddlEdge[iE]).normalized;
        } // for (int iE = 0; iE < 3; ++iE)

        //@ set center to goal dege dir.
        m_dirCenterToBest = (v3PosEdgeGoal - m_posCenterCell).normalized;

        m_fcosttoGoal_ex = fCostFromGoal;
        m_eEdge_bestway  = (E_CELL_SIDEEDGE)iEdgeBestWay;

        m_fcosttoGoal_cen = m_fcosttoGoal_ex + m_arrfDistEdgtoCntr[(int)m_eEdge_bestway];
        m_iLevelToGoal    = iLevelFromGoal;

        for (int iE = 0; iE < 3; ++iE)
        {
            if (iEdgeBestWay != iE)
            {
                m_arrfcosttoGoal_edge[iE] = m_fcosttoGoal_cen + m_arrfDistEdgtoCntr[iE];
            }
        }

        return(true);
    } // public bool setLinkcomputeCell