コード例 #1
0
    /// <summary>
    /// Khi có người chơi gửi phỏm
    /// </summary>
    /// <param name="index">Người gửi phỏm</param>
    /// <param name="indexTo">Gửi phỏm đến người chơi</param>
    /// <param name="cardValue">Card sẽ gửi</param>
    /// <param name="melds">Phỏm ké gửi vào</param>
    public static void AddMeld(int index, int indexTo, int cardValue, int[] melds)
    {
        Meld meld = GetPlayer(indexTo).GetMeld(melds);

        if (meld != null)
        {
            ECard card = GetCard_FromHandPlayer(index, cardValue);
            GetPlayer(index).mCardHand.Remove(card);
            meld.meld.Add(card);

            game.UpdateHand(index, 0.5f);
            game.UpdateHand(indexTo, 0.5f);

            CheckRemoveGiveCard(index);

            card.UpdateParent(indexTo);
            return;
        }

        if (YourController.slotServer == index)
        {
            game.canRequestSort = true;
        }

        Debug.Log(index);
        Debug.Log(indexTo);
        foreach (Meld m in GameModelTLMN.GetPlayer(indexTo).mCardMelds)
        {
            Debug.Log(m.meld);
        }
        Debug.Log(cardValue);
        Debug.Log(melds);

        Debug.LogError("LỖI: Không thể tìm thấy phỏm để gửi");
    }
コード例 #2
0
    public void CheckFinishNormal(GameModelTLMN model)
    {
        if (model.listDiscard == null || model.listDiscard[(int)GameModelTLMN.EDiscard.FaceUp].Count == 0)
        {
            return;
        }

        List <ECard> lastCardTrash = model.listDiscard[(int)GameModelTLMN.EDiscard.FaceUp][model.listDiscard[(int)GameModelTLMN.EDiscard.FaceUp].Count - 1];

        if (lastCardTrash.Count == 1)
        {
            if (lastCardTrash[0].parentCard.Rank == CardLib.Model.Rank.THREE && lastCardTrash[0].parentCard.Suit == CardLib.Model.Suit.SPADE_CLUB_DIAMOND_HEART[0] && ((LobbyTLMN)GameManager.Instance.selectedLobby).config.GAME_TYPE_TLMN == LobbyTLMN.GameConfig.GameTypeLTMN.DEM_LA)
            {
                AudioManager.Instance.Play(AudioManager.SoundEffect.nhan_ba_len, AudioManager.EPlayState.force);
            }
            else
            {
                PlaySoundFinishGame(GamePlayTLMN.EFinishByThangTrangType.NONE);
            }
        }
        else
        {
            PlaySoundFinishGame(GamePlayTLMN.EFinishByThangTrangType.NONE);
        }
    }
コード例 #3
0
    void Drop()
    {
        if (GameManager.CurrentScene == ESceneName.GameplayChan)
        {
            if (GameModelChan.GetPlayer(gameObject.GetComponent <UIContainerAnonymous>().valueInt) == null)
            {
                return;
            }
        }
        else if (GameManager.CurrentScene == ESceneName.GameplayTLMN)
        {
            if (GameModelTLMN.GetPlayer(gameObject.GetComponent <UIContainerAnonymous>().valueInt) == null)
            {
                return;
            }
        }
        else if (GameManager.CurrentScene == ESceneName.GameplayPhom)
        {
            if (GameModelPhom.GetPlayer(gameObject.GetComponent <UIContainerAnonymous>().valueInt) == null)
            {
                return;
            }
        }

        transform.localPosition = oldPosition;
        transform.parent.FindChild("Background").gameObject.SetActive(false);
        oldObject = null;
        Collider col = UICamera.lastHit.collider;

        if (col.gameObject.GetComponent <CUIDraggableObject>() == null)
        {
            return;
        }

        string userName = "";

        if (GameManager.CurrentScene == ESceneName.GameplayChan)
        {
            userName = GameModelChan.GetPlayer(gameObject.GetComponent <UIContainerAnonymous>().valueInt).username;
        }
        else if (GameManager.CurrentScene == ESceneName.GameplayTLMN)
        {
            userName = GameModelTLMN.GetPlayer(gameObject.GetComponent <UIContainerAnonymous>().valueInt).username;
        }
        else if (GameManager.CurrentScene == ESceneName.GameplayPhom)
        {
            userName = GameModelPhom.GetPlayer(gameObject.GetComponent <UIContainerAnonymous>().valueInt).username;
        }

        if (type == EType.CHANGE_AVATAR)
        {
            col.transform.parent.FindChild("Background").gameObject.SetActive(false);
            GameManager.Server.DoRequestPluginGame(Utility.SetEsObject("changePlayerSlot", new object[] {
                "slotId", col.gameObject.GetComponent <UIContainerAnonymous>().valueInt,
                //"player", GameModelChan.GetPlayer(gameObject.GetComponent<UIContainerAnonymous>().valueInt).username
                "player", userName
            }));
        }
    }
コード例 #4
0
    public override void SetColor()
    {
        if (GameManager.GAME == EGame.TLMN && GameModelTLMN.GetPlayer(currentSlot).mCardTrash.Contains(this))
        {
            return;
        }

        gameObject.GetComponentInChildren <UITexture>().color = new Color(112 / 255f, 88 / 255f, 80 / 255f, 255 / 255f);
    }
コード例 #5
0
 public GameModelTLMN(GamePlayTLMN gameplay)
 {
     _model = this;
     _game  = gameplay;
     for (int i = 0; i < listDiscard.Length; i++)
     {
         if (listDiscard[i] == null)
         {
             listDiscard[i] = new List <List <ECard> >();
         }
     }
 }
