Exemplo n.º 1
0
    public override void UpdateParent(int slotIndex)
    {
        if (GameModelChan.GetPlayer(slotIndex) != null)
        {
            bool enableColloder = GameModelChan.GetPlayer(slotIndex).mCardHand.Contains(this) && GameModelChan.YourController != null && GameModelChan.YourController.mSide == currentSide;
            cardTexture.SetCollider(enableColloder);
        }

        if (GameModelChan.GetPlayer(slotIndex).mCardHand.Contains(this))
        {
            gameObject.transform.parent = GameModelChan.game.mPlaymat.locationHand.parent;
        }
        else if (GameModelChan.GetPlayer(slotIndex).mCardTrash.Contains(this))
        {
            gameObject.transform.parent = GameModelChan.game.mPlaymat.locationTrash[(int)currentSide];
        }
        else
        {
            foreach (StealCard stealCard in GameModelChan.GetPlayer(slotIndex).mCardSteal)
            {
                if (stealCard.steals.Contains(this))
                {
                    gameObject.transform.parent = GameModelChan.game.mPlaymat.locationStealCards[(int)currentSide];
                    break;
                }
            }
        }
        gameObject.name = (int)originSide + " " + CardId;
    }
Exemplo n.º 2
0
    private void Server_EventPluginMessageOnProcess(string command, string action, EsObject eso)
    {
        if (command == "getHandRobot")
        {
            if (eso.variableExists("players"))
            {
                foreach (EsObject obj in eso.getEsObjectArray("players"))
                {
                    string username        = obj.getString("userName");
                    PlayerControllerChan p = GameModelChan.GetPlayer(username);
                    if (obj.getIntegerArray("hand").Length != p.mCardHand.Count)
                    {
                        Debug.LogWarning("Số lượng card 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 card = p.mCardHand.Find(c => c.CardId == cardId);
                            if (card == null)
                            {
                                p.mCardHand.Find(c => c.CardId == -1).CardId = cardId;
                            }
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 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
            }));
        }
    }
Exemplo n.º 4
0
 public static void Close()
 {
     if (_instance != null)
     {
         GameModelChan.game.ShowAllOtherObjectWhenFullLaying();
         GameModelChan.ShowAvatarPlayer();
         GameObject.Destroy(_instance.gameObject);
     }
 }
Exemplo n.º 5
0
    public void InitUser(EsObject[] esoArr)
    {
        DestroyUser();
        for (int i = 0; i < esoArr.Length; i++)
        {
            EsObject           eso   = esoArr[i];
            PlayerBettingModel model = new PlayerBettingModel();;
            model.Player = GameModelChan.GetPlayer(eso.getString("userName"));
            if (model == null)
            {
                model = new PlayerBettingModel();
                model.Player.username = eso.getString("userName");
            }
            model.CardId = eso.getInteger("cardId");
            if (winner == eso.getString("userName"))
            {
                model.IsWinner = true;
            }
            else
            {
                model.IsWinner = false;
            }
            model.ETypeLaying = (ETypeLayingBetting)eso.getInteger("gaNgoaiType");
            model.ChipBetting = eso.getLong("value");
            PlayerBettingView bettingView = PlayerBettingView.Create(model, tableUser.transform);
            listBettingPlayer.Add(bettingView);
            if (eso.getString("userName") == GameManager.Instance.mInfo.username)
            {
                bettingView.gameObject.name = "__0";
            }
        }
        tableUser.repositionNow = true;
        // tableUser.Reposition();
        SetCenterUITable(tableUser);

        GameManager.Instance.FunctionDelay(delegate() {
            foreach (PlayerBettingView pv in listBettingPlayer)
            {
                if (pv.model.IsWinner != null)
                {
                    if (pv.model.IsWinner == true)
                    {
                        pv.iconChicken.gameObject.SetActive(true);
                    }
                    else
                    {
                        pv.lbMoney.gameObject.GetComponent <UILabel>().color = new Color(1f, 155f / 255f, 0f);
                        ECardTexture texture1 = pv.gameObject.GetComponentInChildren <ECardTexture>();
                        texture1.card.SetColor(new Color(1f, 1f, 1f, 90f / 255f));
                    }
                }
            }
        }, 0.1f);
    }
Exemplo n.º 6
0
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         if ((GameModelChan.CurrentState == GameModelChan.EGameState.playerFullLaying || GameModelChan.MiniState == GameModelChan.EGameStateMini.wait_player_xuong) && GameModelChan.game.isViewCompleted && GameModelChan.ListGameObjectNoc.Count > 0)
         {
             GameModelChan.DestroyViewNoc();
             GameModelChan.game.deck.transform.FindChild("2. Card").gameObject.SetActive(true);
             GameModelChan.game.isViewCompleted = !GameModelChan.game.isViewCompleted;
         }
     }
 }
