Пример #1
0
        private bool NoStall(Coordinate position, BarrierOrientation orientation)
        {
            var barrierPosition = new Barrier(position, orientation, BarrierPiece.Head);
            var barrierH        = new Barrier(new Coordinate(position.First + 1, position.Second), orientation, BarrierPiece.Tail);
            var barrierV        = new Barrier(new Coordinate(position.First, position.Second + 1), orientation, BarrierPiece.Tail);

            if (orientation.Equals(BarrierOrientation.Horizontal))
            {
                var playerBarrier = new List <IBarrier> {
                    barrierPosition, barrierH
                };
                if (this.barriers.GetBarriersAsGraph().ContainsPath(BarriersGraph.BarriersAsEdgesToRemove(playerBarrier), this.player1Position, this.player1FinishLine))
                {
                    if (this.barriers.GetBarriersAsGraph().ContainsPath(BarriersGraph.BarriersAsEdgesToRemove(playerBarrier), this.player2Position, this.player2FinishLine))
                    {
                        return(true);
                    }
                }
                return(false);
            }
            else
            {
                var playerBarrier = new List <IBarrier> {
                    barrierPosition, barrierV
                };
                if (this.barriers.GetBarriersAsGraph().ContainsPath(BarriersGraph.BarriersAsEdgesToRemove(playerBarrier), this.player1Position, this.player1FinishLine))
                {
                    if (this.barriers.GetBarriersAsGraph().ContainsPath(BarriersGraph.BarriersAsEdgesToRemove(playerBarrier), this.player2Position, this.player2FinishLine))
                    {
                        return(true);
                    }
                }
                return(false);
            }
        }