Example #1
0
	public void Turn () 
	{
		if (Random.Range(0, 10) == 0)
			Kill();
		manager.cascade.UpdateSize();
		// Check the four adjacent tiles to make sure that they exist.

		// Disqualify mountains and crags
		// Also disqualify if last tile occupied

		int coordX = currentTile.x;
		int coordY = currentTile.y;

		List<Tile> candidates = new List<Tile>();

		// Four checks
		Tile currentCheck;

		if (coordY != 0) {
			currentCheck = manager.getTile[coordX, coordY-1];
			if (currentCheck.type != (int)TileType.tile.MOUNTAIN && (previousTile == null || currentCheck != previousTile))
				candidates.Add(currentCheck);
		}

		if (coordX != 0) {
			currentCheck = manager.getTile[coordX-1, coordY];
			if (currentCheck.type != (int)TileType.tile.MOUNTAIN && (previousTile == null || currentCheck != previousTile))
				candidates.Add(currentCheck);
		}

		if (coordX != manager.cascade.width-1) { 
			currentCheck = manager.getTile[coordX+1, coordY];
			if (currentCheck.type != (int)TileType.tile.MOUNTAIN && (previousTile == null || currentCheck != previousTile))
				candidates.Add(currentCheck);
		}

		if (coordY != manager.cascade.height-1) { 
			currentCheck = manager.getTile[coordX, coordY+1];
			if (currentCheck.type != (int)TileType.tile.MOUNTAIN && (previousTile == null || currentCheck != previousTile))
				candidates.Add(currentCheck);
		}

		previousTile = currentTile;
		if (candidates.Count == 0) {
			Kill();
			return;
		}

		currentTile = candidates[Random.Range(0, candidates.Count)];

		// Apply air effects here.
		currentTile.Change((int)TileType.element.AIR);
		manager.Change(manager.objectFromTile[currentTile],currentTile);
		Debug.Log(currentTile.x + "," + currentTile.y);

		transform.position = new Vector3 (
			manager.objectFromTile[currentTile].transform.position.x,
			manager.objectFromTile[currentTile].transform.position.y+manager.worldScale.y, 
			manager.objectFromTile[currentTile].transform.position.z);
	}
Example #2
0
	public void StartFire(Tile newTile)
	{
		tile = newTile;
		tile.fire = true;
		burnout = tile.burnout;
		MeshFilter filter = gameObject.AddComponent<MeshFilter> ();
		MeshRenderer renderer = gameObject.AddComponent<MeshRenderer>();
		
		filter.mesh = Resource.fireMesh;
		renderer.material = Resource.fireMaterial;

		Vector3 FirePosition = 
		transform.position = new Vector3 (
				manager.objectFromTile[tile].transform.position.x,
				manager.objectFromTile[tile].transform.position.y+manager.worldScale.y, 
				manager.objectFromTile[tile].transform.position.z);

		newTile.Change ((int)TileType.element.FIRE);
		manager.Change (manager.objectFromTile [tile], tile);
	}