예제 #1
0
 public void PurchaseFactory(FactoryConfig f)
 {
     if (CanPurchaseFactory(f))
     {
         currentEconomy.purchase(costForFactoryType(f));
         Factory nFactory = new Factory(f);
         factories.Push(nFactory);
         factoryManager.AddFactory(nFactory);
     }
 }
 public void PurchaseAndClose (FactoryConfig f)
 {
     if (GameState.sharedState.CanPurchaseFactory(f))
     {
         GameState.sharedState.PurchaseFactory(f);
         Close();
     } else
     {
         Debug.LogError("Could not purchase");
     }
 }
    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
        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
 public bool CanPurchaseFactory (FactoryConfig f)
 {
     return numberOfFactoryTypeOwned(f.factoryID) < f.maxOfThisType && currentEconomy.canPurchase(costForFactoryType(f));
 }
예제 #7
0
 public Economy costForFactoryType(FactoryConfig factoryType)
 {
     return factoryType.baseBuildCost.applyGrowthCurve(numberOfFactoryTypeOwned(factoryType.factoryID),Config.masterConfig.buildingCostExponent);
 }