Exemplo n.º 1
0
    public uint getMaxPlantes()
    {
        uint basicCapacity = (uint)(getCapacity1() * WorldTerrain.GetInstance().getTotalTilesInAChunk());
        uint bonusCapacity = basicCapacity * InvestigationManager.GetInstance().getPlanterCapacityBonus() / 100;

        return(basicCapacity + bonusCapacity);
    }
 public void clicked()
 {
     if (InvestigationManager.GetInstance().isInvestigated(INVESTIGATIONS_ID.COOP))
     {
         CoopMenu.SetActive(true);
     }
 }
Exemplo n.º 3
0
    void updateBuildingList(bool changeOfTab)
    {
        List <BUILDINGS> buildingsIds = new List <BUILDINGS>();
        BuildingsManager buildingsMan = BuildingsManager.GetInstance();

        foreach (BUILDINGS buildingId in Enum.GetValues(typeof(BUILDINGS)))
        {
            if (buildingId != 0 && !buildingsMan.isBuilded(buildingId))
            {
                if (buildingId != BUILDINGS.PLANTA || InvestigationManager.GetInstance().isInvestigated(INVESTIGATIONS_ID.PLANTA))
                {
                    buildingsIds.Add(buildingId);
                }
            }
        }
        if (changeOfTab)
        {
            selectedId = buildingsIds.Count > 0 ? (int)buildingsIds[0] : 0;
        }
        // UPDATE DATA
        numOfPages   = Convert.ToInt32(Math.Ceiling(buildingsIds.Count / (float)itemsPerPage));
        selectedPage = Math.Min(selectedPage, numOfPages - 1);
        selectedPage = Math.Max(selectedPage, 0);
        showBuildingsSelectedPage(buildingsIds);
        //m_buildingsID = buildingsIds;
    }
Exemplo n.º 4
0
 public void InvestigateEverything()
 {
     for (int i = 0; i < (int)INVESTIGATIONS_ID.QUANTITY; ++i)
     {
         InvestigationManager.GetInstance().InvestigateWithoutWaiting(i);
     }
 }
Exemplo n.º 5
0
    public List <MenuAction> getRiceTerrainActions(RiceTerrainTile riceTerrain)
    {
        //Debug.Log ("Actions for Terrain=" + riceTerrain.getChunkNumber ());
        List <MenuAction> actionsAvailable = new List <MenuAction>();

        if (!isActionInProgress(riceTerrain.getChunkNumber()))
        {
            List <int> actionsCurrentPhase = GameObject.FindGameObjectWithTag("Logic").GetComponent <PhaseManager>().getActionsInCurrentPhase();
            for (uint i = 0; i < actionsCurrentPhase.Count; ++i)
            {
                int currentAction = actionsCurrentPhase[(int)i];

                bool areDependenciesOk   = riceTerrain.checkDependencies(_action[currentAction]);
                bool hasBeenInvestigated = InvestigationManager.GetInstance().areInvestigated(_action[currentAction].getInvestigationRequired());
                bool hasWater            = WorldTerrain.GetInstance().riceChunkHasWater(riceTerrain.getChunkNumber()) || !_action[currentAction].needCanal;
                bool hasActionDone       = riceTerrain.isActionDone(currentAction);

                if (!hasActionDone && hasBeenInvestigated && areDependenciesOk && hasWater)
                {
                    ChunkAction        newAction = _action[currentAction];
                    PerformChunkAction callback  = this.addActionInProgress;
                    ChunkAction        t         = newAction.copyWithCallback(callback, riceTerrain.getChunkNumber());
                    actionsAvailable.Add((MenuAction)t);
                }
                //Debug.Log("  Action "+currentAction+" Dep="+areDependenciesOk+" Inv="+hasBeenInvestigated+" Water="+hasWater+" !Done="+!hasActionDone);
            }
        }
        actionsAvailable.Sort((x, y) => x.priority.CompareTo(y.priority));
        return(actionsAvailable);
    }
