Exemple #1
0
        static void GameOver(object sender, GameOverArgs e)
        {
            double passed_seconds = DateTime.Now.Subtract(last_game_over).TotalSeconds;

            System.Diagnostics.Debug.WriteLine(String.Format("Seconds past since previous game over {0}", passed_seconds));
            if (passed_seconds > 30)  //Cant gameover twice in quick succession.
            {
                System.Diagnostics.Debug.WriteLine("Game over");
                last_game_over = DateTime.Now;
                cg.Chat.Chat(String.Format(">>Unreal 300%. Faster and more lethal, with {0} months of iterative testing.", Math.Round(now.Subtract(birth).Days / (365.25 / 12))));
                cg.Chat.Chat(">>If you'd like to find the server again, you can friend me so it will appear at the top of your server browser.");
                System.Diagnostics.Debug.WriteLine(String.Format("Winning team is {0}.", e.GetWinningTeam()));
                if (current_game_log != null)
                {
                    current_game_log.winning_team = e.GetWinningTeam();
                }
                RemoveBotsIfAny();
                map_chooser.SetRandomMap();
                if (cg.PlayerCount - num_bots < 4)
                {
                    NextMap();
                }
                else
                {
                    int wait_timer = 0;
                    while (cg.GetGameState() != GameState.Ending_Commend && wait_timer < 30)
                    {
                        System.Threading.Thread.Sleep(50);
                        wait_timer++;
                    }
                    NextMap();
                }
            }
        }
Exemple #2
0
    private void onGameOver(System.Object args)
    {
        GameOverArgs gameOverArgs = (GameOverArgs)args;

        SceneFlowManager.Inst.BountiesCollected = gameOverArgs.BountiesCollected;
        gameOver = true;
    }
Exemple #3
0
    /// <summary>
    /// 玩家成功出牌
    /// </summary>
    private void onPlayerSuccessPlay()
    {
        List <Card> cardList = CharacterView.Player.FindSelectCard();

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

        CharacterView.Player.DestroySelectCard();

        //游戏胜利的判断
        if (!CharacterView.Player.HasCard)
        {
            Identity     r   = CharacterView.ComputerRight.Identity;
            Identity     l   = CharacterView.ComputerLeft.Identity;
            Identity     p   = CharacterView.Player.Identity;
            GameOverArgs eee = new GameOverArgs()
            {
                PlayerWin        = true,
                ComputerRightWin = r == p ? true : false,
                ComputerLeftWin  = l == p ? true : false
            };
            dispatcher.Dispatch(CommandEvent.GameOver, eee);
        }
        else
        {
            dispatcher.Dispatch(ViewEvent.COMPLETE_PLAY);
        }
    }
Exemple #4
0
    /// <summary>
    /// 成功出牌
    /// </summary>
    private void OnSuccessedPlay()
    {
        List <Card> cardList = CharacterView.PlayerController.FindSelected();

        //清空桌面
        CharacterView.DeskController.Clear(ShowPoint.Player);
        //添加到桌面
        foreach (var card in cardList)
        {
            CharacterView.DeskController.AddCard(card, false, ShowPoint.Player);
        }
        CharacterView.PlayerController.DestroySelectCard();

        if (!CharacterView.PlayerController.HasCard)
        {
            Identity     r   = CharacterView.ComputerRightController.Identity;
            Identity     l   = CharacterView.ComputerLeftController.Identity;
            Identity     p   = CharacterView.PlayerController.Identity;
            GameOverArgs eee = new GameOverArgs()
            {
                ComputerLeftWin  = l == p? true:false,
                ComputerRightWin = r == p?true:false,
                PlayWin          = true,
                isLandlord       = p == Identity.Landlord
            };
            dispatcher.Dispatch(CommandEvent.GameOver, eee);
        }
    }
Exemple #5
0
    public override void Execute()
    {
        int temp = IntegrationModel.Result;

        GameOverArgs e = (GameOverArgs)evt.data;

        if (e.PlayWin)
        {
            IntegrationModel.PlayIntegration += temp;
        }
        else
        {
            IntegrationModel.PlayIntegration -= temp;
        }

        if (e.ComputerRightWin)
        {
            IntegrationModel.ComputerRightIntegration += temp;
        }
        else
        {
            IntegrationModel.ComputerRightIntegration -= temp;
        }

        if (e.ComputerLeftWin)
        {
            IntegrationModel.ComputerLeftIntegration += temp;
        }
        else
        {
            IntegrationModel.ComputerLeftIntegration -= temp;
        }
    }
Exemple #6
0
 protected virtual void OnGameOver(GameOverArgs e)
 {
     if (GameOver != null)
     {
         GameOver(this, e);
     }
 }
Exemple #7
0
 private void GameEndedCallback(object sender, GameOverArgs e)
 {
     if (PassedSeconds() > 60) //Cant gameover twice in quick succession. Probably false alarm.
     {
         Console.WriteLine("game over detected");
         GameOver();
     }
 }
