コード例 #1
0
        public Turn TryGetHumanTurn(Player player, GlInput input)
        {
            string result = "";

            if (player.team == 0)
            {
                result = SolverA.Run(player.lastInput);
            }
            else if (player.team == 1)
            {
                result = SolverB.Run(player.lastInput);
            }
            else if (player.team == 2)
            {
                result = SolverC.Run(player.lastInput);
            }
            else
            {
                result = SolverD.Run(player.lastInput);
            }

            return(GetProgramTurn(player, result, ExecuteResult.Ok, "ok"));
        }
コード例 #2
0
        public void DrawAll(Frame frame, double stage, double totalStage, bool humanMove, GlInput input) //todo human move??
        {
            frame.CameraViewport(Vector2d.Zero, _arena.size * 1.1);
            frame.Polygon(Color.Gray, new Rect2d(0, 0, 10000, 10000));
            frame.Polygon(Color.LightGray, _arena);
            for (int i = 0; i < 4; i++)
            {
                var color = roundNumber - players[i].man.lastFreezed < 300 / SPEED_FASTER ? Color.Black : players[i].color;
                frame.Circle(color, _manAnimators[i].Get(stage), MAN_RADIUS);
                frame.Circle(Color.Black, _manAnimators[i].Get(stage) + (_manList[i].speedVector).Normalized() * MAN_RADIUS, MAN_RADIUS / 10.0);
                frame.TextCenter(EFont.black, players[i].man.hp.ToString(), _manAnimators[i].Get(stage));
            }
            for (int i = 0; i < _shellList.Count; i++)
            {
                frame.Circle(Color.DarkGreen, _shellAnimators[i].Get(stage), SHELL_RADIUS);
            }
            _walls.ForEach(wall => frame.Polygon(Color.Brown, wall));

            frame.TextTopLeft(EFont.ScoreOne, string.Join("   ", players.Select(x => x.score)), 10, 10);
        }
コード例 #3
0
ファイル: Board.cs プロジェクト: LightRay2/ContestFramework
        public Turn TryGetHumanTurn(Player player, GlInput input)//todo keyboard to input
        {
            this.RotateField(player.team);

            var keys = new Dictionary <Key, Point> {
                { Key.Left, PointDifference(this.RotatePoint(new Point(0, -1), player.team, 0), this.RotatePoint(new Point(0, 0), player.team, 0)) },
                { Key.Right, PointDifference(this.RotatePoint(new Point(0, 1), player.team, 0), this.RotatePoint(new Point(0, 0), player.team, 0)) },
                { Key.Up, PointDifference(this.RotatePoint(new Point(-1, 0), player.team, 0), this.RotatePoint(new Point(0, 0), player.team, 0)) },
                { Key.Down, PointDifference(this.RotatePoint(new Point(1, 0), player.team, 0), this.RotatePoint(new Point(0, 0), player.team, 0)) }
            };

            if (player.humanSelectsDestination)
            {
                if (input.KeyTime(Key.Enter) == 1)
                {
                    player.humanSelectsDestination = false;
                    if (GetAllPossibleDestinations(this.field, player.humanSource).Contains(player.humanDestination))
                    {
                        return(new Turn
                        {
                            firstValidCommand =
                                Tuple.Create(player.humanSource, player.humanDestination)
                            ,
                            colorOnTimeLine = player.color,
                            colorStatusOnTimeLine = Color.Red,
                            nameOnTimeLine = (this.roundNumber / 4).ToString(),
                            shortStatus = "Ручной ход"
                        });
                    }
                }
                foreach (var item in keys)
                {
                    if (input.KeyTime(item.Key) == 1)
                    {
                        var aim = player.humanDestination;
                        aim.Offset(item.Value);
                        if (Val(aim))
                        {
                            player.humanDestination = aim;
                        }
                    }
                }
            }
            else
            {
                if (input.KeyTime(Key.Enter) == 1)
                {
                    player.humanSelectsDestination = true;
                    player.humanDestination        = player.humanSource;
                }
                foreach (var item in keys)
                {
                    if (input.KeyTime(item.Key) == 1)
                    {
                        var aim = player.humanSource;
                        aim.Offset(item.Value);
                        if (Val(aim))
                        {
                            player.humanSource = aim;
                        }
                    }
                }
            }

            return(null);
        }
