Ejemplo n.º 1
0
 /// <summary>
 /// 出牌
 /// </summary>
 /// <param name="ctype"></param>
 private void BeginWith(CharacterType ctype)
 {
     if (ctype == CharacterType.Player)
     {
         //玩家出牌
         if (PlayerHandle != null)
         {
             PlayerHandle(BiggestCharacter != CharacterType.Player);
         }
     }
     else//电脑出牌
     {
         if (ComputerHandle != null)
         {
             ComputerSmartArgs e = new ComputerSmartArgs()
             {
                 CardType      = this.CurrentType,
                 Weight        = this.CurrentWeight,
                 Length        = this.CurrentLength,
                 IsBiggest     = this.BiggestCharacter,
                 CharacterType = this.CurrentCharater
             };
             ComputerHandle(e);
         }
     }
 }
Ejemplo n.º 2
0
    /// <summary>
    /// 开始回合
    /// </summary>
    /// <param name="cType"></param>
    private void BeginWith(CharacterType cType)
    {
        if (cType == CharacterType.Player)
        {
            //------委托
            if (PlayerHandler != null)
            {
                PlayerHandler(_biggesterCharacter != CharacterType.Player);//判断最大出牌着如果是玩家,就必须出
            }
        }
        else
        {
            //------电脑自动出牌----------

            if (ComputionHandler != null)
            {
                ComputerSmartArgs e = new ComputerSmartArgs()
                {
                    biggerst = this.BiggesterCharacter,

                    cardType      = this.CardType,
                    characterType = this.CurrentCharacter,
                    lenght        = this.CurrentLength,
                    weight        = this.CurrentWeight,
                };

                ComputionHandler(e);


                // Debug.Log(_currentCharacter.ToString() + "轮到你出牌了");
            }
        }
    }
Ejemplo n.º 3
0
 /// <summary>
 /// 开始回合
 /// </summary>
 /// <param name="cType"></param>
 private void BeginWith(CharacterType cType)
 {
     if (cType == CharacterType.Player)
     {
         //玩家出牌
         if (PlayerHandler != null)
         {
             PlayerHandler(biggestCharacter != CharacterType.Player);
         }
     }
     else
     {
         //电脑自动出牌
         if (ComputerHandler != null)
         {
             ComputerSmartArgs e = new ComputerSmartArgs()
             {
                 Biggest       = this.Biggest,
                 CardType      = this.CardType,
                 CharacterType = this.Current,
                 Length        = this.Length,
                 Weight        = this.Weight
             };
             ComputerHandler(e);
         }
     }
 }