Exemple #8
0
        public void OnGameOverEvent(GameOverArgs e)
        {
            GameOverHandler gameOverEvent = GameOverEvent;

            if (gameOverEvent != null)
            {
                gameOverEvent(e);
            }
        }
Exemple #9
0
 private void Quiz_GameOverEvent(GameOverArgs e)
 {
     button1.IsEnabled = false;
     button2.IsEnabled = false;
     button3.IsEnabled = false;
     button4.IsEnabled = false;
     next.IsEnabled    = false;
     start.IsEnabled   = true;
 }
Exemple #10
0
    public void WIN(GameEventArgs args)
    {
        onWinScreen = true;
        GameOverArgs winArgs = (GameOverArgs)args;

        rovers = GameHandler.instance.playerJoin.characters;
        bool winsaved  = false;
        bool losesaved = false;

        foreach (Character rover in rovers)
        {
            GamePad.SetVibration(rover.playerIndex, 0, 0);
            if ((int)rover.roverType == winArgs.teamID)
            {
                if (!winsaved)
                {
                    rover.transform.position = roverWinPos1.transform.position;
                    rover.transform.rotation = roverWinPos1.transform.rotation;
                    winsaved = true;
                }
                else
                {
                    rover.transform.position = roverWinPos2.transform.position;
                    rover.transform.rotation = roverWinPos2.transform.rotation;
                }
            }
            else
            {
                if (!losesaved)
                {
                    rover.transform.position = roverLosePos1.transform.position;
                    rover.transform.rotation = roverLosePos1.transform.rotation;
                    losesaved = true;
                }
                else
                {
                    rover.transform.position = roverLosePos2.transform.position;
                    rover.transform.rotation = roverLosePos2.transform.rotation;
                }
            }
        }
        if (winArgs.teamID == 0)
        {
            chinaFlag.SetActive(false);
            StartCoroutine(Enlager(russianFlag.transform));
        }
        else
        {
            russianFlag.SetActive(false);
            StartCoroutine(Enlager(chinaFlag.transform));
        }
        mainCamera.GetComponent <CameraHandler>().enabled = false;
        StartCoroutine(MoveCamera());
    }
    public override void Execute()
    {
        int result = integrationModel.Result;

        GameOverArgs e = evt.data as GameOverArgs;

        #region 更新积分
        if (e.PlayWin)
        {
            integrationModel.PlayerIntergration += result;
        }
        else
        {
            integrationModel.PlayerIntergration -= result;
        }
        if (e.ComputerLeftWin)
        {
            integrationModel.ComputerLeftIntergration += result;
        }
        else
        {
            integrationModel.ComputerLeftIntergration -= result;
        }
        if (e.ComputerRightWin)
        {
            integrationModel.ComputerRightIntergration += result;
        }
        else
        {
            integrationModel.ComputerRightIntergration -= result;
        }
        #endregion

        #region 保存数据
        GameData data = new GameData();
        data.playerIntergration        = integrationModel.PlayerIntergration;
        data.computerLeftIntergration  = integrationModel.ComputerLeftIntergration;
        data.computerRightIntergration = integrationModel.ComputerRightIntergration;
        Toos.SaveData(data);
        #endregion

        //更新积分UI
        dispatcher.Dispatch(ViewEvent.UPDATE_INTEGRATION, data);

        cardModel.InitCardLibary();
        roundModel.InitRound();
        PoolManager.Instance.HideAllObject("Card");

        //显示一个游戏结束的面板
        Toos.CreateUIpanel(PanelType.GameOverPanel);
        dispatcher.Dispatch(ViewEvent.SHOW_INTERGRATION, data);
    }
