Ejemplo n.º 1
0
    void executeObjectBuy()
    {
        RiceObject riceObject = RiceObjectsManager.GetInstance().getRiceObject(selectedId);

        UserDataManager.GetInstance().gold.espendGold(riceObject.Cost);
        RiceObjectsManager.GetInstance().buyRiceObject(selectedId);
    }
Ejemplo n.º 2
0
    public void showObjectsSelectedPage(List <RiceObject> riceObjects)
    {
        buyLeftPanel.gameObject.SetActive(false);
        buyCenterPanel.gameObject.SetActive(false);
        buyRightPanel.gameObject.SetActive(false);
        int initialObject = itemsPerPage * selectedPage;

        for (int i = 0; i < itemsPerPage && i < riceObjects.Count - initialObject; ++i)
        {
            RiceObject riceObjectToAdd = riceObjects[initialObject + i];
            //int objectPrice = riceObjectToAdd.Cost;
            switch (i)
            {
            case 0:
                buyLeftPanel.gameObject.SetActive(true);
                changePanel(buyLeftPanel, riceObjectToAdd.id, riceObjectToAdd.iconImgPath, PanelPosition.LEFT, "");
                break;

            case 1:
                buyCenterPanel.gameObject.SetActive(true);
                changePanel(buyCenterPanel, riceObjectToAdd.id, riceObjectToAdd.iconImgPath, PanelPosition.CENTER, "");
                break;

            case 2:
                buyRightPanel.gameObject.SetActive(true);
                changePanel(buyRightPanel, riceObjectToAdd.id, riceObjectToAdd.iconImgPath, PanelPosition.RIGHT, "");
                break;
            }
        }
    }
Ejemplo n.º 3
0
    private void updateQuantities(List <RiceObject> riceObjects)
    {
        int initialObject = itemsPerPage * selectedPage;

        for (int i = 0; i < itemsPerPage && i < riceObjects.Count - initialObject; ++i)
        {
            RiceObject riceObjectToModify = riceObjects [initialObject + i];
            string     freeObjects        = RiceObjectsManager.GetInstance().howManyFreeOfObject(riceObjectToModify.id).ToString();
            string     quantityObject     = RiceObjectsManager.GetInstance().getQuantityOfObject(riceObjectToModify.id).ToString();
            string     quantityText       = String.Format("{0}/{1}", freeObjects, quantityObject);
            switch (i)
            {
            case 0:
                changeQuantityOnPanel(buyLeftPanel, quantityText);
                break;

            case 1:
                changeQuantityOnPanel(buyCenterPanel, quantityText);
                break;

            case 2:
                changeQuantityOnPanel(buyRightPanel, quantityText);
                break;
            }
        }
    }
Ejemplo n.º 4
0
    //specific camp 1 -> number of busy horses
    //specific camp 2 -> number total of horses
    //specific camp 3 -> current capacity
    public override List <Pair <string, string> > getSpecificBuildingInfo()
    {
        const int  HORSE_ID = 2;
        RiceObject horse    = RiceObjectsManager.GetInstance().getRiceObject(HORSE_ID);

        m_specificBuildingInfo.Clear();
        m_specificBuildingInfo.Add(new Pair <string, string>(Dictionary.getString("BUSY_HORSES"), horse.quantityUsed.ToString()));
        m_specificBuildingInfo.Add(new Pair <string, string>(Dictionary.getString("TOTAL_HORSES"), horse.quantity.ToString()));
        m_specificBuildingInfo.Add(new Pair <string, string>(Dictionary.getString("CURRENT_MAX_CAPACITY"), this.getCapacity1().ToString()));

        return(m_specificBuildingInfo);
    }
Ejemplo n.º 5
0
    public static Dictionary <int, RiceObject> readObjects()
    {
        Dictionary <int, RiceObject> objectList = new Dictionary <int, RiceObject> ();

        TextAsset file = Resources.Load("json/objects", typeof(TextAsset)) as TextAsset;

        try {
            if (file != null)
            {
                JSONNode node = JSON.Parse(file.text);
                for (int j = 0; j < node["OBJECTS"].Count; ++j)
                {
                    JSONNode nodeDeeper  = node["OBJECTS"][j];
                    int      id          = nodeDeeper["ID"].AsInt;
                    string   name        = Dictionary.getString(nodeDeeper["NAME"].Value);
                    string   description = Dictionary.getString(nodeDeeper["DESCRIPTION"].Value);
                    string   img         = nodeDeeper["IMAGE"].Value;
                    int      cost        = nodeDeeper["COST"].AsInt;
                    bool     isDurable   = nodeDeeper["IS_DURABLE"].AsBool;
                    bool     needsGarage = nodeDeeper["NEED_GARAGE"].AsBool;
                    if (needsGarage)
                    {
                        //riceObjectManager.addObjectToGarageNeeded(id);
                    }
                    int        order                 = nodeDeeper["ORDER"].AsInt;
                    RiceObject riceObject            = new RiceObject(id, name, description, img, cost, isDurable, needsGarage, order);
                    List <int> investigationRequired = new List <int>();
                    for (int i = 0; i < nodeDeeper["INVESTIGATION_REQUIRED"].Count; ++i)
                    {
                        investigationRequired.Add(nodeDeeper["INVESTIGATION_REQUIRED"][i].AsInt);
                    }
                    riceObject.InvestigationRequired = investigationRequired;
                    objectList.Add(riceObject.id, riceObject);
                }
            }
            else
            {
                Debug.Log("File json/terrain_actions not loaded");
            }
        }
        catch (Exception ex) {
            Debug.Log(ex.Message);
            Debug.Log(ex.StackTrace);
        }
        return(objectList);
    }