Ejemplo n.º 4
0
 public void BeginWith(CharacterType type)
 {
     if (type == CharacterType.Player)
     {
         //玩家出牌
         if (PlayerHandler != null)
         {
             PlayerHandler(BiggestCharacter != CharacterType.Player);
         }
     }
     else
     {
         //电脑出牌
         if (ComputerHandler != null)
         {
             ComputerSmartArgs args = new ComputerSmartArgs()
             {
                 cardType = CurrentCardType, weight = CurrentWeight, Length = CurrentLength, isBiggest = BiggestCharacter, currentCharacter = CurrentCharacter
             };
             ComputerHandler(args);
         }
     }
 }
    /// <summary>
    /// 电脑玩家出牌的方法
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    IEnumerator DePlay(ComputerSmartArgs obj)
    {
        yield return(new WaitForSeconds(2));

        bool can = false;

        switch (obj.currentCharacter)
        {
        case CharacterType.ComputerRight:
            //清空桌面
            characterView.m_Desk.ClearList(ShowPoint.ComputerRight);
            can = characterView.m_ComputerRight.SmartSelectCards(obj.cardType, obj.weight, obj.Length, CharacterType.ComputerRight == obj.isBiggest);
            //获取电脑玩家出牌的集合
            List <Card> Rightcards = characterView.m_ComputerRight.SelectedCard;
            //获取出牌的类型
            CardType RightcardType = characterView.m_ComputerRight.cardType;
            if (can)
            {
                //桌面添加出的牌
                foreach (var item in Rightcards)
                {
                    characterView.m_Desk.AddCard(item, false, ShowPoint.ComputerRight);
                }
                //封装玩家出牌后的传递数据
                PlayCardArgs play = new PlayCardArgs()
                {
                    cardType = RightcardType, length = Rightcards.Count, weight = ToolsManager.GetWeight(Rightcards, RightcardType), characterType = CharacterType.ComputerRight
                };

                //删除手牌
                //在调用SmartSelectCards方法时,出牌成功,就自动删除
                //出牌成功
                if (!characterView.m_ComputerRight.IHasCard)    //判断牌是否有剩余
                {
                    //游戏结束
                    Identity      p     = characterView.m_player.PlayerIdentity;
                    Identity      Left  = characterView.m_ComputerLeft.PlayerIdentity;
                    Identity      Right = characterView.m_ComputerRight.PlayerIdentity;
                    CharacterType gg    = CharacterType.Player;
                    if (p == Identity.Landlord)
                    {
                        gg = CharacterType.Player;
                    }
                    else if (Left == Identity.Landlord)
                    {
                        gg = CharacterType.ComputerLeft;
                    }
                    else if (Right == Identity.Landlord)
                    {
                        gg = CharacterType.ComputerRight;
                    }
                    GameOverArgs e = new GameOverArgs()
                    {
                        ComputerRigh = true,
                        ComputerLeft = Right == Left ? true : false,
                        PlayerWin    = p == Right ? true : false,
                        type         = gg,
                        isLand       = p == Identity.Landlord ? true : false
                    };
                    dispatcher.Dispatch(CommandEvent.GameOver, e);
                }
                else
                {
                    dispatcher.Dispatch(CommandEvent.PlayCard, play);    //下家出牌
                }
            }
            else
            {
                //不出牌
                dispatcher.Dispatch(CommandEvent.PassCard);
            }
            break;

        case CharacterType.ComputerLeft:
            //清空桌面
            characterView.m_Desk.ClearList(ShowPoint.ComputerLeft);
            can = characterView.m_ComputerLeft.SmartSelectCards(obj.cardType, obj.weight, obj.Length, CharacterType.ComputerLeft == obj.isBiggest);
            //获取电脑玩家出牌的集合
            List <Card> cards = characterView.m_ComputerLeft.SelectedCard;
            //获取出牌的类型
            CardType cardType = characterView.m_ComputerLeft.cardType;
            if (can)
            {
                //桌面添加出的牌
                foreach (var item in cards)
                {
                    characterView.m_Desk.AddCard(item, false, ShowPoint.ComputerLeft);
                }
                //封装玩家出牌后的传递数据
                PlayCardArgs play = new PlayCardArgs()
                {
                    cardType = cardType, length = cards.Count, weight = ToolsManager.GetWeight(cards, cardType), characterType = CharacterType.ComputerLeft
                };

                //删除手牌
                //在调用SmartSelectCards方法时,出牌成功,就自动删除
                //出牌成功
                if (!characterView.m_ComputerLeft.IHasCard)    //判断牌是否有剩余
                {
                    //游戏结束
                    Identity      p     = characterView.m_player.PlayerIdentity;
                    Identity      Left  = characterView.m_ComputerLeft.PlayerIdentity;
                    Identity      Right = characterView.m_ComputerRight.PlayerIdentity;
                    CharacterType gg    = CharacterType.Player;
                    if (p == Identity.Landlord)
                    {
                        gg = CharacterType.Player;
                    }
                    else if (Left == Identity.Landlord)
                    {
                        gg = CharacterType.ComputerLeft;
                    }
                    else if (Right == Identity.Landlord)
                    {
                        gg = CharacterType.ComputerRight;
                    }
                    GameOverArgs e = new GameOverArgs()
                    {
                        ComputerLeft = true,
                        ComputerRigh = Right == Left ? true : false,
                        PlayerWin    = p == Left ? true : false,
                        type         = gg,
                        isLand       = p == Identity.Landlord ? true : false
                    };
                    dispatcher.Dispatch(CommandEvent.GameOver, e);    //派发游戏结束命令
                }
                else
                {
                    dispatcher.Dispatch(CommandEvent.PlayCard, play);   //下家出牌
                }
            }
            else
            {
                //不出牌
                dispatcher.Dispatch(CommandEvent.PassCard);
            }
            break;

        default:
            break;
        }
        // characterView.m_ComputerLeft.SmartSelectCards();
    }
 /// <summary>
 /// 注册电脑玩家的出牌委托
 /// </summary>
 /// <param name="obj"></param>
 public void   RoundModel1_ComputerHandler(ComputerSmartArgs obj)
 {
     StartCoroutine(DePlay(obj));
 }
