コード例 #1
0
ファイル: BoardManager.cs プロジェクト: kojikishiya/Chess
        private List<Tuple< int, int>> getCanMove(
            IEnumerable<Tuple<MoveType, int, int>> locateInfos,
            KomaBase koma)
        {
            var inBoardLocates = this.getInBoardLocate(locateInfos);
            var canMoveLocates = new List<Tuple< int, int>>();

            canMoveLocates.AddRange(this.getNotExistsAny(inBoardLocates));
            canMoveLocates.AddRange(this.getExistsEnemy(inBoardLocates));
            canMoveLocates.AddRange(this.getDirection(inBoardLocates, koma));
            canMoveLocates.AddRange(this.getNormal(inBoardLocates));

            return canMoveLocates;

        }
コード例 #2
0
ファイル: BoardManager.cs プロジェクト: kojikishiya/Chess
        private IEnumerable<Tuple< int, int>> getDirection(
            IEnumerable<Tuple<MoveType, int, int>> locationInfos
            ,KomaBase koma)
        {
            var directions = locationInfos.Where((location) =>
                location.Item1 == MoveType.Direction);
            List<Tuple< int, int>> list = new List<Tuple< int, int>>();

            foreach (var direction in directions)
            {
               int vL = direction.Item2 - koma.Left ;
               int vH =direction.Item3 - koma.Height ;
                for(int i =0;i<8;++i)
                {
                    int left = i * vL + direction.Item2;
                    int height = i * vH + direction.Item3;
                    if (!isInBoard(left) || !isInBoard(height))
                    {
                        break;

                    }
                    else if(this.existsKoma(left,height,playerNo))
                    {
                        break;
                    }
                    else if (this.existsEnemy(left, height))
                    {
                        list.Add(new Tuple<int, int>(left, height));
                        break;
                    }
                    else
                    {
                        list.Add(new Tuple<int, int>(left, height));
                    }
                }
            }
            return list;
           
        }
コード例 #3
0
ファイル: BoardManager.cs プロジェクト: kojikishiya/Chess
        internal void setClicedKoma(int left, int height)
        {
            movableLoacation = new List<Tuple<int, int>>();

            clickedKoma = this.getKoma(left, height);
            if (clickedKoma != null)
            {
                foreach (var locateInfo in this.getCanMove(clickedKoma.GetMovableLoacation(), clickedKoma))
                {
                    movableLoacation.Add(locateInfo);
                }
            }

        }
コード例 #4
0
ファイル: BoardManager.cs プロジェクト: kojikishiya/Chess
        internal void ClearClickedKoma()
        {
            clickedKoma = null;
            movableLoacation.Clear();


        }