public void actionClicked()
 {
     if (!b_haveAllObjectsRequired)
     {
         openBuyMenu();
     }
     else if (!b_areEnoughWorkers)
     {
         openHireMenu();
     }
     else
     {
         const int ID_SEND_HARVEST_TRAD   = 17;
         const int ID_SEND_HARVEST_MODERN = 29;
         if (m_actions[m_currentAction].id != ID_SEND_HARVEST_MODERN && m_actions[m_currentAction].id != ID_SEND_HARVEST_TRAD)
         {
             m_actions[m_currentAction].doMenuAction();
         }
         else
         {
             int  chunk       = ((ChunkAction)m_actions[m_currentAction]).chunk;
             uint riceInChunk = WorldTerrain.GetInstance().getRiceChunkProduction(chunk);
             if (!BuildingsManager.GetInstance().isBuilded(BUILDINGS.PLANTA))
             {
                 Building_Trill trill = (Building_Trill)BuildingsManager.GetInstance().getBuilding(BUILDINGS.TRILL);
                 uint           currentFreeCapacity = trill.getCurrentFreeCapacity();
                 if (currentFreeCapacity >= riceInChunk)
                 {
                     m_actions[m_currentAction].doMenuAction();
                 }
                 else
                 {
                     //uint possibleLost = riceInChunk - currentFreeCapacity;
                     GameObject panelTemplate = Resources.Load("Prefabs/RiceOverflowLostFocusLayer") as GameObject;
                     GameObject panelInstance = Instantiate(panelTemplate);
                     GameObject panel         = panelInstance.transform.FindChild("RiceOverflowPanel").gameObject;
                     panel.GetComponent <RiceOverflowPanelBehaviour>().init((MenuAction)m_actions[m_currentAction]);
                 }
             }
             else
             {
                 Building_Planta planta = (Building_Planta)BuildingsManager.GetInstance().getBuilding(BUILDINGS.PLANTA);
                 uint            currentFreeCapacity = planta.getCurrentFreeCapacity();
                 if (currentFreeCapacity >= riceInChunk)
                 {
                     m_actions[m_currentAction].doMenuAction();
                 }
                 else
                 {
                     //uint possibleLost = riceInChunk - currentFreeCapacity;
                     GameObject panelTemplate = Resources.Load("Prefabs/RiceOverflowLostFocusLayer") as GameObject;
                     GameObject panelInstance = Instantiate(panelTemplate);
                     GameObject panel         = panelInstance.transform.FindChild("RiceOverflowPanel").gameObject;
                     panel.GetComponent <RiceOverflowPanelBehaviour>().init((MenuAction)m_actions[m_currentAction]);
                 }
             }
         }
         kill();
     }
 }
Example #2
0
    public void sendRiceToDry()
    {
        uint riceProduced = getRiceProduced();

        UserDataManager.GetInstance().addRiceProduced(riceProduced);
        UserDataManager.GetInstance().addRiceLost(getRiceLost());
        if (!BuildingsManager.GetInstance().isBuilded(BUILDINGS.PLANTA))
        {
            Building_Trill trill        = (Building_Trill)BuildingsManager.GetInstance().getBuilding(BUILDINGS.TRILL);
            uint           riceOverFlow = (uint)Math.Max((int)(riceProduced - trill.getCurrentFreeCapacity()), 0);
            UserDataManager.GetInstance().addRiceLost(riceOverFlow);
            trill.sendRice(riceProduced);
        }
        else
        {
            Building_Planta planta       = (Building_Planta)BuildingsManager.GetInstance().getBuilding(BUILDINGS.PLANTA);
            uint            riceOverFlow = Math.Max(riceProduced - planta.getCurrentFreeCapacity(), 0);
            UserDataManager.GetInstance().addRiceLost(riceOverFlow);
            planta.sendRice(riceProduced);
        }
        _harvestImg.SetActive(false);
    }