本文整理汇总了C#中TileData类的典型用法代码示例。如果您正苦于以下问题:C# TileData类的具体用法?C# TileData怎么用?C# TileData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TileData类属于命名空间,在下文中一共展示了TileData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindHelper
public static void FindHelper(TileMap tileMap, TileData sourceTile, int movement, FindTilesWithinRangeDTO dto)
{
if (!dto.TileToMaxMovement.ContainsKey(sourceTile)) {
dto.TileToMaxMovement[sourceTile] = movement;
} else {
int maxMove = dto.TileToMaxMovement[sourceTile];
if (movement > maxMove) {
dto.TileToMaxMovement[sourceTile] = movement;
} else {
return;
}
}
//if (visited.Contains(sourceTile)) {
// return;
//}
//visited.Add(sourceTile);
movement = movement - sourceTile.MovementCost;
if (movement <= 0) {
return;
}
if (IsTraversable(tileMap.BottomNeighbor(sourceTile), dto)) {
FindHelper(tileMap, tileMap.BottomNeighbor(sourceTile), movement, dto);
}
if (IsTraversable(tileMap.TopNeighbor(sourceTile), dto)) {
FindHelper(tileMap, tileMap.TopNeighbor(sourceTile), movement, dto);
}
if (IsTraversable(tileMap.LeftNeighbor(sourceTile), dto)) {
FindHelper(tileMap, tileMap.LeftNeighbor(sourceTile), movement, dto);
}
if (IsTraversable(tileMap.RightNeighbor(sourceTile), dto)) {
FindHelper(tileMap, tileMap.RightNeighbor(sourceTile), movement, dto);
}
}
示例2: Read
public object Read(Newtonsoft.Json.JsonReader reader)
{
if (reader.TokenType != Newtonsoft.Json.JsonToken.StartObject)
throw new Exception();
int w = ReadIntProperty(reader, "Width");
int h = ReadIntProperty(reader, "Height");
int d = ReadIntProperty(reader, "Depth");
var grid = new TileData[d, h, w];
reader.Read();
if (reader.TokenType != Newtonsoft.Json.JsonToken.PropertyName || (string)reader.Value != "TileData")
throw new Exception();
ReadAndValidate(reader, Newtonsoft.Json.JsonToken.StartArray);
var queue = new BlockingCollection<Tuple<int, byte[]>>();
var readerTask = Task.Factory.StartNew(() =>
{
for (int i = 0; i < d; ++i)
{
reader.Read();
int z = (int)(long)reader.Value;
byte[] buf = reader.ReadAsBytes();
queue.Add(new Tuple<int, byte[]>(z, buf));
}
queue.CompleteAdding();
});
Parallel.For(0, d, i =>
{
var tuple = queue.Take();
int z = tuple.Item1;
byte[] arr = tuple.Item2;
using (var memStream = new MemoryStream(arr))
{
using (var decompressStream = new DeflateStream(memStream, CompressionMode.Decompress))
using (var streamReader = new BinaryReader(decompressStream))
{
for (int y = 0; y < h; ++y)
for (int x = 0; x < w; ++x)
grid[z, y, x].Raw = streamReader.ReadUInt64();
}
}
});
readerTask.Wait();
ReadAndValidate(reader, Newtonsoft.Json.JsonToken.EndArray);
ReadAndValidate(reader, Newtonsoft.Json.JsonToken.EndObject);
return grid;
}
示例3: TileToDiscover
public void TileToDiscover(string newTileName, int mapPosX, int mapPosY, Transform tileHolder, TileData.Types tileType, int spriteWidth = 0, int spriteHeight = 0)
{
// this is called by Resource grid with the proper tile obj
if (resourceGrid == null)
resourceGrid = ResourceGrid.Grid;
tileToSpawn = objPool.GetObjectForType (newTileName, false, Vector3.zero);
if (tileToSpawn != null) {
tileToSpawn.transform.position = transform.position;
tileToSpawn.transform.parent = tileHolder;
// IF TILE IS NOT EMPTY, IT'S A BUILDING,
// so it will have a Building Click Handler that needs its pos X and pos Y
if (tileType != TileData.Types.empty && tileType != TileData.Types.rock)
{
Building_Handler bClickHandler = tileToSpawn.GetComponent<Building_Handler> ();
if (bClickHandler)
{
bClickHandler.mapPosX = mapPosX;
bClickHandler.mapPosY = mapPosY;
//bClickHandler.resourceGrid = resourceGrid;
//bClickHandler.objPool = objPool;
}
}
if (tileType == TileData.Types.capital)
{
resourceGrid.transporterGObj = tileToSpawn;
//// IF IT'S THE TERRAFORMER it will need the master state manager
//Terraformer_Handler terra = tileToSpawn.GetComponent<Terraformer_Handler>();
// if (terra)
// terra.master_State = master_state;
}
// ADD this tile to the Grid's spawnedTiles array
if (spriteWidth > 0 && spriteHeight > 0)
{
for (int w = -(spriteWidth - 1); w < spriteWidth; w++)
{
for (int h = 0; h < spriteHeight; h++)
{
if (resourceGrid.spawnedTiles[mapPosX + w, mapPosY + h] == null)
{
resourceGrid.spawnedTiles[mapPosX + w, mapPosY + h] = tileToSpawn;
}
}
}
}
else
{
resourceGrid.spawnedTiles [mapPosX, mapPosY] = tileToSpawn;
}
}
}
示例4: GetBuildingFromType
/// <summary>
/// Determines what type of building player wants to build
/// by using the tile's type.
/// </summary>
/// <param name="_tileType"></param>
public void GetBuildingFromType(TileData.Types _tileType)
{
// TODO: Subtract the nanobot cost of this blueprint
//Building_UIHandler building_handler = Building_UIHandler.BuildingHandler;
Build_MainController build_controller = Build_MainController.Instance;
switch (_tileType)
{
case TileData.Types.rock:
Blueprint extractor = GetAvailableBlueprint(TileData.Types.extractor);
Build(extractor);
break;
case TileData.Types.mineral:
Blueprint generator = GetAvailableBlueprint(TileData.Types.generator);
Build(generator);
break;
case TileData.Types.empty:
Debug.Log("NANO B: Building on empty!");
Build(selectedBluePrint);
break;
case TileData.Types.water:
Blueprint waterPump = GetAvailableBlueprint(TileData.Types.desalt_s);
Build(waterPump);
break;
default:
Debug.Log("Cant build on that type of tile!");
break;
}
// Debug.Log("Nanobots left: " + nanoBots);
}
示例5: Save
public void Save(MainViewModel viewModel)
{
GestSpaceData space = new GestSpaceData();
foreach(var tileVm in viewModel.Tiles.Where(t => !t.IsUnused))
{
var tile = new TileData();
space.Tiles.Add(tile);
if(!tileVm.TakeSuggestedName)
{
tile.ForcedName = tileVm.Description;
}
tile.X = (int)tileVm.Position.X;
tile.Y = (int)tileVm.Position.Y;
if(tileVm.SelectedPresenterTemplate != null)
tile.PresenterTemplate = tileVm.SelectedPresenterTemplate.Description;
if(tileVm.SelectedGestureTemplate != null)
tile.GestureTemplate = tileVm.SelectedGestureTemplate.Name;
tile.Program = tileVm.FastContext;
foreach(var evtVm in tileVm.Events)
{
var evt = new EventData();
tile.Events.Add(evt);
evt.Name = evtVm.Name;
if(evtVm.Command != null)
evt.Command = evtVm.Command.Script;
}
}
if(viewModel.CurrentTile != null)
{
space.LastX = (int)viewModel.CurrentTile.Position.X;
space.LastY = (int)viewModel.CurrentTile.Position.Y;
}
Save(space);
}
示例6: BreakThisBuilding
public void BreakThisBuilding(TileData.Types _type, GameObject building)
{
// get me the cost of this building by finding its blueprint
Blueprint bp = GetAvailableBlueprint(_type);
Building_Handler b_Handler = building.GetComponent<Building_Handler>();
if (bp != null)
b_Handler.BreakBuilding(bp.nanoBotCost);
}
示例7: Mission
// Survival Mission:
public Mission(string name, MissionType mType, Blueprint requiredBP, TileData.Types reqResource, int reqAmnt, string desc = "Unknown Signal")
{
missionName = name;
missionType = mType;
requiredBlueprint = requiredBP;
description = desc;
objectiveResource = reqResource;
objectiveAmnt = reqAmnt;
}
示例8: SetColumnAndRow
public void SetColumnAndRow(int column, int row)
{
if (this.TileData == null) {
this.TileData = new TileData();
this.TileData.Tile = this;
}
this.TileData.Column = column;
this.TileData.Row = row;
}
示例9: GetExtractorStats
public void GetExtractorStats(string id, Transform objTransform, ExtractionBuilding extractor, TileData.Types resourceType)
{
if (extractorsMap.ContainsKey(id))
{
// Debug.Log("BP Database: Found stats for " + id);
extractor.Init(resourceType, extractorsMap[id].extractorStats.extractRate, extractorsMap[id].extractorStats.extractPower,
extractorsMap[id].extractorStats.extractAmmount, extractorsMap[id].extractorStats.personalStorageCapacity, objTransform);
}
}
示例10: CheckForBlueprint
public bool CheckForBlueprint(TileData.Types bpType)
{
if (blueprintsMap.ContainsKey(bpType))
{
return true;
}
else
return false;
}
示例11: UnsetDefenderForTile
public void UnsetDefenderForTile(TileData t)
{
DefenderData defenderData;
defenderLookup.TryGetValue (t, out defenderData);
if (defenderData != null) {
Destroy (defenderData.CurrentDefender.gameObject);
defenderData.CurrentDefender = null;
}
}
示例12: OnTerrainOrInteriorChanged
void OnTerrainOrInteriorChanged(IntVector3 p, TileData oldData, TileData newData)
{
if (oldData.HasTree != newData.HasTree)
{
if (newData.HasTree)
AddTree();
else
RemoveTree();
}
}
示例13: AddConnectedTile
public void AddConnectedTile(TileData t)
{
if (ConnectedTiles == null) {
ConnectedTiles = new List<TileData>();
ConnectedTiles.Add(t);
}
else if (!ConnectedTiles.Contains (t)) {
ConnectedTiles.Add(t);
}
}
示例14: UnsetPrisonerForTile
public void UnsetPrisonerForTile(TileData t)
{
PrisonerData prisonerData;
prisonerLookup.TryGetValue(t, out prisonerData);
if (prisonerData != null) {
Destroy(prisonerData.CurrentPrisoner.gameObject);
prisonerData.CurrentPrisoner = null;
}
}
示例15: GetNewTile
GameObject GetNewTile(TileData tileData, float width, float height)
{
var tile = GameObject.Instantiate(tilePrefab);
var tileLayoutElement = tile.GetComponent<LayoutElement>();
tileLayoutElement.preferredWidth = width;
tileLayoutElement.preferredHeight = height;
tile.GetComponent<MapTileView>().SetObject(tileData.objectOnTile);
return tile;
}