Exemplo n.º 7
0
    public void InitUser(EsObject[] esoArr)
    {
        while (listBettingPlayer.Count > 0)
        {
            GameObject.Destroy(listBettingPlayer[0].gameObject);
            listBettingPlayer.RemoveAt(0);
        }
        for (int i = 0; i < esoArr.Length; i++)
        {
            EsObject           eso   = esoArr[i];
            PlayerBettingModel model = new PlayerBettingModel();

            model.Player = GameModelChan.GetPlayer(eso.getString("userName"));
            if (model.Player == null)
            {
                model.Player          = new PlayerControllerChan();
                model.Player.username = eso.getString("userName");
            }
            if (!GameModelChan.game.dicUserBetting.ContainsKey(eso.getString("userName")))
            {
                GameModelChan.game.dicUserBetting.Add(eso.getString("userName"), false);
            }
            model.CardId      = eso.getInteger("cardId");
            model.ETypeLaying = (ETypeLayingBetting)eso.getInteger("gaNgoaiType");
            model.ChipBetting = eso.getLong("value");
            PlayerBettingView bettingView = PlayerBettingView.Create(model, tableUser.transform);
            listBettingPlayer.Add(bettingView);
            if (eso.getString("userName") == GameManager.Instance.mInfo.username)
            {
                parent.model = model;
                ShowButonJoin(model);
                bettingView.gameObject.name = "__0";
            }
        }
        tableUser.repositionNow = true;
        SetCenterUITable(tableUser);
        if (Array.Find <EsObject>(esoArr, eso => eso.getString("userName") == GameManager.Instance.mInfo.username) == null)
        {
            HideBothButton();
        }
        GameManager.Instance.FunctionDelay(delegate()
        {
            foreach (PlayerBettingView view in listBettingPlayer)
            {
                if (GameModelChan.game.dicUserBetting.ContainsKey(view.model.Player.username) && GameModelChan.game.dicUserBetting[view.model.Player.username])
                {
                    view.iconChange.gameObject.SetActive(true);
                    GameModelChan.game.dicUserBetting[view.model.Player.username] = false;
                }
            }
        }, 0.01f);
    }
Exemplo n.º 8
0
 public static ListResultXuongView Create(string correct, string incorrect, int point, string textGa, Electrotank.Electroserver5.Api.EsObject [] listObj, string infoFullaying)
 {
     if (_instance == null)
     {
         GameObject obj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Gameplay/CuocU/ListResultXuongPrefab"));
         obj.name = "__ListResult";
         obj.transform.position = new Vector3(3, 68, -129f);
         _instance = obj.GetComponent <ListResultXuongView>();
         _instance.Init(correct, incorrect, point, textGa, listObj, infoFullaying);
         GameModelChan.HideAvatarPlayer(true);
     }
     return(_instance);
 }
Exemplo n.º 9
0
 public static ListCuocUView Create(float time, float timeCountdown)
 {
     if (_instance == null)
     {
         GameObject obj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Gameplay/CuocU/ListCuocUPrefab"));
         obj.name = "__ListCuocU";
         obj.transform.position = new Vector3(3, 68, -129f);
         _instance = obj.GetComponent <ListCuocUView>();
         GameModelChan.HideAvatarPlayer(false);
     }
     _instance.StartTimer(time, timeCountdown);
     return(_instance);
 }
Exemplo n.º 10
0
    /// <summary>
    /// Bắt đầu game. Reset lại các biến.
    /// </summary>
    public static void CreateNewGame()
    {
        if (GameModelChan.game.isViewCompleted)
        {
            GameModelChan.game.isViewCompleted = !GameModelChan.game.isViewCompleted;
        }

        GameModelChan.ListPlayer.ForEach(p => { if (p.IsHasQuit)
                                                {
                                                    GameModelChan.SetPlayer(p.slotServer, null);
                                                }
                                         });
        ListJoinGameWhenPlaying.ForEach(p => GameModelChan.SetPlayer(p.slotServer, p));
        model.ChangePositionStealAndTrashYourController();
        ListJoinGameWhenPlaying.Clear();
        //if(GameModel.game.iconBettingUp.active)
        if (GameModelChan.game.iconBettingUp.gameObject.activeSelf)
        {
            GameModelChan.game.iconBettingUp.gameObject.SetActive(false);
        }
        GameModelChan.game.Listener.RegisterEventNewGame();
        GameModelChan.game.dicUserBetting.Clear();

        DeckCount       = 23;
        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;

        GameModelChan.UpdatePlayerSide();

        if (IsQuitWhenEndGame)
        {
            game.OnQuitGame(false);
        }
        // clear am thanh
        SoundGameplay.Instances.ResetSoundWhenNewGame();
    }
