コード例 #1
0
ファイル: pvpjackpot.aspx.cs プロジェクト: dovanduy/titan
    protected void PvpJackpotsStages_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName != "Sort" && e.CommandName != "Page")
        {
            int rowIndex          = e.GetSelectedRowIndex() % PvpJackpotsStagesGridView.PageSize;
            int JackpotPvpStageId = (int)PvpJackpotsStagesGridView.DataKeys[rowIndex].Value;

            switch (e.CommandName)
            {
            case "buy":
                try
                {
                    JackpotPvpManager.AddStageForUser(Member.Current, JackpotPvpStageId);
                    SuccessMessage.Text  = L1.OP_SUCCESS;
                    SuccessPanel.Visible = true;
                }
                catch (MsgException ex)
                {
                    ErrorPanel.Visible = true;
                    ErrorMessage.Text  = ex.Message;
                }
                catch (Exception ex)
                {
                    ErrorLogger.Log(ex.Message);
                    throw ex;
                }

                break;

            default:
                break;
            }
        }
    }
コード例 #2
0
ファイル: pvpjackpot.aspx.cs プロジェクト: dovanduy/titan
    private void CheckTime()
    {
        if (!AppSettings.TitanFeatures.JackpotPvpEnabled)
        {
            SearchOpponentPlaceHolder.Visible = false;
            TimeLeftTimer.Tick -= TimeLeftTimer_Tick;
        }
        else
        {
            TimeSpan totalTime = AppSettings.ServerTime - gameStart;
            TimeLiteral.Text = string.Format("{0}: {1} {2}", U4200.TIMELEFT, (maxTime - totalTime.Seconds) > 0 ? (maxTime - totalTime.Seconds).ToString() : "0", L1.SECONDS.ToLower());

            if (totalTime.Seconds > randTime)
            {
                TimeLeftTimer.Enabled = false;

                UserStagesPlaceHolder.Visible     = false;
                SearchOpponentPlaceHolder.Visible = false;
                ErrorPanel.Visible   = false;
                SuccessPanel.Visible = false;

                try
                {
                    bool UserWon = JackpotPvpManager.PlayBattleWithBot(Member.CurrentId, stageToPlayId);

                    BattleResultPlaceHolder.Visible = true;
                    if (UserWon)
                    {
                        WhoWonLiteral.Text       = U6011.BATTLEWON;
                        SmilePlaceHolder.Visible = true;
                        SadPlaceHolder.Visible   = false;
                    }
                    else
                    {
                        WhoWonLiteral.Text       = U6011.BATTLELOST;
                        SmilePlaceHolder.Visible = false;
                        SadPlaceHolder.Visible   = true;
                    }
                }
                catch (MsgException ex)
                {
                    ErrorPanel.Visible = true;
                    ErrorMessage.Text  = ex.Message;
                }
                catch (Exception ex)
                {
                    ErrorLogger.Log(ex.Message);
                }

                return;
            }
        }
    }
コード例 #3
0
ファイル: pvpjackpot.aspx.cs プロジェクト: dovanduy/titan
    protected void UserStagesGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName != "Sort" && e.CommandName != "Page")
        {
            int rowIndex = e.GetSelectedRowIndex() % PvpJackpotsStagesGridView.PageSize;
            int selectedStageToPlayId = (int)UserStagesGridView.DataKeys[rowIndex].Value;
            var BoughtStage           = new JackpotPvpStageBought(selectedStageToPlayId);

            switch (e.CommandName)
            {
            case "play":
                ErrorPanel.Visible   = false;
                SuccessPanel.Visible = false;

                try
                {
                    stageToPlayId = BoughtStage.StageId;
                    JackpotPvpManager.TryCheckSystemPoolsCash(stageToPlayId);

                    Random Rnd = new Random();
                    maxTime  = AppSettings.Addons.PvpJackpotOpponentSearchTime;
                    randTime = Rnd.Next(5, AppSettings.Addons.PvpJackpotOpponentSearchTime);


                    gameStart = AppSettings.ServerTime;

                    UserStagesPlaceHolder.Visible     = false;
                    SearchOpponentPlaceHolder.Visible = true;
                    TimeLeftTimer.Enabled             = true;

                    TimeLiteral.Text = string.Format("{0}: {1} {2}", U4200.TIMELEFT, maxTime.ToString(), L1.SECONDS.ToLower());
                }
                catch (MsgException ex)
                {
                    ErrorPanel.Visible = true;
                    ErrorMessage.Text  = ex.Message;
                }
                catch (Exception ex)
                {
                    ErrorLogger.Log(ex.Message);
                }

                break;

            default:
                break;
            }
        }
    }