Exemplo n.º 1
0
    private void buildBuilding(BUILDINGS buildingId, uint i, uint j)
    {
        BuildingsManager buildingsMan = BuildingsManager.GetInstance();
        Building         building     = buildingsMan.getBuilding(buildingId);

        buildingsMan.build(buildingId, i, j);

        WorldTerrain worldTerrain = WorldTerrain.GetInstance();

        worldTerrain.createBuilding(i, j, building.getVerticalTiles(), building.getHorizontalTiles());

        if (buildingId == BUILDINGS.PLANTA)
        {
            Building_Trill trill = (Building_Trill)buildingsMan.getBuilding(BUILDINGS.TRILL);
            Building_Silo  silo  = (Building_Silo)buildingsMan.getBuilding(BUILDINGS.SILO);
            Building_Era   era   = (Building_Era)buildingsMan.getBuilding(BUILDINGS.ERA);

            trill.stopProduction();
            silo.stopProduction();
            era.stopProduction();

            uint rice = trill.getAllTheRice();
            rice += silo.getAllTheRice();
            rice += era.getAllTheRice();
            ((Building_Planta)building).sendRice(rice);

            destroyBuilding(BUILDINGS.TRILL);
            destroyBuilding(BUILDINGS.SILO);
            destroyBuilding(BUILDINGS.ERA);
        }
    }
Exemplo n.º 2
0
    private void ActSendRiceToSilo()
    {
        Building_Era  era  = (Building_Era)BuildingsManager.GetInstance().getBuilding(BUILDINGS.ERA);
        Building_Silo silo = (Building_Silo)BuildingsManager.GetInstance().getBuilding(BUILDINGS.SILO);
        //uint ricePrepared = era.getAndEraseRicePrepared ();
        uint riceToSend = Math.Min(silo.getCurrentFreeCapacity(), era.getRicePrepared());

        era.takeRicePrepared(riceToSend);
        silo.sendRice(riceToSend);
    }
Exemplo n.º 3
0
    private void ActSendRiceToEra()
    {
        Building_Trill trill = (Building_Trill)BuildingsManager.GetInstance().getBuilding(BUILDINGS.TRILL);
        Building_Era   era   = (Building_Era)BuildingsManager.GetInstance().getBuilding(BUILDINGS.ERA);
        //uint ricePrepared = trill.getAndEraseRicePrepared ();
        uint riceToSend = Math.Min(era.getCurrentFreeCapacity(), trill.getRicePrepared());

        trill.takeRicePrepared(riceToSend);
        era.sendRice(riceToSend);
    }
    private bool loadBuildings()
    {
        string    file_path = "json/buildings";
        TextAsset file      = Resources.Load(file_path, typeof(TextAsset)) as TextAsset;

        if (file != null)
        {
            JSONNode N = JSON.Parse(file.text);
            foreach (BUILDINGS buildingID in Enum.GetValues(typeof(BUILDINGS)))
            {
                string buildingStr = buildingID.ToString();
                switch (buildingID)
                {
                case BUILDINGS.CASA:
                    _buildings [buildingID] = new Building_Home(N [buildingStr], buildingID);
                    break;

                case BUILDINGS.ESTABLO:
                    _buildings [buildingID] = new Building_Stable(N [buildingStr], buildingID);
                    break;

                //case BUILDINGS.GARAJE:
                //	_buildings [buildingID] = new Building_Garage(N [buildingStr], buildingID);
                //	break;
                case BUILDINGS.PLANTER:
                    _buildings [buildingID] = new Building_Planter(N [buildingStr], buildingID);
                    break;

                case BUILDINGS.TRILL:
                    _buildings [buildingID] = new Building_Trill(N [buildingStr], buildingID);
                    break;

                case BUILDINGS.ERA:
                    _buildings [buildingID] = new Building_Era(N [buildingStr], buildingID);
                    break;

                case BUILDINGS.SILO:
                    _buildings [buildingID] = new Building_Silo(N [buildingStr], buildingID);
                    break;

                case BUILDINGS.PLANTA:
                    _buildings [buildingID] = new Building_Planta(N [buildingStr], buildingID);
                    break;

                default:
                    _buildings [buildingID] = new Building(N [buildingStr], buildingID);
                    break;
                }
                _isBuilded [buildingID] = false;
            }
            return(true);
        }
        Debug.Log(file_path + " not loaded");
        return(false);
    }
Exemplo n.º 5
0
    private List <MenuAction> getBEraActions()
    {
        List <MenuAction> actions      = new List <MenuAction> ();
        Building_Era      building     = (Building_Era)BuildingsManager.GetInstance().getBuilding(BUILDINGS.ERA);
        Building_Silo     buildingSilo = (Building_Silo)BuildingsManager.GetInstance().getBuilding(BUILDINGS.SILO);
        MenuAction        actSendRice  = new MenuAction();

        actSendRice.title = Dictionary.getString("SEND_RICE_TO_SILO");
        uint riceToSend = Math.Min(buildingSilo.getCurrentFreeCapacity(), building.getRicePrepared());

        actSendRice.info         = Dictionary.getString("SEND") + " " + riceToSend + " " + Dictionary.getString("KG_RICE_SILO");
        actSendRice.enabled      = (building.getRicePrepared() > 0);
        actSendRice.doMenuAction = new DoMenuAction(ActSendRiceToSilo);
        actions.Add(actSendRice);

        return(actions);
    }
