public Turn ConvertMoveToTurn(MoveWrapper mw)
        {
            CommunicationProtocol.MoveType mt = CommunicationProtocol.MoveType.Insert;
            switch (mw.GetMoveType())
            {
                case engine.wrapper.MoveType.INSERT:
                    mt = CommunicationProtocol.MoveType.Insert;
                    break;
                case engine.wrapper.MoveType.JUMP:
                    mt = CommunicationProtocol.MoveType.Jump;
                    break;
                case engine.wrapper.MoveType.STEP:
                    mt = CommunicationProtocol.MoveType.Move;
                    break;
            }

            Turn t = new Turn();
            t.MoveType = mt;
            if (mw.HasUsedCell())
            {
                t.EmptyTile = ConvertBoardPositionToInt(mw.GetUsedCell());
            }
            else
            {
                t.EmptyTile = null;
            }

            if (mw.GetMoveType() == engine.wrapper.MoveType.INSERT)
            {
                t.FromTile = ConvertBoardPositionToInt(mw.GetToCell());
                t.Direction = Direction.None;
            }
            else
            {
                t.FromTile = ConvertBoardPositionToInt(mw.GetFromCell());
                t.Direction = CalculateDirection(mw.GetToCell(), mw.GetFromCell());
            }

            return t;
        }
 public String MoveWrapperToString(MoveWrapper mw)
 {
     if (mw.HasUsedCell())
         return String.Format("MOVE: Type {0}, FTU: {1},{2},{3}", mw.GetMoveType(), mw.GetFromCell(), mw.GetToCell(), mw.GetUsedCell());
     return String.Format("MOVE: Type {0}, FTU: {1},{2}, None", mw.GetMoveType(), mw.GetFromCell(), mw.GetToCell());
 }
Пример #3
0
        private void OnMoveExecuted(MoveWrapper move)
        {
            if (move.GetMoveType() == MoveType.INSERT)
            {
                _lastMoveHighlight[0] = move.GetToCell();
            }
            else
            {
                _lastMoveHighlight[0] = move.GetFromCell();
                _lastMoveHighlight[1] = move.GetToCell();

                // Adjust coordinates if board moved around.
                if (_lastMoveHighlight[1].X < 0)
                {
                    _lastMoveHighlight[0].X++;
                    _lastMoveHighlight[1].X++;
                }
                if (_lastMoveHighlight[1].Y < 0)
                {
                    _lastMoveHighlight[0].Y++;
                    _lastMoveHighlight[1].Y++;
                }
                if (move.HasUsedCell() &&
                    karoGame.KaroGameManager.Board.GetRelativeCellAt(
                        move.GetUsedCell()).HasTile())
                {
                    if (move.GetUsedCell().X == 0 &&
                        move.GetToCell().X >= 0 &&
                        move.GetToCell().Y >= 0)
                    {
                        _lastMoveHighlight[0].X--;
                        _lastMoveHighlight[1].X--;
                    }
                    if (move.GetUsedCell().Y == 0 &&
                        move.GetToCell().X >= 0 &&
                        move.GetToCell().Y >= 0)
                    {
                        _lastMoveHighlight[0].Y--;
                        _lastMoveHighlight[1].Y--;
                    }
                }
            }
            if (_highlightThread.IsAlive)
            {
                _showHighlight = false;
                _highlightThread.Join();
            }
            _highlightThread = new Thread(RemoveHighlightAfterOneSecond);
            _highlightThread.Start();
        }