本文整理汇总了C#中Tile.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Tile.GetComponent方法的具体用法?C# Tile.GetComponent怎么用?C# Tile.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tile
的用法示例。
在下文中一共展示了Tile.GetComponent方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetTileSide
public void SetTileSide (Tile tile, GameSide tileSide) {
tile.TileSide = tileSide;
switch (tileSide) {
case GameSide.Neutral:
tile.GetComponent<SpriteRenderer>().sprite = _wallSprite;
break;
case GameSide.White:
tile.GetComponent<SpriteRenderer>().sprite = _whiteSprite;
break;
case GameSide.Black:
tile.GetComponent<SpriteRenderer>().sprite = _blackSprite;
break;
}
}
示例2: GetTiles
// Get a list of all the tiles that are connected using BFS
public List<Tile> GetTiles(Tile root)
{
List<Tile> tileList = new List<Tile>();
Queue<Tile> q = new Queue<Tile>();
q.Enqueue(root);
while (q.Count > 0)
{
// pop the first item in the queue
Tile current = q.Dequeue();
tileList.Add(current);
// if nothing pops, then all tiles have been found
if (current == null)
continue;
// loop through all of root's neighbouring tiles
foreach (Transform tile in current.Neighbours)
{
_color = root.GetComponent<Renderer>().material.color;
Color tileColor = tile.GetComponent<Renderer>().material.color;
// get the tile component from the transform
Tile t = tile.GetComponent<Tile>();
// if the two colours match, then the tile is a neighbour
// Enqueue the tile if it is not found in _tiles and in q
if (_color == tileColor && !(tileList.Contains(t)) && !(q.Contains(t)))
q.Enqueue(t);
}
}
return tileList;
}
示例3: Add
void Add(Tile _tile, bool _dynamic)
{
if (!_tile.database) return;
var _tileData = _tile.database[_tile.data];
if (_tileData == null) return;
var _gizmoPrf = _tileData.minimapGizmo ?? defaultGizmo;
var _gizmo = (GameObject)Instantiate(_gizmoPrf.gameObject);
TransformHelper.SetParentWithoutScale(_gizmo, gameObject);
_gizmo.transform.localPosition = _tile.transform.position;
var _gizmoCmp = _gizmo.GetComponent<HUDMinimapTileGizmo>();
if (_gizmoCmp)
{
_gizmoCmp.Refresh(_tile, _tileData);
var _size = _tile.data.sizeWorld;
_size.x *= _tile.transform.localScale.x;
_size.y *= _tile.transform.localScale.y;
_gizmoCmp.SetSize(_size);
}
if (_dynamic)
{
var _updatable = _tile.GetComponent<Updatable>();
if (!_updatable) goto dynamic_end;
_updatable.postUpdate += delegate { _gizmo.transform.localPosition = _tile.transform.position; };
} dynamic_end:;
}
示例4: TileAttatched
public void TileAttatched(Tile tile)
{
tileMgr.ShowCoolTime(tile);
currTile = tile;
currTile.UseTile(this);
currTile.GetComponent<BoxCollider2D>().enabled = false;
currTile.isAttatched = true;
isWaiting = false;
elapsedTime = 0;
}
示例5: Start
void Start()
{
CurrentTile = transform.parent.GetComponent<Tile>(); //set the current tile that the village is currently on
currentColor = CurrentTile.GetComponent<Renderer>().material.color;
Gold = 500;
Wood = 200;
ThisRank = Rank.Hovel; //set beginning village to hovel
Glow = transform.FindChild("Glow").gameObject;
MergeVillages m = gameObject.GetComponent<MergeVillages>();
VillageTerritory = m.GetTiles(CurrentTile);
netView = GetComponent<NetworkView>();
PathFind = transform.gameObject.GetComponentInParent<PathFinding>();
CannonballShotsTaken = 0; //start with no shots on village
}
示例6: ConvertToBomb
private void ConvertToBomb(Tile tile)
{
int originalColorIndex = tile.GetComponent<GridElement>().colorIndex;
tile.DestroyWithDelay();
GameObject bomb = Instantiate (Resources.Load ("Bomb"), tile.transform.position, Quaternion.identity) as GameObject;
bomb.GetComponent<GridElement>().colorSet = true;
bomb.GetComponent<GridElement>().survivesExplosion = false;
int factor = 1;
if(originalColorIndex >= 3){
factor *= -1;
}
bomb.GetComponent<GridElement>().UpdateColorByIndex(Mathf.Abs (originalColorIndex + (3 * factor)));
bomb.transform.parent = GameObject.Find ("Bombs").transform;
grid.GetComponent<Matrix>().InsertIntoMatrixWithoutDestroy(bomb);
Vector3 position = bomb.transform.position;
position.z = position.z - 1;
Instantiate (Resources.Load ("TileTransition"), position, Quaternion.identity);
position = bomb.transform.position;
position.z = position.z + 1;
bomb.transform.position = position;
}
示例7: findRandomEmptyTile
//This method takes in a Tile t and sees whether the village bundle associated with it has an empty tile or not.
Tile findRandomEmptyTile(Tile t)
{
HexGenerator hexgen = GameObject.Find("HexGenerator(Clone)").GetComponent<HexGenerator>(); //this code will reset ALL TILES to unvisited
t.Visited = true;
if (t.IsEmpty) return t; //base case...
foreach (Transform tile in t.Neighbours)
{ //iterate through each of tile t's neighbors
if (t.GetComponent<Renderer>().material.color == tile.transform.GetComponent<Renderer>().material.color && tile.GetComponent<Tile>().Visited != true)
//if the color of the neighbor matches the color of tile t AND has not been visited
{
tile.GetComponent<Tile>().Visited = true; //mark the neighbor tile of t as traversed
Tile test = findRandomEmptyTile(tile.GetComponent<Tile>()); //test to see what it returns
if (test != null) //if test returns some non-null value, return that tile test
{
hexgen.resetVisitedAll(); //reset visited of all tiles before returning
return test;
}
else continue; //if test is null, then look at the next neighbor to see whether there exists an empty tile in that search
}
}
return null; //search has been completed without finding any empty tiles, so return null.
}
示例8: PaintTile
public void PaintTile(Tile t, Material mat)
{
t.GetComponent<Renderer>().material = mat;
paintedTiles.Add(t);
}
示例9: Merge
private void Merge(Tile destination)
{
Unit targetUnit = destination.GetComponent<Unit>();
GetComponent<MergeUnits>().CheckForMerge(this, targetUnit, Home);
_mergeUnit = null;
}
示例10: ApplyTerrainTexture
private void ApplyTerrainTexture(Tile tile, int h, Vector3 m, float altitude)
{
// apply terrain texture
if (altitude<seaLevel)
{
tile.GetComponent<Tile>().terrain = Terrains.WATER;
}
else if (Mathf.Abs(m.y) > articCircle)
{
tile.GetComponent<Tile>().terrain = Terrains.ICE;
}
else if(Mathf.Abs(m.y) < 0.4f)
{
tile.GetComponent<Tile>().terrain = Terrains.SAND;
}
else
{
if (Random.value<0.5f)
{
// spawn a tree!
tile.GetComponent<Tile>().terrain = Terrains.FOREST;
}
}
tile.ReapplyTerrainTexture();
}
示例11: CurrentTile
public void CurrentTile(Tile t)
{
CurrentTerrainImage.sprite = t.GetComponent<SpriteRenderer>().sprite;
}
示例12: Start
void Start()
{
grid.material.color = GameParameters.Instance.selectionColour;
currentTile = Instantiate(GameParameters.Instance.tile).GetComponent<Tile>();
Destroy(currentTile.GetComponent<Collider>());
}