示例#1
0
 public void Clear()
 {
     _console.Clear();
 }
        public override void Run()
        {
            var fetchCount   = 5;
            var printedLines = 0;

            do
            {
                _logConsole.Clear();
                var redControl   = _logConsole.GetColorControlString(TCODColor.red);
                var greenControl = _logConsole.GetColorControlString(TCODColor.green);
                var stopControl  = _logConsole.GetStopControl();

                _logConsole.PrintString(1, 1, "{0}Battlelog:{1}", redControl, stopControl);
                _logConsole.DrawBorder();

                var log = _log.GetLastEntries(fetchCount);
                printedLines = 0;

                foreach (var logEntry in log)
                {
                    _logBuilder.Clear();
                    var printArea = new Rectangle(_logArea.X, _logArea.Y + printedLines, _logArea.Width,
                                                  _logArea.Height - printedLines);
                    if (logEntry.IsCustomMessage)
                    {
                        _logBuilder.Append(logEntry.CustomMessage).AppendNewLine().AppendNewLine();
                        printedLines += _logConsole.PrintString(printArea, _logBuilder.ToString());
                        continue;
                    }

                    _logBuilder.AppendFormat("{0}{1}{2} uses {3} on {4}{5}{6}",
                                             logEntry.CasterIsEnemy ? redControl : greenControl, logEntry.CasterName, stopControl,
                                             logEntry.SpellName, logEntry.ReceiverIsEnemy ? redControl : greenControl,
                                             logEntry.SelfCast ? "self" : logEntry.ReceiverName, stopControl);

                    if (logEntry.AttackDodged)
                    {
                        _logBuilder.Append(" but the attack was dodged");
                    }
                    else
                    {
                        _logBuilder.Append(logEntry.WasHealed ? " healing for " : " dealing ")
                        .Append(logEntry.WasHealed ? greenControl : redControl)
                        .Append(logEntry.Value <= 0d ? "no" : RHelper.SanitizeNumber(logEntry.Value))
                        .Append(stopControl)
                        .Append(logEntry.WasHealed ? " healing" : " damage");
                    }

                    if (logEntry.AttackBlocked)
                    {
                        _logBuilder.Append(" (blocked)");
                    }

                    if (logEntry.WasAfflicted)
                    {
                        _logBuilder.Append(" and inflicting ")
                        .Append(logEntry.AfflictedBy);
                    }

                    _logBuilder.Append("!");

                    if (logEntry.Fatal)
                    {
                        _logBuilder.AppendNewLine()
                        .AppendNewLine()
                        .Append(logEntry.ReceiverName)
                        .AppendNewLine(" dies!");
                    }

                    _logBuilder.AppendNewLine();
                    printedLines += _logConsole.PrintString(printArea, _logBuilder.ToString());
                }
                --fetchCount;
            } while (printedLines > MaxLogLines);
            _root.Blit(_logConsole, _logConsole.Bounds, _position.X, _position.Y);
        }