예제 #1
0
 public bool MapWalkable(int i, int j)
 {
     if (i < 0 || i >= MapWidth)
     {
         return(false);
     }
     if (j < 0 || j >= MapHeight)
     {
         return(false);
     }
     if (map [i, j] != -1)
     {
         if (obj_list.hasObjInRowColumn(i, j))
         {
             List <OBJTYPEData> o = obj_list.getObjByRowColumn(i, j);
             for (int ii = 0; ii < o.Count; ii++)
             {
                 if (o [ii].walkable == false)
                 {
                     return(false);
                 }
             }
             return(true);
         }
         else
         {
             return(true);
         }
     }
     return(false);
 }
예제 #2
0
파일: ligthmap.cs 프로젝트: mengtest/zero
    void buildLocalMap(int width, int heght)
    {
        if (width % 2 == 0)
        {
            width += 1;
        }
        if (heght % 2 == 0)
        {
            heght += 1;
        }
        localmapWidth  = width;
        localmapHeight = heght;
        int centerx = (int)((lightsource.transform.position.x + MapWidth * lineLength * 0.5) / lineLength);
        int centery = (int)((-lightsource.transform.position.y + MapWidth * lineLength * 0.5) / lineLength);

        //Debug.Log ("Light in "+centerx+","+centery);
        //float newcenterx = lineLength * centerx - lineLength * MapWidth / 2 + lineLength / 2;
        //float newcentery = -lineLength * centery + lineLength * MapHeight / 2 - lineLength / 2;
        localmap = new int[heght, width];
        for (int i = 0; i < heght; i++)
        {
            for (int j = 0; j < width; j++)
            {
                localmap [i, j] = -1;
            }
        }
        int beginx = centerx - (width - 1) / 2;
        int beginy = centery - (heght - 1) / 2;
        int endx   = centerx + (width - 1) / 2;
        int endy   = centery + (heght - 1) / 2;

        if (beginx < 0)
        {
            beginx = 0;
        }
        if (beginy < 0)
        {
            beginy = 0;
        }
        if (endx >= MapWidth)
        {
            endx = MapWidth - 1;
        }
        if (endy >= MapHeight)
        {
            endy = MapHeight - 1;
        }
        for (int iy = beginy + 1; iy <= endy - 1; iy++)
        {
            for (int ix = beginx + 1; ix <= endx - 1; ix++)
            {
                if (GameObject.Find("map").GetComponent <RandomDungeonCreator> ().getMapTileType(iy, ix) != "WALL")
                {
                    GameObject  map      = GameObject.Find("map");
                    OBJTYPEList obj_list = map.GetComponent <RandomDungeonCreator>().obj_list;
                    if (obj_list.hasObjInRowColumn(iy, ix))
                    {
                        localmap [iy - (centery - (heght - 1) / 2), ix - (centerx - (width - 1) / 2)] = 0;
                        List <OBJTYPEData> odl = obj_list.getObjByRowColumn(iy, ix);
                        for (int ii = 0; ii < odl.Count; ii++)
                        {
                            if (!odl[ii].lightable)
                            {
                                localmap [iy - (centery - (heght - 1) / 2), ix - (centerx - (width - 1) / 2)] = -1;
                            }
                        }
                    }
                    else
                    {
                        localmap [iy - (centery - (heght - 1) / 2), ix - (centerx - (width - 1) / 2)] = 0;
                    }
                }
            }
        }
    }