Exemple #1
0
        public void RecordBattle(Battle battle, List <Battle> log)
        {
            EBattleRecord record = DBBase.Query <EBattleRecord>("BattleCode='" + battle.Code + "' and GameNum=" + battle.CurGameNum).FirstOrDefault();

            if (record == null)
            {
                return;
            }
            record.EndTime       = DateTime.Now;
            record.IsFinished    = true;
            record.BattleContent = JsonConvert.SerializeObject(log);

            foreach (var s in battle.Sides)
            {
                if (s.AccountID == record.Sider1ID.ToString())
                {
                    record.Sider1Score = s.TotalScore;
                }
                else if (s.AccountID == record.Sider2ID.ToString())
                {
                    record.Sider2Score = s.TotalScore;
                }
                else if (s.AccountID == record.Sider3ID.ToString())
                {
                    record.Sider3Score = s.TotalScore;
                }
                else if (s.AccountID == record.Sider4ID.ToString())
                {
                    record.Sider4Score = s.TotalScore;
                }
            }
            DBBase.Change(record);
        }
Exemple #2
0
        public void JoinBattle(string ip, string port, int accountID, int curGameNum, string battleCode, int takeGold, int taleDiamon)
        {
            try
            {
                EAccount account = DBBase.Get <EAccount>(accountID);
                account.BattleIP   = ip;
                account.BattlePort = port;
                account.BattleCode = battleCode.ToString();
                if (curGameNum == 1)
                {
                    account.Gold    += takeGold;
                    account.Diamond += taleDiamon;
                }

                DBBase.Change(account);
                EBattleRecord record = DBBase.Query <EBattleRecord>("BattleCode='" + battleCode + "' and GameNum=" + curGameNum).FirstOrDefault();
                if (record == null)
                {
                    //创建记录
                    record = new EBattleRecord()
                    {
                        BeginTime  = DateTime.Now,
                        EndTime    = DateTime.Now,
                        BattleCode = battleCode,
                        Sider1ID   = accountID,
                        IsFinished = false,
                        GameNum    = curGameNum
                    };
                    DBBase.Create(record);
                }
                else
                {
                    if (record.Sider1ID == 0)
                    {
                        record.Sider1ID = accountID;
                    }
                    else if (record.Sider2ID == 0)
                    {
                        record.Sider2ID = accountID;
                    }
                    else if (record.Sider3ID == 0)
                    {
                        record.Sider3ID = accountID;
                    }
                    else if (record.Sider4ID == 0)
                    {
                        record.Sider4ID = accountID;
                    }
                    DBBase.Change(record);
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message + " " + ex.StackTrace);
            }
        }
Exemple #3
0
 public void GetBattleRecordCallBack(EBattleRecord record)
 {
     App.Instance.DataLoading.Hide();
     if (string.IsNullOrEmpty(record.BattleContent))
     {
         App.Instance.HintBox.Show("战斗未正常进行,没有回放信息!");
         return;
     }
     GlobalVariable.IsBattleRecordPlay = true;
     GlobalVariable.BattleRecord       = record.BattleContent;
     App.Instance.DetailPageBox.Hide();
     App.Instance.PageGroup.ShowPage("Page_Battle", true);
 }