示例#1
0
    // Use this for initialization
    void Start()
    {
        instance = this;

        for (int i = 0; i < numberOfBuildings; i++)
        {
            buildingBasisMeshRenderers[i] = buildingsBasis[i].GetComponent <MeshRenderer>();
        }

        selectedBuildingIndex = -1;

        DataFileHandler.SetBuildingsLocationsOnFirstLaunch(buildingLocationsDataFile, numberOfBuildings);
        buildingsLocations = DataFileHandler.ReadBuildingLocations(buildingLocationsDataFile, numberOfBuildings);
        for (int i = 0; i < numberOfBuildings; i++)
        {
            buildings[i].transform.position = new Vector3(buildingsLocations[i].x, buildingsLocations[i].y, buildingsLocations[i].z);
        }

        DataFileHandler.SetBuildingsSquaresOnFirstLaunch(baseSquaresDataFile, baseGridDimensionX_p + baseGridDimensionX_n, baseGridDimensionZ_p + baseGridDimensionZ_n);
        base_squares = DataFileHandler.ReadBaseSquares(baseSquaresDataFile, baseGridDimensionX_p + baseGridDimensionX_n, baseGridDimensionZ_p + baseGridDimensionZ_n);

        selectedBuildingArrows.transform.position = new Vector3(0, -100, 0);
    }
    // Use this for initialization
    void Start()
    {
        instance = this;

        isGamePaused = false;

        canonCount         = canonContainer.transform.childCount;
        crossbowCount      = crossbowContainer.transform.childCount;
        defences           = new Transform[canonCount + crossbowCount];
        buildingsLocations = new BuildingLocation[canonCount + crossbowCount];
        for (int i = 0; i < canonCount + crossbowCount; i++)
        {
            if (i < canonCount)
            {
                defences[i] = canonContainer.transform.GetChild(i);
            }
            else
            {
                defences[i] = crossbowContainer.transform.GetChild(i - canonCount);
            }
        }

        DataFileHandler.SetBuildingsLocationsOnFirstLaunch(buildingLocationsDataFile, canonCount + crossbowCount);
        buildingsLocations = DataFileHandler.ReadBuildingLocations(buildingLocationsDataFile, canonCount + crossbowCount);
        for (int i = 0; i < canonCount + crossbowCount; i++)
        {
            defences[i].transform.position = new Vector3(buildingsLocations[i].x, buildingsLocations[i].y, buildingsLocations[i].z);
        }

        livesText.text = "Lives: " + liveCount.ToString();

        timer = 0;

        obstacleButtons[0].image.color = new Color(0, 0, 0, 1);
        selectedObstacleIndex          = -1;
        isBombReady = true;
    }