Exemplo n.º 11
0
    public static void Create(string fromPos, string toPos)
    {
        #region MOVE EFFECT MONEY EXCHANGE
        GameObject obj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Gameplay/ChipEffectPrefab"));
        obj.transform.parent        = GameModelChan.game.mPlaymat.locationPlayer[(int)GameModelChan.GetPlayer(fromPos).mSide];
        obj.transform.localScale    = Vector3.one;
        obj.transform.localPosition = Vector3.zero;
        obj.transform.parent        = GameModelChan.game.mPlaymat.transform.parent.parent;
        obj.AddComponent <MoneyExchangeView>();
        obj.name = "Money Exchange";
        Vector3 posFrom = obj.transform.localPosition;
        Vector3 posTo   = Vector3.zero;
        if (toPos == "ga")
        {
            posTo = GameModelChan.game.deck.transform.localPosition;
        }
        else
        {
            posTo = GameModelChan.game.mPlaymat.locationPlayer[(int)GameModelChan.GetPlayer(toPos).mSide].localPosition;
            if (GameModelChan.YourController != null && toPos == GameModelChan.YourController.username)
            {
                posTo.y = -290f;
            }
        }

        posFrom.z -= 30f;
        posTo.z   -= 30f;
        TweenPosition tpos = obj.AddComponent <TweenPosition>();
        tpos.from     = posFrom;
        tpos.to       = posTo;
        tpos.duration = TIME_EFFECT;

        //TweenScale tScale = obj.AddComponent<TweenScale>();
        //tScale.from = new Vector3(30f, 30f, 1f);
        //tScale.to = new Vector3(58, 36f, 1f);
        //tScale.duration = TIME_EFFECT / 3f;
        #endregion
    }
Exemplo n.º 12
0
    public void OnClickXuong(GameObject go)
    {
        List <int> cuoc = new List <int>();

        listItem.FindAll(item => item.cuoc.countClick > 0).ForEach(item => { for (int i = 0; i < item.cuoc.countClick; i++)
                                                                             {
                                                                                 cuoc.Add(item.cuoc.id);
                                                                             }
                                                                   });

        if (cuoc.Count == 0)
        {
            NotificationView.ShowMessage("Bạn vui lòng lựa chọn cước sắc trước!", 2f);
            return;
        }

        GameModelChan.ShowAvatarPlayer();
        GameManager.Server.DoRequestPluginGame(Utility.SetEsObject(Fields.GAMEPLAY.PLAY, new object[] {
            Fields.ACTION, "xuong",
            "cuoc", cuoc.ToArray()
        }));
        GameObject.Destroy(gameObject);
    }
    public override void OnPublicMessage(Electrotank.Electroserver5.Api.PublicMessageEvent e)
    {
        #region VIEW CONTENT CHAT

        if (e.UserName != GameManager.Instance.mInfo.username)
        {
            PlayerControllerChan player = GameModelChan.GetPlayer(e.UserName);
            if (player != null)
            {
                if (playerChats.ContainsKey(player))
                {
                    if (playerChats[player] != null)
                    {
                        playerChats[player].DestroyMe();
                    }
                    playerChats.Remove(player);
                }
                playerChats.Add(GameModelChan.GetPlayer(e.UserName), PlayerChat.Create(e.Message, GameModelChan.GetPlayer(e.UserName)));
            }
        }
        #endregion
        str = string.Format("{0}" + e.UserName.ToUpper() + ":[-] " + e.Message + "\n", GameModelChan.ListWaitingPlayer.Find(plc => plc.username == e.UserName) != null ? "[FFCC00]" : "[FF6600]");
        base.OnPublicMessage(e);
    }
