Ejemplo n.º 1
0
    public void ShowBuildingBtn(GameObject btn)
    {
        //建筑物上方的按钮点击后调用这个函数
        //点击查看建筑物。
        sandbox.SetActive(false);
        toSandboxBtn.gameObject.SetActive(true);
        show.SetActive(true);
        int index = Array.IndexOf(buildingNames, btn.tag);

        if (index != -1)
        {
            sandbox.SetActive(false);
            toSandboxBtn.gameObject.SetActive(true);
            show.SetActive(true);
            BuildingShow showComponent = show.GetComponent <BuildingShow>();
            Transform    buildingNode  = showComponent.BuildingNode.transform;
            for (int i = 0; i < buildingNode.childCount; i++)
            {
                Destroy(buildingNode.GetChild(0).gameObject);
            }
            GameObject building = GameObject.Instantiate(buildingPrefabs[index], Vector3.zero, Quaternion.Euler(0, 0, 0), buildingNode);

            // building.GetComponent<Scaling>().factor = 10;
            building.transform.localPosition = new Vector3(0, 0.0f, 0);
            switch (btn.tag)
            {
            case "SchoolHistoryMuseum":
                // building.GetComponent<Scaling>().factor = 10;
                showComponent.BuildingName      = "校史馆";
                showComponent.BuildingIntroduce = "云南大学于1992年成立档案馆,2005年12月学校当时校史研究室并入。" + "\n" +
                                                  "截至2016年底,共有直至档案103057卷,855958件,排列长度1679米,资料1164册,学籍卡片64000余张,所为胶片100盘,卷片长1189米,还有录音、录像带、光盘和2450件有保存价值的实物。";
                break;

            case "Library":
                building.GetComponent <Scaling>().factor = 6.55f;
                showComponent.BuildingName      = "图书馆";
                showComponent.BuildingIntroduce = "云南大学图书馆始建于1923年,由校本部图书馆和呈贡校区图书馆两个部分组成,总面积53975平方米,总藏书量为2511748册,另有电子体图书433369册," +
                                                  "自制电子图书327册,中文数据库5个,外文数据库10个,缩微资料511件。";
                break;

            case "MingYuan":
                showComponent.BuildingName      = "明远楼";
                showComponent.BuildingIntroduce = "云南大学呈贡校区明远楼为云南大学呈贡校区办公楼,占地面积为27485.5平方米,有地上5层、地下1层,气势恢宏,庄严肃穆,与图书馆、学生会堂同为校区标志性建筑。";
                break;

            case "belfry":
                showComponent.BuildingName      = "钟楼";
                showComponent.BuildingIntroduce = "1955年兴建配套工程水塔兼作钟楼。塔共七层,高26米,连塔顶钢架共高20米。\n" +
                                                  "“钟楼接回”为云南大学校园一景。\n" + "2005年列为昆明市历史文化遗产保护建筑。";
                break;

            case "dormitry":
                showComponent.BuildingName      = "宿舍";
                showComponent.BuildingIntroduce = "四人一间,独立卫浴";
                break;

            default:
                break;
            }

            //去掉下面这个for循环,物体的旋转可能会出问题。
            for (int i = 0; i < transform.childCount; i++)
            {
                transform.GetChild(i).localRotation = Quaternion.identity;
            }
            building.transform.localRotation = Quaternion.Euler(0, 0, 0);
        }
    }
Ejemplo n.º 2
0
    public void BuildingBtnClick(List <GameObject> btns)
    {
        //这个函数在建筑的按钮点击时调用
        string[] keys = new string[btns.Count];
        for (int i = 0; i < btns.Count; i++)
        {
            keys[i] = btns[i].tag;
        }
        foreach (GameObject btn in btns)
        {
            if (isMovedOut)
            {
                btn.GetComponent <BuildingBtn>().enabled = false;
                foreach (var button in display.transform.Find("Campus").GetComponentsInChildren <Button>())
                {
                    //将按钮面向摄像机
                    button.gameObject.GetComponent <BuildingBtn>().enabled = false;
                    button.transform.GetChild(0).transform.localRotation   = Quaternion.identity;
                }
            }
            btn.GetComponent <Button>().onClick.AddListener(() =>
            {
                soundManager.GetComponent <_SoundManager>().PlaySound("ButtonClick");

                display.transform.Find("Campus").GetComponent <Collider>().enabled = false;
                _MapManager.CloseMap();
                show_instance = GameObject.Instantiate(buildingShow, Vector3.zero, Quaternion.identity, display.transform);
                show_instance.transform.localPosition = new Vector3(0, 0.01f, 0.01751f);
                show_instance.transform.localRotation = Quaternion.identity;
                BuildingShow showComponent            = show_instance.GetComponent <BuildingShow>();
                GameObject building = GameObject.Instantiate(helper.tag_prefab[btn.tag], Vector3.zero, Quaternion.identity,
                                                             show_instance.GetComponent <BuildingShow>().BuildingNode.transform);
                building.transform.localPosition = Vector3.zero;
                building.transform.localRotation = Quaternion.identity;
                string choice;
                if (btn.tag.StartsWith("dormitry"))
                {
                    choice = "dormitry";
                }
                else
                {
                    choice = btn.tag;
                }
                Debug.Log(choice);
                switch (choice)
                {
                case "SchoolHistoryMuseum":
                    showComponent.BuildingName      = "校史馆";
                    showComponent.BuildingIntroduce = "云南大学于1992年成立档案馆,2005年12月学校当时校史研究室并入。" + "\n" +
                                                      "截至2016年底,共有直至档案103057卷,855958件,排列长度1679米,资料1164册,学籍卡片64000余张,所为胶片100盘,卷片长1189米,还有录音、录像带、光盘和2450件有保存价值的实物。";
                    break;

                case "Library":
                    building.GetComponent <Scaling>().factor = 6.55f;
                    showComponent.BuildingName      = "图书馆";
                    showComponent.BuildingIntroduce = "云南大学图书馆始建于1923年,由校本部图书馆和呈贡校区图书馆两个部分组成,总面积53975平方米,总藏书量为2511748册,另有电子体图书433369册," +
                                                      "自制电子图书327册,中文数据库5个,外文数据库10个,缩微资料511件。";
                    break;

                case "MingYuan":
                    showComponent.BuildingName      = "明远楼";
                    showComponent.BuildingIntroduce = "云南大学呈贡校区明远楼为云南大学呈贡校区办公楼,占地面积为27485.5平方米,有地上5层、地下1层,气势恢宏,庄严肃穆,与图书馆、学生会堂同为校区标志性建筑。";
                    break;

                case "belfry":
                    showComponent.BuildingName      = "钟楼";
                    showComponent.BuildingIntroduce = "1955年兴建配套工程水塔兼作钟楼。塔共七层,高26米,连塔顶钢架共高20米。\n" +
                                                      "“钟楼接回”为云南大学校园一景。\n" + "2005年列为昆明市历史文化遗产保护建筑。";
                    break;

                case "dormitry":
                    showComponent.BuildingName      = "宿舍";
                    showComponent.BuildingIntroduce = "四人一间,独立卫浴";
                    break;

                default:
                    break;
                }
                UIManager.RemoveAndDestroy(keys);
                UIManager.Toggle("ReturnBtn");
                UIManager.Toggle("ResetBtn");
                histroyShow.SetActive(false);
            });
        }
    }