コード例 #6
0
    void OnClickDone()
    {
        if (GameModelTLMN.CurrentState >= GameModelTLMN.EGameState.deal)
        {
            if (strPick.Trim() != "")
            {
                if (IS_TYPE_FORCE_ROBOT && lastPicks.Count > 0 && GameModelTLMN.CurrentState > GameModelTLMN.EGameState.deal)
                {
                    if (GameManager.GAME == EGame.TLMN)
                    {
                        GameManager.Server.DoRequestPluginGame(Utility.SetEsObject("forceRobotDiscard", new object[] {
                            "cards", lastPicks.ToArray(),
                            "player", GameModelTLMN.GetNextPlayer(GameModelTLMN.IndexInTurn).username
                        }));
                    }
                    else
                    {
                        GameManager.Server.DoRequestPluginGame(Utility.SetEsObject("forceRobotDiscard", new object[] {
                            "cardId", lastPick,
                            "player", GameModelTLMN.GetNextPlayer(GameModelTLMN.IndexInTurn).username
                        }));
                    }
                }
                else
                {
                    GameManager.Server.DoRequestPluginGame(Utility.SetEsObject("orderNextCard", new object[] {
                        "cardId", lastPick
                    }));
                }
            }
        }
        else
        {
            List <EsObject> lst = new List <EsObject>();
            GameModelTLMN.ListPlayer.ForEach(p =>
            {
                EsObject obj = new EsObject();
                obj.setString(Fields.GAMEPLAY.PLAYER, p.username);
                obj.setString("cards", string.IsNullOrEmpty(playerPick[p.slotServer]) ? "" : playerPick[p.slotServer].Trim());
                lst.Add(obj);
            });

            GameManager.Server.DoRequestPluginGame(Utility.SetEsObject("orderHands", new object[] {
                "handsOrdered", lst.ToArray()
            }));
        }
        OnButtonClick(null);
    }
コード例 #7
0
    public override void UpdateButtonAddMeld()
    {
        while (listObjAddMeld.Count > 0)
        {
            GameObject.Destroy(listObjAddMeld[0].Value);
            listObjAddMeld.Remove(listObjAddMeld[0]);
        }

        if (GameModelTLMN.game.listGiveCard.Count == 0)
        {
            return;
        }
        if (GameModelTLMN.YourController.mCardMelds.Count == 0)
        {
            return;
        }

        if (GameModelTLMN.game.ListClickCard.Count == 1 && GameModelTLMN.game.listGiveCard.Find(gc => gc.cardId == GameModelTLMN.game.ListClickCard[0].CardId) != null)
        {
            #region ADVANCE
            foreach (GamePlayTLMN.GiveCard give in GameModelTLMN.game.listGiveCard.FindAll(gc => gc.cardId == GameModelTLMN.game.ListClickCard[0].CardId))
            {
                PlayerControllerTLMN p = GameModelTLMN.GetPlayer(give.slotIndex);
                Meld meld      = p.GetMeld(give.meldResponse);
                int  indexMeld = p.mCardMelds.FindIndex(m => m == meld);

                int       side     = (int)GameModelTLMN.GetPlayer(give.slotIndex).mSide;
                Transform trans    = GameModelTLMN.game.mPlaymat.locationMelds[side];
                Vector3   position = GameModelTLMN.game.mPlaymat.GetLocationMeld(GameModelTLMN.GetPlayer(give.slotIndex), indexMeld, 2);
                position.z = -12;

                GameObject obj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Gameplay/btAddMeldPrefab"));
                obj.GetComponent <UIButtonMessage>().target = GameModelTLMN.game.gameObject; //SendTo Gameplay Method OnClickAddMeldCard
                UIContainerAnonymous contaniner = obj.AddComponent <UIContainerAnonymous>();
                contaniner.intermediary = give;

                obj.transform.parent        = trans.parent;
                obj.transform.localPosition = position;
                obj.transform.localScale    = Vector3.one;

                listObjAddMeld.Add(new KeyValuePair <GamePlayTLMN.GiveCard, GameObject>(give, obj));
            }
            #endregion
        }
    }
コード例 #8
0
    /// <summary>
    /// Cập nhật lại Parent của GameObject và tên.
    /// </summary>
    /// <param name="slotIndex">Index của parent mới</param>
    public override void UpdateParent(int slotIndex)
    {
        if (GameModelTLMN.GetPlayer(slotIndex).mCardHand.Contains(this))
        {
            if (currentSide != originSide && imageStar == null)
            {
                imageStar = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Cards/BigCard/CardEffect"));
                imageStar.transform.parent        = gameObject.transform;
                imageStar.transform.localPosition = new Vector3(0f, 0f, -0.1f);
                imageStar.transform.localScale    = new Vector3(48f, 66f, 0f);
                imageStar.transform.localRotation = new Quaternion(0f, 0f, 0f, 0f);

                //Chờ card xử lý iTween xong chạy lại effect
                GameManager.Instance.FunctionDelay(delegate() { imageStar.transform.localPosition = new Vector3(0f, 0f, -0.1f); imageStar.transform.localScale = new Vector3(48f, 66f, 0f); imageStar.transform.localRotation = new Quaternion(0f, 0f, 0f, 0f); }, 0.75f);
            }
        }

        if (GameModelTLMN.GetPlayer(slotIndex) != null)
        {
            cardTexture.SetCollider(GameModelTLMN.GetPlayer(slotIndex).mCardHand.Contains(this) &&
                                    GameModelTLMN.YourController.mSide == currentSide);
        }

        if (GameModelTLMN.GetPlayer(slotIndex).mCardHand.Contains(this))
        {
            gameObject.transform.parent = GameModelTLMN.game.mPlaymat.locationHand[(int)currentSide].parent;
        }
        else if (GameModelTLMN.GetPlayer(slotIndex).mCardTrash.Contains(this))
        {
            gameObject.transform.parent = GameModelTLMN.game.mPlaymat.locationTrash[currentSlot].parent;
        }
        else
        {
            foreach (Meld meld in GameModelTLMN.GetPlayer(slotIndex).mCardMelds)
            {
                if (meld.meld.Contains(this))
                {
                    gameObject.transform.parent = GameModelTLMN.game.mPlaymat.locationMelds[currentSlot].parent;
                    break;
                }
            }
        }
        gameObject.name = (int)originSide + " " + CardId;
    }
