Ejemplo n.º 1
0
    public static void Create(int indexFrom, int indexTo, int money)
    {
        #region MOVE EFFECT MONEY EXCHANGE
        GameObject obj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Gameplay/ChipEffectPrefab"));
        obj.AddComponent <MoneyExchangeView>();

        obj.name                 = "Money Exchange";
        obj.transform.parent     = GameModelPhom.game.mPlaymat.locationPlayer[0].parent;
        obj.transform.localScale = Vector3.one;
        //obj.transform.localScale = new Vector3(40f, 40f, 40f);

        Vector3 posFrom = GameModelPhom.game.mPlaymat.locationPlayer[(int)GameModelPhom.GetPlayer(indexFrom).mSide].localPosition;
        posFrom.z -= 30f;
        Vector3 posTo = GameModelPhom.game.mPlaymat.locationPlayer[(int)GameModelPhom.GetPlayer(indexTo).mSide].localPosition;
        posTo.z -= 30f;
        if (indexTo == GameModelPhom.YourController.slotServer)
        {
            posTo.y = -290f;
        }


        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
    }
Ejemplo n.º 2
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 GameModelPhom.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");
    }
Ejemplo 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
            }));
        }
    }
Ejemplo n.º 4
0
    public void UpdateButtonAddMeld()
    {
        while (listObjAddMeld.Count > 0)
        {
            GameObject.Destroy(listObjAddMeld[0].Value);
            listObjAddMeld.Remove(listObjAddMeld[0]);
        }

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

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

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

                GameObject obj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Gameplay/btAddMeldPrefab"));
                obj.GetComponent <UIButtonMessage>().target = GameModelPhom.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 <GamePlayPhom.GiveCard, GameObject>(give, obj));
            }
            #endregion
        }
    }
Ejemplo n.º 5
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 (GameModelPhom.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.GetComponent <UISprite>().depth = gameObject.GetComponent <ECardTexture>().texture.depth;
                imageStar.transform.localPosition         = new Vector3(0f, 0f, -0.1f);
                imageStar.transform.localScale            = new Vector3(0.48f, 0.48f, 1f);
                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(0.48f, 0.48f, 1f); imageStar.transform.localRotation = new Quaternion(0f, 0f, 0f, 0f); }, 0.75f);
            }
        }

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

        if (GameModelPhom.GetPlayer(slotIndex).mCardHand.Contains(this))
        {
            gameObject.transform.parent = GameModelPhom.game.mPlaymat.locationHand[(int)currentSide].parent;
        }
        else if (GameModelPhom.GetPlayer(slotIndex).mCardTrash.Contains(this))
        {
            gameObject.transform.parent = GameModelPhom.game.mPlaymat.locationTrash[currentSlot].parent;
        }
        else
        {
            foreach (Meld meld in GameModelPhom.GetPlayer(slotIndex).mCardMelds)
            {
                if (meld.meld.Contains(this))
                {
                    gameObject.transform.parent = GameModelPhom.game.mPlaymat.locationMelds[currentSlot].parent;
                    break;
                }
            }
        }

        gameObject.name = (int)originSide + " " + CardId;
    }