Ejemplo n.º 7
0
    /// <summary>
    /// 电脑出牌
    /// </summary>
    /// <param name="e"></param>
    /// <returns></returns>
    IEnumerator Delay(ComputerSmartArgs e)
    {
        bool can = false;

        yield return(new WaitForSeconds(1f));

        switch (e.CharacterType)
        {
        case CharacterType.ComputerRight:
            //清空桌面
            CharacterView.DeskController.Clear(ShowPoint.ComputerRight);

            can = CharacterView.ComputerRightController.SmartSelectCards(e.CardType, e.Weight, e.Length,
                                                                         e.IsBiggest == CharacterType.ComputerRight);
            //UnityEngine.Debug.Log(e.IsBiggest.ToString());
            //UnityEngine.Debug.Log("CRight"+can);
            if (can)
            {
                List <Card> cardList = CharacterView.ComputerRightController.SelectCards;
                CardType    CurrType = CharacterView.ComputerRightController.CurrentType;
                //添加牌到桌面
                foreach (var card in cardList)
                {
                    CharacterView.DeskController.AddCard(card, false, ShowPoint.ComputerRight);
                }
                PlayCardArgs ee = new PlayCardArgs()
                {
                    CardType      = CurrType,
                    Length        = cardList.Count,
                    CharacterType = CharacterType.ComputerRight,
                    Weight        = Tools.GetWeight(cardList, CurrType)
                };
                //判断胜负
                if (!CharacterView.ComputerRightController.HasCard)
                {
                    Identity     r   = CharacterView.ComputerRightController.Identity;
                    Identity     l   = CharacterView.ComputerLeftController.Identity;
                    Identity     p   = CharacterView.PlayerController.Identity;
                    GameOverArgs eee = new GameOverArgs()
                    {
                        ComputerRightWin = true,
                        ComputerLeftWin  = l == r?true:false,
                        PlayWin          = p == r?true:false,
                        isLandlord       = p == Identity.Landlord
                    };
                    dispatcher.Dispatch(CommandEvent.GameOver);
                }
                else
                {
                    dispatcher.Dispatch(CommandEvent.PlayCard, ee);
                }
            }
            else
            {
                dispatcher.Dispatch(CommandEvent.PassCard);
            }

            break;

        case CharacterType.ComputerLeft:
            //清空桌面
            CharacterView.DeskController.Clear(ShowPoint.ComputerLeft);

            can = CharacterView.ComputerLeftController.SmartSelectCards(e.CardType, e.Weight, e.Length,
                                                                        e.IsBiggest == CharacterType.ComputerLeft);
            //UnityEngine.Debug.Log("cOMPUTER LEFT    "+can);
            //UnityEngine.Debug.Log(e.IsBiggest.ToString());
            if (can)
            {
                List <Card> cardList = CharacterView.ComputerLeftController.SelectCards;
                CardType    CurrType = CharacterView.ComputerLeftController.CurrentType;
                //添加牌到桌面
                foreach (var card in cardList)
                {
                    CharacterView.DeskController.AddCard(card, false, ShowPoint.ComputerLeft);
                }
                PlayCardArgs ee = new PlayCardArgs()
                {
                    CardType      = CurrType,
                    Length        = cardList.Count,
                    CharacterType = CharacterType.ComputerLeft,
                    Weight        = Tools.GetWeight(cardList, CurrType)
                };
                //判断胜负
                if (!CharacterView.ComputerLeftController.HasCard)
                {
                    Identity     r   = CharacterView.ComputerRightController.Identity;
                    Identity     l   = CharacterView.ComputerLeftController.Identity;
                    Identity     p   = CharacterView.PlayerController.Identity;
                    GameOverArgs eee = new GameOverArgs()
                    {
                        ComputerLeftWin  = true,
                        ComputerRightWin = r == l?true:false,
                        PlayWin          = p == l?true:false,
                        isLandlord       = p == Identity.Landlord
                    };
                    dispatcher.Dispatch(CommandEvent.GameOver);
                }
                else
                {
                    dispatcher.Dispatch(CommandEvent.PlayCard, ee);
                }
            }
            else
            {
                dispatcher.Dispatch(CommandEvent.PassCard);
            }

            break;
        }
    }
