Beispiel #1
0
 /// <summary>
 /// 交换下子选手
 /// </summary>
 public void ChangePlayer()
 {
     if (DoPlayer.Index == 0)
     {
         DoPlayer = GamePlayers[1] as FiveGamePlayer;
     }
     else if (DoPlayer.Index == 1)
     {
         DoPlayer = GamePlayers[0] as FiveGamePlayer;
     }
 }
Beispiel #2
0
        /// <summary>
        /// 设置布局
        /// </summary>
        /// <param name="r"></param>
        /// <param name="c"></param>
        /// <returns></returns>
        public async Task <bool> SetLayout(int r, int c)
        {
            r--;
            c--;
            if (r >= Row || c >= Col || r < 0 || r < 0 || Layout[r, c] != 0)
            {
                return(false);
            }
            Layout[r, c] = DoPlayer.Index;
            UpdatePlayerInfo(r, c, false);
            DrawImage(r, c, Brushes[DoPlayer.Index - 1]);
            var idx = DoPlayer.Index % GamePlayers.Count;

            DoPlayer = GamePlayers[idx] as FiveGamePlayer;
            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// 对上一步的悔棋
        /// </summary>
        /// <param name="r"></param>
        /// <param name="c"></param>
        /// <returns></returns>
        public async Task <bool> ResetLast(int r, int c)
        {
            r--;
            c--;
            if (Layout[r, c] == 0)
            {
                return(false);
            }
            Layout[r, c] = 0;
            UpdatePlayerInfo(r, c, true);
            //切换选手
            var idx = DoPlayer.Index % GamePlayers.Count;

            DoPlayer = GamePlayers[idx] as FiveGamePlayer;
            DrawImage(r, c, WhiteBrush);
            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="gameInput"></param>
        /// <returns></returns>
        public async override Task <bool> Init(GameInput gameInput)
        {
            if (!IsFullPlayer)
            {
                return(false);
            }
            if (GamePlayers.Count > 0)
            {
                return(true);
            }
            int index = 1;

            foreach (var item in BaseInfos)
            {
                GamePlayers.Add(new FiveGamePlayer()
                {
                    PlayerId = item.Id, PlayerNickName = item.Name, Number = 0, Index = index++
                });
            }
            DoPlayer = GamePlayers[this.Random.Next(0, GamePlayers.Count)] as FiveGamePlayer;

            UpdatePlayerInfo(0, 0, false, true);
            return(true);
        }