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


C# Player.ToCellState方法代码示例

本文整理汇总了C#中Player.ToCellState方法的典型用法代码示例。如果您正苦于以下问题:C# Player.ToCellState方法的具体用法?C# Player.ToCellState怎么用?C# Player.ToCellState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Player的用法示例。


在下文中一共展示了Player.ToCellState方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetReversableCellPositions

    private IEnumerable<CellPosition> GetReversableCellPositions(int row, int column, Player player)
    {
        var state = GetCellState(row, column);
        var other = player.GetOtherPlayer().ToCellState();
        var pc = player.ToCellState();

        var list = new List<CellPosition>();
        list.AddRange(GetReversableCellPositionsByDirection(row, column, -1, 0, pc, other));
        list.AddRange(GetReversableCellPositionsByDirection(row, column, 1, 0, pc, other));
        list.AddRange(GetReversableCellPositionsByDirection(row, column, 0, -1, pc, other));
        list.AddRange(GetReversableCellPositionsByDirection(row, column, 0, 1, pc, other));
        list.AddRange(GetReversableCellPositionsByDirection(row, column, -1, -1, pc, other));
        list.AddRange(GetReversableCellPositionsByDirection(row, column, -1, 1, pc, other));
        list.AddRange(GetReversableCellPositionsByDirection(row, column, 1, -1, pc, other));
        list.AddRange(GetReversableCellPositionsByDirection(row, column, 1, 1, pc, other));
        return list;
    }
开发者ID:84110,项目名称:Vantan.PS14A,代码行数:17,代码来源:OthelloView.cs

示例2: IsPlaceable

    private bool IsPlaceable(int row, int column, Player player)
    {
        var state = GetCellState(row, column);
        if (state != CellState.None) { return false; }

        var other = player.GetOtherPlayer().ToCellState();
        var pc = player.ToCellState();
        return IsPlaceableByDirection(row, column, -1 , 0, pc, other)
            || IsPlaceableByDirection(row, column, 1, 0, pc, other)
            || IsPlaceableByDirection(row, column, 0, -1, pc, other)
            || IsPlaceableByDirection(row, column, 0, 1, pc, other)
            || IsPlaceableByDirection(row, column, -1, -1, pc, other)
            || IsPlaceableByDirection(row, column, -1, 1, pc, other)
            || IsPlaceableByDirection(row, column, 1, -1, pc, other)
            || IsPlaceableByDirection(row, column, 1, 1, pc, other);
    }
开发者ID:84110,项目名称:Vantan.PS14A,代码行数:16,代码来源:OthelloView.cs

示例3: Place

    private void Place(int row, int column, Player player)
    {
        var cellState = player.ToCellState();
        UpdateCell(row, column, cellState);

        var cellPositions = GetReversableCellPositions(row, column, player);
        foreach (var pt in cellPositions)
        {
            UpdateCell(pt.Row, pt.Column, cellState);
        }
    }
开发者ID:84110,项目名称:Vantan.PS14A,代码行数:11,代码来源:OthelloView.cs

示例4: GetReversibleCellPositionsByDirection

    private IEnumerable<CellPosition> GetReversibleCellPositionsByDirection(int row, int column, int dr, int dc, Player player)
    {
        var own = player.ToCellState();
        var other = player.GetOtherPlayer().ToCellState();

        var ncp = new CellPosition(row + dr, column + dc);
        if (GetCellState(ncp.Row, ncp.Column) != other)
        {
            return new CellPosition[0];
        }

        var list = new List<CellPosition>() { ncp };
        for(var icp = new CellPosition(ncp.Row + dr, ncp.Column + dc);
            icp.Row >= 0 && icp.Column >= 0 &&
            icp.Row < Rows && icp.Column < Columns;
            icp = new CellPosition(icp.Row + dr, icp.Column + dc)
        )
        {
            var cell = GetCellState(icp.Row, icp.Column);
            if (cell == other) { list.Add(icp); }
            else if (cell == own) { return list; }
            else { break; }
        }
        return new CellPosition[0];
    }
开发者ID:LeonAkasaka,项目名称:Vantan.PS14B,代码行数:25,代码来源:OthelloTableView.cs

示例5: GetReversibleCellPositionsByDirection

        GetReversibleCellPositionsByDirection(
            CellPosition pt, int dr, int dc, Player player)
    {
        var other = player.ToOtherPlayer().ToCellState();
        var npt = new CellPosition(pt.Row + dr, pt.Column + dc);
        if (GetCellState(npt.Row, npt.Column) != other)
        {
            return new CellPosition[0];
        }

        var list = new List<CellPosition>();
        list.Add(npt);
        var pc = player.ToCellState();
        for (
            var ipt = new CellPosition(npt.Row + dr, npt.Column + dc);
            ipt.Row >= 0 && ipt.Column >= 0 &&
            ipt.Row < Rows && ipt.Column < Columns;
            ipt = new CellPosition(ipt.Row + dr, ipt.Column + dc))
        {
            var s = GetCellState(ipt.Row, ipt.Column);
            if (s == pc) { return list.ToArray(); }
            else if (s == other) { list.Add(ipt); }
            else { break; }
        }
        return new CellPosition[0];
    }
开发者ID:LeonAkasaka,项目名称:Vantan.PH14,代码行数:26,代码来源:OthelloTableView.cs

示例6: PlaceAnime

    private IEnumerator PlaceAnime(CellPosition pt, Player player)
    {
        var positions = GetReversibleCellPositions(pt, player);
        if (positions.Length == 0) { yield break; }
        
        // 新規に自分の石を置く
        _othelloCells[pt.Row, pt.Column].CellState = player.ToCellState();

        // 挟まれた石をひっくり返す
        var list = new List<OthelloCellView>();
        foreach(var rcpt in positions)
        {
            var cell = _othelloCells[rcpt.Row, rcpt.Column];
            var e = cell.UpdateCell(player.ToCellState());
            list.Add(cell);

            StartCoroutine(e);
            yield return new WaitForSeconds(0.1F);
        }

        while (true)
        {
            var isContinue = false;
            foreach (var cell in list)
            {
                if (cell.CellState != player.ToCellState())
                {
                    isContinue = true;
                    break;
                }
            }

            if (!isContinue) { break; }
            yield return null;
        }
    }
开发者ID:LeonAkasaka,项目名称:Vantan.PH14,代码行数:36,代码来源:OthelloTableView.cs

示例7: Place

    private void Place(CellPosition pt, Player player)
    {
        var positions = GetReversibleCellPositions(pt, player);
        if (positions.Length == 0) { return; }

        // 新規に自分の石を置く
        _othelloCells[pt.Row, pt.Column].CellState = player.ToCellState();
        foreach (var rcpt in positions)
        {
            var cell = _othelloCells[rcpt.Row, rcpt.Column];
            cell.CellState = player.ToCellState();
        }
    }
开发者ID:LeonAkasaka,项目名称:Vantan.PH14,代码行数:13,代码来源:OthelloTableView.cs


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