Exemplo n.º 6
0
    private List <MenuAction> getBTrillActions()
    {
        List <MenuAction> actions     = new List <MenuAction> ();
        Building_Trill    building    = (Building_Trill)BuildingsManager.GetInstance().getBuilding(BUILDINGS.TRILL);
        Building_Era      buildingEra = (Building_Era)BuildingsManager.GetInstance().getBuilding(BUILDINGS.ERA);
        MenuAction        actSendRice = new MenuAction();

        if (buildingEra.getCurrentFreeCapacity() == 0)
        {
            actSendRice.title = Dictionary.getString("ERA_FILLED");
        }
        else
        {
            actSendRice.title = Dictionary.getString("SEND_RICE_TO_ERA");
        }
        uint riceToSend = Math.Min(buildingEra.getCurrentFreeCapacity(), building.getRicePrepared());

        actSendRice.info         = Dictionary.getString("SEND") + " " + riceToSend + " " + Dictionary.getString("KG_RICE_TERRAIN");
        actSendRice.enabled      = (riceToSend > 0);
        actSendRice.doMenuAction = new DoMenuAction(ActSendRiceToEra);
        actions.Add(actSendRice);
        return(actions);
    }
    public void save(BuildingManagerData buildingManagerData)
    {
        foreach (KeyValuePair <BUILDINGS, bool> builded in IsBuilded)
        {
            if (builded.Value)
            {
                BuildingData buildingData = new BuildingData();
                buildingData.ID = builded.Key;
                switch (builded.Key)
                {
                case BUILDINGS.CASA: {
                    Building_Home b = (Building_Home)getBuilding(builded.Key);
                    buildingData.i     = b.getRow();
                    buildingData.j     = b.getCol();
                    buildingData.Level = b.getCurrentLevel();
                }
                break;

                case BUILDINGS.ESTABLO: {
                    Building_Stable b = (Building_Stable)getBuilding(builded.Key);
                    buildingData.i     = b.getRow();
                    buildingData.j     = b.getCol();
                    buildingData.Level = b.getCurrentLevel();
                }
                break;

                //case BUILDINGS.GARAJE: {
                //        Building_Garage b = (Building_Garage)getBuilding(builded.Key);
                //        buildingData.i = b.getRow();
                //        buildingData.j = b.getCol();
                //        buildingData.Level = b.getCurrentLevel();
                //    }
                //    break;
                case BUILDINGS.PLANTER: {
                    Building_Planter b = (Building_Planter)getBuilding(builded.Key);
                    buildingData.i            = b.getRow();
                    buildingData.j            = b.getCol();
                    buildingData.Level        = b.getCurrentLevel();
                    buildingData.SpecialSlot1 = b.estaSembrat() ? 1 : 0;
                    buildingData.SpecialSlot2 = (int)b.DiesSembrat;
                    buildingData.SpecialSlot3 = (int)b.Plantes;
                }
                break;

                case BUILDINGS.TRILL: {
                    Building_Trill b = (Building_Trill)getBuilding(builded.Key);
                    buildingData.i            = b.getRow();
                    buildingData.j            = b.getCol();
                    buildingData.Level        = b.getCurrentLevel();
                    buildingData.SpecialSlot1 = (int)b.getRiceUnprepared();
                    buildingData.SpecialSlot2 = (int)b.getRicePrepared();
                }
                break;

                case BUILDINGS.ERA: {
                    Building_Era b = (Building_Era)getBuilding(builded.Key);
                    buildingData.i            = b.getRow();
                    buildingData.j            = b.getCol();
                    buildingData.Level        = b.getCurrentLevel();
                    buildingData.SpecialSlot1 = (int)b.getRiceUnprepared();
                    buildingData.SpecialSlot2 = (int)b.getRicePrepared();
                }
                break;

                case BUILDINGS.SILO: {
                    Building_Silo b = (Building_Silo)getBuilding(builded.Key);
                    buildingData.i            = b.getRow();
                    buildingData.j            = b.getCol();
                    buildingData.Level        = b.getCurrentLevel();
                    buildingData.SpecialSlot1 = (int)b.getAllTheRice();
                }
                break;

                case BUILDINGS.PLANTA: {
                    Building_Planta b = (Building_Planta)getBuilding(builded.Key);
                    buildingData.i            = b.getRow();
                    buildingData.j            = b.getCol();
                    buildingData.Level        = b.getCurrentLevel();
                    buildingData.SpecialSlot1 = (int)b.getRiceUnprepared();
                }
                break;
                }
                buildingManagerData.BuildingsBuilded.Add(buildingData);
            }
        }
    }