示例#1
0
    /// <summary>
    /// 生成新的地板
    /// </summary>
    public void GreatMapFloor()
    {
        GameObject tmp_Floor = null;

        if (floors.Count > 0)
        {
            tmp_Floor = floors[0];
            //tmp_Floor.SetActive(true);
            tmp_Floor.transform.position = guideObj.transform.position;
            tmp_Floor.transform.rotation = guideObj.transform.rotation;
            floors.RemoveAt(0);
        }
        else
        {
            tmp_Floor = Instantiate(mapFloor, guideObj.transform.position, guideObj.transform.rotation) as GameObject;
        }
        nowFloors.Add(tmp_Floor);
        FloorCollider tmp_FloorCollider = tmp_Floor.GetComponent <FloorCollider>();

        tmp_FloorCollider.ChangeChildrensPos();
        tmp_FloorCollider.number = floorNumber;             //编号赋值
        floorNumber++;
        guideObj.transform.position += guideObj.transform.forward;
        tmpFloors.Add(tmp_FloorCollider);
    }
示例#2
0
    /// <summary>
    /// 生成转向地板
    /// </summary>
    public void GreatRotaFloor()
    {
        GameObject    rotaObj;
        FloorCollider tmp_FloorColider = null;

        guideObj.transform.position += guideObj.transform.forward;
        if (rotaFloors.Count > 0)           //保存的列表当中有进行取出操作
        {
            rotaObj = rotaFloors[0];
            //rotaObj.SetActive(true);
            tmp_FloorColider           = rotaObj.GetComponent <FloorCollider>();
            tmp_FloorColider.nowTag    = NameTag.RotaTag;       //转向标识
            rotaObj.transform.position = guideObj.transform.position;
            rotaObj.transform.rotation = guideObj.transform.rotation;
            tmp_FloorColider.isInit    = true;
            tmp_FloorColider.ChangeChildrensPos();
            rotaFloors.RemoveAt(0);
        }
        else
        {
            rotaObj                 = Instantiate(rotaFloor, guideObj.transform.position, guideObj.transform.rotation);
            tmp_FloorColider        = rotaObj.GetComponent <FloorCollider>();
            tmp_FloorColider.nowTag = NameTag.RotaTag;          //转向标识
            tmp_FloorColider.ChangeChildrensPos();
        }

        int rotaModel = Random.Range(1, 3);

        if (rotaModel == 1)             //左转向
        {
            guideObj.transform.Rotate(Vector3.up, -90f);
            guideObj.transform.position += guideObj.transform.forward * 2;
        }
        else                            //右转向
        {
            guideObj.transform.Rotate(Vector3.up, 90f);
            guideObj.transform.position += guideObj.transform.forward * 2;
        }
        nowFloors.Add(rotaObj);                //将这个物体添加进待处理列表
        tmp_FloorColider.number = floorNumber; //编号赋值
        floorNumber++;
        tmpFloors.Add(tmp_FloorColider);
    }