Exemplo n.º 6
0
    void updateAvailableInfo()
    {
        InvestigationManager im             = InvestigationManager.GetInstance();
        List <Investigation> investigations = im.getAvailableInvestigations();

        if (investigations.Count == 0)
        {
            investigationButton.interactable = false;

            investigationButtonText.text = Dictionary.getString("ALL_RESEARCHED");
            nameText.text        = "";
            priceText.text       = "";
            descriptionText.text = "";
        }
        else
        {
            Investigation selectedInvest = im.getInvestigation(selectedId);
            nameText.text                    = selectedInvest.getName();
            priceText.text                   = " " + Dictionary.getString("COST") + " " + selectedInvest.getCost();
            descriptionText.text             = selectedInvest.getDesc();
            investigationButton.interactable = true;
            investigationButtonText.text     = Dictionary.getString("RESEARCH");
            //selectedInvest.printInfo ();
        }
    }
Exemplo n.º 7
0
    void init()
    {
        if (m_itemDescriptionText == null)
        {
            m_itemDescriptionText = GameObject.Find("ItemTitle").GetComponent <Text>();
        }
        if (m_currentItemBonusText == null)
        {
            m_currentItemBonusText = GameObject.Find("CurrentItemBonus").GetComponent <Text>();
        }
        if (m_nextItemBonusText == null)
        {
            m_nextItemBonusText = GameObject.Find("NextItemBonus").GetComponent <Text>();
        }

        if (m_coopPanels.Count == 0)
        {
            for (int i = 1; i <= (int)MilestoneType.NUMBER_MILESTONES; ++i)
            {
                m_coopPanels.Add(GameObject.Find("CoopItemPanel_" + i).GetComponent <RectTransform>());
                m_coopPanelImages.Add(m_coopPanels[m_coopPanels.Count - 1].transform.FindChild("ObjectImage").GetComponent <Image>());
            }
        }

        m_selectedMilestone = MilestoneType.EXPANSION;

        updateCoopList();
        updateSelectedMilestone();

        bool ecoGrant = InvestigationManager.GetInstance().isInvestigated(INVESTIGATIONS_ID.ECO_SUBVENCION);

        m_coopPanels [(int)MilestoneType.ECOLOGY].GetComponent <Button> ().interactable = ecoGrant;
    }
    public void sellRice(uint riceToSell)
    {
        //rice.addRiceSold(riceToSell);
        float coopBonus = CoopManager.GetInstance().getCurrentTotalProductionBonus() / 100.0f;
        float invBonus  = InvestigationManager.GetInstance().getGoldBonusPerRiceSold() / 100.0f;

        gold.addRiceGold(riceToSell * (LogicManager.PRICE_PER_RICE + LogicManager.PRICE_PER_RICE * coopBonus + LogicManager.PRICE_PER_RICE * invBonus));
    }
 void Update()
 {
     if (year < tm.getCurrentYear())
     {
         year = tm.getCurrentYear();
         InvestigationManager.GetInstance().newYear();
         GameObject.FindWithTag("InvestigationMenuParent").GetComponent <InvestigationMenu> ().newYear();
     }
 }
