コード例 #1
0
ファイル: PlayerNoteView.cs プロジェクト: SomeCloud/DiceGame
        public PlayerNoteView(EasyPlayer Player, bool active) : base()
        {
            player = Player;
            Size   = new Size(760, 50);
            if (active)
            {
                BackColor = Color.LightGreen;
            }
            else
            {
                BackColor = Color.Transparent;
            }

            Func F = (score) => {
                switch (score)
                {
                case 1:
                    return(Properties.Resources._1);

                case 2:
                    return(Properties.Resources._2);

                case 3:
                    return(Properties.Resources._3);

                case 4:
                    return(Properties.Resources._4);

                case 5:
                    return(Properties.Resources._5);

                case 6:
                    return(Properties.Resources._6);

                default:
                    return(new Bitmap(50, 50));
                }
            };

            PlayerName = new Label()
            {
                Parent = this, Location = new Point(0, 10), Size = new Size(300, 30), Font = new Font(Font.FontFamily, 14), Text = player.Name
            };
            PlayerScore = new Label()
            {
                Parent = this, Location = new Point(310, 10), Size = new Size(200, 50), Font = new Font(Font.FontFamily, 14), Text = "Score: " + player.Score
            };
            PlayerMoveScore = new Label()
            {
                Parent = this, Location = new Point(510, 10), Size = new Size(200, 30), Font = new Font(Font.FontFamily, 14), Text = "Last Round: " + player.Move
            };
            if (player.Move > 0)
            {
                DicePicture = new PictureBox()
                {
                    Parent = this, Location = new Point(710, 0), Size = new Size(50, 50), Image = F(player.Move), SizeMode = PictureBoxSizeMode.StretchImage
                };
            }
        }
        /// <summary>
        /// 同步视频流信息
        /// </summary>
        /// <param name="isEdit"></param>
        private void SynItem(bool isEdit = false)
        {
            string id = string.Empty;

            if (isEdit)
            {
                id = GetNowSelectedStreamItem();
            }
            else
            {
                id = IpStreamID.Text;
            }
            if (id == null)
            {
                return;
            }
            if (id.Length == 0)
            {
                Program.ShowNotice(5000, "编辑流信息", "流的ID不能为空,已为您设置为默认值", ToolTipIcon.Warning);
                IpStreamID.Text = "默认的输入源";
                return;
            }
            var item = new EasyPlayer((EasyPlayerAPI.EASY_VIDEO_RENDER_TYPE)OptVideoRenderType.SelectedIndex, (EasyPlayerAPI.EASY_VIDEO_SCALE_MODE)OptVideoClipType.SelectedIndex, (EasyPlayerAPI.EASY_STREAM_LINK_MODE)OptProtocal.SelectedIndex, IPStreamSrc.Text, IntPtr.Zero)
            {
                //Speed=Convert.ToInt32()
                Volume = (int)(IpStreamVolume.Value * 5.1 - 255)
            };

            if (!isEdit || id != IpStreamID.Text)
            {
                if (Program.manager.AddStream(IpStreamID.Text, Convert.ToInt32(OptPrivilege.SelectedIndex) + 1, item))
                {
                    var entity = LoadDataFromEntity(IpStreamID.Text);
                    if (entity != null)
                    {
                        LoadDataFromItem(IpStreamID.Text, entity);
                    }
                    Program.ShowNotice(5000, "编辑流信息", $"已新增ID为{IpStreamID.Text}的流", ToolTipIcon.Info);
                }
                else
                {
                    Program.ShowNotice(5000, "编辑流信息", $"编辑失败,已存在ID为{IpStreamID.Text}的流", ToolTipIcon.Warning);
                };
            }
            else if (isEdit)
            {
                Program.manager.VideoStream[id].Player = item;
                Program.manager.OnMonitorPrivilegeChanged(Program.manager.VideoStream[id], Convert.ToInt32(OptPrivilege.SelectedIndex) + 1);
                var entity = LoadDataFromEntity(id);
                if (entity != null)
                {
                    LoadDataFromItem(id, entity);
                }
                Program.ShowNotice(5000, "编辑流信息", $"编辑成功,已编辑ID为{IpStreamID.Text}的流", ToolTipIcon.Warning);
            }
            ReloadLstVideoStream();
            RelocateLstVideoStream();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            var player1 = new EasyPlayer();
            var player2 = new PostEasterPlayer();

            TicTacToeEngine.PlayGame(player1, player2);

            Console.ReadLine();
        }