Ejemplo n.º 6
0
    public override void UpdateButton()
    {
        GameModelPhom.game.deck.SetActive((int)GameModelPhom.CurrentState >= (int)GameModelPhom.EGameState.deal && GameModelPhom.DeckCount > 0);

        GameModelPhom.game.deck.transform.FindChild("btDrawInDeck").gameObject.SetActive(GameModelPhom.IsYourTurn && GameModelPhom.MiniState == GameModelPhom.EGameStateMini.stealCard_or_draw);

        if (GameModelPhom.YourController.PlayerState == PlayerControllerPhom.EPlayerState.waiting)
        {
            return;
        }

        if (GameModelPhom.DealCardDone == false)
        {
            return;
        }

        GameModelPhom.game.btSorted.gameObject.SetActive(GameModelPhom.CurrentState == GameModelPhom.EGameState.playing);

        #region NHOM 2
        UpdateButtonLayMeld();
        #endregion

        GameModelPhom.game.btStealCard.gameObject.SetActive(GameModelPhom.IsYourTurn && GameModelPhom.game.stolen);

        if (objStealCard == null && GameModelPhom.IsYourTurn && GameModelPhom.game.stolen)
        {
            int       side  = (int)GameModelPhom.GetPlayer(GameModelPhom.IndexLastInTurn).mSide;
            Transform trans = GameModelPhom.game.mPlaymat.locationTrash[side];
            objStealCard = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Gameplay/btStealCardPrefab"));
            objStealCard.GetComponent <UIButtonMessage>().target = GameModelPhom.game.gameObject; //SendTo Gameplay Method OnProcessStealCard
            objStealCard.transform.parent        = trans.parent;
            objStealCard.transform.localPosition = new Vector3(trans.localPosition.x, trans.localPosition.y, -5);
            objStealCard.transform.localScale    = Vector3.one;
        }
        else if (objStealCard != null)
        {
            GameObject.Destroy(objStealCard);
        }

        UpdateButtonDiscard();
    }
    public override void OnPublicMessage(Electrotank.Electroserver5.Api.PublicMessageEvent e)
    {
        #region VIEW CONTENT CHAT

        if (e.UserName != GameManager.Instance.mInfo.username)
        {
            PlayerControllerPhom player = GameModelPhom.GetPlayer(e.UserName);
            if (player != null)
            {
                if (playerChats.ContainsKey(player))
                {
                    if (playerChats[player] != null)
                    {
                        playerChats[player].DestroyMe();
                    }
                    playerChats.Remove(player);
                }
                playerChats.Add(GameModelPhom.GetPlayer(e.UserName), PlayerChat.Create(e.Message, GameModelPhom.GetPlayer(e.UserName)));
            }
        }
        #endregion
        str = "[FF6600]" + e.UserName.ToUpper() + ":[-] " + e.Message + "\n";
        base.OnPublicMessage(e);
    }
Ejemplo n.º 8
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");
                    PlayerControllerPhom p = GameModelPhom.GetPlayer(username);
                    if (obj.getIntegerArray("hand").Length != p.mCardHand.Count)
                    {
                        Debug.LogWarning("Số lượng PhomCard 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 PhomCard = p.mCardHand.Find(c => c.CardId == cardId);
                            if (PhomCard == null)
                            {
                                p.mCardHand.Find(c => c.CardId == -1).CardId = cardId;
                            }
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 9
0
 public override void ChangeSide(int slotIndex)
 {
     currentSide = GameModelPhom.GetPlayer(slotIndex).mSide;
     currentSlot = slotIndex;
 }
Ejemplo n.º 10
0
 public PhomCard(int slotIndex, int cardId)
     : base(slotIndex, cardId)
 {
     originSide = currentSide = GameModelPhom.game == null ? ESide.You : GameModelPhom.GetPlayer(slotIndex).mSide;
 }
Ejemplo n.º 11
0
 public PhomCard(int slotIndex)
     : base(slotIndex)
 {
     originSide = currentSide = GameModelPhom.GetPlayer(slotIndex).mSide;
 }
Ejemplo n.º 12
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);
            }
        }
    }