Exemplo n.º 14
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);
            }
        }
    }
    /// <summary>
    /// Thực hiện sau khi người chơi pick lần thứ 2
    /// </summary>
    IEnumerator OnPickDone(ECard card)
    {
        #region THÔNG BÁO VỚI SERVER LÀ ĐÃ THỰC HIỆN XONG BƯỚC 2
        if (!serverRequestUpdateHandStep2 && GameModelChan.YourController != null && GameModelChan.IndexInTurn == GameModelChan.YourController.slotServer)
        {
            int index = Array.FindIndex <GameObject>(listPickObject, obj => obj == card.gameObject);
            GameManager.Server.DoRequestPluginGame(Utility.SetEsObject(Fields.GAMEPLAY.PLAY, new object[] {
                Fields.ACTION, "getHand", "slotChoice", Utility.SetEsObject(null, "donePick", index)
            }));
        }
        #endregion

        #region CHỜ SERVER TRẢ VỀ THÔNG TIN NGƯỜI CHƠI
        while (string.IsNullOrEmpty(firstPlayer) || firstCardServerResponse == -1)
        {
            yield return(new WaitForEndOfFrame());
        }

        pickAfterDealcard.CardId = firstCardServerResponse;
        pickAfterDealcard.gameObject.transform.parent        = card.gameObject.transform.parent;
        pickAfterDealcard.gameObject.transform.localPosition = Vector3.zero;
        pickAfterDealcard.gameObject.SetActive(true);
        pickAfterDealcard.gameObject.transform.localPosition = new Vector3(pickAfterDealcard.gameObject.transform.localPosition.x, pickAfterDealcard.gameObject.transform.localPosition.y, -2f);
        iTween.RotateTo(pickAfterDealcard.gameObject, new Vector3(0f, 0f, 0f), 0.5f);
        yield return(new WaitForSeconds(0.5f));

        #endregion

        List <DealCardRotation> listDealcard = new List <DealCardRotation>();

        #region QUY ĐỊNH VỊ TRÍ SẼ ĐẾN CỦA CÁC MÔ BÀI
        PlayerControllerChan playerFirst = GameModelChan.ListPlayerInGame.Find(p => p.username == firstPlayer);
        DealCardRotation     dealFirst   = DealCardRotation.GetListRotation.Find(d => d.transform.childCount == 2);
        listDealcard.Add(dealFirst);
        dealFirst.StartRotate(playerFirst.mSide);
        PlayerControllerChan nextPlayer = GameModelChan.GetNextPlayer(playerFirst.slotServer);
        DealCardRotation     nextDeal   = dealFirst.GetNextAvalible;
        for (int i = 0; i < GameModelChan.ListPlayerInGame.Count - 1; i++)
        {
            listDealcard.Add(nextDeal);
            nextDeal.StartRotate(nextPlayer.mSide);
            nextPlayer = GameModelChan.GetNextPlayer(nextPlayer.slotServer);
            nextDeal   = nextDeal.GetNextAvalible;
        }
        #endregion

        while (!listDealcard.TrueForAll(d => d.isComplete))
        {
            yield return(new WaitForFixedUpdate());
        }

        #region DI CHUYỂN VỀ VỊ TRÍ CÓ AVATAR
        DealCardRotation.GetListRotation.ForEach(dealCard => {
            if (dealCard.transform.childCount > 0)
            {
                MoveAllChildToTransform(dealCard.transform, GameModelChan.ListPlayerInGame.Find(p => p.mSide == dealCard.sideEnd).cuiPlayer.transform, 0.5f);
            }
        }
                                                 );
        #endregion
        yield return(new WaitForSeconds(0.6f));

        currentStep = StepDealCard.DONE;
        Array.ForEach <GameObject>(listPickObject, obj => GameObject.Destroy(obj));
    }
Exemplo n.º 16
0
 public ChanCard(int slotIndex, int cardId)
     : base(slotIndex, cardId)
 {
     originSide = currentSide = GameModelChan.game == null ? ESide.Slot_0 : GameModelChan.GetPlayer(slotIndex) == null ? ESide.Slot_0 : GameModelChan.GetPlayer(slotIndex).mSide;
 }
Exemplo n.º 17
0
    /// <summary>
    /// Khi có người chơi đánh bài
    /// </summary>
    /// <param name="index">Người đánh bài</param>
    /// <param name="cardValue">Card đã đánh</param>
    public static void Discard(int soundId, int index, int cardValue, params string[] discardToPlayer)
    {
        ECard card = GetCard_FromHandPlayer(index, cardValue);

        if (GameModelChan.YourController == null || GameModelChan.YourController.slotServer != index)
        {
            card = new ChanCard(index, cardValue);
            card.Instantiate(game.mPlaymat.locationPlayer[(int)GetPlayer(index).mSide]);
            GetPlayer(index).mCardHand.Add(card);
            card.UpdateParent(index);
        }
        GetPlayer(index).mCardDiscardedAndDraw.Add(card);
        GetPlayer(index).mCardDiscarded.Add(card);
        GetPlayer(index).mCardHand.Remove(card);

        if (discardToPlayer != null && discardToPlayer.Length > 0 && discardToPlayer[0] != null)
        {
            PlayerControllerChan p = GetPlayer(discardToPlayer[0]);
            GetPlayer(discardToPlayer[0]).mCardTrash.Add(card);
            card.ChangeSide(p.slotServer);
            card.UpdateParent(p.slotServer);
        }
        else
        {
            GetPlayer(index).mCardTrash.Add(card);
        }



        game.fullLaying = false;

        card.UpdateParent(index);
        if (YourController != null && YourController.slotServer == index)
        {
            game.OnClickSort(game.btSorted.gameObject);
        }
        else
        {
            game.UpdateHand(index, 0.5f);
        }

        if (discardToPlayer != null && discardToPlayer.Length > 0 && discardToPlayer[0] != null)
        {
            game.UpdateHand(GetPlayer(discardToPlayer[0]).slotServer, 0.5f);
        }
        if (discardToPlayer != null && discardToPlayer.Length > 0 && discardToPlayer[0] != null)// co' chiu' tra? cua
        {
            Debug.Log(GameModelChan.GetPlayer(discardToPlayer[0]).username + " PlayerState " + GameModelChan.GetPlayer(index).PlayerState.ToString());

            if (GameModelChan.GetPlayer(discardToPlayer[0]).PlayerState == EPlayerController.EPlayerState.inTurnStealOrIgnore)
            {
                // Chíu cây bốc
                MiniState = EGameStateMini.stealCard_or_skip;
                //SoundGameplay.Instances.playAudioDisCard(cardValue, GetPlayer(index), GetPlayer(discardToPlayer[0]), null);
            }
            else
            {
                // Chíu cây bốc đánh
                MiniState = EGameStateMini.stealCard_or_draw;
                //SoundGameplay.Instances.playAudioDisCard(cardValue, GetPlayer(index), GetNextPlayer(discardToPlayer[0]), null);
            }
        }
        else
        {
            MiniState = EGameStateMini.stealCard_or_draw;
            //SoundGameplay.Instances.playAudioDisCard(cardValue, GetPlayer(index), GetNextPlayer(index), GetLastPlayer(index));
        }
        SoundGameplay.Instances.PlaySoundInGame(soundId, GetPlayer(index));
    }
