Ejemplo n.º 1
0
        protected override bool Update()
        {
            // Convert Next
            Tip   tip      = _model.GetTip(); // Get raw Tip
            Tuple tipTuple = tip.Tuple;

            _model.AcquireResourceMutex(Model.Model.MutexType.TIP);
            if (tipTuple == null)
            {
                // No path node existed, release & return
                _model.ReleaseResourceMutex(Model.Model.MutexType.TIP);
                return(false);
            }
            if (tip.IsActive == false)
            {
                // Tip is not activated, release & return
                _model.ReleaseResourceMutex(Model.Model.MutexType.TIP);
                return(false);
            }
            // Convert
            _pairList    = new Point[2];
            _pairList[0] = new Point(tipTuple.GetFirst().X, tipTuple.GetFirst().Y);
            _pairList[1] = new Point(tipTuple.GetSecond().X, tipTuple.GetSecond().Y);
            _model.ReleaseResourceMutex(Model.Model.MutexType.TIP);

            return(true);
        }
Ejemplo n.º 2
0
        public override void Paint(Graphics g)
        {
            // Determine the game state
            if (_model.GetState() == Model.Model.GameState.PLAYING)
            {
                // Paint all blocks
                Block[][] map = _model.GetMap();
                for (int i = 1; i <= 10; ++i)
                {
                    for (int j = 1; j <= 8; ++j)
                    {
                        _paintBlock(g, i, j, map[i][j].GetImageId());
                    }
                }

                // Paint boarder of selected blocks
                Tuple    tuple     = _model.GetSelectedBlocksTuple();
                Position firstPos  = tuple.GetFirst();
                Position secondPos = tuple.GetSecond();
                if (firstPos != null)
                {
                    PaintBoarder(g, _boarderPen, firstPos.X, firstPos.Y);
                }
                if (secondPos != null)
                {
                    PaintBoarder(g, _boarderPen, secondPos.X, secondPos.Y);
                }
            }
        }