public void OnStart()
        {
            matchingType = PhotonNetwork.lobby.Equals(LobbyManager.LeagueLobby) ? MatchingType.League : MatchingType.Club;

            var playerName        = PhotonNetwork.playerName;
            var playerFightRecord = new FightRecord(0, 0);
            var player            = new WaitingPlayer(playerName, playerFightRecord, 1000);

            playerPanel.Set(player);
            inPlayerPanel();

            if (PhotonNetwork.otherPlayers.Length > 0)
            {
                var otherPlayer         = PhotonNetwork.otherPlayers[0];
                var opponentName        = otherPlayer.NickName;
                var opponentFightRecord = new FightRecord(0, 0);
                var opponent            = new WaitingPlayer(opponentName, opponentFightRecord, 1000);
                opponentPanel.Set(opponent);
                inOpponentPanel();
                startModeSelect();
            }
            else
            {
                inWaitingWindow();
            }
        }
        private Dictionary <string, List <FightRecord> > GetFightCard(HtmlNode document)
        {
            var result = new Dictionary <string, List <FightRecord> >();

            var rows = document.SelectNodes(Fight_Card_Xpath);

            if (rows is not null && rows.Any())
            {
                rows.RemoveAt(1);

                string key   = string.Empty;
                var    value = new List <FightRecord>();

                foreach (var row in rows)
                {
                    var childs = row.ChildNodes.Where(node => node.NodeType == HtmlNodeType.Element).ToList();

                    if (childs.Count == 1 && childs[0].Name == "th")
                    {
                        key = childs[0].InnerText.Trim();

                        if (result.ContainsKey(key))
                        {
                            Log(LogLevel.Debug, $"Сontains non-unique fight cards. Non-unique key: {key}");
                            return(new Dictionary <string, List <FightRecord> >());
                        }

                        result.Add(key, new List <FightRecord>());
                        continue;
                    }

                    var fightRecord = new FightRecord()
                    {
                        WeightClass   = GetInnerTextFrom(childs[0]),
                        FirtsFighter  = GetInnerTextFrom(childs[1]),
                        SecondFighter = GetInnerTextFrom(childs[3]),
                        Method        = GetInnerTextFrom(childs[4]),
                        Round         = GetInnerTextFrom(childs[5]),
                        Time          = GetInnerTextFrom(childs[6])
                    };

                    result[key].Add(fightRecord);
                }
            }

            var announcedBoutsNode = document.SelectNodes(Announced_Bouts_Xpath)?.FirstOrDefault();

            if (announcedBoutsNode is not null)
            {
                AddAnnouncedBouts(announcedBoutsNode, result);
            }

            return(result);
        }
        public override void OnPhotonPlayerConnected(PhotonPlayer player)
        {
            Debug.Log("WaitingManager::OnPhotonPlayerConnected");
            // TODO:
            // var record = (FightRecord)player.CustomProperties["FightRecord"];
            // var rating = (int)player.CustomProperties["Rating"];
            var record        = new FightRecord(0, 0);
            var rating        = 1000;
            var waitingPlayer = new WaitingPlayer(player.NickName, record, rating);

            opponentPanel.Set(waitingPlayer);
            startModeSelectTransition();

            PhotonNetwork.room.IsOpen = false;
            startModeSelect();
        }
