Exemple #1
0
    void BuildFarm()
    {
        //Hide biome and food models
        GameObject innerDecoration    = selectedTile.transform.GetChild(1).gameObject;
        GameObject resourceDecoration = selectedTile.transform.GetChild(4).gameObject;

        if (innerDecoration != null)
        {
            innerDecoration.SetActive(false);
        }
        if (resourceDecoration != null)
        {
            resourceDecoration.SetActive(false);
        }

        //If upgrading farm, replace farm model (unused for now since upgraded farms have same models)
        if (mc.getBuildingTier(toBuild) > 1)
        {
            GameObject currentFarmDecoration = selectedTile.transform.GetChild(5).gameObject;
            Destroy(currentFarmDecoration);
        }

        GameObject buildingModel      = tryLoadBuilding(selectedTile.item + "-1");  //Get model of farm
        GameObject buildingDecoration = Instantiate((buildingModel) as GameObject); //Add model to scene

        PlaceDecoration(selectedTile, buildingDecoration, .1f, .15f);               //Place farm model

        EmitFarmParticles(selectedTile);                                            //Play farm building particle effect
        sc.playBuildSound();                                                        //Play building sound effect

        selectedTile.buildings [0] = toBuild;                                       //Update first index of tile's building list with farm

        mc.AddFarm(toBuild, selectedTileID);                                        //Manage farm addition in money controller

        uic.UpdateResourceUI();                                                     //Reload UI to reflect new resource
        uic.UpdateTileMenu();                                                       //Update tile menu to reflect new farm
        lc.ManageWorldLights();                                                     //Update new farm's lights
    }