コード例 #4
0
        /// <summary>
        /// The constructor for the game; instantializes all required variables
        /// </summary>
        /// <param name="numOfCards"> The deck size for the game </param>
        /// <param name="difficulty"> The difficulty of the ai player </param>
        public frmDurakGame(int numOfCards, char difficulty)
        {
            InitializeComponent();

            //Create a deck with the specified number of cards
            talon = new Deck(numOfCards);

            //Shuffle the deck
            talon = talon.Shuffle();

            //Create the human player
            humanPlayer = new Player(talon);

            //Set the attacker to be the human player
            attacker = humanPlayer;

            //Create an ai player based on the difficulty
            if (difficulty == 'e')
            {
                EasyPlayer easy = new EasyPlayer(talon);

                //Set the defender and cpuPlayer
                defender  = easy;
                cpuPlayer = easy;
            }
            else if (difficulty == 'h')
            {
                MediumPlayer med = new MediumPlayer(talon);

                //Set the defender and cpuPlayer
                defender  = med;
                cpuPlayer = med;
            }

            //Set the trump suit
            Card.trump = talon.getTrumpSuit();

            //Adds the deck images to the form
            SetDeck();

            //Draw everything to the form
            Redraw();
        }
コード例 #5
0
        static void Main(string[] args)
        {
            //Deck testDeck = new Deck();

            //foreach (Card card in testDeck)
            //{
            //    Console.WriteLine(card.ToString());
            //}

            Deck testDeck = new Deck(36);

            foreach (Card card in testDeck)
            {
                Console.WriteLine(card.ToString());
            }

            testDeck = testDeck.Shuffle();

            Card.trump = testDeck[testDeck.Count - 1].suit;

            Console.WriteLine("");

            foreach (Card card in testDeck)
            {
                Console.WriteLine(card.ToString());
            }

            EasyPlayer compPlayer = new EasyPlayer(testDeck);

            IComputerPlayer cpuPlayer = compPlayer;

            Player testPlayer = compPlayer;

            Cards playedCards = new Cards();

            //playedCards.Add(new Card(Suit.Spade, Rank.Eight));
            //playedCards.Add(new Card(Suit.Spade, Rank.Jack));

            Console.WriteLine("");

            foreach (Card card in playedCards)
            {
                Console.WriteLine(card.ToString());
            }

            Console.WriteLine("");

            foreach (Card card in testPlayer.GetHand())
            {
                if (card.isPlayable(playedCards))
                {
                    Console.WriteLine(card.ToString() + " is playable");
                }
                else
                {
                    Console.WriteLine(card.ToString() + " is not playable");
                }
            }

            Console.WriteLine("");

            try
            {
                Console.WriteLine(cpuPlayer.selectCard(playedCards).ToString() + " was played!");
            }
            catch (OperationCanceledException e)
            {
                Console.WriteLine(e.Message);
            }

            //Console.WriteLine("");

            //foreach (Card card in testHand)
            //{
            //    Console.WriteLine(card.ToString());
            //}

            //Console.WriteLine("");

            //foreach (Card card in testDeck)
            //{
            //    Console.WriteLine(card.ToString());
            //}

            //if (testDeck[0] > testDeck[1])
            //{
            //    Console.WriteLine("Greater");
            //}
            //else
            //{
            //    Console.WriteLine("Less or equal");
            //}

            //if (testDeck[0] >= testDeck[1])
            //{
            //    Console.WriteLine("Greater or equal");
            //}
            //else
            //{
            //    Console.WriteLine("Less");
            //}

            Console.ReadKey();
        }