コード例 #1
0
        private void DrawGameInfo(uint gameTick = 0)
        {
            IUnit unit = Game.ActiveUnit;

            _gameInfo.Tile(Pattern.PanelGrey)
            .DrawRectangle3D();

            if (Game.CurrentPlayer != Human || (unit != null && Human != unit.Owner) || (GameTask.Any() && !GameTask.Is <Show>() && !GameTask.Is <Message>()))
            {
                _gameInfo.FillRectangle(2, _gameInfo.Height - 8, 6, 6, (byte)((gameTick % 4 < 2) ? 15 : 8));
                return;
            }

            if (unit != null)
            {
                int yy = 2;
                _gameInfo.DrawText(Human.TribeName, 0, 5, 4, 2, TextAlign.Left);
                _gameInfo.DrawText(unit.Name, 0, 5, 4, (yy += 8), TextAlign.Left);

                if (unit.Veteran)
                {
                    _gameInfo.DrawText("Veteran", 0, 5, 8, (yy += 8), TextAlign.Left);
                }

                if (unit is BaseUnitAir)
                {
                    _gameInfo.DrawText($"Moves: {unit.MovesLeft}({(unit as BaseUnitAir).FuelLeft})", 0, 5, 4, (yy += 8), TextAlign.Left);
                }
                else if (unit.PartMoves > 0)
                {
                    _gameInfo.DrawText($"Moves: {unit.MovesLeft}.{unit.PartMoves}", 0, 5, 4, (yy += 8), TextAlign.Left);
                }
                else
                {
                    _gameInfo.DrawText($"Moves: {unit.MovesLeft}", 0, 5, 4, (yy += 8), TextAlign.Left);
                }
                _gameInfo.DrawText((unit.Home == null ? "NONE" : unit.Home.Name), 0, 5, 4, (yy += 8), TextAlign.Left);
                _gameInfo.DrawText($"({Map[unit.X, unit.Y].Name})", 0, 5, 4, (yy += 8), TextAlign.Left);

                if (Map[unit.X, unit.Y].RailRoad)
                {
                    _gameInfo.DrawText("(RailRoad)", 0, 5, 4, (yy += 8), TextAlign.Left);
                }
                else if (Map[unit.X, unit.Y].Road)
                {
                    _gameInfo.DrawText("(Road)", 0, 5, 4, (yy += 8), TextAlign.Left);
                }
                if (Map[unit.X, unit.Y].Irrigation)
                {
                    _gameInfo.DrawText("(Irrigation)", 0, 5, 4, (yy += 8), TextAlign.Left);
                }
                else if (Map[unit.X, unit.Y].Mine)
                {
                    _gameInfo.DrawText("(Mining)", 0, 5, 4, (yy += 8), TextAlign.Left);
                }

                yy += 11;

                IUnit[] units = Map[unit.X, unit.Y].Units.Where(u => u != unit).Take(8).ToArray();
                for (int i = 0; i < units.Length; i++)
                {
                    int ix = 7 + ((i % 4) * 16);
                    int iy = yy + (((i - (i % 4)) / 4) * 16);
                    _gameInfo.AddLayer(units[i].ToBitmap(), ix, iy);
                }
            }
            else
            {
                if (gameTick % 4 < 2)
                {
                    _gameInfo.DrawText($"End of Turn", 0, 5, 4, 26, TextAlign.Left);
                }
                _gameInfo.DrawText($"Press Enter", 0, 5, 4, 42, TextAlign.Left);
                _gameInfo.DrawText($"to continue", 0, 5, 4, 50, TextAlign.Left);
            }
        }