private void generateMap() {

		// Initializing the script object that will contain information regarding terrain
		terrainHolder = new World_TerrainHolder ();

		// Setting data and generating world
		terrainHolder.setData (chunkSize, numChunks, terrainType);
		terrainHolder.generateWorld ();

	}
	void Start() {

		terrainHolderObj = GameObject.Find ("WorldTerrainHolder");
		terrainHolder = (World_TerrainHolder)terrainHolderObj.GetComponent<World_TerrainHolder>();

		terrainHolder.worldGenWorld ();

		terrainHolder.loadSpawn ();



	}
	public void Start() {

		// Assigning the script of terrainObject to terrainHolder
		terrainHolder = (World_TerrainHolder)terrainObject.GetComponent<World_TerrainHolder>();

		// Initializing the rectangles for the screen buttons
		accept = new Rect (460, 500, 150, 50);
		generate = new Rect (460, 560, 150, 50);
		exit = new Rect (460, 620, 150, 50);

		// Initializing the rectangles for sliders

		chunkSlider = new Rect (620, 500, 150, 10);
		numChunkSlider = new Rect (620, 520, 150, 10);

		// Initializing slider values
		chunkSize = 19;
		numChunks = 11;
		terrainType = 0;
	}
Exemplo n.º 4
0
	void Start() {

		// Setting up stuff

		terrainHolderObj = GameObject.Find ("WorldTerrainHolder");
		terrainHolder = (World_TerrainHolder)terrainHolderObj.GetComponent<World_TerrainHolder>();

		playerHolder = GameObject.Find ("PlayerHolder");
		ph = (PlayerHolder)playerHolder.GetComponent<PlayerHolder> ();

		terrainChunkMap = terrainHolder.getChunkTerrain ();
		terrainCostMap = terrainHolder.getTerrainCost ();
		reloadTerrain ();
		wcs.initialize (terrainChunkMap, tilesToUse, terrainHolder.getChunkSize());
		chunkSize = terrainHolder.getChunkSize ();

		isChunkLoad = new bool[terrainChunkMap.GetLength (0), terrainChunkMap.GetLength (1)];

		// Calculating XBound

		xBound = chunkSize * terrainChunkMap.GetLength (0) * tileSize;
		xBound = xBound / 2.0f;
			
		yBound = chunkSize * terrainChunkMap.GetLength (1) * tileSize;
		yBound = yBound/2.0f;

		Debug.Log ("Calculated XBound to :" + xBound + ", YBound to :" + yBound);

		// Generating cornucopia chunks...

		short centerChunk = (short)(terrainChunkMap.GetLength (0) / 2);

		for (int i = centerChunk-2; i < centerChunk+3; i++) {
			for (int j = centerChunk-2; j < centerChunk+3; j++) {

				short[,] tmpChunk = wcs.spawnChunk ((short)i, (short)j);
				terrainHolder.copyInChunk (i,j,tmpChunk);

			}
		}

		// Spawning in cornucopia chunks

		for (int i = centerChunk-2; i < centerChunk+3; i++) {
			for (int j = centerChunk-2; j < centerChunk+3; j++) {

				short[,] tmpChunk = terrainHolder.copyOutChunk(i, j);
				loadInChunk (tmpChunk, i, j);
			}
		}

		reloadTerrain ();







		// Instantiating in players

		int numPlayers = ph.getNumPlayers ();
		float rads = 360 / numPlayers;
		rads = (rads * 3.14159f / 180.0f);

		for (int i = 0; i < numPlayers; i++) {

			float currentAngle = rads * i;

			//Debug.Log ("Angle : " + (180.0f*currentAngle/3.14159f));

			float xCord = (Mathf.Cos (currentAngle));
			float yCord = (Mathf.Sin (currentAngle));

			//Debug.Log ("X:" + xCord + ", Y:" + yCord);

			xCord *= (8.0f * 0.4f);
			yCord *= (8.0f * 0.4f);

			//Debug.Log ("X:" + xCord + ", Y:" + yCord);

			int xRemaind = (int)(xCord / 0.4f);
			int yRemaind = (int)(yCord / 0.4f);

			xCord = xRemaind * 0.4f;
			yCord = yRemaind * 0.4f;

			GameObject player = ph.getPlayer (i);
			player.SetActive (true);

			Debug.Log ("Putting player " + i + " at " + xCord + "," + yCord);
			player.transform.Translate (xCord,yCord,0);
		}

		currentPlayer = ph.getPlayer (0);
		pi = (PlayerInfo)currentPlayer.GetComponent<PlayerInfo> ();
		pi.isCurrentPlayer = true;

		UpdateCamera ();
	}