Exemplo n.º 10
0
    void init()
    {
        Text m_riceProductionNumberText = GameObject.Find("RiceProductionNumberText").GetComponent <Text>();
        Text m_riceSoldNumberText       = GameObject.Find("RiceSoldNumberText").GetComponent <Text>();
        Text m_riceLostNumberText       = GameObject.Find("RiceLostNumberText").GetComponent <Text>();
        Text m_grantEcologyNumberText   = GameObject.Find("EcologyGrantNumberText").GetComponent <Text>();

        UserDataManager userData        = UserDataManager.GetInstance();
        uint            anualProduction = userData.getRiceProducedThisYear();

        m_riceProductionNumberText.text = anualProduction.ToString();

        WorldTerrain         wt     = WorldTerrain.GetInstance();
        InvestigationManager invMan = InvestigationManager.GetInstance();
        //uint riceOfChunksDisabled = (uint) wt.getNumberOfChunks() * RiceTerrainTile.MAX_RICE_UNITS * WorldTerrain.RICE_CHUNK_W * WorldTerrain.RICE_CHUNK_H;
        //uint riceLostThisYear = userData.getRiceLostThisYear() + riceOfChunksDisabled;
        uint riceLostThisYear = (uint)(wt.getNumberOfChunks() * RiceTerrainTile.MAX_RICE_UNITS * WorldTerrain.RICE_CHUNK_W * WorldTerrain.RICE_CHUNK_H * (1 + invMan.getRicePerChunkBonus() * 0.01f) - anualProduction);

        m_riceLostNumberText.text = riceLostThisYear.ToString();

        int anualRiceSold = userData.gold.getRiceGoldAddThisYear();

        m_riceSoldNumberText.text = anualRiceSold.ToString();

        bool ecoGrant = InvestigationManager.GetInstance().isInvestigated(INVESTIGATIONS_ID.ECO_SUBVENCION);

        if (ecoGrant)
        {
            int ecoGrantBonus = CoopManager.GetInstance().getCurrentEcologyBonus();
            m_grantEcologyNumberText.text = ecoGrantBonus.ToString();
        }
        else
        {
            m_grantEcologyNumberText.text = "";
            GameObject.Find("EcologyGrantText").GetComponent <Text>().enabled          = false;
            GameObject.Find("EcologyGrantNumberUnits").GetComponent <Image> ().enabled = false;
            GameObject.Find("EcologyGrantButtonHelp").SetActive(false);
        }

        RankingManager.GetInstance().addScore((int)anualProduction);

        CoopManager.GetInstance().happyNewYear();

        UserDataManager.GetInstance().resetYearlyData();

        /*
         * const float TON = 1000000.0f;
         * if (anualRiceSold < TON) {
         *      m_riceProductionNumberText.text = anualRiceSold.ToString ();
         * } else {
         *      m_riceProductionNumberText.text = (anualRiceSold / TON).ToString ("0.00");
         *      m_riceProductionNumberUnitsText = "T";
         * }
         */
        GameObject.Find("Logic").GetComponent <TimeManager> ().pauseTime();
    }
Exemplo n.º 11
0
    public uint getRiceProduced()
    {
        float penalization = PenalizationManager.GetInstance().getPercentageForChunk(_chunkID);
        uint  riceLost     = (uint)(Math.Ceiling((float)MAX_RICE_UNITS * penalization * 0.01f));
        float bonusRice    = MAX_RICE_UNITS * (float)InvestigationManager.GetInstance().getRicePerChunkBonus() * 0.01f;

        riceLost = Math.Min((uint)bonusRice + MAX_RICE_UNITS, riceLost);
        //UserDataManager.GetInstance().addRiceLost(Math.Min(MAX_RICE_UNITS, riceLost));
        uint riceProduced = Math.Max(MAX_RICE_UNITS + (uint)bonusRice - riceLost, (uint)0);

        return(riceProduced);
    }
Exemplo n.º 12
0
    public void happyNewYear()
    {
        checkEcologyMilestone();
        //checkTotalProductionMilestone ();
        checkAnualProductionMilestone();

        if (InvestigationManager.GetInstance().isInvestigated(INVESTIGATIONS_ID.ECO_SUBVENCION))
        {
            int grant = getCurrentEcologyBonus();
            UserDataManager.GetInstance().addGold((uint)grant);
        }
    }
Exemplo n.º 13
0
    public void ExecuteInvestigation()
    {
        InvestigationManager im = InvestigationManager.GetInstance();
        int investigationPrice  = im.getInvestigation(selectedId).getCost();

        UserDataManager.GetInstance().gold.espendGold(investigationPrice);
        im.startInvestigation(selectedId);
        UpdateInvestigationList(true);
        updateAvailableInfo();
        //UpdateinvestigationList (); //--
        //updatePageInfo (); //--
    }
Exemplo n.º 14
0
    void updateAvailableList(bool changeOfTab)
    {
        InvestigationManager im             = InvestigationManager.GetInstance();
        List <Investigation> investigations = im.getAvailableInvestigations();

        if (changeOfTab && investigations.Count > 0)
        {
            selectedId = investigations[0].getID();
        }

        showInvestigationsList(investigations);
    }
    public List <RiceObject> getRiceObjectsAvailable()
    {
        List <RiceObject> _objectsAvailable = new List <RiceObject>();

        foreach (RiceObject riceObject in _object.Values)
        {
            bool hasBeenInvestigated = InvestigationManager.GetInstance().areInvestigated(riceObject.InvestigationRequired);
            if (hasBeenInvestigated)
            {
                _objectsAvailable.Add(riceObject);
            }
        }
        _objectsAvailable.Sort((x, y) => x.order.CompareTo(y.order));
        return(_objectsAvailable);
    }
