コード例 #1
0
ファイル: GameState.cs プロジェクト: adamtelfer/idlecraft
 public void PurchaseFactory(FactoryConfig f)
 {
     if (CanPurchaseFactory(f))
     {
         currentEconomy.purchase(costForFactoryType(f));
         Factory nFactory = new Factory(f);
         factories.Push(nFactory);
         factoryManager.AddFactory(nFactory);
     }
 }
コード例 #2
0
 public void PurchaseAndClose (FactoryConfig f)
 {
     if (GameState.sharedState.CanPurchaseFactory(f))
     {
         GameState.sharedState.PurchaseFactory(f);
         Close();
     } else
     {
         Debug.LogError("Could not purchase");
     }
 }
コード例 #3
0
    public void AddCell(FactoryConfig f)
    {
        GameObject g = Instantiate(prefab);
        g.transform.SetParent(ListContainer.transform);
        g.transform.localScale = new Vector3(1f, 1f, 1f);

        FactoryPurchaseCell cell = g.GetComponent<FactoryPurchaseCell>();
        cell.SetFactory(f);
        cell.parentView = this;
        cells.Add(cell);

        RectTransform rect = ListContainer.GetComponent<RectTransform>();
        rect.sizeDelta = new Vector2(0f, g.GetComponent<RectTransform>().rect.height * ListContainer.transform.childCount);
    }
コード例 #4
0
ファイル: Factory.cs プロジェクト: adamtelfer/idlecraft
        public Factory (FactoryConfig f)
        {
            config = f;
            currentCapacityLevel = 0;
            currentSpeedLevel = 0;
            currentQuantityLevel = 0;

            currentProfit = new Economy();

            timeToProduceUnit = 60f / ((float)this.unitsPerMinute);

            _time = timeToProduceUnit;
            _status = FactoryStatus.WORKING;
        }
コード例 #5
0
    public void SetFactory ( FactoryConfig f )
    {
        factoryToPurchase = f;

        name.text = f.name;
        description.text = f.description;
        cost.text = GameState.sharedState.costForFactoryType(f).gold.ToString();

        purchaseButton.interactable = GameState.sharedState.CanPurchaseFactory(f);

        numberOfFactories.text = string.Format("built {0}/{1} factories", GameState.sharedState.numberOfFactoryTypeOwned(f.factoryID), f.maxOfThisType);
        if (GameState.sharedState.numberOfFactoryTypeOwned(f.factoryID) >= f.maxOfThisType)
        {
            numberOfFactories.color = Color.red;
            numberOfFactories.fontStyle = FontStyles.Bold;
        } else
        {
            numberOfFactories.color = Color.black;
            numberOfFactories.fontStyle = FontStyles.Normal;
        }
    }
コード例 #6
0
ファイル: GameState.cs プロジェクト: adamtelfer/idlecraft
 public bool CanPurchaseFactory (FactoryConfig f)
 {
     return numberOfFactoryTypeOwned(f.factoryID) < f.maxOfThisType && currentEconomy.canPurchase(costForFactoryType(f));
 }
コード例 #7
0
ファイル: GameState.cs プロジェクト: adamtelfer/idlecraft
 public Economy costForFactoryType(FactoryConfig factoryType)
 {
     return factoryType.baseBuildCost.applyGrowthCurve(numberOfFactoryTypeOwned(factoryType.factoryID),Config.masterConfig.buildingCostExponent);
 }