Ejemplo n.º 8
0
 void Roundmodel_ComputerHandle(ComputerSmartArgs e)
 {
     StartCoroutine(Delay(e));
 }
Ejemplo n.º 9
0
    /// <summary>
    /// 延迟出牌
    /// </summary>
    IEnumerator DelayOneSecond(ComputerSmartArgs e)
    {
        yield return(new WaitForSeconds(1f));

        bool can = false;

        switch (e.CharacterType)
        {
        case CharacterType.ComputerRight:
            can = CharacterView.ComputerRight.ComputerSmartPlayCard(e.CardType, e.Weight, e.Length, e.Biggest == CharacterType.ComputerRight);
            //出牌的检测
            if (can)
            {
                List <Card> cardList =
                    CharacterView.ComputerRight.SelectCards;
                CardType cardType = CharacterView.ComputerRight.CurrType;

                //添加牌到桌面
                CharacterView.Desk.Clear();
                foreach (Card card in cardList)
                {
                    CharacterView.AddCard(CharacterType.Desk, card, false);
                }

                //可以出牌
                PlayCardArgs ee = new PlayCardArgs()
                {
                    cardType      = cardType,
                    characterType = CharacterType.ComputerRight,
                    Length        = cardList.Count,
                    Weight        = Tools.GetWeight(cardList, cardType)
                };

                if (!CharacterView.ComputerRight.HasCard)
                {
                    Identity     r   = CharacterView.ComputerRight.Identity;
                    Identity     l   = CharacterView.ComputerLeft.Identity;
                    Identity     p   = CharacterView.Player.Identity;
                    GameOverArgs eee = new GameOverArgs()
                    {
                        ComputerRightWin = true,
                        ComputerLeftWin  = l == r ? true : false,
                        PlayerWin        = p == r ? true : false
                    };
                    dispatcher.Dispatch(CommandEvent.GameOver, eee);
                }
                else
                {
                    dispatcher.Dispatch(CommandEvent.PlayCard, ee);
                }
            }
            else
            {
                dispatcher.Dispatch(CommandEvent.PassCard);
            }
            break;

        case CharacterType.ComputerLeft:
            can = CharacterView.ComputerLeft.ComputerSmartPlayCard(e.CardType, e.Weight, e.Length, e.Biggest == CharacterType.ComputerLeft);
            //出牌的检测
            if (can)
            {
                List <Card> cardList =
                    CharacterView.ComputerLeft.SelectCards;
                CardType cardType = CharacterView.ComputerLeft.CurrType;

                //添加牌到桌面
                CharacterView.Desk.Clear();
                foreach (Card card in cardList)
                {
                    CharacterView.AddCard(CharacterType.Desk, card, false);
                }

                //可以出牌
                PlayCardArgs ee = new PlayCardArgs()
                {
                    cardType      = cardType,
                    characterType = CharacterType.ComputerLeft,
                    Length        = cardList.Count,
                    Weight        = Tools.GetWeight(cardList, cardType)
                };

                if (!CharacterView.ComputerLeft.HasCard)
                {
                    Identity     r   = CharacterView.ComputerRight.Identity;
                    Identity     l   = CharacterView.ComputerLeft.Identity;
                    Identity     p   = CharacterView.Player.Identity;
                    GameOverArgs eee = new GameOverArgs()
                    {
                        ComputerLeftWin  = true,
                        ComputerRightWin = r == l ? true : false,
                        PlayerWin        = p == l ? true : false
                    };
                    dispatcher.Dispatch(CommandEvent.GameOver, eee);
                }
                else
                {
                    dispatcher.Dispatch(CommandEvent.PlayCard, ee);
                }
            }
            else
            {
                dispatcher.Dispatch(CommandEvent.PassCard);
            }
            break;

        default:
            break;
        }
    }
