Exemple #1
0
    void Start()
    {
        transform.position = Vector3.zero;

        finishedLevel = false;

        if (GetLevel() != null)
        {
            terrainGenerator.CreateTerrain(GetLevel().heights);
            anchorPointLocations = GetLevel().anchorPointLocations;
            roadLevel            = GetLevel().roadLevel;
            bridgeBudget         = GetLevel().budget;
        }
        else
        {
            terrainGenerator.CreateTerrain();
            bridgeBudget = 100000;
        }

        snapPoints       = new GameObject();
        snapPoints.name  = "SnapPointsContainer";
        bridgeBeams      = new GameObject();
        bridgeBeams.name = "BridgeBeamsContainer";

        bridgeCost = 0;

        roadLevel = 18;

        int     w    = snapPositionsDimensions._1;
        int     h    = snapPositionsDimensions._2;
        Vector3 dims = new Vector3(w * snapPointSeparations.x, h * snapPointSeparations.y, 0);

        gridOrigin.x = -dims.x / 2.0f + snapPointOffset.x;
        gridOrigin.y = -dims.y / 2.0f + snapPointOffset.y;
        gridOrigin.z = snapPointOffset.z;

        trainGoal = gridOrigin.x + dims.x;

        for (int j = 0; j != h; j++)
        {
            for (int i = 0; i != w; i++)
            {
                bool       foundAnchor = FindAnchorPointIndex(i, j) != -1;
                Vector3    pos         = FromSnapToSpace(new Vector3(i, j, gridOrigin.z));
                GameObject go          = Instantiate((foundAnchor? AnchorPointPrefab: SnapPointPrefab), pos, new Quaternion()) as GameObject;
                go.transform.parent = snapPoints.transform;
                go.layer            = 8;
                go.GetComponent <SnapPoint>().position = Tuple <int, int> .Of(i, j);

                go.GetComponent <SnapPoint>().isBase            = foundAnchor;
                go.GetComponent <SnapPoint>().isBaseTerrain     = foundAnchor;
                go.GetComponent <SnapPoint>().bridgeSetupParent = this;
            }
        }

        LevelStage = eLevelStage.SetupStage;
    }
Exemple #2
0
	void Start () {
		transform.position = Vector3.zero;
		
		finishedLevel = false;
		
		if (GetLevel () != null) {
			terrainGenerator.CreateTerrain(GetLevel ().heights);
			anchorPointLocations = GetLevel ().anchorPointLocations;
			roadLevel = GetLevel().roadLevel;
			bridgeBudget = GetLevel().budget;
		} else {
			terrainGenerator.CreateTerrain();
			bridgeBudget = 100000;
		}

		snapPoints = new GameObject();
		snapPoints.name = "SnapPointsContainer";
		bridgeBeams = new GameObject();
		bridgeBeams.name = "BridgeBeamsContainer";

		bridgeCost = 0;

		roadLevel = 18;

		int w = snapPositionsDimensions._1;
		int h = snapPositionsDimensions._2;
		Vector3 dims = new Vector3(w*snapPointSeparations.x, h*snapPointSeparations.y, 0);

		gridOrigin.x = -dims.x/2.0f+snapPointOffset.x;
		gridOrigin.y = -dims.y/2.0f+snapPointOffset.y;
		gridOrigin.z = snapPointOffset.z;

		trainGoal = gridOrigin.x + dims.x;
		
		for (int j = 0; j != h; j++) {
			for (int i = 0; i != w; i++) {
				bool foundAnchor = FindAnchorPointIndex(i, j) != -1;
				Vector3 pos = FromSnapToSpace(new Vector3(i, j, gridOrigin.z));
				GameObject go = Instantiate((foundAnchor? AnchorPointPrefab: SnapPointPrefab), pos, new Quaternion()) as GameObject;
				go.transform.parent = snapPoints.transform;
				go.layer = 8;
				go.GetComponent<SnapPoint>().position = Tuple<int, int>.Of(i, j);
				go.GetComponent<SnapPoint>().isBase = foundAnchor;
				go.GetComponent<SnapPoint>().isBaseTerrain = foundAnchor;
				go.GetComponent<SnapPoint>().bridgeSetupParent = this;
			}
		}

		LevelStage = eLevelStage.SetupStage;
	}