当前位置: 首页>>代码示例>>C#>>正文


C# Tile.GetComponent方法代码示例

本文整理汇总了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;
		}		
	}
开发者ID:ABAmvrosov,项目名称:Tess,代码行数:14,代码来源:TileFactory.cs

示例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;
	}
开发者ID:EmilioF,项目名称:UnityProjects,代码行数:36,代码来源:MergeVillages.cs

示例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:;
    }
开发者ID:JamesKim2998,项目名称:snugdc-project-ricochet,代码行数:29,代码来源:HUDMinimapTile.cs

示例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;
 }
开发者ID:penspanic,项目名称:godhelp,代码行数:10,代码来源:EventBase.cs

示例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        
	}
开发者ID:EmilioF,项目名称:UnityProjects,代码行数:19,代码来源:Village.cs

示例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;
 }
开发者ID:eiseneker,项目名称:color-puzzler,代码行数:21,代码来源:EventController.cs

示例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.
	}
开发者ID:EmilioF,项目名称:UnityProjects,代码行数:24,代码来源:Village.cs

示例8: PaintTile

 public void PaintTile(Tile t, Material mat)
 {
     t.GetComponent<Renderer>().material = mat;
     paintedTiles.Add(t);
 }
开发者ID:AndrewHarryKim,项目名称:SeanJamesMattAndrew,代码行数:5,代码来源:GameManager.cs

示例9: Merge

	private void Merge(Tile destination)
	{
		Unit targetUnit = destination.GetComponent<Unit>();
		GetComponent<MergeUnits>().CheckForMerge(this, targetUnit, Home);
		_mergeUnit = null;
	}
开发者ID:EmilioF,项目名称:UnityProjects,代码行数:6,代码来源:Peasant.cs

示例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();
 }
开发者ID:TuLLVC,项目名称:perontor,代码行数:25,代码来源:PlanetaryGeometry.cs

示例11: CurrentTile

 public void CurrentTile(Tile t)
 {
     CurrentTerrainImage.sprite = t.GetComponent<SpriteRenderer>().sprite;
 }
开发者ID:indspenceable,项目名称:tbs-roguelike,代码行数:4,代码来源:UIManager.cs

示例12: Start

 void Start()
 {
     grid.material.color = GameParameters.Instance.selectionColour;
     currentTile = Instantiate(GameParameters.Instance.tile).GetComponent<Tile>();
     Destroy(currentTile.GetComponent<Collider>());
 }
开发者ID:lukemonaghan,项目名称:MahjongTiles,代码行数:6,代码来源:LevelMaker.cs


注:本文中的Tile.GetComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。