コード例 #4
0
ファイル: Board.cs プロジェクト: LightRay2/ContestFramework
        public void DrawAll(Frame frame, double stage, double totalStage, bool humanMove, GlInput input)
        {
            //todo implement as out parameter
            //statusBarText = "";

            //you can preload sprites or not

            double frameWidth  = 800;
            double frameHeight = 600;

            //total 509 509
            //49 49
            //8 10 (x y)
            frame.CameraViewport(frameWidth, frameHeight);
            #region board game draw
            //frame.TextCustom(EFont.small, "маленький текст o k очень много текста длинный тест", new Vector2d(0.0, 0), new Vector2d(200, 200), Align.justify, 200);
            //frame.TextCustom(EFont.small, "маленький текст o k очень много текста длинный тест", new Vector2d(0.5, 0.5), new Vector2d(200, 200), Align.justify, 200, 3);
            //frame.TextCustom(EFont.small, "маленький текст o k очень много текста длинный тест", new Vector2d(1.0, 0.2), new Vector2d(200, 500), Align.justify, 200);
            //  frame.SpriteCustom(ESprite.board10, 0, 0, 0, 0, 0, SpecialDraw.All(1, 1, 0, 2, 0.5));
            //frame.SpriteCustom(ESprite.Design, 0.5, 0.5, 400, 400, 30, SpecialDraw.All(0.6, 0.6, 1, -2, 1));



            var boardTopLeft   = new Vector2d(66, 73);
            var corner         = new Vector2d(73, 82);
            var oppositeCorner = new Vector2d(488, 517);
            var tileSize       = (oppositeCorner - corner) / 10;

            double teamNamesHeight = 45;

            //доска и шашки
            frame.SpriteCorner(ESprite.background, 0, 0);



            frame.SpriteCorner(ESprite.board10, boardTopLeft);


            var firstTileCenter = corner + tileSize / 2;
            var spritePlayers   = new List <ESprite> {
                ESprite.green,
                ESprite.red,
                ESprite.violet,
                ESprite.yellow
            };
            var spritePlayerRects = new List <ESprite> {
                ESprite.greenRect,
                ESprite.redRect,
                ESprite.violetRect,

                ESprite.yellowRect
            };

            //подсвечиваем противоположный от ходящего уголок
            var center = this.teamTurn == 0 ? new Vector2d(8) :
                         this.teamTurn == 1 ? new Vector2d(2, 8) :
                         this.teamTurn == 2 ? new Vector2d(2) :
                         new Vector2d(8, 2);

            frame.SpriteCenter(spritePlayerRects[this.teamTurn], corner + tileSize.MultEach(center), sizeExact: tileSize * 4, opacity: 0.7);



            this.RotateField(0);
            for (int row = 0; row < 10; row++)
            {
                for (int col = 0; col < 10; col++)
                {
                    var player = this.field[row, col];
                    if (player == null)
                    {
                        continue;
                    }
                    var movingOnRoundTileInPlayer0 = this.RotatePoint(player.movingOnRoundTile, 0, this.teamTurn);
                    if (player.movingOnRound == this.roundNumber &&
                        movingOnRoundTileInPlayer0.X == row && movingOnRoundTileInPlayer0.Y == col)
                    {
                        //значит на этом ходу шашка перемещается, ее рисуем между клетками и выше всех
                        double curPartOfPath = this.playerAnimator.Get(stage);

                        int index = (int)curPartOfPath.ToRange(0, this.movePath.Count - 2);

                        double curPartOfSingleMove = curPartOfPath - index;//- index * (totalStage / (this.movePath.Count - 1));
                        var    fromPoint           = new Point(this.movePath[index].Y, this.movePath[index].X);
                        var    toPoint             = new Point(this.movePath[index + 1].Y, this.movePath[index + 1].X);
                        var    from     = firstTileCenter + tileSize.MultEach(PointToVector(this.RotatePoint(fromPoint, this.teamTurn, 0)));
                        var    to       = firstTileCenter + tileSize.MultEach(PointToVector(this.RotatePoint(toPoint, this.teamTurn, 0)));
                        var    position = from + (to - from) * curPartOfSingleMove;
                        frame.SpriteCenter(spritePlayers[player.team],
                                           position, depth: 1);//рисуем выше всех
                    }
                    else
                    {
                        frame.SpriteCenter(spritePlayers[player.team],
                                           firstTileCenter + tileSize.MultEach(new Vector2d(col, row)));
                    }
                }
            }


            #region названия команд и счет, номер хода
            double fromBoardToNearest  = 12;
            double fromBoardToFarthest = 62;
            double sideProtrusion      = 40;

            var boardSize = SpriteList.All[ESprite.board10].DefaultDrawSettings.sizeExact.Value;

            Vector2d[] textPosition = new[] {
                boardTopLeft - new Vector2d(sideProtrusion, fromBoardToNearest),
                boardTopLeft - new Vector2d(sideProtrusion, fromBoardToNearest),
                boardTopLeft + new Vector2d(0, boardSize.X) + new Vector2d(sideProtrusion, fromBoardToNearest),
                boardTopLeft + new Vector2d(0, boardSize.X) + new Vector2d(sideProtrusion, fromBoardToNearest)
            };

            //top names
            frame.TextBottomLeft(EFont.teamSmall3, this.players[2].name,
                                 boardTopLeft - new Vector2d(sideProtrusion, fromBoardToNearest),
                                 boardSize.X + sideProtrusion * 2, Align.left);
            frame.TextBottomLeft(EFont.teamSmall4, this.players[3].name,
                                 boardTopLeft - new Vector2d(sideProtrusion, fromBoardToNearest),
                                 boardSize.X + sideProtrusion * 2, Align.right);
            //bottom names
            frame.TextBottomLeft(EFont.teamSmall2, this.players[1].name,
                                 boardTopLeft + new Vector2d(0, boardSize.Y) + new Vector2d(-sideProtrusion, fromBoardToFarthest),
                                 boardSize.X + sideProtrusion * 2, Align.left);
            frame.TextBottomLeft(EFont.teamSmall1, this.players[0].name,
                                 boardTopLeft + new Vector2d(0, boardSize.Y) + new Vector2d(-sideProtrusion, fromBoardToFarthest),
                                 boardSize.X + sideProtrusion * 2, Align.right);

            var scores = this.players.Select(x => { this.RotateField(x.team); return(GetDistanceToWin(this.field, x)); }).ToList();
            //top scores
            frame.TextTopLeft(EFont.teamBig3, scores[2].ToString(),
                              boardTopLeft - new Vector2d(sideProtrusion, fromBoardToFarthest),
                              boardSize.X + sideProtrusion * 2, Align.left);
            frame.TextTopLeft(EFont.teamBig4, scores[3].ToString(),
                              boardTopLeft - new Vector2d(sideProtrusion, fromBoardToFarthest),
                              boardSize.X + sideProtrusion * 2, Align.right);
            //bottom scores
            frame.TextTopLeft(EFont.teamBig2, scores[1].ToString(),
                              boardTopLeft + new Vector2d(0, boardSize.Y) + new Vector2d(-sideProtrusion, fromBoardToNearest),
                              boardSize.X + sideProtrusion * 2, Align.left);
            frame.TextTopLeft(EFont.teamBig1, scores[0].ToString(),
                              boardTopLeft + new Vector2d(0, boardSize.Y) + new Vector2d(-sideProtrusion, fromBoardToNearest),
                              boardSize.X + sideProtrusion * 2, Align.right);

            //turn number
            frame.TextCenter(EFont.regular, string.Format("- {0} -", this.lastPlayerMadeTurns),
                             boardTopLeft.X + boardSize.X / 2, boardTopLeft.Y / 2);
            #endregion

            //выбор ходов и логирование



            //управление с клавиатуры
            if (humanMove)
            {
                double opacity         = 0.7;
                var    tileSource      = this.RotatePoint(this.players[this.teamTurn].humanSource, 0, this.teamTurn);
                var    tileDestination = this.RotatePoint(this.players[this.teamTurn].humanDestination, 0, this.teamTurn);
                if (this.players[this.teamTurn].humanSelectsDestination == true)
                {
                    frame.SpriteCenter(ESprite.humanSource, firstTileCenter + tileSize.MultEach(new Vector2d(tileSource.Y, tileSource.X)), opacity: opacity);
                    frame.SpriteCenter(ESprite.humanPointer, firstTileCenter + tileSize.MultEach(new Vector2d(tileDestination.Y, tileDestination.X)), opacity: opacity);
                }
                else
                {
                    frame.SpriteCenter(ESprite.humanPointer, firstTileCenter + tileSize.MultEach(new Vector2d(tileSource.Y, tileSource.X)), opacity: opacity);
                }


                this.RotateField(0);
                if (this.field[tileSource.X, tileSource.Y] != null && this.field[tileSource.X, tileSource.Y].team == this.teamTurn)
                {
                    var allPossible = GetAllPossibleDestinations(this.field, tileSource);
                    allPossible.ForEach(p => frame.SpriteCenter(ESprite.humanDestination, firstTileCenter + tileSize.MultEach(new Vector2d(p.Y, p.X)), opacity: opacity));
                }
            }

            #endregion


            #region timeline
            //{
            //    if (!initialized)
            //        InitTimeLine();

            //    double thinWidth = 2, thickWidth = 4;
            //    var colorLight = Color.FromArgb(80, 48, 66, 76);
            //    var colorDark = Color.FromArgb(120, 41, 58, 68);
            //    var colorLine = Color.Black;
            //    var colorCurrent = Color.Red;
            //    var colorMouse = Color.Orange;

            //    //текущий размер блока и привязка верха(привязка не может быть меньше 0)


            //    //отрисуем , что есть +текущую позицию + указатель мыши + раскрасим под мышью + найдем точную временную позицию мыши

            //    #region old commented
            //    //double prevStart = 0;
            //    //var roundList = this.rounds
            //    //    .Select(r =>
            //    //    {
            //    //        var duration = Math.Max(0.1, r.totalStage);//чтобы можно было ход мышкой выбрать
            //    //        var res = new { name = r.nameForTimeLine, duration = duration, start = prevStart + duration };
            //    //        prevStart = res.start;
            //    //        return res;
            //    //    }).ToList();
            //    //double currentPos = roundList[ this.roundNumber].start + stage;
            //    #endregion

            //    #region прямоугольник и клетки
            //    var roundVisibleRects = new List<Tuple<int, Rect2d>>();
            //    frame.Path(colorLine, thickWidth, rect);
            //    if (currentTopTime < 0)
            //        currentTopTime = 0;

            //    double zeroY = rect.top - currentTopTime * currentHeightPerRound;
            //    for (int i = 0; i < this.rounds.Count; i++)
            //    {
            //        double top = zeroY + i * currentHeightPerRound;
            //        double bottom = top + currentHeightPerRound;
            //        var bottomInsideRect = bottom.IsInRange(rect.top, rect.bottom, true);
            //        var topIndiseRect = top.IsInRange(rect.top, rect.bottom, true);
            //        var topAboveBottomBelow = top <= rect.top && bottom >= rect.bottom;
            //        if (bottomInsideRect)
            //        {
            //            frame.Path(colorLine, thickWidth,
            //                rect.left, bottom, rect.right, bottom);

            //        }
            //        if (topIndiseRect || bottomInsideRect || topAboveBottomBelow)
            //        {
            //            var realTop = Math.Max(rect.top, top);
            //            var realBottom = Math.Min(rect.bottom, bottom);
            //            roundVisibleRects.Add(Tuple.Create(i, new Rect2d(rect.left, realTop, rect.size.X, realBottom - realTop)));
            //            if (realBottom - realTop >= minDistBetweenLines)
            //            {
            //                frame.TextCenter(EFont.regular, this.rounds[i].nameForTimeLine,
            //                    (rect.right + rect.left) / 2, (realTop + realBottom) / 2);
            //            }
            //        }
            //    }
            //    #endregion

            //    double currentPos = this.roundNumber + (stage / totalStage).ToRange(0, 1);
            //    var currentPosY = zeroY + currentPos * currentHeightPerRound;
            //    if (currentPosY.IsInRange(rect.top, rect.bottom, true))
            //    {
            //        frame.Path(colorCurrent, thickWidth, rect.left, currentPosY, rect.right, currentPosY);
            //    }

            //    Cursor.Show();
            //    foreach (var roundRect in roundVisibleRects)
            //    {
            //        if (GeomHelper.PointInSimpleRect(input.Mouse, roundRect.Item2))
            //        {
            //            Cursor.Hide();
            //            var top = zeroY + roundRect.Item1 * currentHeightPerRound;
            //            var distanceToTop = input.Mouse.Y - top;
            //            var mouseY = (distanceToTop <= mouseDropMaxDistance) ? top : input.Mouse.Y;
            //            frame.Path(colorMouse, thickWidth, rect.left, mouseY, rect.right, mouseY);


            //            if (input.LeftMouseUp)
            //            {
            //                frame.Polygon(colorDark, roundRect.Item2);
            //                //go to
            //            }
            //            else
            //            {
            //                frame.Polygon(colorLight, roundRect.Item2);
            //            }
            //            break;
            //        }
            //    }

            //    //обработаем колесико
            //    if (GeomHelper.PointInSimpleRect(input.Mouse, rect))
            //    {
            //        if (input.Wheel != 0)
            //        {
            //            //нужно оставить то, что под мышкой, на месте, и при этом изменить height
            //            double k = 1 + input.Wheel / 10.0;
            //            double mousePosTime = (input.Mouse.Y - zeroY) / currentHeightPerRound;
            //            if (mousePosTime > this.rounds.Count && input.Wheel > 0)
            //                mousePosTime = this.rounds.Count;
            //            currentHeightPerRound *= k;
            //            double curDist = mousePosTime - currentTopTime;
            //            currentTopTime = mousePosTime - curDist / k;
            //            if (currentTopTime < 0)
            //                currentTopTime = 0;
            //        }
            //    }


            //    //сделаем переключение хода, если был клик

            //    //обработаем колесико и стрелочки вверх-вниз

            //    //если текущая позиция за кадром и мышь не наведена , перейти на нее

            //}
            #endregion
        }
