コード例 #1
0
    /// <summary>
    /// Shows the building construct (Tip).
    /// </summary>
    /// <param name="buildingName">Building name.</param>
    public void ShowBuildingConstruct(string buildingName)
    {
        ShowBuidTip();
        ClearBuildTip();

        buildTipButton [0].gameObject.SetActive(true);
        buildTipButton[0].gameObject.GetComponentInChildren <Text>().text = "Cancel";
        buildTipButton [1].gameObject.SetActive(true);
        buildTipButton[1].gameObject.GetComponentInChildren <Text>().text = "Build";
        buildTipButton [1].gameObject.name = buildingName;

        Building b = new Building();

        switch (buildingName)
        {
        case "BedRoom":
            b = LoadTxt.GetBuilding("Bedroom", GameData._playerData.BedRoomOpen + 1);
            break;

        case "Warehouse":
            b = LoadTxt.GetBuilding("Warehouse", GameData._playerData.WarehouseOpen + 1);
            break;

        case "Kitchen":
            b = LoadTxt.GetBuilding("Kitchen", GameData._playerData.KitchenOpen + 1);
            break;

        case "Workshop":
            b = LoadTxt.GetBuilding("Workshop", GameData._playerData.WorkshopOpen + 1);
            break;

        case "Well":
            b = LoadTxt.GetBuilding("Well", GameData._playerData.WellOpen + 1);
            break;

        case "Study":
            b = LoadTxt.GetBuilding("Study", GameData._playerData.StudyOpen + 1);
            break;

        case "Farm":
            b = LoadTxt.GetBuilding("Farm", GameData._playerData.FarmOpen + 1);
            break;

        case "Pets":
            b = LoadTxt.GetBuilding("Pets", GameData._playerData.PetsOpen + 1);
            break;

        case "Achievement":
            b = LoadTxt.GetBuilding("Achievement", GameData._playerData.AchievementOpen + 1);
            break;

        case "Altar":
            b = LoadTxt.GetBuilding("Altar", GameData._playerData.AltarOpen + 1);
            break;

        default:
            Debug.Log("没有找到建筑--" + buildingName);
            break;
        }
        buildTipText [0].text = b.name;
        SetTipDesc(b);
        buildTipButton [1].interactable = CheckReq(b.combReq);
    }
コード例 #2
0
    public void ConstructBuilding()
    {
        string   s = buildTipButton [1].gameObject.name;
        Building b = new Building();

        switch (s)
        {
        case "BedRoom":
            b = LoadTxt.GetBuilding("Bedroom", GameData._playerData.BedRoomOpen + 1);
            if (!CheckReq(b.combReq))
            {
                break;
            }
            else
            {
                StartCoroutine(WaitAndBuildRoom(b));
                break;
            }

        case "Warehouse":
            b = LoadTxt.GetBuilding("Warehouse", GameData._playerData.WarehouseOpen + 1);
            if (!CheckReq(b.combReq))
            {
                break;
            }
            else
            {
                StartCoroutine(WaitAndBuildWarehouse(b));
                break;
            }

        case "Kitchen":
            b = LoadTxt.GetBuilding("Kitchen", GameData._playerData.KitchenOpen + 1);
            if (!CheckReq(b.combReq))
            {
                break;
            }
            else
            {
                StartCoroutine(WaitAndBuildKitchen(b));
                break;
            }

        case "Workshop":
            b = LoadTxt.GetBuilding("Workshop", GameData._playerData.WorkshopOpen + 1);
            if (!CheckReq(b.combReq))
            {
                break;
            }
            else
            {
                StartCoroutine(WaitAndBuildWorkshop(b));
                break;
            }

        case "Study":
            b = LoadTxt.GetBuilding("Study", GameData._playerData.StudyOpen + 1);
            if (!CheckReq(b.combReq))
            {
                break;
            }
            else
            {
                StartCoroutine(WaitAndBuildStudy(b));
                break;
            }

        case "Farm":
            b = LoadTxt.GetBuilding("Farm", GameData._playerData.FarmOpen + 1);
            if (!CheckReq(b.combReq))
            {
                break;
            }
            else
            {
                StartCoroutine(WaitAndBuildFarm(b));
                break;
            }

        case "Pets":
            b = LoadTxt.GetBuilding("Pets", GameData._playerData.PetsOpen + 1);
            if (!CheckReq(b.combReq))
            {
                break;
            }
            else
            {
                StartCoroutine(WaitAndBuildPets(b));
                break;
            }

        case "Well":
            b = LoadTxt.GetBuilding("Well", GameData._playerData.WellOpen + 1);
            if (!CheckReq(b.combReq))
            {
                break;
            }
            else
            {
                StartCoroutine(WaitAndBuildWell(b));
                break;
            }

        case "MailBox":
            break;

        case "Altar":
            b = LoadTxt.GetBuilding("Altar", GameData._playerData.AltarOpen + 1);
            if (!CheckReq(b.combReq))
            {
                break;
            }
            else
            {
                StartCoroutine(WaitAndBuildAltar(b));
                break;
            }

        default:
            break;
        }

        MoveBuildTip();
    }