Exemple #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // Block Page if we haven't selected a Character
                if (Session["activeCharacter"] != null)
                {
                    // pull out the friendlyURL variable telling us who what battle we're looking at
                    fRecord = Utilities.FindFight(int.Parse(Page.RouteData.Values["var"].ToString()));

                    // so we have a character selected, now we make sure it's involved in the fight
                    if (fRecord.IsInvolved((int)Session["activeCharacter"]))
                    {
                        // find our character
                        Character = Utilities.FindCharacter(fRecord.GetOwnedBy((int)Session["currentUser"]));

                        // find opponent
                        Opponent = Utilities.FindCharacter(fRecord.GetNOT(Character.Id));
                    }
                    else
                    {
                        // redirect to BattleSummary page
                        Response.BufferOutput = true;
                        Response.Redirect("~/BattleSummary/");
                    }
                }
                else if (Session["loggedin"] != null)
                {
                    // redirect to character select page
                    Response.BufferOutput = true;
                    Response.Redirect("~/Character/");
                }
                else
                {
                    // redirect to login page
                    Response.BufferOutput = true;
                    Response.Redirect("~/Account/Login");
                }
            }
            catch
            {
                // if we're missing our variable we've hit an error
                Response.BufferOutput = true;
                Response.Redirect("~/Shared/ErrorPage");
            }
        }
        private void AddAnnouncedBouts(HtmlNode node, Dictionary <string, List <FightRecord> > result)
        {
            var ul = node.NextSibling?.NextSibling;

            if (ul is not null && ul.Name == "ul")
            {
                var li = ul.ChildNodes?.Where(node => node.NodeType == HtmlNodeType.Element).ToList();
                if (li is not null && li.Any())
                {
                    var key = "Announced bouts";

                    if (result.ContainsKey(key))
                    {
                        Log(LogLevel.Debug, $"Сontains non-unique fight cards. Non-unique key: {key}");
                        return;
                    }

                    result.Add(key, new List <FightRecord>());

                    foreach (var item in li)
                    {
                        var sup = item.ChildNodes.Where(node => node.Name == "sup").FirstOrDefault();
                        if (sup is not null)
                        {
                            item.ChildNodes.Remove(sup);
                        }
                        var text     = GetInnerTextFrom(item);
                        var splited  = text.Split(':');
                        var fighters = splited[1].Split("vs.");

                        var fightRecord = new FightRecord()
                        {
                            WeightClass   = splited[0].Replace("bout", string.Empty).Trim(),
                            FirtsFighter  = fighters[0].Trim(),
                            SecondFighter = fighters[1].Trim(),
                            Method        = string.Empty,
                            Round         = string.Empty,
                            Time          = string.Empty
                        };

                        result[key].Add(fightRecord);
                    }
                }
            }
        }
Exemple #6
0
 public static string FormatRecord(FightRecord record)
 {
     return($"{record.FightCount:0000}戦 {record.WinCount:0000}勝 {record.LoseCount:0000}敗 (勝率: {record.WinRate * 100:00.0}%)");
 }
 private void ResetData()
 {
     this.listLog.Clear();
     for (int i = GangFightManager.Instance.FightRecord.get_Count() - 1; i >= 0; i--)
     {
         FightRecord fightRecord = GangFightManager.Instance.FightRecord.get_Item(i);
         string      text;
         string      text2;
         int         num;
         int         num2;
         if (fightRecord.fromId == fightRecord.winnerId)
         {
             text  = fightRecord.fromName;
             text2 = fightRecord.toName;
             num   = fightRecord.fromWinCount;
             num2  = fightRecord.toWinCount;
         }
         else
         {
             text2 = fightRecord.fromName;
             text  = fightRecord.toName;
             num2  = fightRecord.fromWinCount;
             num   = fightRecord.toWinCount;
         }
         string text3 = "<color=#A75A42>(" + fightRecord.time + ")</color>";
         string text4 = string.Empty;
         string text5 = string.Empty;
         if (num == 0)
         {
             text4 = GameDataUtils.GetChineseContent(505013, false);
         }
         else
         {
             string chineseContent = GameDataUtils.GetChineseContent(505011, false);
             text4 = chineseContent.Replace("xx", " " + num.ToString() + " ");
         }
         if (num >= num2)
         {
             text5 = string.Concat(new string[]
             {
                 text3,
                 "<color=#b600a7>[",
                 text,
                 "]</color><color=#4A3C31>",
                 GameDataUtils.GetChineseContent(505010, false),
                 "</color><color=#b600a7>[",
                 text2,
                 "]</color><color=#4A3C31>",
                 text4,
                 "</color>"
             });
         }
         else
         {
             text5 = string.Concat(new object[]
             {
                 text3,
                 "<color=#b600a7>[",
                 text,
                 "]</color><color=#4A3C31>",
                 GameDataUtils.GetChineseContent(505021, false),
                 "</color><color=#b600a7>[",
                 text2,
                 "]</color><color=#4A3C31>",
                 GameDataUtils.GetChineseContent(505022, false),
                 " ",
                 num2,
                 " ",
                 GameDataUtils.GetChineseContent(505004, false),
                 ",",
                 text4,
                 "</color>"
             });
         }
         this.listLog.Add(text5);
     }
 }
 public WaitingPlayer(string name, FightRecord fightRecord, int rating)
 {
     this.Name        = name;
     this.FightRecord = fightRecord;
     this.Rating      = rating;
 }