Ejemplo n.º 13
0
    /// <summary>
    /// Hiện thông tin, kết quả khi hết trận.
    /// </summary>
    private IEnumerator _FinishGame()
    {
        #region SET RESULT
        if (game.gameFinishType == GamePlayPhom.EFinishType.NORMAL)
        {
            GamePlayPhom.Summary sum = game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.TOP_2);
            if (sum != null)
            {
                GameModelPhom.GetPlayer(sum.targetPlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.VE_NHAT;
                GameModelPhom.GetPlayer(sum.sourcePlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.VE_NHI;
            }
            else
            {
                if (game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.MOM) != null)
                {
                    GameModelPhom.GetPlayer(game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.MOM).targetPlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.VE_NHAT;
                }
                else if (game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.XAO_KHAN) != null)
                {
                    GamePlayPhom.Summary xaoKhan = game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.XAO_KHAN);
                    GameModelPhom.GetPlayer(xaoKhan.targetPlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.XAO_KHAN;
                    ListPlayerInGame.ForEach(p =>
                    {
                        if (p.username != xaoKhan.targetPlayer)
                        {
                            p.summary.result = PlayerControllerPhom.FinishGame.ResultSprite.MOM;
                        }
                    });
                }
            }

            sum = game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.TOP_3);
            if (sum != null)
            {
                GameModelPhom.GetPlayer(sum.sourcePlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.VE_BA;
            }

            sum = game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.TOP_4);
            if (sum != null)
            {
                GameModelPhom.GetPlayer(sum.sourcePlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.VE_TU;
            }

            List <GamePlayPhom.Summary> lstSum = game.summaryGame.FindAll(o => o.action == GamePlayPhom.Summary.EAction.MOM);
            if (lstSum.Count > 0)
            {
                foreach (GamePlayPhom.Summary s in lstSum)
                {
                    GameModelPhom.GetPlayer(s.sourcePlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.MOM;
                }
            }
        }
        else
        {
            GamePlayPhom.Summary sum;
            if (game.gameFinishType == GamePlayPhom.EFinishType.U_THUONG || game.gameFinishType == GamePlayPhom.EFinishType.U_DEN_THUONG)
            {
                sum = game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.U_THUONG || o.action == GamePlayPhom.Summary.EAction.U_TRON || o.action == GamePlayPhom.Summary.EAction.DEN_LANG);
                if (sum != null)
                {
                    GameModelPhom.GetPlayer(sum.targetPlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.U;
                }
            }
            else if (game.gameFinishType == GamePlayPhom.EFinishType.U_TRON || game.gameFinishType == GamePlayPhom.EFinishType.U_DEN_TRON)
            {
                sum = game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.U_TRON || o.action == GamePlayPhom.Summary.EAction.DEN_LANG);
                if (sum != null)
                {
                    GameModelPhom.GetPlayer(sum.targetPlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.U_TRON;
                }
            }
            else if (game.gameFinishType == GamePlayPhom.EFinishType.U_XUONG)
            {
                sum = game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.U_XUONG);
                if (sum != null)
                {
                    GameModelPhom.GetPlayer(sum.targetPlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.U_XUONG;
                }
            }
        }
        #endregion

        #region SHOW OTHER HAND
        foreach (PlayerControllerPhom p in GameModelPhom.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; });

            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

        #region CHUYỂN CÁC QUÂN BÀI THẮNG TRẮNG RA GIỮA MÀN HÌNH
        if (game.gameFinishType != GamePlayPhom.EFinishType.NORMAL && YourController.mCardHand.Count == 0)
        {
            int i = 0;
            YourController.mCardMelds.ForEach(meld =>
            {
                for (int j = 0; j < meld.meld.Count; j++)
                {
                    ECard card = meld.meld[j];
                    card.SetHightlight();
                    Hashtable hash = new Hashtable();
                    hash.Add("islocal", true);
                    hash.Add("time", 0.75f);
                    hash.Add("position", game.mPlaymat.GetLocationFulllaying(YourController, i, j));
                    iTween.MoveTo(card.gameObject, hash);
                    iTween.ScaleTo(card.gameObject, Vector3.one * 1.5f, 0.75f);
                }
                i++;
            });
        }
        #endregion

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

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

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

        #region PLAY SOUNDS

        SoundGamePhom.Instances.PlaySound(game);


        #endregion

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

        MiniState = EGameStateMini.summary_exchange;

        GameModelPhom.game.UpdateUserInfo();

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

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

        //DestroyObject();

        game.IsProcesResonseDone = true;
    }