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


C# Cell.GetComponent方法代码示例

本文整理汇总了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);
        }
开发者ID:jtabG,项目名称:Alone,代码行数:15,代码来源:TextureMapDrawState.cs

示例2: GetWallType

 private WallType? GetWallType(Cell cell)
 {
     var wall = cell.GetComponent<WallTile>();
     if (wall != null) { return wall.WallType; }
     return null;
 }
开发者ID:TheJP,项目名称:GlobalGameJam2016,代码行数:6,代码来源:RoomGenerator.cs

示例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;
       }
 }
开发者ID:satirikasha,项目名称:MatchThree,代码行数:8,代码来源:BoardEditor.cs

示例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;
       }
 }
开发者ID:satirikasha,项目名称:MatchThree,代码行数:8,代码来源:BoardEditor.cs

示例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();
    }
开发者ID:Bass-Players,项目名称:ImmunityGame,代码行数:68,代码来源:Unit.cs

示例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);

            }
        }
开发者ID:jtabG,项目名称:Alone,代码行数:11,代码来源:MapEditing.cs

示例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);

                    }
                }
        }
开发者ID:jtabG,项目名称:Alone,代码行数:20,代码来源:MapEditing.cs


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