当前位置: 首页>>代码示例>>C#>>正文


C# PictureBox.FirstOrDefault方法代码示例

本文整理汇总了C#中System.Windows.Forms.PictureBox.FirstOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# PictureBox.FirstOrDefault方法的具体用法?C# PictureBox.FirstOrDefault怎么用?C# PictureBox.FirstOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.PictureBox的用法示例。


在下文中一共展示了PictureBox.FirstOrDefault方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: playerButtonClick

        private bool playerButtonClick(Button button)
        {
            if (gameStateController.AskForPlayerMoveOrEndTheRoundNow_ReturnWinner() != -1)
            {
                StartNewRound(gameStateController.AskForPlayerMoveOrEndTheRoundNow_ReturnWinner());
                return false;
            }

            roundStatus.Text = "A unit has been summoned to battle!";

            List<Card> deck;
            if (gameStateController.gameState.player1Turn)
            {
                deck = gameStateController.gameState.player1.playerDeck;
            }
            else
            {
                deck = gameStateController.gameState.player2.playerDeck;
            }

            foreach (Card card in deck)
            {
                if (card.Name == button.Text)
                {

                    if (gameStateController.gameState.player1Turn)
                    {
                        if (button.Text == "Melee")
                        {
                            var array = new PictureBox[] { player1melee1, player1melee2, player1melee3, player1melee4, player1melee5, player1melee6, player1melee7 };
                            var box = array.FirstOrDefault(a => a.Image == null);
                            box.Image =Image.FromFile(@"C:\Users\The Chemist\Documents\GitHub\CardGame\Images\" + card.Name + ".PNG");
                        }
                        else if (button.Text == "Range")
                        {
                            var array = new PictureBox[] { player1range1, player1range2, player1range3, player1range4, player1range5, player1range6, player1range7 };
                            var box = array.FirstOrDefault(a => a.Image == null);
                            box.Image = Image.FromFile(@"C:\Users\The Chemist\Documents\GitHub\CardGame\Images\" + card.Name + ".PNG");
                        }
                        else if (button.Text == "Siege")
                        {
                            var array = new PictureBox[] { player1siege1, player1siege2, player1siege3, player1siege4, player1siege5, player1siege6, player1siege7 };
                            var box = array.FirstOrDefault(a => a.Image == null);
                            box.Image = Image.FromFile(@"C:\Users\The Chemist\Documents\GitHub\CardGame\Images\" + card.Name + ".PNG");
                        }
                        else
                        {
                            var array = new PictureBox[] { player1special1, player1special2, player1special3 };
                            var box = array.FirstOrDefault(a => a.Image == null);
                            box.Image = Image.FromFile(@"C:\Users\The Chemist\Documents\GitHub\CardGame\Images\" + card.Name + ".PNG");
                        }
                    }
                    else
                    {
                        if (button.Text == "Melee")
                        {
                            var array = new PictureBox[] { player2melee1, player2melee2, player2melee3, player2melee4, player2melee5, player2melee6, player2melee7 };
                            var box = array.FirstOrDefault(a => a.Image == null);
                            box.Image = Image.FromFile(@"C:\Users\The Chemist\Documents\GitHub\CardGame\Images\" + card.Name + ".PNG");
                        }
                        else if (button.Text == "Range")
                        {
                            var array = new PictureBox[] { player2range1, player2range2, player2range3, player2range4, player2range5, player2range6, player2range7 };
                            var box = array.FirstOrDefault(a => a.Image == null);
                            box.Image = Image.FromFile(@"C:\Users\The Chemist\Documents\GitHub\CardGame\Images\" + card.Name + ".PNG");
                        }
                        else if (button.Text == "Siege")
                        {
                            var array = new PictureBox[] { player2siege1, player2siege2, player2siege3, player2siege4, player2siege5, player2siege6, player2siege7 };
                            var box = array.FirstOrDefault(a => a.Image == null);
                            box.Image = Image.FromFile(@"C:\Users\The Chemist\Documents\GitHub\CardGame\Images\" + card.Name + ".PNG");
                        }
                        else
                        {
                            var array = new PictureBox[] { player2special1, player2special2, player2special3 };
                            var box = array.FirstOrDefault(a => a.Image == null);
                            box.Image = Image.FromFile(@"C:\Users\The Chemist\Documents\GitHub\CardGame\Images\" + card.Name + ".PNG");
                        }
                    }
                    gameStateController.PlayACard(card);
                    break;
                }
            }

            UpdateField();
            return true;
        }
开发者ID:ReggaeLuke,项目名称:CardGame,代码行数:87,代码来源:Form1.cs


注:本文中的System.Windows.Forms.PictureBox.FirstOrDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。