コード例 #1
0
    public void ResourceInterfase()
    {
        foreach (Text text in ResourceTestList)
        {
            switch (text.transform.name)
            {
            case "Population":
                text.text = "인구 : " + CtrlPlayer.CurResource("WorkPopulation") + "/" + CtrlPlayer.UnitList.Count + "()";
                break;

            case "Food":
                text.text = "식량 : " + CtrlPlayer.CurResource("Food") + "/" + CtrlPlayer.CurResource("FoodStorage") + "()";
                break;
            }
        }
    }
コード例 #2
0
ファイル: BuildingMng.cs プロジェクト: ChartaP/BattleProject
    public BuildingCtrl CreateBuilding(PlayerCtrl Owner, UnitCtrl Worker, BuildingInfo buildingInfo, Vector3 buildingPos)
    {
        foreach (string Cost in buildingInfo.Cost.Keys)
        {
            if (Cost == "time")
            {
                continue;
            }
            if (Owner.CurResource(Cost) - buildingInfo.Cost[Cost] < 0)
            {
                gameMng.interfaceMng.AlertText(Cost + "가 부족합니다");
                return(null);
            }
        }
        foreach (string Cost in buildingInfo.Cost.Keys)
        {
            if (Cost == "time")
            {
                continue;
            }
            Owner.UseResource(Cost, buildingInfo.Cost[Cost]);
        }
        GameObject   pre  = Resources.Load("Prefab/" + buildingInfo.Component) as GameObject;
        BuildingCtrl temp = Instantiate(pre, this.transform).GetComponent <BuildingCtrl>();

        temp.SetBuilding(this, buildingInfo, Owner, buildingPos);
        buildingList.Add(temp);

        foreach (MeshRenderer mesh in temp.transform.GetComponentsInChildren <MeshRenderer>())
        {
            if (mesh.transform.tag == "Unit")
            {
                mesh.material = Owner.playerMater;
            }
            if (mesh.transform.tag == "Interface")
            {
                if (Owner == gameMng.playerMng.CtrlPlayer)
                {
                    mesh.material = RangeMater[0];
                }
                if (Owner != gameMng.playerMng.CtrlPlayer)
                {
                    mesh.material = RangeMater[1];
                }
            }
        }
        Worker.receiptOrder(new GameSys.Order.Build(temp.Target));
        return(temp);
    }