本文整理汇总了C#中TileData类的典型用法代码示例。如果您正苦于以下问题:C# TileData类的具体用法?C# TileData怎么用?C# TileData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TileData类属于命名空间,在下文中一共展示了TileData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:Shnagenburg,项目名称:TacticsGame,代码行数:33,代码来源:FindTilesWithinRangeThreadsafe.cs
示例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;
}
开发者ID:tomba,项目名称:dwarrowdelf,代码行数:60,代码来源:TileGridReaderWriter.cs
示例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;
}
}
}
开发者ID:cesarrac,项目名称:TheyRise-game,代码行数:60,代码来源:DiscoverTile.cs
示例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);
}
开发者ID:cesarrac,项目名称:TheyRise-game,代码行数:39,代码来源:NanoBuilding_Handler.cs
示例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);
}
开发者ID:NicolasDorier,项目名称:GestSpace,代码行数:35,代码来源:GestSpaceRepository.cs
示例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);
}
开发者ID:cesarrac,项目名称:TheyRise-game,代码行数:8,代码来源:NanoBuilding_Handler.cs
示例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;
}
开发者ID:cesarrac,项目名称:TheyRise-game,代码行数:10,代码来源:Mission.cs
示例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;
}
开发者ID:Shnagenburg,项目名称:TacticsGame,代码行数:9,代码来源:Tile.cs
示例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);
}
}
开发者ID:cesarrac,项目名称:TheyRise-game,代码行数:9,代码来源:BlueprintDatabase.cs
示例10: CheckForBlueprint
public bool CheckForBlueprint(TileData.Types bpType)
{
if (blueprintsMap.ContainsKey(bpType))
{
return true;
}
else
return false;
}
开发者ID:cesarrac,项目名称:TheyRise-game,代码行数:9,代码来源:NanoBuilder.cs
示例11: UnsetDefenderForTile
public void UnsetDefenderForTile(TileData t)
{
DefenderData defenderData;
defenderLookup.TryGetValue (t, out defenderData);
if (defenderData != null) {
Destroy (defenderData.CurrentDefender.gameObject);
defenderData.CurrentDefender = null;
}
}
开发者ID:EpicPants90,项目名称:ELB,代码行数:10,代码来源:DefendingUnitManager.cs
示例12: OnTerrainOrInteriorChanged
void OnTerrainOrInteriorChanged(IntVector3 p, TileData oldData, TileData newData)
{
if (oldData.HasTree != newData.HasTree)
{
if (newData.HasTree)
AddTree();
else
RemoveTree();
}
}
开发者ID:tomba,项目名称:dwarrowdelf,代码行数:10,代码来源:EnvTreeHandler.cs
示例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);
}
}
开发者ID:EpicPants90,项目名称:ELB,代码行数:10,代码来源:TileData.cs
示例14: UnsetPrisonerForTile
public void UnsetPrisonerForTile(TileData t)
{
PrisonerData prisonerData;
prisonerLookup.TryGetValue(t, out prisonerData);
if (prisonerData != null) {
Destroy(prisonerData.CurrentPrisoner.gameObject);
prisonerData.CurrentPrisoner = null;
}
}
开发者ID:EpicPants90,项目名称:ELB,代码行数:10,代码来源:DefendingUnitManager.cs
示例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;
}
开发者ID:KarolStola,项目名称:ThePatfinder,代码行数:10,代码来源:MapView.cs
示例16: Blueprint
// For a Required Blueprint (like Terraformer, Generator, etc)
public Blueprint(string Name, TileData.Types _type, BuildingType tType)
{
buildingName = Name;
memoryCost = 0;
nanoBotCost = 0;
tileType = _type;
description = " ";
buildingType = tType;
}
开发者ID:cesarrac,项目名称:TheyRise-game,代码行数:11,代码来源:Blueprint.cs
示例17: GetTileData
/**
*
*/
public override bool GetTileData(Vector3Int location, ITileMap tileMap, ref TileData tileData)
{
base.GetTileData(location, tileMap, ref tileData);
int mask = GetMask(location, tileMap, ref tileData);
int index = GetIndex(mask);
tileData.sprite = GetTileSprite(index);
tileData.gameobject = GetTileGameObject(index);
return true;
}
开发者ID:thijsdaniels,项目名称:Metroidvania,代码行数:15,代码来源:MorphTile.cs
示例18: AddBluePrint
public void AddBluePrint(TileData.Types bpType, Blueprint bp)
{
blueprintsMap.Add(bpType, bp);
if (bpType != TileData.Types.terraformer)
{
cur_memory -= bp.memoryCost;
}
if (!bpTypes.Contains(bpType))
bpTypes.Add(bpType);
}
开发者ID:cesarrac,项目名称:TheyRise-game,代码行数:12,代码来源:NanoBuilder.cs
示例19: SetupTags
private void SetupTags(TileData wall, Point textTagTilePosition)
{
foreach (var textTag in wall.TextTags.Where(x => !x.Processed && x.GetParentPosition(textTagTilePosition) == CurrentTile.GridPosition))
{
textTag.Processed = true;
var tag = new TextTag(builder.GetWallPosition(textTag.TilePosition, CurrentTile), textTag.IsVisible,
textTag.TilePosition == TilePosition.East_TopRight || textTag.TilePosition == TilePosition.West_BottomRight, textTag.Text.Replace("|", Environment.NewLine))
{
AcceptMessages = textTag.HasTargetingActuator
};
CurrentTile.SubItems.Add(tag);
}
}
开发者ID:ggrrin,项目名称:DungeonMaster,代码行数:13,代码来源:WallActuatorCreator.cs
示例20: IsTraversable
public static bool IsTraversable(TileData tileData, FindTilesWithinRangeDTO dto)
{
if (tileData == null) {
return false;
}
if (tileData.OccupiedTeam == dto.MoveThroughMask) {
return false;
}
if (dto.MoveThroughMask == TeamId.MOVE_THROUGH_NONE && tileData.OccupiedTeam != -1) {
return false;
}
return true;
}
开发者ID:Shnagenburg,项目名称:TacticsGame,代码行数:13,代码来源:FindTilesWithinRangeThreadsafe.cs
注:本文中的TileData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论