示例#1
0
文件: GameForm.cs 项目: jdharms/20-20
        /*-----------------------------------------------------------------------------------------------------------*/
        /*-----------------------------------------------MADE SHOT END-----------------------------------------------*/
        /*-----------------------------------------------------------------------------------------------------------*/
        /*************************************************************************************************************/
        /*************************************************MISSED SHOT*************************************************/
        /*************************************************************************************************************/
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void missedShot_Click(object sender, EventArgs e)
        {
            if (firstSelectedPlayer == null)
            {
                MessageBox.Show("Please select at least one player above", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (secondSelectedPlayer != null && firstSelectedPlayer.TeamId == secondSelectedPlayer.TeamId)
            {
                MessageBox.Show("Selected players must be on different teams", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (!pointSelected)
            {
                MessageBox.Show("Please select a location on the court", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                firstSelectedContext.Text = "Shooter";
                if (secondSelectedContext != null)
                    secondSelectedContext.Text = "Blocker";
            }

            MissedShotEvent mse = null;
            string str = this.getQuickPromptResult(sender, false);

            if (str == null)
            {
                return;
            }

            string blocker = secondSelectedPlayer == null ? null : secondSelectedPlayer.Id;
            DataForm dataForm = null;
            //HAS TO BE A FREE THROW!!
            if (str.Equals("1"))
            {
                dataForm = new DataForm(pac, "missedShot", DataForm.REBOUND, generateDataFormLocation(missedShotButton));
                dataForm.playerShot = firstSelectedPlayer;
                dataForm.ShowDialog();
                if (dataForm.cancelled)
                {
                    return;
                }
                mse = new MissedShotEvent(pac, firstSelectedPlayer.Id, firstSelectedPlayer.TeamId, null,
                                          "free-throw", 1, false, currPoint);
            }
            // can be a jumpshot, layup, dunk, tip-in
            else if (str.Equals("2"))
            {
                Console.WriteLine("HEY: " + str);
                dataForm = new DataForm(pac, "missedShot", DataForm.SHOT_TYPE, generateDataFormLocation(missedShotButton));
                dataForm.playerShot = firstSelectedPlayer;
                dataForm.ShowDialog();
                if (dataForm.cancelled)
                {
                    return;
                }

                mse = new MissedShotEvent(pac, firstSelectedPlayer.Id, firstSelectedPlayer.TeamId, blocker,
                                          dataForm.shotType, 2, dataForm.fastbreak, currPoint);
            }
            else if (str.Equals("3"))
            {
                dataForm = new DataForm(pac, "missedShot", DataForm.FASTBREAK, generateDataFormLocation(missedShotButton));
                dataForm.playerShot = firstSelectedPlayer;
                dataForm.ShowDialog();
                if (dataForm.cancelled)
                {
                    return;
                }

                mse = new MissedShotEvent(pac, firstSelectedPlayer.Id, firstSelectedPlayer.TeamId, blocker,
                                          "jump-shot", 3, dataForm.fastbreak, currPoint);
            }

            if (dataForm.rebounded)
            {
                waitingForReboundClick = true;
                savedReboundType = dataForm.reboundType;
                savedEvent = mse;
                savedPlayer = dataForm.playerRebounded;
                courtBox.Refresh();
                courtBox.CreateGraphics().DrawString("Please Select A Rebound Location",
                    new Font(madeShotButton.Font.FontFamily, 20.0f), Brushes.SaddleBrown, new Point(2, 2));
                buttonPanel.Visible = false;
                return;
            }
            confirmAndSendEvent(mse);
        }
示例#2
0
文件: GameForm.cs 项目: jdharms/20-20
        /*-----------------------------------------------------------------------------------------------------------*/
        /*-----------------------------------------------TURNOVER END------------------------------------------------*/
        /*-----------------------------------------------------------------------------------------------------------*/
        /************************************************************************************************************/
        /****************************************************FOUL****************************************************/
        /************************************************************************************************************/
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void foul_Click(object sender, EventArgs e)
        {
            string str = this.getQuickPromptResult(sender, false);

            bool ejected = false;
            if (str == null)
            {
                return;
            }
            else if (str.ToLower().Equals("ejection"))
            {
                ejected = true;
                str = this.getQuickPromptResult(sender, true);
                if (str == null)
                {
                    return;
                }
            }
            print(str);
            FoulEvent fe = null;
            SubstitutionEvent se = null;
            if (!str.Equals("Technical"))
            {
                if (firstSelectedPlayer == null)
                {
                    MessageBox.Show("Please select at least one player above", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else if (secondSelectedPlayer != null && firstSelectedPlayer.TeamId == secondSelectedPlayer.TeamId)
                {
                    MessageBox.Show("Selected players must be on different teams", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else if (!pointSelected)
                {
                    MessageBox.Show("Please select a location on the court", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    firstSelectedContext.Text = "Commit";
                    if (secondSelectedContext != null)
                        secondSelectedContext.Text = "Drew";
                }
            }
            string drewBy = secondSelectedPlayer == null ? null : secondSelectedPlayer.Id;
            if (str.Equals("Offensive"))
            {
                DataForm dataForm = new DataForm(pac, "foul", DataForm.CHARGING, generateDataFormLocation(foulButton));
                dataForm.ejected = ejected;
                dataForm.committedBy = firstSelectedPlayer;
                dataForm.ShowDialog();
                if (dataForm.cancelled)
                {
                    return;
                }

                if (dataForm.ejected)
                {
                    se = new SubstitutionEvent(pac, dataForm.replacingPlayer.Id, firstSelectedPlayer.Id, firstSelectedPlayer.TeamId);
                }

                fe = new FoulEvent(pac, firstSelectedPlayer.TeamId, firstSelectedPlayer.Id,
                    drewBy, dataForm.foulType, ejected, currPoint);
            }
            else if (str.Equals("Defensive"))
            {
                DataForm dataForm = new DataForm(pac, "foul", DataForm.FOUL_TYPE, generateDataFormLocation(foulButton));
                dataForm.ejected = ejected;
                dataForm.committedBy = firstSelectedPlayer;
                dataForm.ShowDialog();
                if (dataForm.cancelled)
                {
                    return;
                }

                if (dataForm.ejected)
                {
                    se = new SubstitutionEvent(pac, dataForm.replacingPlayer.Id, firstSelectedPlayer.Id, firstSelectedPlayer.TeamId);
                }
                fe = new FoulEvent(pac, firstSelectedPlayer.TeamId, firstSelectedPlayer.Id,
                    drewBy, dataForm.foulType, ejected, currPoint);
            }
            else if (str.Equals("Technical"))
            {
                DataForm dataForm = new DataForm(pac, "tech", DataForm.TECHNICAL, generateDataFormLocation(foulButton));
                dataForm.ejected = ejected;
                dataForm.committedBy = firstSelectedPlayer;
                dataForm.ShowDialog();
                if (dataForm.cancelled)
                {
                    return;
                }

                if (dataForm.cancelled)
                {
                    return;
                }

                if (dataForm.ejected)
                {
                    se = new SubstitutionEvent(pac, dataForm.replacingPlayer.Id, dataForm.committedBy.Id, dataForm.committedBy.TeamId);
                }
                fe = new FoulEvent(pac, dataForm.committedBy.TeamId, dataForm.committedBy.Id,
                    null, "technical", ejected, currPoint);

            }

            confirmAndSendEvent(fe);
            if (se != null)
            {
                confirmAndSendEvent(se);
            }
        }
示例#3
0
文件: GameForm.cs 项目: jdharms/20-20
        /*------------------------------------------------------------------------------------------------------------*/
        /*------------------------------------------------JUMPBALL END------------------------------------------------*/
        /*------------------------------------------------------------------------------------------------------------*/
        /*************************************************************************************************************/
        /**************************************************MADE SHOT**************************************************/
        /*************************************************************************************************************/
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void madeShot_Click(object sender, EventArgs e)
        {
            if (firstSelectedPlayer == null)
            {
                MessageBox.Show("Please select at least one player above", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (secondSelectedPlayer != null && firstSelectedPlayer.TeamId != secondSelectedPlayer.TeamId)
            {
                MessageBox.Show("Selected players must be on the same team", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (!pointSelected)
            {
                MessageBox.Show("Please select a location on the court", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                firstSelectedContext.Text = "Shooter";
                if (secondSelectedContext != null)
                    secondSelectedContext.Text = "Assist";
            }

            bool goaltending = false;

            string str = getQuickPromptResult(sender, false);
            if (str == null)
            {
                return;
            }
            else if (str.ToLower().Equals("goaltending"))
            {
                goaltending = true;
                str = getQuickPromptResult(sender, true);
                if (str == null)
                {
                    return;
                }
            }

            MadeShotEvent mse = null;
            string assistId = secondSelectedPlayer != null ? secondSelectedPlayer.Id : null;
            //HAS TO BE A FREE THROW!!
            if (str.Equals("1"))
            {
                DataForm dataForm = new DataForm(pac, "madeShot", DataForm.GOALTENDING, generateDataFormLocation(madeShotButton));
                dataForm.Location = generateDataFormLocation(madeShotButton);
                dataForm.ShowDialog();
                if (dataForm.cancelled)
                {
                    return;
                }
                mse = new MadeShotEvent(pac, firstSelectedPlayer.Id, firstSelectedPlayer.TeamId, null,
                                        "free-throw", 1, false, goaltending, currPoint);
            }
            // can be a jumpshot, layup, dunk, tip-in
            else if (str.Equals("2"))
            {
                DataForm dataForm = new DataForm(pac, "madeShot", DataForm.SHOT_TYPE, generateDataFormLocation(madeShotButton));
                dataForm.ShowDialog();
                if (dataForm.cancelled)
                {
                    return;
                }
                mse = new MadeShotEvent(pac, firstSelectedPlayer.Id, firstSelectedPlayer.TeamId, assistId,
                                        dataForm.shotType, 2, dataForm.fastbreak, goaltending, currPoint);
            }
            else if (str.Equals("3"))
            {
                DataForm dataForm = new DataForm(pac, "madeShot", DataForm.FASTBREAK, generateDataFormLocation(madeShotButton));
                dataForm.ShowDialog();
                if (dataForm.cancelled)
                {
                    return;
                }

                mse = new MadeShotEvent(pac, firstSelectedPlayer.Id, firstSelectedPlayer.TeamId, assistId,
                                        "jump-shot", 3, dataForm.fastbreak, goaltending, currPoint);
            }

            confirmAndSendEvent(mse);
        }
示例#4
0
文件: GameForm.cs 项目: jdharms/20-20
        /*-----------------------------------------------------------------------------------------------------------*/
        /*----------------------------------------------MISSED SHOT END----------------------------------------------*/
        /*-----------------------------------------------------------------------------------------------------------*/
        /************************************************************************************************************/
        /**************************************************TURNOVER**************************************************/
        /************************************************************************************************************/
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void turnover_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)
            {
                if (firstSelectedPlayer == null)
                {
                    MessageBox.Show("Please select at least one player above", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else if (secondSelectedPlayer != null && firstSelectedPlayer.TeamId == secondSelectedPlayer.TeamId)
                {
                    MessageBox.Show("Selected players must be on different teams", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else if (!pointSelected)
                {
                    MessageBox.Show("Please select a location on the court", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    firstSelectedContext.Text = "Commit";
                    if (secondSelectedContext != null)
                        secondSelectedContext.Text = "Forced";
                    DataForm dataForm = new DataForm(pac, "turnover", -1, generateDataFormLocation(turnoverButton));
                    dataForm.ShowDialog();
                    if (dataForm.cancelled)
                    {
                        return;
                    }

                    string forcedBy = secondSelectedPlayer == null ? null : secondSelectedPlayer.Id;

                    TurnoverEvent te = new TurnoverEvent(pac, firstSelectedPlayer.Id, forcedBy, dataForm.turnoverType, currPoint);

                    confirmAndSendEvent(te);
                }
            }
        }