コード例 #9
0
    /// <summary>
    /// Bắt đầu game. Reset lại các biến.
    /// </summary>
    public static void CreateNewGame()
    {
        GameModelTLMN.ListPlayer.ForEach(p => { if (p.IsHasQuit)
                                                {
                                                    GameModelTLMN.SetPlayer(p.slotServer, null);
                                                }
                                         });

        ListJoinGameWhenPlaying.ForEach(p => GameModelTLMN.SetPlayer(p.slotServer, p));
        ListJoinGameWhenPlaying.Clear();

        GameModelTLMN.game.Listener.RegisterEventNewGame();

        DealCardDone = false;

        DeckCount       = 52;
        IndexInTurn     = 0;
        IndexLastInTurn = 0;

        game.stolen         = false;
        game.fullLaying     = false;
        game.canRequestSort = true;

        game.listGiveCard.Clear();
        game.sortList.Clear();
        game.summaryGame.Clear();
        game.meldList.Clear();

        MiniState = EGameStateMini.discard;

        GameModelTLMN.UpdatePlayerSide();

        if (IsQuitWhenEndGame)
        {
            game.OnQuitGame(false);
        }

        model.OnCreateNewGame();
    }
コード例 #10
0
    public override void OnPublicMessage(Electrotank.Electroserver5.Api.PublicMessageEvent e)
    {
        #region VIEW CONTENT CHAT

        if (e.UserName != GameManager.Instance.mInfo.username)
        {
            PlayerControllerTLMN player = GameModelTLMN.GetPlayer(e.UserName);
            if (player != null)
            {
                if (playerChats.ContainsKey(player))
                {
                    if (playerChats[player] != null)
                    {
                        playerChats[player].DestroyMe();
                    }
                    playerChats.Remove(player);
                }
                playerChats.Add(GameModelTLMN.GetPlayer(e.UserName), PlayerChat.Create(e.Message, GameModelTLMN.GetPlayer(e.UserName)));
            }
        }
        #endregion
        str = "[FF6600]" + e.UserName.ToUpper() + ":[-] " + e.Message + "\n";
        base.OnPublicMessage(e);
    }
コード例 #11
0
    private void Server_EventPluginMessageOnProcess(string command, string action, EsObject eso)
    {
        if (command == "getHandRobot")
        {
            IS_TYPE_FORCE_ROBOT = true;

            if (eso.variableExists("players"))
            {
                foreach (EsObject obj in eso.getEsObjectArray("players"))
                {
                    string username        = obj.getString("userName");
                    PlayerControllerTLMN p = GameModelTLMN.GetPlayer(username);
                    if (obj.getIntegerArray("hand").Length != p.mCardHand.Count)
                    {
                        Debug.LogWarning("Số lượng TLMNCard không phù hợp giũa client và server: " + p.username);
                    }
                    else
                    {
                        if (p.mCardHand.FindAll(c => c.CardId == -1).Count == 0)
                        {
                            return;
                        }

                        foreach (int cardId in obj.getIntegerArray("hand"))
                        {
                            ECard TLMNCard = p.mCardHand.Find(c => c.CardId == cardId);
                            if (TLMNCard == null)
                            {
                                p.mCardHand.Find(c => c.CardId == -1).CardId = cardId;
                            }
                        }
                    }
                }
            }
        }
    }
コード例 #12
0
 public TLMNCard(int slotIndex)
     : base(slotIndex)
 {
     originSide = currentSide = GameModelTLMN.GetPlayer(slotIndex).mSide;
 }
コード例 #13
0
 public override void ChangeSide(int slotIndex)
 {
     currentSide = GameModelTLMN.GetPlayer(slotIndex).mSide;
     currentSlot = slotIndex;
 }
コード例 #14
0
 public TLMNCard(int slotIndex, int cardId)
     : base(slotIndex, cardId)
 {
     originSide = currentSide = GameModelTLMN.game == null ? ESide.You : GameModelTLMN.GetPlayer(slotIndex).mSide;
 }
コード例 #15
0
    void OnDrag(Vector2 delta)
    {
        if (GameManager.CurrentScene == ESceneName.GameplayChan)
        {
            if (GameModelChan.GetPlayer(gameObject.GetComponent <UIContainerAnonymous>().valueInt) == null)
            {
                return;
            }
        }
        else if (GameManager.CurrentScene == ESceneName.GameplayTLMN)
        {
            if (GameModelTLMN.GetPlayer(gameObject.GetComponent <UIContainerAnonymous>().valueInt) == null)
            {
                return;
            }
        }
        else if (GameManager.CurrentScene == ESceneName.GameplayPhom)
        {
            if (GameModelPhom.GetPlayer(gameObject.GetComponent <UIContainerAnonymous>().valueInt) == null)
            {
                return;
            }
        }

        if (enabled && UICamera.currentTouchID > -2)
        {
            if (!mIsDragging)
            {
                mIsDragging = true;

                Vector3 pos = transform.localPosition;

                if (type == EType.CHANGE_AVATAR)
                {
                    pos.z = -2;
                }
                else
                {
                    pos.z = 0f;
                }

                transform.localPosition = pos;
                transform.parent.FindChild("Background").gameObject.SetActive(true);
            }
            else
            {
                Collider col = UICamera.lastHit.collider;
                if (col.gameObject.GetComponent <CUIDraggableObject>() != null)
                {
                    if (oldObject == null)
                    {
                        col.gameObject.transform.parent.FindChild("Background").gameObject.SetActive(true);
                        oldObject = col.gameObject;
                    }
                    else
                    {
                        oldObject.transform.parent.FindChild("Background").gameObject.SetActive(false);
                        if (oldObject.GetComponent <UIContainerAnonymous>().valueInt != col.gameObject.GetComponent <UIContainerAnonymous>().valueInt)
                        {
                            oldObject.transform.parent.FindChild("Background").gameObject.SetActive(false);
                            col.gameObject.transform.parent.FindChild("Background").gameObject.SetActive(true);
                            oldObject = col.gameObject;
                        }
                        else
                        {
                            oldObject.transform.parent.FindChild("Background").gameObject.SetActive(true);
                        }
                    }
                }
                else
                {
                    if (oldObject != null && oldObject.transform.parent.FindChild("Background").gameObject.activeSelf)
                    {
                        oldObject.transform.parent.FindChild("Background").gameObject.SetActive(false);
                        oldObject = null;
                    }
                }
                transform.localPosition += new Vector3(delta.x * 960 / Screen.width, delta.y * 640 / Screen.height, 0f);
            }
        }
    }