Exemplo n.º 18
0
 public GameModelChan(GameplayChan gameplay)
 {
     _model = this;
     _game  = gameplay;
 }
Exemplo n.º 19
0
 public ChanCard(int slotIndex)
     : base(slotIndex)
 {
     originSide = currentSide = GameModelChan.GetPlayer(slotIndex).mSide;
 }
Exemplo n.º 20
0
 public static void RemoveAllPlayerWhenAddWaitingPlayer()
 {
     ListWaitingPlayer.Clear();
     ListPlayer.ForEach(p => { GameModelChan.SetPlayer(p.slotServer, null); });
     ListPlayer.Clear();
 }
Exemplo n.º 21
0
    void ProcessGeneral(string command, string action, EsObject eso)
    {
        if (command == Fields.RESPONSE.CREATE_GAME)
        {
            #region CREATE_GAME
            if (eso.getBoolean("successful"))
            {
                GameManager.Instance.selectedLobby.SetDataJoinLobby(eso);
            }
            else
            {
                NotificationView.ShowMessage("Lỗi! Tạo bàn chơi không thành công.", 3f);
            }
            #endregion
        }
        else if (command == "joinGame")
        {
            #region JOIN GAME
            if (EventLoadSence != null)
            {
                EventLoadSence();
            }
            GameManager.Instance.selectedLobby.SetDataJoinLobby(eso);
            WaitingView.Hide();
            PlaySameDevice.SaveDeviceWhenJoinGame();
            #endregion
        }
        else if (command == "removeFriend")
        {
            #region REMOVE FRIEND
            EsObject obj = eso.getEsObject("user");

            User pendingUser = GameManager.Instance.mInfo.pendingBuddies.Find(user => user.username == (obj.variableExists("username") ? obj.getString("username") : obj.getString(Fields.PLAYER.USERNAME)));
            if (pendingUser != null)
            {
                GameManager.Instance.mInfo.pendingBuddies.Remove(pendingUser);

                if (EventFriendPendingChanged != null)
                {
                    EventFriendPendingChanged(pendingUser, true);
                }
            }
            else
            {
                pendingUser = GameManager.Instance.mInfo.buddies.Find(user => user.username == (obj.variableExists("username") ? obj.getString("username") : obj.getString(Fields.PLAYER.USERNAME)));
                GameManager.Instance.mInfo.buddies.Remove(pendingUser);

                if (EventFriendChanged != null)
                {
                    EventFriendChanged(pendingUser, true);
                }
            }
            #endregion
        }
        else if (command == "acceptFriendRequest")
        {
            #region ACCEPT FRIEND REQUEST
            EsObject obj  = eso.getEsObject("user");
            User     user = new User(obj);

            if (GameManager.Instance.mInfo.requestBuddies.Find(u => u.username == user.username) != null)
            {
                GameManager.Instance.mInfo.requestBuddies.Remove(GameManager.Instance.mInfo.requestBuddies.Find(u => u.username == user.username));
            }

            if (GameManager.Instance.mInfo.buddies.Find(u => u.username == user.username) == null)
            {
                User pendingUser = GameManager.Instance.mInfo.pendingBuddies.Find(u => u.username == user.username);
                if (pendingUser != null)
                {
                    GameManager.Instance.mInfo.pendingBuddies.Remove(pendingUser);
                }

                GameManager.Instance.mInfo.buddies.Add(user);
                if (EventFriendChanged != null)
                {
                    EventFriendChanged(user, false);
                }
            }
            #endregion
        }
        else if (command == "friendRequest")
        {
            #region FRIEND REQUEST
            EsObject obj  = eso.getEsObject("user");
            User     user = new User(obj);
            GameManager.Instance.mInfo.pendingBuddies.Add(user);

            if (EventFriendPendingChanged != null)
            {
                EventFriendPendingChanged(user, false);
            }
            #endregion
        }
        else if (command == "inComingMessage")
        {
            #region INCOME MESSAGE
            Messages message = new Messages(eso.getEsObject("message"));
            GameManager.Instance.mInfo.messages.Add(message);

            RegisterEventMessageChanged(message, false);
            #endregion
        }
        else if (command == "outGoingMessage")
        {
            #region OUT GOING MESSAGE
            Messages mess = new Messages();
            mess.SetDataOutGoing(eso);
            GameManager.Instance.mInfo.messages.Add(mess);
            RegisterEventMessageChanged(mess, true);
            #endregion
        }
        else if (command == "systemMessage")
        {
            #region SYSTEM MESSAGE
            Messages message = new Messages(eso.getEsObject("message"));

            message.sender        = 0;
            message.read          = false;
            message.receiver      = GameManager.Instance.mInfo.id;
            message.receiver_name = GameManager.Instance.mInfo.username;

            MessageSystemCache.SaveCache(new Hashtable[] { message.ParseToHashtable });

            if (message.type != 0)
            {
                ServerMessagesView.MessageServer(message.content);
            }
            else
            {
                RegisterEventMessageChanged(message, false);
            }
            #endregion
        }
        else if (command == "invitePlayGame")
        {
            #region INVITE PLAY GAME
            string actionInvited = "joinGame";
            if (eso.variableExists("action"))
            {
                actionInvited = eso.getString("action");
            }

            if (actionInvited == "createGame")
            {
                NotificationView.ShowConfirm("Xác nhận", "Bạn có muốn tạo phòng mới hay không?",
                                             delegate()
                {
                    GameManager.Server.DoRequestPlugin(Utility.SetEsObject(Fields.RESPONSE.CREATE_GAME,
                                                                           new object[] { "config", createRoom() }));
                }, delegate()
                {
                    GameManager.Server.DoRequestCommand("abortInvitation");
                });
            }
            else
            {
                #region INVITE PLAYER
                string userName = eso.getString(Fields.PLAYER.USERNAME);
                int    gameId   = eso.getInteger("gameId");
                string password = eso.variableExists("password") ? eso.getString("password") : "";
                if (password.Length == 0 && eso.variableExists("config"))
                {
                    EsObject esoConfig = eso.getEsObject("config");
                    if (esoConfig.variableExists("password"))
                    {
                        password = esoConfig.getString("password");
                    }
                }
                int roomId    = eso.getInteger("roomId");
                int zoneId    = eso.getInteger("zoneId");
                int gameIndex = eso.getInteger("gameIndex");

                if (GameManager.CurrentScene == ESceneName.LobbyChan || GameManager.CurrentScene == ESceneName.LobbyPhom || GameManager.CurrentScene == ESceneName.LobbyTLMN)
                {
                    string contentMsg = "Bạn nhận được một lời mời chơi!";
                    if (userName.Length > 0)
                    {
                        contentMsg = "\"" + Utility.Convert.ToTitleCase(userName) +
                                     "\" gửi bạn một lời mời tham gia vào bàn chơi số " + gameIndex + ".\n\n";
                    }
                    NotificationView.ShowConfirm("Mời chơi",
                                                 contentMsg,
                                                 delegate()
                    {
                        //GameManager.Instance.selectedLobby = GameManager.CurrentScene == ESceneName.LobbyChan ? new LobbyChan(zoneId, roomId, gameId) : GameManager.CurrentScene == ESceneName.LobbyPhom ? new LobbyPhom(zoneId, roomId, gameId) : new LobbyTLMN(zoneId, roomId, gameId);
                        if (GameManager.CurrentScene == ESceneName.LobbyPhom)
                        {
                            GameManager.Instance.selectedLobby = new LobbyPhom(zoneId, roomId, gameId);
                        }
                        else if (GameManager.CurrentScene == ESceneName.LobbyChan)
                        {
                            GameManager.Instance.selectedLobby = new LobbyChan(zoneId, roomId, gameId);
                        }
                        else
                        {
                            GameManager.Instance.selectedLobby = new LobbyTLMN(zoneId, roomId, gameId);
                        }
                        GameManager.Server.DoJoinGame(password);
                    }, delegate()
                    {
                        GameManager.Server.DoRequestCommand("abortInvitation");
                    });
                }
                #endregion
            }
            #endregion
        }
        else if (command == "updateUserInfo")
        {
            #region CẬP NHẬT THÔNG TIN USERS
            if (eso.variableExists("userName") && eso.getString("userName") == GameManager.Instance.mInfo.username)
            {
                if (eso.variableExists("field"))
                {
                    string field = eso.getString("field");

                    if (field == "money")
                    {
                        string moneyType = "";
                        if (eso.variableExists("moneyType"))
                        {
                            moneyType = eso.getString("moneyType");
                        }
                        if (moneyType != "" && moneyType == "chip")
                        {
                            long.TryParse(eso.getString("value"), out GameManager.Instance.mInfo.chip);
                        }
                        else if (moneyType != "" && moneyType == "gold")
                        {
                            long.TryParse(eso.getString("value"), out GameManager.Instance.mInfo.gold);
                        }
                    }
                    else if (field == "experience")
                    {
                        GameManager.Instance.mInfo.SetDataUser(eso.getEsObject("userInfo"));
                    }

                    if (EventUpdateUserInfo != null)
                    {
                        EventUpdateUserInfo();
                    }
                }
            }
            else if (eso.variableExists("userName") && eso.getString("userName") != GameManager.Instance.mInfo.username)
            {
                if (GameManager.CurrentScene == ESceneName.GameplayChan && eso.variableExists("field"))
                {
                    string field = eso.getString("field");
                    if (field == "experience")
                    {
                        if (GameModelChan.GetPlayer(eso.getString("userName")) != null)
                        {
                            GameModelChan.GetPlayer(eso.getString("userName")).SetDataUser(eso.getEsObject("userInfo"));
                        }
                    }
                }
            }
            #endregion
        }
        else if (command == "updateConfigClient")
        {
            #region CẬP NHẬT THÔNG TIN CONFIG
            if (eso.variableExists("config"))
            {
                IDictionary obj  = (IDictionary)JSON.JsonDecode(eso.getString("config"));
                string      type = obj[Fields.CONFIGCLIENT.KEY_TYPE_REAL_TIME].ToString();
                switch (type)
                {
                case Fields.CONFIGCLIENT.VALUE_ADS:
                    Announcement announce = new Announcement(
                        Convert.ToInt32(obj["index"]),
                        obj["description"].ToString(),
                        obj["scenes"].ToString() == "lobby"
                                ? Announcement.Scene.lobby
                                : obj["scenes"].ToString() == "login"
                                ? Announcement.Scene.login
                                : Announcement.Scene.announce,
                        obj["url"].ToString(),
                        obj["image"].ToString(),
                        obj["type"].ToString() == "Ads" ? Announcement.Type.Advertisement : Announcement.Type.Event
                        );
                    GameManager.Instance.ListAnnouncement.Remove(GameManager.Instance.ListAnnouncement.Find(ads => ads.show == announce.show && ads.type == Announcement.Type.Advertisement));
                    GameManager.Instance.ListAnnouncement.Add(announce);
                    if (EventAdsChanged != null)
                    {
                        EventAdsChanged(obj);
                    }
                    break;

                case Fields.CONFIGCLIENT.VALUE_HELP:
                    StoreGame.Remove(StoreGame.EType.CACHE_HELP);
                    GameManager.Instance.ListHelp.Clear();
                    StoreGame.SaveString(StoreGame.EType.CACHE_HELP, JSON.JsonEncode(obj[Fields.RESPONSE.PHP_RESPONSE_ITEMS]));
                    ArrayList list = (ArrayList)obj[Fields.RESPONSE.PHP_RESPONSE_ITEMS];
                    foreach (Hashtable item in list)
                    {
                        GameManager.Instance.ListHelp.Add(item);
                    }
                    if (EventHelpChanged != null)
                    {
                        EventHelpChanged(obj);
                    }
                    break;

                case Fields.CONFIGCLIENT.VALUE_CONFIG_CLIENT:
                    ArrayList items = (ArrayList)obj[Fields.RESPONSE.PHP_RESPONSE_ITEMS];
                    foreach (Hashtable item in items)
                    {
                        GameManager.Setting.Platform.AddOrUpdatePlatformConfig(item);
                    }
                    if (GameManager.Setting.Platform.GetConfigByType(PlatformType.url_ping) != null)
                    {
                        ServerWeb.URL_PING = GameManager.Setting.Platform.GetConfigByType(PlatformType.url_ping).Value;
                    }
                    if (EventConfigClientChanged != null)
                    {
                        EventConfigClientChanged(obj);
                    }
                    break;
                }
            }
            #endregion
        }
        else if (command == Fields.RESPONSE.DAYLY_GIFT)
        {
            #region Thông tin trả về khi nhận quà tặng
            //AnnouncementView.Instance.Close();
            if (eso.variableExists("textNotification"))
            {
                if (GameObject.Find("__Announcement") != null)
                {
                    AnnouncementView.Instance.SetCenterOnNextCurrentDay();
                }
                GameManager.Instance.FunctionDelay(delegate()
                {
                    string text = eso.getString("textNotification");
                    NotificationView.ShowMessage(text);
                }, 1f);
                GameManager.Instance.ListAnnouncement.RemoveAll(a => a.show == Announcement.Scene.announce && a.type == Announcement.Type.Gift);
            }
            #endregion
        }
        else if (command == Fields.RESPONSE.GET_MESSAGE)
        {
            #region LẤY THÔNG TIN TIN NHẮN TỪ SERVER
            WaitingView.Hide();
            //disable total count khi chưa load messeage
            this.totalMesseageCount = -1;
            if (eso.variableExists("messages"))
            {
                EsObject[] array = eso.getEsObjectArray("messages");
                System.Array.ForEach <EsObject>(array, o => { GameManager.Instance.mInfo.messages.Add(new Messages(o)); });

                List <Messages> systemMessage = GameManager.Instance.mInfo.messages.FindAll(m => m.sender == 0);
                GameManager.Instance.ListMessageSystem.Clear();
                while (systemMessage.Count > 0)
                {
                    GameManager.Instance.ListMessageSystem.Add(systemMessage[0]);
                    GameManager.Instance.mInfo.messages.Remove(systemMessage[0]);
                    systemMessage.RemoveAt(0);
                }
                if (EventGetMessageCallBack != null)
                {
                    EventGetMessageCallBack();
                }
            }
            #endregion
        }
        else if (command == Fields.RESPONSE.GET_BUDDIES)
        {
            #region LẤY THÔNG TIN DANH SÁCH BẠN BÈ
            WaitingView.Hide();
            GameManager.Instance.mInfo.SetDataUser(eso);
            if (EventGetBuddiesCallBack != null)
            {
                EventGetBuddiesCallBack();
            }
            #endregion
        }
        else if (command == "getLevel")
        {
            if (eso.variableExists("level"))
            {
                GameManager.Instance.mInfo.level = eso.getInteger("level");
            }
            if (eso.variableExists("experience"))
            {
                GameManager.Instance.mInfo.experience = eso.getInteger("experience");
            }
            if (eso.variableExists("expMinCurrentLevel"))
            {
                GameManager.Instance.mInfo.expMinCurrentLevel = eso.getInteger("expMinCurrentLevel");
            }
            if (eso.variableExists("expMinNextLevel"))
            {
                GameManager.Instance.mInfo.expMinNextLevel = eso.getInteger("expMinNextLevel");
            }
        }
    }
