本文整理汇总了C#中Cell.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Cell.GetComponent方法的具体用法?C# Cell.GetComponent怎么用?C# Cell.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cell
的用法示例。
在下文中一共展示了Cell.GetComponent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawAtPoint
public override void DrawAtPoint(Cell cell, Vector2 point)
{
var pointInCell = Map.WorldToLocalTile(point);
cell.Tiles[(int)pointInCell.y * Map.NumberOfTiles + (int)pointInCell.x].TextureIndex = _currentTileIndex;
var texture = (Texture2D)cell.GetComponent<Renderer>().sharedMaterial.mainTexture;
// pTexture is point in texture coords
Vector2 pTexture = pointInCell * Map.TileResolution;
texture.SetPixels((int)pTexture.x, (int)pTexture.y, Map.TileResolution, Map.TileResolution, _currentTileColors);
// For performance, don't update right away instead do them all at once at the end
_textureUpdate.Add(texture);
}
示例2: GetWallType
private WallType? GetWallType(Cell cell)
{
var wall = cell.GetComponent<WallTile>();
if (wall != null) { return wall.WallType; }
return null;
}
示例3: SelectCell
private void SelectCell(Cell cell)
{
switch(Mode) {
case BoardEditorMode.Delete: cell.GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 0.5f); break;
case BoardEditorMode.Restore: var renderer = cell.GetComponent<SpriteRenderer>(); renderer.enabled = true; renderer.color = new Color(1, 1, 1, 0.5f); break;
default: cell.GetComponent<SpriteRenderer>().color = Color.green; break;
}
}
示例4: DeselectCell
private void DeselectCell(Cell cell)
{
switch(Mode) {
case BoardEditorMode.Delete: cell.GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 1); break;
case BoardEditorMode.Restore: var renderer = cell.GetComponent<SpriteRenderer>(); renderer.color = new Color(1, 1, 1, 1); if(cell.Data.IsVoid) renderer.enabled = false; break;
default: cell.GetComponent<SpriteRenderer>().color = Color.white; break;
}
}
示例5: MoveToCell
/// <summary>
/// This (unit) moves to a given cell.
/// </summary>
/// <param name="cell">The cell which the unit moves to.</param>
/// <returns>Waits till the end frame.</returns>
public IEnumerator MoveToCell(Cell cell, bool spawn)
{
Board.Instance.MovingMode = true;
Debug.Log (Board.Instance.MovingMode);
EndTurnPanel.Instance.EnableEndTurnButton (false);
cell.ResetCellValues();
Node unitPosition =
Board.Instance.Graph[Board.Instance.SelectedUnit.CellPosition.X, Board.Instance.SelectedUnit.CellPosition.Y];
Stack<Node> path;
if (!spawn)
{
path = cell.SetPath(Board.Instance.Graph[cell.X, cell.Y],
Board.Instance.Graph[unitPosition.X, unitPosition.Y],
new Stack<Node>(),
Board.Instance.Graph[cell.X, cell.Y].H);
}
else
{
List<Node> spawnPath = new List<Node>();
spawnPath.Add(Board.Instance.Graph[cell.X, cell.Y]);
spawnPath = Board.Instance.SelectedBase.FindSpawnPath(Board.Instance.Graph[cell.X, cell.Y], spawnPath);
path = new Stack<Node>(spawnPath);
}
_animator = this.GetComponent<Animator>();
_animator.Play("Walk");
_animator.speed = 2f;
foreach (Node n in path)
{
PlaySound("Walk");
yield return
StartCoroutine(MoveToNextNode(this.transform.position,
new Vector3(n.X, n.Y, this.gameObject.transform.position.z), 2f, n));
}
Board.Instance.SelectedUnit.CellPosition = cell;
Board.Instance.SelectedUnit.CellPosition.IsInMovementRange = false;
Board.Instance.SelectedUnit.CellPosition.PlacedUnit = this;
cell.GetComponent<MeshRenderer>().material.color = Board.Instance.SelectedUnit.SelectionColor;
cell.IsOccupied = true;
_animator.Play("Idle");
EndTurnPanel.Instance.EnableEndTurnButton (true);
if (!TurnOver)
{
if (!CheckEnemiesInAttackRange())
{
UnitTurnIsOver();
this.DeselectUnit();
}
}
else
{
UnitTurnIsOver();
this.DeselectUnit();
}
Board.Instance.MovingMode = false;
GameController.Instance.IsDone();
}
示例6: CheckMeshInDictionary
private void CheckMeshInDictionary(Cell cell)
{
if (!_verts.ContainsKey(cell))
{
var mf = cell.GetComponent<MeshFilter>();
var mesh = mf.sharedMesh;
_verts.Add(cell, mesh.vertices);
}
}
示例7: UpdateHeights
private void UpdateHeights(Cell cell)
{
var mesh = cell.GetComponent<MeshFilter>().sharedMesh;
var numOfVerts = _map.NumberOfTiles + 1;
for (var y = 0; y < _map.NumberOfTiles; y++)
{
for (var x = 0; x < _map.NumberOfTiles; x++)
{
var vx = mesh.vertices[y * numOfVerts + (x + 1)];
var vy = mesh.vertices[(y + 1) * numOfVerts + x];
var height = (vx.y + vy.y) / 2f;
cell.UpdateHeight(x, y, height);
}
}
}