Exemplo n.º 1
0
    void SpawnObject()
    {
        Building building = buildings[index];

        if (LevelProgression.getLevel() >= building.lvlReq &&
            LevelProgression.getWood() >= building.woodCost &&
            LevelProgression.getStone() >= building.stoneCost &&
            LevelProgression.getSeeds() >= building.seedCost) // Check if buildable
        {
            // Update game values
            LevelProgression.AddCivPoints(building.civVal);
            LevelProgression.AddPollPoints(building.polVal);
            LevelProgression.AddSeeds(-1 * building.seedCost);
            LevelProgression.AddWood(-1 * building.woodCost);
            LevelProgression.AddStone(-1 * building.stoneCost);

            // Calc location to spawn
            GameObject prefab          = building.obj;
            Vector3    playerPos       = player.transform.position;
            Vector3    playerDirection = player.transform.forward;
            Vector3    spawnPos        = playerPos + playerDirection * spawnDistance;
            spawnPos.Set(spawnPos.x, spawnPos.y, spawnPos.z);

            // Spawn new object
            Instantiate(prefab, spawnPos, prefab.transform.rotation);
        }
    }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     civPoints.text  = LevelProgression.getCivPoints().ToString();
     level.text      = LevelProgression.getLevel().ToString();
     polPoints.text  = LevelProgression.getPollPoints().ToString();
     stoneCount.text = LevelProgression.getStone().ToString();
     woodCount.text  = LevelProgression.getWood().ToString();
     seedCount.text  = LevelProgression.getSeeds().ToString();
 }