Exemplo n.º 1
0
 public void AddBuilding(BuildingType building)
 {
     if (building.GetBuildingType() == BuildingType.EBuildingType.DINNER)
     {
         currentBuildings.Add(building);
         GiveRandomNPCTarget();
     }
 }
Exemplo n.º 2
0
    //Canvia el material del edificio y setea el nodo a construido
    public void BuildBuilding(MeshRenderer[] actualMat)
    {
        Renderer[] childRenderer = availableBuilding.transform.GetComponentsInChildren <MeshRenderer>();
        for (int i = 0; i < childRenderer.Length; i++)
        {
            childRenderer[i].material = actualMat[i].sharedMaterial;
        }
        SetIsBuilt(true);
        availableBuilding.transform.tag = "Building";
        var navMeshSurface = availableBuilding.GetComponent <NavMeshSurface>();

        if (navMeshSurface != null)
        {
            NavMeshManager.CalculateNavMesh(navMeshSurface);
        }
        if (myBuildingType.GetBuildingType() == BuildingType.EBuildingType.PIPE)
        {
            NavMeshManager.AddPipe(myBuildingType.GetComponent <PipeRoom>());
            NavMeshManager.CalculateOffMeshLinks();
        }
    }
Exemplo n.º 3
0
    //Recibe un edificio y un material y lo instancia en la escena
    public void SetAvailableBuilding(GameObject _building, Material availableMat)
    {
        if (!isBuilt)
        {
            if (availableBuilding != null)
            {
                Destroy(availableBuilding);
            }

            availableBuilding = Instantiate(_building, transform.position, _building.transform.rotation, transform);

            myBuildingType = availableBuilding.transform.GetComponent <BuildingType>();
            myBuildingType.SetManager(nodeManager, this);
            if (myBuildingType.GetBuildingType() == BuildingType.EBuildingType.PIPE)
            {
                myBuildingType.ConnectPipe();
            }


            myBuildingType.ChangeMaterial(availableMat);
        }
    }
Exemplo n.º 4
0
    void Start()
    {
        if (instance != null)
        {
            Debug.LogError("There are two game controllers for some reason!");
        }
        else
        {
            instance = this;
        }

        // Create the starting planet.
        planets.Add(new Planet("Earth", STARTING_PLANET_SIZE_X, STARTING_PLANET_SIZE_Y, STARTING_PLANET_RESOURCE_ABUNDANCY, STARTING_PLANET_RELATIVE_RESOURCE_ABUNDANCY));
        currentPlanet = planets [0];

        // Load the planet so all the tiles etc. get created.
        LoadPlanet(planets [0]);

        // Figure out how many tiles there are on the planet.
        int noTiles = 0;

        for (int x = 0; x < STARTING_PLANET_SIZE_X; x++)
        {
            for (int y = 0; y < STARTING_PLANET_SIZE_Y; y++)
            {
                if (planets[0].GetTileAt(x, y).tileType == "land")
                {
                    noTiles += 1;
                }
            }
        }

        int cityEnergyUsage           = BuildingType.GetBuildingType("city").inputs [0].amount;
        int mineEnergyUsage           = BuildingType.GetBuildingType("mine").inputs [0].amount;
        int oilRigEnergyUsage         = BuildingType.GetBuildingType("oilRig").inputs [0].amount;
        int oilRigProduction          = BuildingType.GetBuildingType("oilRig").outputs [0].amount;
        int generatorOilUsage         = BuildingType.GetBuildingType("generator").inputs [0].amount;
        int generatorEnergyProduction = BuildingType.GetBuildingType("generator").outputs [0].amount;

        // Calculate the no. of cities to add.
        int noCities = (int)(STARTING_CITIES_PERCENT * noTiles);

        // Place enough generators to sustain the cities and mines, rounded down.
        int noGenerators = (int)(((float)noCities * cityEnergyUsage + STARTING_MINES * mineEnergyUsage) / (generatorEnergyProduction - oilRigEnergyUsage * generatorOilUsage / oilRigProduction));

        // Place enough oil rigs to power the generators rounded down.
        int noOilRigs = (int)(((float)noGenerators) * generatorOilUsage / oilRigProduction);

        // Create a bunch of starting buildings.
        for (int i = 0; i < noOilRigs; i++)
        {
            planets [0].AutoPlaceFreeBuilding(BuildingType.GetBuildingType("oilRig"));
        }
        for (int i = 0; i < STARTING_MINES; i++)
        {
            planets [0].AutoPlaceFreeBuilding(BuildingType.GetBuildingType("mine"));
        }
        for (int i = 0; i < noGenerators; i++)
        {
            planets [0].AutoPlaceFreeBuilding(BuildingType.GetBuildingType("generator"));
        }
        for (int i = 0; i < noCities; i++)
        {
            planets [0].AutoPlaceFreeBuilding(BuildingType.GetBuildingType("city"));
        }
        for (int i = 0; i < 0; i++)
        {
            planets [0].AutoPlaceFreeBuilding(BuildingType.GetBuildingType("turbine"));
        }

        // Set the starting population.
        planets [0].SetAmountOf("population", noCities * BuildingType.GetBuildingType("city").maxOccupants - STARTING_CITY_CAPACITY_LEFT);

        // Set starting resources.
        planets [0].ChangeAmountOf("metal", STARTING_METAL);
        planets [0].ChangeAmountOf("energy", (int)(noCities * cityEnergyUsage * STARTING_ENERGY_MULTIPLIER));

        // Set the current planet variable.
        currentPlanet = planets [0];

        // Set the camera somewhere nice :).
        Camera.main.transform.position = new Vector3(STARTING_PLANET_SIZE_X / 2f, STARTING_PLANET_SIZE_Y / 2f, -100);
    }