示例#1
0
        protected override void CursorPress(Point cursor)
        {
            if (!Waiting)
            {
                var stone = new Stone((byte)cursor.X, (byte)cursor.Y, !isBlack);

                foreach (var node in currentNodes)
                {
                    if (node.X == stone.X && node.Y == stone.Y)
                    {
                        cache.Add(description, currentNodes);
                        Request(node.ID, isBlack);

                        backButton.Enabled  = false;
                        startButton.Enabled = false;

                        stone.IsBlack = !isBlack;
                        Game.PlaceStone(stone);
                        description = node.Description;

                        SoundUtils.Play("Stone");
                        Invalidate();
                        return;
                    }
                }
            }
        }
示例#2
0
        private void UpdateView(object sender, EventArgs args)
        {
            Invalidate();
            SetTimeLabel();

            if (IGSGame.MovesMade > lastMove)
            {
                SoundUtils.Play("Stone");
            }
            lastMove = IGSGame.MovesMade;
        }
示例#3
0
        public override void Edit(GoGame game, byte x, byte y)
        {
            var stone = new Stone(x, y, true);

            stone.IsBlack = game.BlackToPlay();
            if (game.CanPlace(stone))
            {
                if (!game.Continue(stone))
                {
                    game.PlaceStone(stone);
                }
                SoundUtils.Play("Stone");
            }
        }
示例#4
0
        protected virtual void CursorPress(Point cursor)
        {
            var black =
                Game.CurrentNode is GoMoveNode ?
                !(Game.CurrentNode as GoMoveNode).Stone.IsBlack :
                (Game.CurrentNode as GoSetupNode).BlackToPlay;
            var stone = new Stone((byte)cursor.X,
                                  (byte)cursor.Y,
                                  black ?? true);

            if (Game.CanPlace(stone))
            {
                Game.PlaceStone(stone);
                SoundUtils.Play("Stone");
            }
        }
示例#5
0
        private void PlaceStone(Stone stone)
        {
            GoNode node = null;

            foreach (var child in Game.CurrentNode.ChildNodes)
            {
                if (child is GoMoveNode)
                {
                    if ((child as GoMoveNode).Stone.X == stone.X &&
                        (child as GoMoveNode).Stone.Y == stone.Y)
                    {
                        node    = child;
                        message = string.Empty;
                        break;
                    }
                }
            }
            if (node != null)
            {
                Game.ToMove(node);
                if (Game.CurrentNode is GoMoveNode)
                {
                    SoundUtils.Play("Stone");
                }
                var count = node.ChildNodes.Count;
                if (count > 0)
                {
                    var variant = random.Next(0, count - 1);
                    Game.ToMove(node.ChildNodes[variant]);
                    if (Game.CurrentNode is GoMoveNode)
                    {
                        SoundUtils.Play("Stone");
                    }
                    playerTurn = true;
                }
                else
                {
                    playerTurn = false;
                }

                if (!Game.CurrentNode.HasChildren)
                {
                    if (format.IsRightVariant(Game.CurrentNode))
                    {
                        message = "Solved";
                    }
                    else
                    {
                        message = "Wrong";
                    }
                }

                Invalidate();
                SetComment();
            }
            else
            {
                message = "No path";
                Invalidate();
            }
        }