A reduced resource tile model to manually cache only needed data.
Esempio n. 1
0
	public override Color GetColorFromTile (ResourceTileLite tile) {
		switch (tile.zone) {
		case ZoneType.None:
			return GetColor(MappingColor.NoZoning);
		case ZoneType.Protected:
			return GetColor(MappingColor.Protected);
		case ZoneType.Residential:
			return GetColor(MappingColor.Residential);
		default:
			return GetColor(MappingColor.Empty);
		}
	}
	protected override int CalculateCost (ResourceTileLite[] tiles)
	{
		int count = 0;
		foreach (ResourceTileLite tile in tiles) {
			if (!tile.outpostRequested) {
				count += cost;
			} else {
				//Discount if survey was requested
				count += cost/2;
			}
		}
		return count;
	}
Esempio n. 3
0
	public Region(ResourceTileLite[] tiles)
	{
		left = tiles[0].x;
		right = tiles[0].x;
		top = tiles[0].y;
		bottom = tiles[0].y;
		foreach (ResourceTileLite tile in tiles) {
			bottom = Mathf.Min(bottom, tile.y);
			top = Mathf.Max(top, tile.y);
			left = Mathf.Min(left, tile.x);
			right = Mathf.Max(right, tile.x);
		}
	}
Esempio n. 4
0
	/// <summary>
	/// Create an empty ResourceTileLite.
	/// </summary>
	public static ResourceTileLite Empty()
	{
		ResourceTileLite ret = new ResourceTileLite();
		ret.id = -1;
		ret.zone = ZoneType.None;
		ret.permittedActions = 0;
		return ret;
	}
Esempio n. 5
0
	public override Color GetColorFromTile (ResourceTileLite tile)
	{
		bool test = InputManager.use.resourceTileSelection.Contains(tile.id);
		return (test) ? GetColor(MappingColor.Empty) : GetColor(MappingColor.Disabled);
	}
Esempio n. 6
0
	public override Color GetColorFromTile (ResourceTileLite tile)
	{
		if ( tile.idOwner == Player.current.id ) {
			return GetColor(MappingColor.UserOwned);
		} else {
			if ( tile.idOwner != -1) {
				return GetColor(MappingColor.OtherOwned);
			} else {
				return GetColor(MappingColor.Unowned);
			}
		}
	}
Esempio n. 7
0
	public override Color GetColorFromTile (ResourceTileLite tile)
	{
		return Color.Lerp(GetColor(MappingColor.Undesirable),GetColor(MappingColor.Desirable),tile.desirability);
	}
Esempio n. 8
0
	public override Color GetColorFromTile (ResourceTileLite tile) {
		//int cmp = 1 << Player.current.permissionBitmaskByActionType[GameGUIManager.use.currentAction.GetType()];
		return (tile.IsActionPermitted(InputManager.use.currentAction)) ? GetColor(MappingColor.Empty) : GetColor(MappingColor.Disabled);
	}
Esempio n. 9
0
	/// <summary>
	/// Calculates the cost of performing this action on the given tiles
	/// </summary>
	/// <returns>
	/// The cost.
	/// </returns>
	/// <param name='tiles'>
	/// Tiles.
	/// </param>
	protected virtual int CalculateCost(ResourceTileLite[] tiles)
	{
		//This is the default way. Override to do tweaked calculations
		return tiles.Length * cost;
	}
Esempio n. 10
0
	public abstract Color GetColorFromTile(ResourceTileLite tile);
Esempio n. 11
0
	public static ResourceTileLite[] GetResourceTileCacheGroup(out Status status, params int[] ids)
	{
		ResourceTileLite[] tiles = new ResourceTileLite[ids.Length];
		status = Status.Failed;
		for(int i=0;i<ids.Length;i++) {
			tiles[i] = GetResourceTileCacheWithId(ids[i],out status);
			if (status == Status.Failed) break;
		}
		return tiles;
	}
Esempio n. 12
0
	public static ResourceTileLite[,] GetResourceTileCacheRegion(Region region)
	{
		ResourceTileLite[,] tiles = new ResourceTileLite[region.height,region.width];
		for( int r=region.bottom; r<region.height; r++) {
			for (int c=region.left; c<region.width; c++) {
				try {
					tiles[r,c] = use.resourceTileCache[r,c];
				}
				catch (System.IndexOutOfRangeException) {
					Debug.LogWarning("Trying to get tile that doesn't exist in the cache");
					tiles[r,c] = new ResourceTileLite();
				}
			}
		}
		return tiles;
	}
Esempio n. 13
0
	/// <summary>
	/// Gets the resource tile cache under mouse cursor.
	/// </summary>
	/// <returns>
	/// true if able to retrieve a cache at the specified position, otherwise false.
	/// </returns>
	/// <param name='tile'>
	/// The cache under the mouse cursor.
	/// </param>
	public static bool GetResourceTileCacheUnderMouseCursor(out ResourceTileLite tile)
	{
		return GetResourceTileCacheAtWorldPosition(GetWorldCoordinateAtMousePosition(), out tile);
	}
Esempio n. 14
0
	/// <summary>
	/// Gets the resource tile cache at world position.
	/// </summary>
	/// <returns>
	/// true if able to retrieve a cache at the specified position, otherwise false.
	/// </returns>
	/// <param name='worldPosition'>
	/// World position.
	/// </param>
	/// <param name='tile'>
	/// The cache at the specified position.
	/// </param>
	public static bool GetResourceTileCacheAtWorldPosition(Vector3 position, out ResourceTileLite tile)
	{
		position = use.terrain.transform.InverseTransformPoint(position);
		try {
			tile = use.resourceTileCache[(int)position.z, (int)position.x];
			return (!tile.Equals(ResourceTileLite.Empty()));
		}
		catch (System.IndexOutOfRangeException) {
			tile = ResourceTileLite.Empty();
			return false;
		}
	}