コード例 #1
0
    public void UpgradeFactory()
    {
        App    app  = UnityEngine.Object.FindObjectOfType <App>();
        string type = GetComponentInChildren <Text>().text;
        //    MyEnum.Goods goodType = (MyEnum.Goods)System.Enum.Parse(typeof(MyEnum.Goods), type);
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.payForFactory(player, good);
        player.industry.setFactoryLevel(good, player.industry.getFactoryLevel(good) + 1);
        int factoryLevel = player.industry.getFactoryLevel(good);

        if (factoryLevel == 1)
        {
            productionLevelImage.sprite = Resources.Load("Sprites/factorySmall",
                                                         typeof(Sprite)) as Sprite;
        }
        if (factoryLevel == 2)
        {
            productionLevelImage.sprite = Resources.Load("Sprites/FactoryBig") as Sprite;
        }
        PlayerReceiver.increaseFactoryLevel(player, good);
        float ableToProduce = player.industry.determineCanProduce(good, player);

        canProduce.text     = "Able to Produce: " + ableToProduce.ToString();
        slider.maxValue     = (float)Math.Floor(ableToProduce);
        APValue.text        = player.getAP().ToString();
        button.interactable = false;
    }
コード例 #2
0
ファイル: Factory.cs プロジェクト: alabecki/Imperial-Times
    private void upgradeFactory()
    {
        {
            Debug.Log("Upgrade Factory");
            Debug.Log("Good Type: " + goodType.text);
            App app = UnityEngine.Object.FindObjectOfType <App>();
            //string type = GetComponentInChildren<Text>().text;
            //    MyEnum.Goods goodType = (MyEnum.Goods)System.Enum.Parse(typeof(MyEnum.Goods), type);
            factoryType = (MyEnum.Goods)System.Enum.Parse(typeof(MyEnum.Goods), goodType.text);

            Nation player = State.getNations()[app.GetHumanIndex()];
            PlayerPayer.payForFactory(player, factoryType);
            player.industry.setFactoryLevel(factoryType, player.industry.getFactoryLevel(factoryType) + 1);
            int factoryLevel = player.industry.getFactoryLevel(factoryType);
            if (factoryLevel == 1)
            {
                factoryLevelImage.sprite = Resources.Load("Sprites/factorySmall", typeof(Sprite)) as Sprite;
            }
            if (factoryLevel == 2)
            {
                factoryLevelImage.sprite = Resources.Load("Sprites/factoryMedium", typeof(Sprite)) as Sprite;
            }
            if (factoryLevel == 3)
            {
                factoryLevelImage.sprite = Resources.Load("Sprites/FactoryBig", typeof(Sprite)) as Sprite;
            }
            factoryLevelText.text = "Factory Level: " + factoryLevel;

            // float ableToProduce = player.industry.determineCanProduce(factoryType, player);
            canProduce.text        = "0";
            factorySlider.maxValue = 0;
            AP.text = player.getAP().ToString();
            upgrade.interactable      = false;
            produceGoods.interactable = false;
            int index = getBuildingIndex();


            Transform buildingStubb = buildingModel.transform.GetChild(index);
            Debug.Log("Name of object: " + buildingStubb.name);
            GameObject building = buildingStubb.GetChild(1).gameObject;
            building.SetActive(true);
            // Debug.Log("Name of object: " + cube.name);
        }
    }