Ejemplo n.º 1
0
    void placeEnemy()
    {
        OBJTYPEList        obj_list = map.GetComponent <RandomDungeonCreator>().obj_list; //获取object列表
        List <OBJTYPEData> ems      = obj_list.getListByType(OBJTYPE.OBJTYPE_ENEMY);

        if (map.GetComponent <RoundControler> ().enemy.Count > 0)
        {
            for (int i = 0; i < map.GetComponent <RoundControler> ().enemy.Count; i++)
            {
                Destroy(map.GetComponent <RoundControler> ().enemy [i].gameObject);
            }
        }
        map.GetComponent <RoundControler> ().enemy = new List <GameObject>();
        for (int i = 0; i < ems.Count; i++)
        {
            GameObject a = (GameObject)Instantiate(enemyPrefab[((ObjectEnemy)ems[i]).Enemy_type], transform.position, transform.rotation);
            a.name = "Enemy" + i;
            a.GetComponent <playerMove> ().initStatus();
            a.GetComponent <playerMove> ().set(ems[i].row, ems[i].column);
            map.GetComponent <RoundControler> ().enemy.Add(a);
            a.GetComponent <playerStatus> ().AI           = true;
            a.GetComponent <playerStatus> ().HP           = Random.Range(1, 100);
            a.GetComponent <playerStatus> ().ATK          = Random.Range(1, 20);
            a.GetComponent <playerStatus> ().ATKRange     = Random.Range(1, 2);
            a.GetComponent <playerStatus> ().SPEED        = Random.Range(1, 20);
            a.GetComponent <playerStatus> ().MOV          = Random.Range(1, 4);
            a.GetComponent <playerStatus> ().isDanger     = true;
            a.GetComponent <playerStatus> ().isPlayerTeam = false;
            ((ObjectEnemy)ems [i]).thisOBJ        = a;
            a.GetComponent <playerMove> ().MapOBJ = (ObjectEnemy)ems [i];
        }
    }
Ejemplo n.º 2
0
    GameObject PlacePlayer()
    {
        if (map.GetComponent <RoundControler> ().player != null)
        {
            Destroy(map.GetComponent <RoundControler> ().player.gameObject);
        }
        OBJTYPEList obj_list = map.GetComponent <RandomDungeonCreator>().obj_list;        //获取object列表
        int         row      = obj_list.getListByType(OBJTYPE.OBJTYPE_PLAYER) [0].row;
        int         column   = obj_list.getListByType(OBJTYPE.OBJTYPE_PLAYER) [0].column;
        //Vector2 pos = map.GetComponent<TilesManager> ().posTransform (row,column);
        GameObject a = (GameObject)Instantiate(playerPrefab, transform.position, transform.rotation);

        a.name = "Player";
        a.GetComponent <playerMove> ().initStatus();
        a.GetComponent <playerMove> ().set(row, column);
        map.GetComponent <RoundControler> ().player   = a;
        a.GetComponent <playerStatus> ().AI           = false;
        a.GetComponent <playerStatus> ().HP           = Random.Range(1, 100);
        a.GetComponent <playerStatus> ().HPMAX        = a.GetComponent <playerStatus> ().HP;//测试血槽 by kola
        a.GetComponent <playerStatus> ().ATK          = Random.Range(1, 20);
        a.GetComponent <playerStatus> ().ATKRange     = Random.Range(1, 2);
        a.GetComponent <playerStatus> ().SPEED        = Random.Range(1, 20);
        a.GetComponent <playerStatus> ().MOV          = Random.Range(1, 4);
        a.GetComponent <playerStatus> ().isDanger     = false;
        a.GetComponent <playerStatus> ().isPlayerTeam = true;
        GameObject.Find("Cameras").GetComponent <followCenter>().player    = a;
        GameObject.Find("lightCover").GetComponent <followCenter>().player = a;
        obj_list.getListByType(OBJTYPE.OBJTYPE_PLAYER) [0].thisOBJ         = a;
        a.GetComponent <playerMove> ().MapOBJ = obj_list.getListByType(OBJTYPE.OBJTYPE_PLAYER) [0];
        Debug.Log("Create player" + a.name);

        return(a);
    }
Ejemplo n.º 3
0
    void Awake()
    {
        map    = GameObject.Find("map");
        role   = transform.Find("man").gameObject;
        weapon = transform.Find("weapon").gameObject;
        OBJTYPEList obj_list = map.GetComponent <RandomDungeonCreator>().obj_list;        //获取object列表

        row         = obj_list.getListByType(OBJTYPE.OBJTYPE_PLAYER) [0].row;
        column      = obj_list.getListByType(OBJTYPE.OBJTYPE_PLAYER) [0].column;
        orientation = "DOWN";
        iniCell     = new int[2];
        iniCell [0] = row;
        iniCell [1] = column;
        iniPos      = map.GetComponent <TilesManager>().posTransform(row, column);
        //初始化位置
        transform.position = iniPos;
        astar = new Astar();
    }
Ejemplo n.º 4
0
 //初始化地图
 void iniMap()
 {
     numOfObj = 0;
     //roomsID = new List<int>();
     rooms   = new List <RoomData>();
     mazesID = new List <int>();
     //doorsID = new List<int>();
     idtype   = new Dictionary <int, string>();
     obj_list = new OBJTYPEList();
     map      = new int[MapHeight, MapWidth];
     for (int i = 0; i < MapHeight; i++)
     {
         for (int j = 0; j < MapWidth; j++)
         {
             map [i, j] = -1;
         }
     }
 }
Ejemplo n.º 5
0
    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;
                    }
                }
            }
        }
    }