Exemplo n.º 16
0
    void updateCompletedList(bool changeOfTab)
    {
        InvestigationManager im             = InvestigationManager.GetInstance();
        List <Investigation> investigations = im.getCompletedInvestigations();

        if (changeOfTab && investigations.Count > 0)
        {
            selectedId = investigations [0].getID();
        }
        else if (investigations.Count == 0)
        {
            selectedId = -1;
        }

        showInvestigationsList(investigations);
    }
 public static void init()
 {
     m_am      = ActionManager.GetInstance();
     m_bm      = BuildingsManager.GetInstance();
     m_tm      = GameObject.Find("Logic").GetComponent <TimeManager>();
     m_cm      = CoopManager.GetInstance();
     m_um      = UserDataManager.GetInstance();
     m_im      = InvestigationManager.GetInstance();
     m_lm      = GameObject.Find("Logic").GetComponent <LogicManager>();
     m_pm      = PenalizationManager.GetInstance();
     m_phasem  = GameObject.FindGameObjectWithTag("Logic").GetComponent <PhaseManager>();
     m_plaguem = PlagueManager.GetInstance();
     m_rm      = RankingManager.GetInstance();
     m_rom     = RiceObjectsManager.GetInstance();
     m_workerm = WorkerManager.GetInstance();
     m_worldm  = WorldTerrain.GetInstance();
     m_tutMan  = GameObject.FindGameObjectWithTag("Tutorial").GetComponent <TutorialManager> ();
 }
Exemplo n.º 18
0
    private int getEcologyScore()
    {
        int investigationPoint = InvestigationManager.GetInstance().isInvestigated(INVESTIGATIONS_ID.ECOLOGY) ? 1 : 0;
        int plagueControlPoint = m_ecologyPlageControlPoint;
        int weedControlPoint   = m_ecologyWeedControlPoint;
        //ecologyScore += m_ecologyStubbleManagementPoint;
        int       fertilizerPoint          = m_ecologyFertilizerPoint;
        const int INUNDAR_CAMPOS_ACTION_ID = 2;
        int       inundarPoint             = WorldTerrain.GetInstance().todosLosChunksInundados() ? 1 : 0;

        int ecologyScore = investigationPoint + plagueControlPoint + weedControlPoint + fertilizerPoint + inundarPoint;

        Debug.Log("EcologiScore=" + ecologyScore);
        Debug.Log("..investigationPoint=" + investigationPoint);
        Debug.Log("..plagueControlPoint=" + plagueControlPoint);
        Debug.Log("..weedControlPoint=" + weedControlPoint);
        Debug.Log("..fertilizerPoint=" + fertilizerPoint);
        Debug.Log("..inundarPoint=" + inundarPoint);
        return(ecologyScore);
    }
Exemplo n.º 19
0
 int checkPlagues()
 {
     for (int i = 0; i < plagueCount; i++)
     {
         Plague p = pm.getPlague(i);
         if (p.alreadyHappened())
         {
             continue;
         }
         if (p.getMonthIn() > tm.getCurrentMonth() + 1 || p.getMonthOut() < tm.getCurrentMonth() + 1)
         {
             continue;
         }
         int prob = Random.Range(1, 100);
         if (prob <= p.getSpawnChance() - InvestigationManager.GetInstance().getPlagueDecreaseBonus())
         {
             return(i);
         }
     }
     return(-1);
 }
Exemplo n.º 20
0
    void updateProgressInfo()
    {
        InvestigationManager im             = InvestigationManager.GetInstance();
        List <Investigation> investigations = im.getProgressInvestigations();

        if (investigations.Count == 0)
        {
            investigationButton.interactable = false;

            investigationButtonText.text = Dictionary.getString("NOTHING_UNDER_RESEARCH");
            nameText.text        = "";
            priceText.text       = "";
            descriptionText.text = "";
        }
        else
        {
            Investigation selectedInvest = im.getInvestigation(selectedId);
            nameText.text                    = selectedInvest.getName();
            priceText.text                   = " " + Dictionary.getString("COST") + " " + selectedInvest.getCost();
            descriptionText.text             = selectedInvest.getDesc();
            investigationButton.interactable = false;
            investigationButtonText.text     = Dictionary.getString("RESEARCH_UNDERWAY");
        }
    }