Ejemplo n.º 10
0
 /// <summary>
 /// 电脑自动出牌
 /// </summary>
 /// <param name="obj"></param>
 private void RoundModel_ComputerHandler(ComputerSmartArgs e)
 {
     StartCoroutine("DelayOneSecond", e);
 }
Ejemplo n.º 11
0
    IEnumerator DelayOneSecound(ComputerSmartArgs obj)
    {
        yield return(new WaitForSeconds(1f));

        bool can = false;

        switch (obj.characterType)
        {
        case CharacterType.ComputerRight:
            can = characterView.ComputerRight.ComputerSemarPlayCard(obj.cardType, obj.weight, obj.lenght, obj.biggerst == CharacterType.ComputerRight);
            if (can)
            {
                List <Card> cardList = characterView.ComputerRight.SelectCards;
                CardType    cardType = characterView.ComputerRight.currType;
                //--------------------------添加牌到桌面----------------



                characterView.Desk.Clear();    //添加牌之前把桌面清空下。这里可以做一个剩余牌数(记牌器),把出的牌临时放到一个数组里面,把总牌数减去手牌减去临时数组,就是剩余牌数,这是一个扩展
                foreach (Card card in cardList)
                {
                    characterView.AddCard(CharacterType.Desk, card, false);
                }


                //-----------------可以出牌-------------------
                PlayCardArg ee = new PlayCardArg(cardList.Count, Toos.GetWeight(cardList, cardType), CharacterType.ComputerRight, cardType);


                if (!characterView.ComputerRight.HasCard)
                {
                    Identity     r   = characterView.ComputerRight.Identity;
                    Identity     l   = characterView.ComputerLeft.Identity;
                    Identity     p   = characterView.player.Identity;
                    GameOverArgs eee = new GameOverArgs()
                    {
                        ComputerRightWin = true,

                        ComputerLeftWin = l == r ? true : false,
                        PlayWin         = p == r ? true: false,
                    };


                    dispatcher.Dispatch(CommandEvent.GameOver, eee);
                }
                else
                {
                    dispatcher.Dispatch(CommandEvent.PlayCard, ee);
                }
            }
            else
            {
                dispatcher.Dispatch(CommandEvent.PassCard);
            }

            break;

        case CharacterType.ComputerLeft:

            can = characterView.ComputerLeft.ComputerSemarPlayCard(obj.cardType, obj.weight, obj.lenght, obj.biggerst == CharacterType.ComputerLeft);

            if (can)
            {
                List <Card> cardList = characterView.ComputerLeft.SelectCards;
                CardType    cardType = characterView.ComputerLeft.currType;
                //--------------------------添加牌到桌面----------------
                characterView.Desk.Clear();    //添加牌之前把桌面清空下。这里可以做一个剩余牌数(记牌器),把出的牌临时放到一个数组里面,把总牌数减去手牌减去临时数组,就是剩余牌数,这是一个扩展
                foreach (Card card in cardList)
                {
                    characterView.AddCard(CharacterType.Desk, card, false);
                }


                //-----------------可以出牌-------------------
                PlayCardArg ee = new PlayCardArg(cardList.Count, Toos.GetWeight(cardList, cardType), CharacterType.ComputerLeft, cardType);

                if (!characterView.ComputerLeft.HasCard)
                {
                    Identity     r   = characterView.ComputerRight.Identity;
                    Identity     l   = characterView.ComputerLeft.Identity;
                    Identity     p   = characterView.player.Identity;
                    GameOverArgs eee = new GameOverArgs()
                    {
                        ComputerLeftWin  = true,
                        ComputerRightWin = r == l ? true : false,
                        PlayWin          = p == l ? true : false,
                    };


                    dispatcher.Dispatch(CommandEvent.GameOver, eee);
                }
                else
                {
                    dispatcher.Dispatch(CommandEvent.PlayCard, ee);
                }
            }
            else
            {
                dispatcher.Dispatch(CommandEvent.PassCard);
            }

            break;

        default:
            break;
        }
    }
Ejemplo n.º 12
0
 /// <summary>
 /// 电脑自动出牌
 /// </summary>
 /// <param name="obj"></param>
 private void RoundModel_ComputionHandler(ComputerSmartArgs obj)
 {
     StartCoroutine("DelayOneSecound", obj);
 }