コード例 #5
0
ファイル: Game.cs プロジェクト: LightRay2/ContestFramework
        public void DrawAll(Frame frame, double stage, double totalStage, bool humanMove, GlInput input) //todo human move??
        {
            if (allColors.Count == 0)
            {
                for (int i = 0; i <= 3; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        for (int k = 0; k < 4; k++)
                        {
                            allColors.Add(Color.FromArgb(i * 85, j * 85, k * 85));
                        }
                    }
                }
            }
            if (Debugger.IsAttached)
            {
                if (input.KeyTime(Key.Z) == 1)
                {
                    currentFieldColor = RandomColor();
                }
                if (input.KeyTime(Key.X) == 1)
                {
                    currentFieldOpacity += 0.1;
                    if (currentFieldOpacity > 1)
                    {
                        currentFieldOpacity = 0.5;
                    }
                }
                if (input.KeyTime(Key.C) == 1)
                {
                    topColorIndex++;
                    if (topColorIndex >= topColorList.Count)
                    {
                        topColorIndex = 0;
                    }
                    currentFieldColor = topColorList[topColorIndex];
                }
                if (input.KeyTime(Key.V) == 1)
                {
                    blackOpacity += 10;
                    if (blackOpacity >= 250)
                    {
                        blackOpacity = 40;
                    }
                }
                if (input.KeyTime(Key.B) == 1)
                {
                    blackOpacity = 0;
                    allColorIndex++;
                    if (allColorIndex >= allColors.Count)
                    {
                        allColorIndex = 0;
                    }
                    currentFieldColor = allColors[allColorIndex];
                }
            }

            // topColorIndex = 6;
            // currentFieldColor = topColorList[topColorIndex];
            blackOpacity        = 170;
            currentFieldOpacity = 0.90;

            //!!! будьте внимательны (ранний drawall перед любыми методами)
            int frameWidth = 112, frameHeight = 84;

            frame.CameraViewport(frameWidth, frameHeight);

            frame.Polygon(currentFieldColor, new Rect2d(0, 0, frameWidth, frameHeight)); //todo line around polygon

            var fieldCorner = new Vector2d((frameWidth - _arena.size.X - FrameworkSettings.Timeline.TileWidth) / 2, (frameHeight - _arena.size.Y) / 2);
            var lineWidth   = 0.4;

            //frame.Path(Color.Black, lineWidth, _arena + fieldCorner);
            //frame.Path(Color.Black, lineWidth, fieldCorner + new Vector2d(_arena.size.X / 2, 0), fieldCorner + new Vector2d(_arena.size.X / 2, _arena.size.Y));


            frame.SpriteCorner(ESprite.fieldPerfect, fieldCorner, sizeExact: _arena.size, opacity: currentFieldOpacity, depth: 1);
            // if (_manAnimators.Count != 0) //т е еще не было process turn
            //  {


            var blackColor = Color.FromArgb(blackOpacity, 0, 0, 0);

            frame.Polygon(blackColor, new Rect2d(0, 0, 1000, fieldCorner.Y));
            frame.Polygon(blackColor, new Rect2d(0, fieldCorner.Y, fieldCorner.X, _arena.size.Y));
            frame.Polygon(blackColor, new Rect2d(fieldCorner.X + _arena.size.X, fieldCorner.Y, 1000, _arena.size.Y));
            frame.Polygon(blackColor, new Rect2d(0, fieldCorner.Y + _arena.size.Y, 1000, 1000));


            for (int i = 0; i < _manList.Count; i++)
            {
                var man = _manList[i];
                if (i < 5)
                {
                    frame.SpriteCenter(ESprite.man03, _manAnimators[i].Get(stage) + fieldCorner, sizeOnlyWidth: 4, depth: 2, opacity: 1.0);
                }
                else
                {
                    frame.SpriteCenter(ESprite.man04, _manAnimators[i].Get(stage) + fieldCorner, sizeOnlyWidth: 4, depth: 2);
                }
                //frame.Circle(man.Color, _manAnimators[i].Get(stage) + fieldCorner, _manRadius);

                frame.TextCenter(EFont.playerNumbers, (i % 5).ToString(), _manAnimators[i].Get(stage) + fieldCorner, depth: 3);
            }

            //   var curMan = _manAnimators[6].Get(stage);



            //frame.Circle(Color.Gray, _ballAnimator.Get(stage) + fieldCorner, _ballRadius);
            if (_drawBall)
            {
                frame.SpriteCenter(ESprite.ball, _ballAnimator.Get(stage) + fieldCorner, sizeOnlyWidth: 2, depth: 2);
            }

            // }

            frame.TextBottomLeft(EFont.TeamOne, players[0].name, fieldCorner.X, fieldCorner.Y - 3); //todo framework text without declaration?
            frame.TextCustomAnchor(EFont.TeamTwo, players[1].name, 1, 1, fieldCorner.X + _arena.size.X, fieldCorner.Y - 3);

            frame.TextCustomAnchor(EFont.ScoreOne, players[0].score.ToString(), 1, 1, fieldCorner.X + _arena.size.X / 2 - 5, fieldCorner.Y - 3);
            frame.TextBottomLeft(EFont.ScoreTwo, players[1].score.ToString(), fieldCorner.X + _arena.size.X / 2 + 5, fieldCorner.Y - 3); //todo framework text without declaration?


            //frame.TextCustomAnchor(EFont.Time, roundNumber.ToString(), 0.5, 1, fieldCorner.X + _arena.size.X / 2, fieldCorner.Y - 3);


            if (GeomHelper.PointInSimpleRect(input.Mouse, _arena + fieldCorner))
            {
                var coord = input.Mouse - fieldCorner;
                var str   = string.Format("{0}  {1}", coord.X.Rounded(3), coord.Y.Rounded(3));
                frame.TextCustomAnchor(EFont.CoordsOnField, str, 0.5, 1, input.Mouse - Vector2d.UnitY * 1.5, depth: 101);
            }

            //  frame.SpriteCenter(ESprite.green, 100, 80, depth:1, sizeOnlyWidth:4);

            if (Debugger.IsAttached)
            {
                if (input.LeftMouseUp)
                {
                    var position = input.Mouse - fieldCorner;
                    if (GeomHelper.PointInSimpleRect(position, _arena))
                    {
                        _explosionStartedRound = roundNumber + 1;
                        explosionPosition      = position;
                    }
                }
            }

            if (roundNumber - _explosionStartedRound <= 2 && roundNumber >= _explosionStartedRound)
            {
                try
                {
                    frame.SpriteCenter(ESprite.explosion, explosionPosition + fieldCorner, sizeExact: new Vector2d(30), frameNumber:
                                       (int)((roundNumber - _explosionStartedRound) * 10 + stage * 10).ToRange(0, 30));
                }


                catch
                {
                }
            }

            if (_lastGoalRoundNumber != -1 && roundNumber - _lastGoalRoundNumber < _PARTY_AFTER_GOAL_TIME && roundNumber != _lastGoalRoundNumber)
            {
                frame.TextCenter(EFont.Goal, "ГОЛ !!!", fieldCorner + _arena.center, depth: 100000);
            }

            if (players.Sum(x => x.possession) > 0)
            {
                var pos = players[0].possession * 1.0 / players.Sum(x => x.possession);

                var one = (int)Math.Round(pos * 10000);
                var two = 10000 - one;

                double horsz = 0.6;
                var    rect  = new Rect2d(fieldCorner.X - horsz / 2, fieldCorner.Y + _arena.size.Y + 5.7, horsz, 2);

                frame.PolygonWithDepth(Color.FromArgb(150, 150, 150), 10, new Rect2d(fieldCorner.X, fieldCorner.Y + _arena.size.Y + 6.4, _arena.size.X, 0.6));
                frame.PolygonWithDepth(Color.FromArgb(150, 150, 150), 10, rect + Vector2d.UnitX * _arena.size.X * pos);

                //  if (this.GameFinished)
                {
                    frame.TextTopLeft(EFont.Possession, one.ToString(), fieldCorner.X, fieldCorner.Y + _arena.size.Y + 8, depth: 21);
                    frame.TextCustomAnchor(EFont.Possession, two.ToString(), 1, 0, fieldCorner.X + _arena.size.X, fieldCorner.Y + _arena.size.Y + 8, depth: 21);
                }
            }
        }