Ejemplo n.º 6
0
    //specific camp 1 -> number of busy machines
    //specific camp 2 -> number total of machines
    //specific camp 3 -> current capacity
    public override List <Pair <string, string> > getSpecificBuildingInfo()
    {
        List <int> garageNeededObject = RiceObjectsManager.GetInstance().GarageNeededObjects;
        int        totalQuantityUsed  = 0;
        int        totalQuantity      = 0;

        foreach (int id in garageNeededObject)
        {
            RiceObject riceObject = RiceObjectsManager.GetInstance().getRiceObject(id);
            totalQuantity     += riceObject.quantity;
            totalQuantityUsed += riceObject.quantityUsed;
        }
        m_specificBuildingInfo.Clear();
        m_specificBuildingInfo.Add(new Pair <string, string>(Dictionary.getString("MACHINERY_BUSY"), totalQuantityUsed.ToString()));
        m_specificBuildingInfo.Add(new Pair <string, string>(Dictionary.getString("MACHINERY_TOTAL"), totalQuantity.ToString()));
        m_specificBuildingInfo.Add(new Pair <string, string>(Dictionary.getString("CURRENT_MAX_CAPACITY"), this.getCapacity1().ToString()));

        return(m_specificBuildingInfo);
    }
    private void updateObjectRequired()
    {
        b_haveAllObjectsRequired = true;
        int i;

        for (i = 0; i < m_currentObjectList.Count; ++i)
        {
            m_requirements [i + 1].gameObject.SetActive(true);
            int        idObjectSelected = m_currentObjectList [i];
            RiceObject objectSelected   = RiceObjectsManager.GetInstance().getRiceObject(idObjectSelected);
            m_requirements [i + 1].text = objectSelected.title;
            bool isCurrentObjectAvailable = RiceObjectsManager.GetInstance().isThereAvailable(m_currentObjectList [i]);
            b_haveAllObjectsRequired = b_haveAllObjectsRequired && isCurrentObjectAvailable;
            string img = isCurrentObjectAvailable ? TICK_IMG_PATH : WRONG_IMG_PATH;
            m_requirements [i + 1].transform.FindChild("Tick").gameObject.GetComponent <Image> ().sprite =
                Resources.Load <Sprite> (img);
        }
        for (; i < MAX_REQUIREMENTS - 1; ++i)
        {
            m_requirements [i + 1].gameObject.SetActive(false);
        }
    }
Ejemplo n.º 8
0
    void updateObjectInfo()
    {
        RiceObject riceObject = RiceObjectsManager.GetInstance().getRiceObject(selectedId);

        nameText.text          = riceObject.title;
        priceText.text         = Dictionary.getString("COST") + ": " + riceObject.Cost.ToString();
        descriptionText.text   = riceObject.info;
        buyButton.interactable = true;
        buyButtonText.text     = Dictionary.getString("BUY");
        if (selectedId == HORSE_ID)
        {
            BuildingsManager bm     = BuildingsManager.GetInstance();
            Building_Stable  stable = (Building_Stable)bm.getBuilding(BUILDINGS.ESTABLO);
            int numOfHorses         = RiceObjectsManager.GetInstance().getQuantityOfObject(selectedId);
            if ((!bm.isBuilded(BUILDINGS.ESTABLO) && numOfHorses >= 1) || (stable.getCurrentCapacity() <= numOfHorses))
            {
                buyButton.interactable = false;
                buyButtonText.text     = Dictionary.getString("NO_SPACE_LEFT_STABLE");
            }
        }
        else if (riceObject.NeedsGarage)
        {
            //Building_Garage garage = (Building_Garage)BuildingsManager.GetInstance().getBuilding(BUILDINGS.GARAJE);
            //if (garage.getCurrentCapacity() <= RiceObjectsManager.GetInstance().getTotalObjectsThatNeedGarage()) {
            //    buyButton.interactable = false;
            //    buyButtonText.text = Dictionary.getString("NO_SPACE_LEFT_GARAGE");
            //}
        }
        if (_tutMan.getState() == TutorialManager.STATES.TutInfoHouse5 ||
            _tutMan.getState() == TutorialManager.STATES.TutPlantell_NO ||
            _tutMan.getState() == TutorialManager.STATES.TutBuildingsB1_NO ||
            _tutMan.getState() == TutorialManager.STATES.TutBuildingsB2_NO ||
            _tutMan.getState() == TutorialManager.STATES.TutBuildingsB3_NO)
        {
            buyButton.interactable = false;
        }
    }