Exemplo n.º 21
0
    public BonusType getCurrentBonus()
    {
        int level = InvestigationManager.GetInstance().isInvestigated(INVESTIGATIONS_ID.COOP) ? m_level : 0;

        return(m_bonus[level]);
    }
Exemplo n.º 22
0
    public void produceWeeds()
    {
        //return;
        foreach (int i in _currentWeed.Keys)
        {
            // --- PRODUCE NEW WEED ---- //
            if (ActionManager.GetInstance().isActionInProgressInAChunk(i))
            {
                continue;
            }

            //--GROW WEED --//
            foreach (int tile in _currentWeed[i])
            {
                _parent.growWeedOnTile(i, tile);
            }

            if (_currentWeed[i].Count < _tilesPerChunk)
            {
                float randomNumber = UnityEngine.Random.value;
                float probability  = WEED_PROBABILITY_CHUNK;
                if (_parent.hasChunkAppliedHerbicide(i))
                {
                    probability *= WEED_HERBICIDE_MODIFIER;
                }
                if (_parent.hasChunkAppliedFangueig(i))
                {
                    probability *= WEED_FANGUEJAR_MODIFIER;
                }
                probability *= (1 - ((float)InvestigationManager.GetInstance().getBadWeedDecreaseBonus() / 100.0f));
                if (randomNumber <= probability)
                {
                    uint randomTile = (uint)((UnityEngine.Random.value) * (float)(_tilesPerChunk));
                    while (_currentWeed[i].Contains(randomTile))
                    {
                        randomTile = (uint)((UnityEngine.Random.value) * (float)(_tilesPerChunk));
                        foreach (uint tile in _currentWeed[i])
                        {
                            Debug.Log("tiles::" + tile);
                        }
                    }
                    int      randomWeed = (int)((UnityEngine.Random.value) * (float)(TYPES_OF_WEED - 1));
                    TypeWeed weed       = TypeWeed.NONE;
                    switch (randomWeed)
                    {
                    case 0:
                        weed = TypeWeed.WILD_RICE_PHASE_1;
                        break;

                    case 1:
                        weed = TypeWeed.CIPERACEA;
                        break;
                    }
                    _parent.updateWeedStateInTile(i, (int)randomTile, weed);
                    _currentWeed[i].Add(randomTile);
                }
            }
            // --- EXPAND WEED ---- //
            if (_currentWeed[i].Count < _tilesPerChunk)
            {
                float randomNumber = UnityEngine.Random.value;
                float probability  = WEED_PROBABILITY_EXPANSION;
                if (_parent.hasChunkAppliedHerbicide(i))
                {
                    probability *= WEED_HERBICIDE_MODIFIER;
                }
                if (_parent.hasChunkAppliedFangueig(i))
                {
                    probability *= WEED_FANGUEJAR_MODIFIER;
                }
                probability *= (1 - ((float)InvestigationManager.GetInstance().getBadWeedDecreaseBonus() / 100.0f));
                if (randomNumber <= probability)
                {
                    uint randomTile = (uint)((UnityEngine.Random.value) * (float)(_tilesPerChunk));
                    while (_currentWeed[i].Contains(randomTile))
                    {
                        randomTile = (uint)((UnityEngine.Random.value) * (float)(_tilesPerChunk));
                    }
                    int      randomWeed = (int)((UnityEngine.Random.value) * (float)(TYPES_OF_WEED - 1));
                    TypeWeed weed       = TypeWeed.NONE;
                    switch (randomWeed)
                    {
                    case 0:
                        weed = TypeWeed.WILD_RICE_PHASE_1;
                        break;

                    case 1:
                        weed = TypeWeed.CIPERACEA;
                        break;
                    }
                    _parent.updateWeedStateInTile(i, (int)randomTile, weed);
                    _currentWeed[i].Add(randomTile);
                }
            }
        }
    }