コード例 #6
0
ファイル: Game.cs プロジェクト: LightRay2/ContestFramework
 public Turn TryGetHumanTurn(Player player, GlInput input)
 {
     return(new Turn());
 }
コード例 #7
0
        public void DrawAll(Frame frame, double stage, double totalStage, bool humanMove, GlInput input) //todo human move??
        {
            //!!! будьте внимательны (ранний drawall перед любыми методами)
            int frameWidth = 160, frameHeight = 120;

            frame.CameraViewport(frameWidth, frameHeight);

            frame.PolygonWithDepth(Color.Wheat, -100, new Rect2d(0, 0, frameWidth, frameHeight)); //todo line around polygon
            //frame.SpriteCorner(ESprite.brownGrunge, 0, -100, sizeOnlyHeight: frameHeight + 100);


            //  frame.SpriteCorner(ESprite.back2, 0, 0, sizeOnlyWidth: frameWidth);

            var fieldCorner = new Vector2d(10, 10);
            var lineWidth   = 0.4;

            frame.Path(Color.Black, lineWidth, _arena + fieldCorner);

            frame.SpriteCorner(ESprite.field, fieldCorner, sizeExact: _arena.size, opacity: 0.4);

            frame.Polygon(Color.FromArgb(150, 0, 0, 0), new Rect2d(110, 0, 1000, 1000));
            frame.Polygon(Color.FromArgb(150, 0, 0, 0), new Rect2d(0, 0, 110, 10));
            frame.Polygon(Color.FromArgb(150, 0, 0, 0), new Rect2d(0, 10, 10, 100));
            frame.Polygon(Color.FromArgb(150, 0, 0, 0), new Rect2d(0, 110, 110, 1000));

            frame.Path(Color.Black, 2, _arena + fieldCorner);
            //  frame.Path(Color.Black, lineWidth, fieldCorner + new Vector2d(_arena.size.X / 2, 0), fieldCorner + new Vector2d(_arena.size.X / 2, _arena.size.Y));

            // if (_manAnimators.Count != 0) //т е еще не было process turn
            //  {



            for (int i = 0; i < _manList.Count; i++)
            {
                var man       = _manList[i];
                var pos       = _manAnimators[i].Get(stage);
                var direction = _manAnimators[i].Get(stage + 0.001) - _manAnimators[i].Get(stage - 0.001);
                var lookAt    = pos + direction;
                if (i == 0)
                {
                    frame.SpriteCenter(ESprite.man0, pos + fieldCorner, angleLookToPoint: lookAt + fieldCorner, sizeExact: new Vector2d(_manRadius * 2));
                }
                else
                {
                    frame.SpriteCenter(ESprite.man1, pos + fieldCorner, angleLookToPoint: lookAt + fieldCorner, sizeExact: new Vector2d(_manRadius * 2));
                }
                // frame.Circle(man.Color, _manAnimators[i].Get(stage) + fieldCorner, _manRadius);
            }

            _ballList.ForEach(ball => frame.SpriteCenter(ESprite.mushroom, ball + fieldCorner, sizeExact: new Vector2d(_ballRadius * 2))
                              /*frame.Circle(Color.Gray, ball + fieldCorner, _ballRadius)*/);

            _ballFantom.ForEach(ball =>
            {
                if (ball.Item2 >= stage)
                {
                    frame.SpriteCenter(ESprite.mushroom, ball.Item1 + fieldCorner, sizeExact: new Vector2d(_ballRadius * 2));
                }
                //  frame.Circle(Color.Gray, ball.Item1 + fieldCorner, _ballRadius);
            });


            // }

            frame.TextTopLeft(EFont.player0, players[0].name + ": " + players[0].score.ToString(), 10, 3);
            frame.TextCustomAnchor(EFont.player1, players[1].name + ": " + players[1].score.ToString(), 1, 0, 110, 3);

            frame.TextCustomAnchor(EFont.main, roundNumber.ToString(), 0.5, 0, 60, 3);


            #region old
            //  //!!! будьте внимательны (ранний drawall перед любыми методами)
            //  int frameWidth = 160, frameHeight = 120;
            //  frame.CameraViewport(frameWidth, frameHeight);

            //  // frame.Polygon(Color.Wheat, new Rect2d(0, 0, frameWidth, frameHeight)); //todo line around polygon
            //  frame.SpriteCorner(ESprite.brownGrunge, 0, -100, sizeOnlyHeight: frameHeight+100);


            ////  frame.SpriteCorner(ESprite.back2, 0, 0, sizeOnlyWidth: frameWidth);

            //  var fieldCorner = new Vector2d(10, 10);
            //  var lineWidth = 0.4;

            //  frame.Path(Color.Black, lineWidth, _arena + fieldCorner);

            //  frame.SpriteCorner(ESprite.field, fieldCorner, sizeExact: _arena.size, opacity:0.6);

            //  frame.Polygon(Color.FromArgb(180, 0, 0, 0), new Rect2d(110, 0, 1000, 1000));
            //  frame.Polygon(Color.FromArgb(180, 0, 0, 0), new Rect2d(0, 0, 110, 10));
            //  frame.Polygon(Color.FromArgb(180, 0, 0, 0), new Rect2d(0, 10, 10, 100));
            //  frame.Polygon(Color.FromArgb(180, 0, 0, 0), new Rect2d(0, 110, 110, 1000));

            //  frame.Path(Color.Black, 2, _arena + fieldCorner);
            //  //  frame.Path(Color.Black, lineWidth, fieldCorner + new Vector2d(_arena.size.X / 2, 0), fieldCorner + new Vector2d(_arena.size.X / 2, _arena.size.Y));

            //  // if (_manAnimators.Count != 0) //т е еще не было process turn
            //  //  {



            //  for (int i = 0; i < _manList.Count; i++)
            //  {
            //      var man = _manList[i];
            //      var pos = _manAnimators[i].Get(stage);
            //      var direction = _manAnimators[i].Get(stage + 0.001) - _manAnimators[i].Get(stage - 0.001);
            //      var lookAt = pos + direction;
            //      if (i == 0)
            //          frame.SpriteCenter(ESprite.man0, pos + fieldCorner,angleLookToPoint: lookAt, sizeExact: new Vector2d(_manRadius * 2));
            //      else
            //          frame.SpriteCenter(ESprite.man1, pos + fieldCorner, angleLookToPoint: lookAt, sizeExact: new Vector2d(_manRadius*2));
            //     // frame.Circle(man.Color, _manAnimators[i].Get(stage) + fieldCorner, _manRadius);
            //  }

            //  _ballList.ForEach(ball => frame.SpriteCenter(ESprite.mushroom, ball + fieldCorner, sizeExact: new Vector2d(_ballRadius * 2))
            //              /*frame.Circle(Color.Gray, ball + fieldCorner, _ballRadius)*/);

            //  _ballFantom.ForEach(ball =>
            //  {
            //      if (ball.Item2 >= stage)
            //          frame.SpriteCenter(ESprite.mushroom, ball.Item1 + fieldCorner, sizeExact: new Vector2d(_ballRadius * 2));
            //        //  frame.Circle(Color.Gray, ball.Item1 + fieldCorner, _ballRadius);
            //  });


            //  // }

            //  frame.TextTopLeft(EFont.timelineNormal, players[0].name+": "+ players[0].score.ToString(), 3, 3);
            //  frame.TextCustomAnchor(EFont.timelineNormal, players[1].name + ": " + players[1].score.ToString(), 1, 0, 107, 3);
            #endregion
        }