Exemple #12
0
        static void SetGameEnded(object sender, GameOverArgs e)
        {
            double passed_seconds = DateTime.Now.Subtract(last_game_over).TotalSeconds;

            if (passed_seconds > 60)  //Cant gameover twice in quick succession.
            {
                System.Diagnostics.Debug.WriteLine("game ended");
                last_game_over = DateTime.Now;

                if (current_game_log != null)
                {
                    System.Diagnostics.Debug.WriteLine(String.Format("Winning team is {0}.", e.GetWinningTeam()));
                    current_game_log.winning_team = e.GetWinningTeam();
                }
                game_ended = true;
            }
        }
    /// <summary>
    /// 响应玩家出牌成功的命令
    /// </summary>
    /// <param name="payload"></param>
    private void OnSuccessPlayCard()
    {
        List <Card> cardsList = characterView.m_player.FindCards(); //获取被选中牌的集合

        characterView.m_Desk.ClearList(ShowPoint.Player);           //清空玩家显示牌的桌面
        foreach (Card item in cardsList)                            //将出的牌显示到桌面
        {
            characterView.m_Desk.AddCard(item, false, ShowPoint.Player);
        }

        characterView.m_player.DestorySelected();//移除玩家手牌中被选中的牌
        characterView.m_player.CardsSort(false);

        if (!characterView.m_player.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()
            {
                PlayerWin    = true,
                ComputerRigh = Right == p ? true : false,
                ComputerLeft = p == Left ? true : false,
                type         = gg,
                isLand       = p == Identity.Landlord ? true:false
            };
            dispatcher.Dispatch(CommandEvent.GameOver, e);//派发游戏结束命令
        }
    }
    /// <summary>
    /// 玩家成功出牌
    /// </summary>
    public void onPlayerSuccessPlay()
    {
        List <Card> cardList = characterView.player.FindSelectCard();

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


        characterView.player.DeleteSelectCardUI();
        //-----游戏胜利的判断-------
        if (!characterView.player.HasCard)
        {
            Identity     r   = characterView.ComputerRight.Identity;
            Identity     l   = characterView.ComputerLeft.Identity;
            Identity     p   = characterView.player.Identity;
            GameOverArgs eee = new GameOverArgs()
            {
                PlayWin          = true,
                ComputerRightWin = r == p ? true : false,
                ComputerLeftWin  = l == p ? true : false,
            };



            dispatcher.Dispatch(CommandEvent.GameOver, eee);
        }


        else
        {
            //---------------发送事件-----------------------------
            dispatcher.Dispatch(ViewEvent.COMPLETE_PLAY);
        }
    }
Exemple #15
0
    public override void Execute()
    {
        //更新数据
        int          temp = integrationModel.Result;
        GameOverArgs e    = (GameOverArgs)evt.data;

        //玩家胜利
        if (e.PlayerWin)
        {
            if (e.type == CharacterType.Player)
            {
                integrationModel.PlayerIntegration += temp * 2;
            }
            else
            {
                integrationModel.PlayerIntegration += temp;
            }
        }
        else
        {
            if (e.type == CharacterType.Player)
            {
                integrationModel.PlayerIntegration -= temp * 2;
            }
            else
            {
                integrationModel.PlayerIntegration -= temp;
            }
        }
        //右边电脑玩家胜利
        if (e.ComputerRigh)
        {
            if (e.type == CharacterType.ComputerRight)
            {
                integrationModel.ComputerRightIntegration += temp * 2;
            }
            else
            {
                integrationModel.ComputerRightIntegration += temp;
            }
        }
        else
        {
            if (e.type == CharacterType.ComputerRight)
            {
                integrationModel.ComputerRightIntegration -= temp * 2;
            }
            else
            {
                integrationModel.ComputerRightIntegration -= temp;
            }
        }
        //左边电脑玩家胜利
        if (e.ComputerLeft)
        {
            if (e.type == CharacterType.ComputerLeft)
            {
                integrationModel.ComputerLeftIntegration += temp * 2;
            }
            else
            {
                integrationModel.ComputerLeftIntegration += temp;
            }
        }
        else
        {
            if (e.type == CharacterType.ComputerLeft)
            {
                integrationModel.ComputerLeftIntegration -= temp * 2;
            }
            else
            {
                integrationModel.ComputerLeftIntegration -= temp;
            }
        }
        ///用于更新结束面板的显示
        round.isLand = e.isLand;
        round.isWin  = e.PlayerWin;
        //存储数据
        GameData data = new GameData()
        {
            m_playerIntegration        = integrationModel.PlayerIntegration,
            m_computerLeftIntegration  = integrationModel.ComputerLeftIntegration,
            m_computerRightIntegration = integrationModel.ComputerRightIntegration
        };

        ToolsManager.SaveData(data);
        //显示数据
        GameData gameData = new GameData()
        {
            m_playerIntegration        = integrationModel.PlayerIntegration,
            m_computerLeftIntegration  = integrationModel.ComputerLeftIntegration,
            m_computerRightIntegration = integrationModel.ComputerRightIntegration
        };

        dispatcher.Dispatch(ViewEvent.UpdateIntegration, gameData);
        //添加游戏结束面板
        ToolsManager.CreatePrefab(PrefabType.GameOverPanel);
        //清空游戏缓存,初始化游戏数据
        round.Init();
        cardModel.Init();
    }
Exemple #16
0
 void Start()
 {
     GameEventHandler.Subscribe(GameEvent.GameOver, WIN);
     args = new GameOverArgs();
 }
Exemple #17
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;
        }
    }
Exemple #18
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;
        }
    }
    /// <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();
    }
Exemple #20
0
 void GameOver(object sender, GameOverArgs e)
 {
     UnSubscribeCurrentGameEvent();
     mineFieldForm.GameOver();
     gameOverForm.ShowGameOver(e.GameOverType);
 }
    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;
        }
    }