コード例 #16
0
    void OnGUI()
    {
        float BOX_WIDTH  = Screen.width - SPACE_LEFT * 2;
        float BOX_HEIGHT = Screen.height - SPACE_TOP * 2;

        float BUTTON_HEIGHT = (BOX_WIDTH - 200f) / 24f;

        Rect rect = new Rect(SPACE_LEFT, SPACE_TOP, BOX_WIDTH, BOX_HEIGHT);

        GUI.DrawTexture(rect, background);
        GUI.Box(rect, "");
        {
            GUILayout.BeginArea(rect, "");
            {
                #region LINE 1
                GUILayout.BeginHorizontal(GUILayout.Height(BOX_HEIGHT / 3));
                {
                    GUILayout.FlexibleSpace();
                    foreach (PlayerControllerTLMN p in GameModelTLMN.ListPlayer)
                    {
                        GUILayout.BeginVertical();
                        {
                            GUILayout.BeginHorizontal();
                            {
                                float contentWidth = BOX_WIDTH - 100f;
                                GUILayout.Space(30f);
                                GUILayout.Label(p.username, GUILayout.Width(100f));
                                GUILayout.TextField(playerPick[p.slotServer] == null ? "" : playerPick[p.slotServer], GUILayout.Width(contentWidth - 150f - (BUTTON_HEIGHT * 2)));

                                if (GUILayout.Button("CLEAR", new GUILayoutOption[] { GUILayout.Width(BUTTON_HEIGHT * 2) }))
                                {
                                    playerPick[p.slotServer] = "";
                                }
                            }
                            GUILayout.EndHorizontal();
                        }
                        GUILayout.BeginVertical();
                    }
                }
                GUILayout.EndHorizontal();
                #endregion

                GUILayout.FlexibleSpace();

                #region LINE 2
                GUILayout.BeginHorizontal(GUILayout.Height(BOX_HEIGHT / 3));
                {
                    float contentWidth = BOX_WIDTH - 20f;
                    GUILayout.BeginVertical(GUILayout.Width(contentWidth / 4));
                    {
                        #region
                        if (GameModelTLMN.CurrentState > GameModelTLMN.EGameState.deal && GameManager.Instance.mInfo.role >= User.ERole.Tester)
                        {
                            //GUILayout.FlexibleSpace();
                            //GUILayout.BeginHorizontal(GUILayout.Width(BOX_WIDTH - 200f));
                            GUILayout.Space(BUTTON_HEIGHT * 2);
                            if (GUILayout.Button("YÊU CẦU ĐÁNH BÀI", new GUILayoutOption[] { GUILayout.Width(BUTTON_HEIGHT * 4), GUILayout.Height(BUTTON_HEIGHT) }))
                            {
                                OnClickRequestHandRobot();
                            }
                            if (GUILayout.Button("YÊU CẦU BỐC BÀI", new GUILayoutOption[] { GUILayout.Width(BUTTON_HEIGHT * 4), GUILayout.Height(BUTTON_HEIGHT) }))
                            {
                                IS_TYPE_FORCE_ROBOT = false;
                            }
                            //GUILayout.EndHorizontal();
                        }
                        else
                        {
                            GUILayout.Label(" ", GUILayout.Height(BUTTON_HEIGHT));
                        }
                        #endregion
                    }
                    GUILayout.EndVertical();

                    GUILayout.BeginVertical(GUILayout.Width(contentWidth / 3));
                    {
                        string[] lst = strPick.Split(" ".ToCharArray(), StringSplitOptions.None);
                        GUILayout.Label("BẠN ĐANG CHỌN: " + (lst.Length - 1) + " TLMNCard.", GUILayout.Width(contentWidth / 3));
                        GUILayout.TextField(strPick);
                        if (GUILayout.Button("CLEAR", GUILayout.Height(BUTTON_HEIGHT)))
                        {
                            strPick = "";
                        }

                        foreach (PlayerControllerTLMN p in GameModelTLMN.ListPlayer)
                        {
                            if (GUILayout.Button("SET TO " + p.username, GUILayout.Height(BUTTON_HEIGHT)))
                            {
                                playerPick[p.slotServer] = strPick;
                                strPick = "";
                                lastPicks.Clear();
                            }
                        }
                    }
                    GUILayout.EndVertical();

                    GUILayout.BeginVertical(GUILayout.Width(contentWidth / 3));
                    {
                        GUILayout.Label(" ");

                        if (GUILayout.Button("ĐÃ XONG", new GUILayoutOption[] { GUILayout.Width(contentWidth / 3 / 2), GUILayout.Height(contentWidth / 3 / 2) }))
                        {
                            OnClickDone();
                            lastPicks.Clear();
                        }
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();
                #endregion

                GUILayout.FlexibleSpace();

                #region LINE 3
                GUILayout.BeginHorizontal(GUILayout.Height(BOX_HEIGHT / 3));
                {
                    int index = 0;
                    for (int i = 0; i < 13; i++)
                    {
                        GUILayout.BeginVertical();
                        for (int j = 0; j < 4; j++)
                        {
                            string str = GameModelTLMN.game.cardController.Deck.PeekCard(index).ToString();

                            if (strPick.IndexOf(str) >= 0)
                            {
                                str = "";
                            }

                            if (IS_TYPE_FORCE_ROBOT == false)
                            {
                                if (cardPlaying.Find(c => c.CardId == index) != null)
                                {
                                    str = "";
                                }
                            }
                            else
                            {
                                if (GameModelTLMN.CurrentState >= GameModelTLMN.EGameState.deal && GameModelTLMN.GetNextPlayer(GameModelTLMN.IndexInTurn).mCardHand.Find(c => c.CardId == index) == null)
                                {
                                    str = "";
                                }
                            }

                            if (Array.TrueForAll <string>(playerPick, p => p == null || (p != null && p.IndexOf(str) == -1)))
                            {
                                if (GUILayout.Button(str, new GUILayoutOption[] { GUILayout.Width(BUTTON_HEIGHT * 2), GUILayout.Height(BUTTON_HEIGHT) }))
                                {
                                    if (string.IsNullOrEmpty(str) == false &&

                                        ((GameModelTLMN.CurrentState >= GameModelTLMN.EGameState.deal)
                                        ?
                                         GameManager.GAME == EGame.Phom ?
                                         strPick.Split(" ".ToCharArray(), StringSplitOptions.None).Length <= 1
                                        :
                                         strPick.Split(" ".ToCharArray(), StringSplitOptions.None).Length <= MAX_CARD_ON_HAND
                                        :
                                         strPick.Split(" ".ToCharArray(), StringSplitOptions.None).Length <= MAX_CARD_ON_HAND)
                                        )
                                    {
                                        if (!lastPicks.Contains(index))
                                        {
                                            lastPicks.Add(index);
                                        }

                                        lastPick = index;
                                        strPick += str + " ";
                                    }
                                }
                            }
                            else
                            {
                                GUILayout.Button("", new GUILayoutOption[] { GUILayout.Width(BUTTON_HEIGHT * 2), GUILayout.Height(BUTTON_HEIGHT) });
                            }
                            index++;
                        }
                        GUILayout.EndVertical();
                    }
                }
                GUILayout.EndHorizontal();
                #endregion
            }
            GUILayout.EndArea();
        }
    }
コード例 #17
0
    IEnumerator _FinishGame()
    {
        game.ClearEffectCardPair();
        game.lbDiscard.Text = "";

        Debug.Log("Finish type: " + game.gameFinishTypeTLMN);
        GamePlayTLMN.Summary sum;

        //Mặc định tất cả đều thua nếu là kiểu đếm lá, sau đó set icon thêm sau
        if (((LobbyTLMN)GameManager.Instance.selectedLobby).config.GAME_TYPE_TLMN == LobbyTLMN.GameConfig.GameTypeLTMN.DEM_LA)
        {
            foreach (PlayerControllerTLMN p in GameModelTLMN.ListPlayerInGame)
            {
                p.summaryTLMN.resultTLMN = PlayerControllerTLMN.FinishGameTLMN.ResultSpriteTLMN.THOI_LA;
            }
        }

        if (game.gameFinishTypeTLMN == GamePlayTLMN.EFinishTypeTLMN.NORMAL_DEMLA || game.gameFinishTypeTLMN == GamePlayTLMN.EFinishTypeTLMN.NORMAL_DEMLA_DUC_BA_BICH)
        {
            SoundGamePlayTLMN.Instance.CheckFinishNormal(model);
            #region ĐẾM LÁ
            sum = game.summaryGame.Find(o => o.actionTLMN == GamePlayTLMN.Summary.EActionTLMN.THUA_DEM_LA);
            if (sum != null)
            {
                GameModelTLMN.GetPlayer(sum.targetPlayer).summaryTLMN.resultTLMN = (game.gameFinishTypeTLMN == GamePlayTLMN.EFinishTypeTLMN.NORMAL_DEMLA_DUC_BA_BICH
                    ? PlayerControllerTLMN.FinishGameTLMN.ResultSpriteTLMN.DUC_3_BICH
                    : PlayerControllerTLMN.FinishGameTLMN.ResultSpriteTLMN.THANG);
            }
            #endregion
            // play sound nhan 3
        }
        else if (game.gameFinishTypeTLMN == GamePlayTLMN.EFinishTypeTLMN.NORMAL_XEPHANG)
        {
            #region XẾP HẠNG
            sum = game.summaryGame.Find(o => o.actionTLMN == GamePlayTLMN.Summary.EActionTLMN.TOP_2);
            if (sum != null)
            {
                GameModelTLMN.GetPlayer(sum.targetPlayer).summaryTLMN.resultTLMN = PlayerControllerTLMN.FinishGameTLMN.ResultSpriteTLMN.VE_NHAT;
                GameModelTLMN.GetPlayer(sum.sourcePlayer).summaryTLMN.resultTLMN = PlayerControllerTLMN.FinishGameTLMN.ResultSpriteTLMN.VE_NHI;
            }

            sum = game.summaryGame.Find(o => o.actionTLMN == GamePlayTLMN.Summary.EActionTLMN.TOP_3);
            if (sum != null)
            {
                GameModelTLMN.GetPlayer(sum.sourcePlayer).summaryTLMN.resultTLMN = PlayerControllerTLMN.FinishGameTLMN.ResultSpriteTLMN.VE_BA;
            }

            sum = game.summaryGame.Find(o => o.actionTLMN == GamePlayTLMN.Summary.EActionTLMN.TOP_4);
            if (sum != null)
            {
                GameModelTLMN.GetPlayer(sum.sourcePlayer).summaryTLMN.resultTLMN = PlayerControllerTLMN.FinishGameTLMN.ResultSpriteTLMN.VE_TU;
            }
            #endregion
        }
        else //if (game.gameFinishTypeTLMN == Gameplay.EFinishTypeTLMN.THANG_TRANG)
        {
            //play sound thang trang
            SoundGamePlayTLMN.Instance.PlaySoundFinishGame(game.gameFinishThangTrangType);
            #region THẮNG TRẮNG
            if (game.gameFinishThangTrangType == GamePlayTLMN.EFinishByThangTrangType.TU_QUY_BANG_CAI)
            {
                sum = game.summaryGame.Find(o => o.actionTLMN == GamePlayTLMN.Summary.EActionTLMN.THANG_TRANG);
                if (sum != null)
                {
                    GameModelTLMN.GetPlayer(sum.targetPlayer).summaryTLMN.resultTLMN = PlayerControllerTLMN.FinishGameTLMN.ResultSpriteTLMN.CAY_CAI_TAO_HANG;
                    game.lbDiscard.Text = "Tứ Quý Cây Cái";
                }
            }
            else if (game.gameFinishThangTrangType == GamePlayTLMN.EFinishByThangTrangType.BA_DOI_THONG_CO_CAI)
            {
                sum = game.summaryGame.Find(o => o.actionTLMN == GamePlayTLMN.Summary.EActionTLMN.THANG_TRANG);
                if (sum != null)
                {
                    GameModelTLMN.GetPlayer(sum.targetPlayer).summaryTLMN.resultTLMN = PlayerControllerTLMN.FinishGameTLMN.ResultSpriteTLMN.CAY_CAI_TAO_HANG;
                    game.lbDiscard.Text = "Ba Đôi Thông Có Cái";
                }
            }
            else if (game.gameFinishThangTrangType == GamePlayTLMN.EFinishByThangTrangType.BON_DOI_THONG_CO_CAI)
            {
                sum = game.summaryGame.Find(o => o.actionTLMN == GamePlayTLMN.Summary.EActionTLMN.THANG_TRANG);
                if (sum != null)
                {
                    GameModelTLMN.GetPlayer(sum.targetPlayer).summaryTLMN.resultTLMN = PlayerControllerTLMN.FinishGameTLMN.ResultSpriteTLMN.CAY_CAI_TAO_HANG;
                    game.lbDiscard.Text = "Bốn Đôi Thông Có Cái";
                }
            }
            else if (game.gameFinishThangTrangType == GamePlayTLMN.EFinishByThangTrangType.TU_QUY_2)
            {
                sum = game.summaryGame.Find(o => o.actionTLMN == GamePlayTLMN.Summary.EActionTLMN.THANG_TRANG);
                if (sum != null)
                {
                    GameModelTLMN.GetPlayer(sum.targetPlayer).summaryTLMN.resultTLMN = PlayerControllerTLMN.FinishGameTLMN.ResultSpriteTLMN.THANG_TRANG;
                    game.lbDiscard.Text = "Tứ Quý Hai";
                }
            }
            else if (game.gameFinishThangTrangType == GamePlayTLMN.EFinishByThangTrangType.HAI_TU_QUY)
            {
                sum = game.summaryGame.Find(o => o.actionTLMN == GamePlayTLMN.Summary.EActionTLMN.THANG_TRANG);
                if (sum != null)
                {
                    GameModelTLMN.GetPlayer(sum.targetPlayer).summaryTLMN.resultTLMN = PlayerControllerTLMN.FinishGameTLMN.ResultSpriteTLMN.THANG_TRANG;
                    game.lbDiscard.Text = "Hai Tứ Quý";
                }
            }
            else if (game.gameFinishThangTrangType == GamePlayTLMN.EFinishByThangTrangType.NAM_DOI_THONG)
            {
                sum = game.summaryGame.Find(o => o.actionTLMN == GamePlayTLMN.Summary.EActionTLMN.THANG_TRANG);
                if (sum != null)
                {
                    GameModelTLMN.GetPlayer(sum.targetPlayer).summaryTLMN.resultTLMN = PlayerControllerTLMN.FinishGameTLMN.ResultSpriteTLMN.THANG_TRANG;
                    game.lbDiscard.Text = "Năm Đôi Thông";
                }
            }
            else if (game.gameFinishThangTrangType == GamePlayTLMN.EFinishByThangTrangType.SAU_DOI_THONG)
            {
                sum = game.summaryGame.Find(o => o.actionTLMN == GamePlayTLMN.Summary.EActionTLMN.THANG_TRANG);
                if (sum != null)
                {
                    GameModelTLMN.GetPlayer(sum.targetPlayer).summaryTLMN.resultTLMN = PlayerControllerTLMN.FinishGameTLMN.ResultSpriteTLMN.THANG_TRANG;
                    game.lbDiscard.Text = "Sáu Đôi";
                }
            }
            else if (game.gameFinishThangTrangType == GamePlayTLMN.EFinishByThangTrangType.SANH_3_DEN_A)
            {
                sum = game.summaryGame.Find(o => o.actionTLMN == GamePlayTLMN.Summary.EActionTLMN.THANG_TRANG);
                if (sum != null)
                {
                    GameModelTLMN.GetPlayer(sum.targetPlayer).summaryTLMN.resultTLMN = PlayerControllerTLMN.FinishGameTLMN.ResultSpriteTLMN.THANG_TRANG;
                    game.lbDiscard.Text = "Sảnh Từ 3 Đến A";
                }
            }
            else //if (game.gameFinishThangTrangType == Gameplay.EFinishByThangTrangType.SANH_RONG)
            {
                sum = game.summaryGame.Find(o => o.actionTLMN == GamePlayTLMN.Summary.EActionTLMN.THANG_TRANG);
                if (sum != null)
                {
                    GameModelTLMN.GetPlayer(sum.targetPlayer).summaryTLMN.resultTLMN = PlayerControllerTLMN.FinishGameTLMN.ResultSpriteTLMN.SANH_RONG;
                }
            }

            #endregion
        }
        //play sound
        #region SHOW OTHER HAND
        foreach (PlayerControllerTLMN p in GameModelTLMN.ListPlayerInGame)
        {
            if (p.slotServer == YourController.slotServer)
            {
                continue;
            }

            //Đặt những card ăn vào danh sách card của bản thân (Fix trường hợp có người Ù giữa trận card ăn bị kẹt chèn đè lên)
            p.mCardHand.ForEach(c => { c.originSide = c.currentSide; c.originSlot = c.currentSlot; });
            foreach (int cardId in p.summaryTLMN.inHandTLMN)
            {
                if (p.mCardHand.Find(c => c.CardId == cardId) == null)
                {
                    p.mCardHand.Find(c => c.CardId == -1).CardId = cardId;
                }
            }
            p.mCardHand.Sort((c1, c2) => c1.CompareTo(c2));
        }
        #endregion

        #region CHUYỂN CÁC QUÂN BÀI THẮNG TRẮNG RA GIỮA MÀN HÌNH
        if (game.gameFinishTypeTLMN == GamePlayTLMN.EFinishTypeTLMN.THANG_TRANG)
        {
            int i = 0;
            game.cardEffectFinishGame.ForEach(card =>
            {
                game.winner.mCardHand.Remove(card);
                card.cardTexture.texture.depth = i;
                iTween.MoveTo(card.gameObject, iTween.Hash("islocal", true, "time", 0.75f, "position", game.mPlaymat.GetLocationEffect(i, game.cardEffectFinishGame)));
                iTween.ScaleTo(card.gameObject, Vector3.one * 1.5f, 0.75f);
                iTween.RotateTo(card.gameObject, Vector3.zero, 0.75f);
                GameManager.Instance.FunctionDelay(delegate() { card.SetHightlight(); }, 1f);
                i++;
            });
        }
        #endregion
        game.UpdateHand();

        //0.5s cho Start Game mới. O.5s cho Gameplay Process Command Update Hand
        float time = game.TimeCountDown;

        float timeShowPoint = (time - 1) / 3f;
        float timeShowResult = timeShowPoint, timeShowMoney = timeShowPoint;

        MiniState = EGameStateMini.summary_point;
        GameModelTLMN.game.UpdateUI();
        yield return(new WaitForSeconds(timeShowPoint));

        #region PLAY SOUNDS
        //        if (YourController.PlayerState >= PlayerController.EPlayerState.ready)
        //        {
        //
        //        }
        #endregion

        MiniState = EGameStateMini.summary_result;
        GameModelTLMN.game.UpdateUI();
        yield return(new WaitForSeconds(timeShowResult));

        MiniState = EGameStateMini.summary_exchange;

        GameModelTLMN.game.UpdateUserInfo();

        GameModelTLMN.game.UpdateUI();
        yield return(new WaitForSeconds(timeShowMoney));

        MiniState = EGameStateMini.summary_end;
        GameModelTLMN.game.UpdateUI();
        yield return(new WaitForSeconds(0.5f));

        game.IsProcesResonseDone = true;
        game.lbDiscard.Text      = "";
    }
コード例 #18
0
    public void PlaySound(GameModelTLMN model, GamePlayTLMN game, List <ECard> lastDisCard, PlayerControllerTLMN currentController)
    {
        if (model.listDiscard == null || model.listDiscard[(int)GameModelTLMN.EDiscard.FaceUp].Count == 0)
        {
            return;
        }

        if (model.listDiscard[(int)GameModelTLMN.EDiscard.FaceUp].Count == 1)
        {
            if (game.cardController.TypeLastDiscard == CardControllerTLMN.EMultiType.Vertical && lastDisCard.Count > 2)
            {
                PlaySoundWhenFirstTurn(lastDisCard);
            }
            else if (lastDisCard.Count == 1)
            {
                if (lastDisCard[0].parentCard.Rank == CardLib.Model.Rank.THREE && lastDisCard[0].parentCard.Suit == CardLib.Model.Suit.SPADE_CLUB_DIAMOND_HEART[0] && currentController.mCardHand.Count != 0 && ((LobbyTLMN)GameManager.Instance.selectedLobby).config.GAME_TYPE_TLMN == LobbyTLMN.GameConfig.GameTypeLTMN.DEM_LA)
                {
                    AudioManager.Instance.Play(AudioManager.SoundEffect.danh_khong_lai_thoi, AudioManager.EPlayState.force);
                }
            }
        }
        switch (lastDisCard.Count)
        {
        case 1:
            if (lastDisCard[0].parentCard.Rank == CardLib.Model.Rank.TWO)
            {
                if (lastDisCard[0].parentCard.Suit == CardLib.Model.Suit.SPADE_CLUB_DIAMOND_HEART[3])
                {
                    AudioManager.Instance.Play(AudioManager.SoundEffect.hang_dau_chat_di, AudioManager.EPlayState.force);
                }
                else
                {
                    AudioManager.Instance.Play(AudioManager.SoundEffect.heo, AudioManager.EPlayState.force);
                }
            }
            else if (lastDisCard[0].parentCard.Rank == CardLib.Model.Rank.ACE && lastDisCard[0].parentCard.Suit == CardLib.Model.Suit.SPADE_CLUB_DIAMOND_HEART[3])
            {
                AudioManager.Instance.Play(AudioManager.SoundEffect.xin_con_heo, AudioManager.EPlayState.force);
            }
            break;

        case 2:

            if (isContainsACEHeart(lastDisCard))
            {
                AudioManager.Instance.Play(AudioManager.SoundEffect.xin_doi_heo, AudioManager.EPlayState.force);
            }
            if (lastDisCard[0].parentCard.Rank == CardLib.Model.Rank.TWO)
            {
                if (isContainsTwoHeart(lastDisCard))
                {
                    AudioManager.Instance.Play(AudioManager.SoundEffect.tu_quy_dau, AudioManager.EPlayState.force);
                }
                else
                {
                    AudioManager.Instance.Play(AudioManager.SoundEffect.doi_heo, AudioManager.EPlayState.force);
                }
            }
            break;

        case 4:
            if (game.cardController.TypeLastDiscard == CardControllerTLMN.EMultiType.Horizontal)
            {
                List <ECard> lastCardTrash = model.listDiscard[(int)GameModelTLMN.EDiscard.FaceUp][model.listDiscard[(int)GameModelTLMN.EDiscard.FaceUp].Count - 1];
                if (lastCardTrash.Count == 2)
                {
                    if (isContainsTwoHeart(lastCardTrash))
                    {
                        AudioManager.Instance.Play(AudioManager.SoundEffect.tu_quy_day, AudioManager.EPlayState.force);
                    }
                    else
                    {
                        AudioManager.Instance.Play(AudioManager.SoundEffect.tu_quy, AudioManager.EPlayState.force);
                    }
                }
                else
                {
                    AudioManager.Instance.Play(AudioManager.SoundEffect.tu_quy, AudioManager.EPlayState.force);
                }
            }
            else if (game.cardController.TypeLastDiscard == CardControllerTLMN.EMultiType.Vertical)
            {
                if (lastDisCard[0].parentCard.Rank == CardLib.Model.Rank.SIX && lastDisCard[lastDisCard.Count - 1].parentCard.Rank == CardLib.Model.Rank.NINE)
                {
                    AudioManager.SoundEffect[] effect = { AudioManager.SoundEffect.sanh_4, AudioManager.SoundEffect.san_bang_tat_ca, AudioManager.SoundEffect.song_bang_tinh_cam };
                    System.Random r = new System.Random();
                    AudioManager.Instance.Play(effect[r.Next(effect.Length)], AudioManager.EPlayState.force);
                }
                else if (lastDisCard[0].parentCard.Rank == CardLib.Model.Rank.THREE && lastDisCard[lastDisCard.Count - 1].parentCard.Rank == CardLib.Model.Rank.SIX)
                {
                }
            }
            break;

        case 6:
        case 8:
            List <ECard> lastCardTrashDoiThong = model.listDiscard[(int)GameModelTLMN.EDiscard.FaceUp][model.listDiscard[(int)GameModelTLMN.EDiscard.FaceUp].Count - 1];
            if (game.cardController.TypeLastDiscard == CardControllerTLMN.EMultiType.MoreThreePairs && lastDisCard.Count == 6 && !isContainsTwoHeart(lastCardTrashDoiThong))
            {
            }
            else if (game.cardController.TypeLastDiscard == CardControllerTLMN.EMultiType.MoreThreePairs && lastDisCard.Count == 8 && !isContainsTwoHeart(lastCardTrashDoiThong))
            {
            }
            else if ((game.cardController.TypeLastDiscard == CardControllerTLMN.EMultiType.MoreThreePairs && lastDisCard.Count == 6 && isContainsTwoHeart(lastCardTrashDoiThong)) || (game.cardController.TypeLastDiscard == CardControllerTLMN.EMultiType.MoreThreePairs && lastDisCard.Count == 8 && isContainsTwoHeart(lastCardTrashDoiThong)))
            {
                AudioManager.Instance.Play(AudioManager.SoundEffect.hang_day, AudioManager.EPlayState.force);
            }
            break;
        }
    }
コード例 #19
0
    void OnDragCard(DragGesture gesture)
    {
        FingerGestures.Finger finger = gesture.Fingers[0];

        if (!GameModelTLMN.DealCardDone)
        {
            return;
        }

        if (gesture.Phase == ContinuousGesturePhase.Started)
        {
            dragObject = gesture.Selection;

            if (dragObject == null)
            {
                return;
            }
            if (dragObject.GetComponent <ECardTexture>() == null)
            {
                return;
            }
            if (gameObject.GetComponent <iTween>() && gameObject.GetComponent <iTween>().isRunning)
            {
                return;
            }
            //set depth to top
            dragObject.GetComponent <ECardTexture>().texture.depth = 15;
            beginPosition = dragObject.transform.localPosition;
            // Lưu lại ngón đang drag
            dragFingerIndex = finger.Index;
        }
        else if (finger.Index == dragFingerIndex)  //Xử lý drag. Đảm bảo chắc là đối tượng đang kéo là đối tượng bạn đang chọn.
        {
            if (finger.Index != 0)
            {
                return;
            }

            if (gesture.Phase == ContinuousGesturePhase.Updated)
            {
                dragObject.gameObject.transform.position = GetWorldPos(gesture.Position);
            }
            else
            {
                //Thiết lập lại khi kết thúc drag
                dragFingerIndex = -1;
                dragObject.transform.localPosition = beginPosition;

                GameObject obj = gesture.PickObject(gameObject.GetComponent <ScreenRaycaster>(), gesture.Position);

                if (obj == null)
                {
                    return;
                }

                if (obj.name == "MainDesk")
                {
                    if (GameModelTLMN.CanDiscard(new List <ECard>(new ECard[] { dragObject.GetComponent <ECardTexture>().card })))
                    {
                        dragObject.gameObject.transform.position = GetWorldPos(gesture.Position);
                        GameModelTLMN.game.OnDiscard(new List <ECard>(new ECard[] { dragObject.GetComponent <ECardTexture>().card }));
                    }
                }
                else
                {
                    ECard dragCard = dragObject.GetComponent <ECardTexture>().card;
                    bool  isChange = false;
                    if (obj.name == "Hand-Left")
                    {
                        GameModelTLMN.YourController.mCardHand.Remove(dragCard);
                        GameModelTLMN.YourController.mCardHand.Insert(0, dragCard);
                        isChange = true;
                    }
                    else if (obj.name == "Hand-Right")
                    {
                        GameModelTLMN.YourController.mCardHand.Remove(dragCard);
                        GameModelTLMN.YourController.mCardHand.Add(dragCard);
                        isChange = true;
                    }
                    else if (obj.GetComponent <ECardTexture>() != null)
                    {
                        int indexOf     = GameModelTLMN.YourController.mCardHand.IndexOf(GameModelTLMN.YourController.mCardHand.Find(c => c == obj.GetComponent <ECardTexture>().card));
                        int indexOfDrag = GameModelTLMN.YourController.mCardHand.IndexOf(GameModelTLMN.YourController.mCardHand.Find(c => c == dragCard));

                        if (indexOfDrag > indexOf && indexOf + 1 < GameModelTLMN.YourController.mCardHand.Count)
                        {
                            indexOf++;
                        }

                        GameModelTLMN.YourController.mCardHand.Remove(dragCard);
                        GameModelTLMN.YourController.mCardHand.Insert(indexOf, dragCard);
                        isChange = true;
                    }

                    if (isChange)
                    {
                        GameModelTLMN.model.GetCardCollection();
                    }
                }
                GameModelTLMN.game.UpdateHand(GameModelTLMN.YourController.slotServer, 0.5f);
                //Debug.Log(obj.name);
            }
        }
    }