Exemplo n.º 22
0
 /// <summary>
 /// Xử lý hạ phỏm của người chơi nào đó
 /// </summary>
 public static void Start_WaitFullLaying()
 {
     GameModelChan.ActiveState(EGameState.playerFullLaying);
 }
Exemplo n.º 23
0
    /// <summary>
    /// Hiện thông tin, kết quả khi hết trận.
    /// </summary>
    private IEnumerator _FinishGame()
    {
        #region SHOW OTHER HAND
        foreach (PlayerControllerChan p in GameModelChan.ListPlayerInGame)
        {
            if (GameModelChan.YourController != null && 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; });

            List <int> lst = new List <int>();
            while (p.summary.inHand.Count > 0)
            {
                if (p.mCardHand.Find(c => c.CardId == p.summary.inHand[0]) == null)
                {
                    lst.Add(p.summary.inHand[0]);
                }
                p.summary.inHand.RemoveAt(0);
            }

            foreach (int _value in lst)
            {
                ECard card = p.mCardHand.Find(c => c.CardId == -1);
                if (card != null)
                {
                    card.CardId = _value;
                }
            }

            p.mCardHand.Sort((c1, c2) => c1.CardId.CompareTo(c2.CardId));
        }
        game.UpdateHand();
        #endregion


        //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;
        GameModelChan.game.UpdateUI();
        yield return(new WaitForSeconds(timeShowPoint));

        #region PLAY SOUNDS


        #endregion

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

        MiniState = EGameStateMini.summary_exchange;

        //GameModel.game.UpdateUserInfo();

        //GameModel.game.UpdateUI();
        //yield return new WaitForSeconds(timeShowMoney);

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

        //DestroyObject();

        game.lbDiscard.text = "";

        ListResultXuongView.Close();
        game.fullLayingEffect.Destroy();

        GameModelChan.CreateNewGame();

        ListPlayerInGame.ForEach(p =>
        {
            p.warningMessage = "";
            p.Reset();
            p.summary.result = PlayerControllerChan.FinishGame.ResultSprite.None;
        });

        game.IsProcesResonseDone = true;
    }
Exemplo n.º 24
0
 public override void ChangeSide(int slotIndex)
 {
     currentSide = GameModelChan.GetPlayer(slotIndex).mSide;
     currentSlot = slotIndex;
 }