コード例 #1
0
        public void PrintBattleStatus(BattleStatus status, BattleTypers typers)
        {
            _output.WriteLine(new string('-', Width));
            _output.WriteLine();

            if (typers.SelectedPlayerId == status.Player.PlayerId)
            {
                Console.ForegroundColor = ConsoleColor.Green;
            }

            _output.Write($"{(status.Player.IsVotedToStop ? "(stop) " : string.Empty)}{status.Player.Name}   [ {status.Player.Hp} / {status.Player.MaxHp} ]   ");
            Console.ForegroundColor = ConsoleColor.Gray;

            _output.WriteLine(typers.GetPlayerTyper(status.Player.PlayerId));
            _output.WriteLine();

            foreach (var player in status.BattleNeighbors)
            {
                if (typers.SelectedPlayerId == player.PlayerId)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }

                _output.Write($"{(player.IsVotedToStop ? "(stop) " : string.Empty)}{player.Name}   [ {player.Hp} / {player.MaxHp} ]   ");
                Console.ForegroundColor = ConsoleColor.Gray;

                _output.WriteLine(typers.GetPlayerTyper(player.PlayerId));
                _output.WriteLine();
            }

            _output.WriteLine(new string('-', Width));
            _output.WriteLine();

            foreach (var skillId in status.SkillIds)
            {
                var skill = Data.Data.GetSkill(skillId);

                if (typers.SelectedSkillId == skillId)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }

                _output.Write($"{skill.Name}   ");

                if (typers.SelectedSkillId == skillId)
                {
                    Console.ForegroundColor = ConsoleColor.Gray;
                }

                _output.Write(typers.GetSkillTyper(skill.SkillId));
                _output.WriteLine();
                _output.WriteLine();
            }

            _output.WriteLine(new string('-', Width));

            _output.WriteLine();
            _output.Write("Stop - ");
            _output.WriteLine(typers.StopTyper);
        }
コード例 #2
0
 public void SetBattle(BattleTypers battleTypers)
 {
     Reset(battleTypers);
     BattleTypers = battleTypers;
 }
コード例 #3
0
ファイル: Game.cs プロジェクト: ewancoder/typerealm-old
        private void Update()
        {
            lock (_lock)
            {
                Console.Clear();

                if (_status == null)
                {
                    _printer.PrintLoadingScreen();
                    return;
                }

                _printer.PrintNotifications(_notifications);

                // Battle priority is higher than alerts.
                if (_status.BattleStatus != null)
                {
                    if (_typers.BattleTypers == null)
                    {
                        var battleTypers = new BattleTypers(this, _status.BattleStatus.SkillIds, _status.BattleStatus.BattleNeighbors.Concat(new[] { _status.BattleStatus.Player }).Select(p => p.PlayerId));
                        _typers.SetBattle(battleTypers);
                    }

                    _printer.PrintBattleStatus(_status.BattleStatus, _typers.BattleTypers);
                    return;
                }

                _printer.PrintPlayerStatus(_status.PlayerStatus);

                if (_typers.AlertTypers == null && _alerts.Any())
                {
                    _currentAlert = _alerts.Dequeue();
                    var alertTypers = new AlertTypers(this);
                    _typers.OpenAlert(alertTypers);
                }

                if (_typers.AlertTypers != null)
                {
                    _printer.PrintAlert(_currentAlert, _typers.AlertTypers);
                    return;
                }

                if (_isPlayerSelecting)
                {
                    var battleEligibleNeighbors = _status.ZoneStatus.Neighbors
                                                  .Where(n => !n.IsInBattle && !n.IsDead);

                    if (_typers.PlayerSelectionTypers == null)
                    {
                        var playerSelectionTypers = new PlayerSelectionTypers(this, battleEligibleNeighbors.Select(n => n.PlayerId));
                        _typers.SetPlayerSelection(playerSelectionTypers);
                    }

                    if (_selectedPlayers != null) // Typer is done.
                    {
                        _connection.Send(new StartBattleCommand
                        {
                            ParticipantsExceptMeIds = _selectedPlayers
                        });

                        _selectedPlayers   = null;
                        _isPlayerSelecting = false;
                        return;
                    }

                    _printer.PrintPlayerSelectionStatus(battleEligibleNeighbors, _typers.PlayerSelectionTypers);
                    return;
                }

                if (_status.PlayerStatus.PassZone != null)
                {
                    if (_typers.PassZoneTypers == null)
                    {
                        var passZoneTypers = new PassZoneTypers(this, _status.PlayerStatus.PassZone);
                        _typers.SetPassZone(passZoneTypers);
                        _previousDirection = _status.PlayerStatus.PassZone.Direction;
                    }

                    if (_previousDirection != _status.PlayerStatus.PassZone.Direction)
                    {
                        // Update for new direction and distance.
                        var passZoneTypers = new PassZoneTypers(this, _status.PlayerStatus.PassZone); // Can't flip direction. Need to recreate because need smaller/bigger text for reverse direction.
                        _typers.SetPassZone(passZoneTypers);
                        _previousDirection = _status.PlayerStatus.PassZone.Direction;
                    }

                    _printer.PrintPassingStatus(_status.PassZoneStatus, _status.PlayerStatus.PassZone, _typers.PassZoneTypers);
                    return;
                }

                var zone = Data.Data.GetZone(_status.PlayerStatus.Zone.ZoneId);

                if (_typers.ZoneTypers == null)
                {
                    var zoneTypers = new ZoneTypers(this, zone.ZoneExits.Concat(zone.ZoneEntrances));
                    _typers.SetZone(zoneTypers);
                }

                _printer.PrintZoneInfo(_status.ZoneStatus, _status.PlayerStatus, _typers.ZoneTypers);
            }
        }