Exemple #1
0
    public bool IsObjectTypeMatch(int x, int y, SceneEditor.MapObjectType eType)
    {
        if (x < 0 || x >= mia_array.GetLength(0))
        {
            return(false);
        }
        if (y < 0 || y >= mia_array.GetLength(1))
        {
            return(false);
        }
        if (mia_array[x, y] == eType)
        {
            return(true);
        }
        else
        {
            return(false);
        }
        //if (!m_TempObjectInfo.ContainsKey(0))
        //{
        //    return false;
        //}
        //if (m_TempObjectInfo[0].ContainsKey(x))
        //{
        //    Dictionary<int, SceneEditor.MapObjectType> ObjInfo = m_TempObjectInfo[0][x];
        //    SceneEditor.MapObjectType value;
        //    if (ObjInfo.TryGetValue(y, out value))
        //    {
        //        if (value == eType)
        //        {
        //            return true;
        //        }
        //        else
        //        {
        //            return false;
        //        }
        //    }
        //    else
        //    {
        //        return false;
        //    }

        //}
        //return false;
    }
Exemple #2
0
    public void InitArray(bool ismove = false)
    {
        if (ismove)
        {
            int x = 0;
            if (transform.position.x >= 0)
            {
                x = (int)transform.position.x;
            }
            else
            {
                x = (int)transform.position.x - 1;
            }
            int z = 0;
            if (transform.position.z >= 0)
            {
                z = (int)transform.position.z;
            }
            else
            {
                z = (int)transform.position.z - 1;
            }

            gameObject.transform.position = new Vector3(x, transform.position.y, z);
        }

        if (mia_array == null)
        {
            //int realwidth = Mathf.CeilToInt(0.5f * (m_numberOfRows / m_cellSize) / (float)Math.Sin(Math.PI * Math.Abs(m_XAngle) / 180.0) + 0.5f * (m_numberOfColumns / m_cellSize) / (float)Math.Cos(Math.PI * Math.Abs(m_XAngle) / 180.0));
            //int realHeight = Mathf.CeilToInt(0.5f * (m_numberOfRows / m_cellSize) / (float)Math.Sin(Math.PI * m_YAngle / 180.0) + 0.5f * (m_numberOfColumns / m_cellSize) / (float)Math.Cos(Math.PI * m_YAngle / 180.0));
            int realwidth  = Mathf.CeilToInt(m_numberOfColumns / m_cellSize);
            int realHeight = Mathf.CeilToInt(m_numberOfRows / m_cellSize);
            mia_array    = new SceneEditor.MapObjectType[realwidth, realHeight];
            mi_PreColoms = m_numberOfColumns;
            mi_PreRows   = m_numberOfRows;
        }
        if (mi_PreColoms != m_numberOfColumns || mi_PreRows != m_numberOfRows)
        {
            // int realwidth = Mathf.CeilToInt(0.5f * (m_numberOfRows / m_cellSize) / (float)Math.Sin(Math.PI * Math.Abs(m_XAngle) / 180.0) + 0.5f * (m_numberOfColumns / m_cellSize) / (float)Math.Cos(Math.PI * Math.Abs(m_XAngle) / 180.0));
            // int realHeight = Mathf.CeilToInt(0.5f * (m_numberOfRows / m_cellSize) / (float)Math.Sin(Math.PI * m_YAngle / 180.0) + 0.5f * (m_numberOfColumns / m_cellSize) / (float)Math.Cos(Math.PI * m_YAngle / 180.0));

            int realwidth  = Mathf.CeilToInt(m_numberOfColumns / m_cellSize);
            int realHeight = Mathf.CeilToInt(m_numberOfRows / m_cellSize);

            //int preWidth = Mathf.CeilToInt(0.5f * (mi_PreRows / m_cellSize) / (float)Math.Sin(Math.PI * Math.Abs(m_XAngle) / 180.0) + 0.5f * (mi_PreColoms / m_cellSize) / (float)Math.Cos(Math.PI * Math.Abs(m_XAngle) / 180.0));
            // int preHeight = Mathf.CeilToInt(0.5f * (mi_PreRows / m_cellSize) / (float)Math.Sin(Math.PI * m_YAngle / 180.0) + 0.5f * (mi_PreColoms / m_cellSize) / (float)Math.Cos(Math.PI * m_YAngle / 180.0));

            int preWidth  = Mathf.CeilToInt(mi_PreColoms / m_cellSize);
            int preHeight = Mathf.CeilToInt(mi_PreRows / m_cellSize);

            int minx = Math.Min(preWidth, realwidth);
            int miny = Math.Min(preHeight, realHeight);

            SceneEditor.MapObjectType[,] temparray = new SceneEditor.MapObjectType[realwidth, realHeight];
            for (int i = 0; i < minx; i++)
            {
                for (int j = 0; j < miny; j++)
                {
                    temparray[i, j] = mia_array[i, j];
                }
            }
            mia_array    = temparray;
            mi_PreColoms = m_numberOfColumns;
            mi_PreRows   = m_numberOfRows;
            mi_MaxNumber = Mathf.Max(mi_PreColoms, mi_PreRows);
        }

        for (int i = 0; i < mia_array.GetLength(0); i++)
        {
            for (int j = 0; j < mia_array.GetLength(1); j++)
            {
                Vector2 worldPos = GetWorldPosByMapPos(i, j);
                if (worldPos.x < 0 || worldPos.x >= m_numberOfColumns)
                {
                    mia_array[i, j] = SceneEditor.MapObjectType.eObstcale;
                }
                if (worldPos.y < 0 || worldPos.y >= m_numberOfRows)
                {
                    mia_array[i, j] = SceneEditor.MapObjectType.eObstcale;
                }
            }
        }
    }