Example #1
0
    void setListData(Card card)
    {
        GameObject itemObj    = NGUITools.AddChild(grid.gameObject, cardObj);
        NumberCard itemSource = itemObj.GetComponent <NumberCard>();

        itemSource.setData(card.isOpen, card.index);
        itemSource.selectCallback((int index) => {
            Debug.Log("select index : " + index);
            IndicatorManager.Instance().show("로딩중입니다.");

            selectIndex = index;
            RequestSelectFieldCard req = new RequestSelectFieldCard(UserManager.Instance().email, index, roomNo);
            SocketManager.Instance().sendMessage(req);
        });
        cardObjList.Add(itemObj);
    }
Example #2
0
 public void selectedCard(bool isOpen, int index)
 {
     if (isOpen)
     {
         //유저카드선택
     }
     else
     {
         //필드카드선택
         if (!isInit)
         {
             RequestInit req = new RequestInit(roomNo);
             SocketManager.Instance().sendMessage(req);
             IndicatorManager.Instance().show("다른 유져의 선택을 기다립니다.");
         }
         else
         {
             //attack
             userListPanel.attackGuide.gameObject.SetActive(true);
         }
     }
 }
Example #3
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();
        turnMessage.gameObject.SetActive(false);

        ResponseGameCardInfo res = JsonUtility.FromJson <ResponseGameCardInfo>(DavinciCommon.gamePlayingData.json);

        initState(res);

        IndicatorManager.Instance().hide();
        UserManager.Instance().loadData();

        selectableCard.delegateSelected += selectedCard;

        attackPanel.gameObject.SetActive(false);
        selectableCard.gameObject.SetActive(false);

        maxIndex = res.fieldCardList.Count - 1;

        roomNo = res.roomNo;

        foreach (UserGameData user in res.userList)
        {
            if (user.email.Equals(UserManager.Instance().email))
            {
                isMaster = user.userType == (int)Common.USER_TYPE.MASTER ? true : false;
            }
        }

        userListPanel.init(res.userList, roomNo);

        selectableCard.init(res.fieldCardList, roomNo);
        int selectCount = res.userList.Count > 3 ? 3 : 4;

        selectableCard.show(selectCount);
        initLoadingPanel.gameObject.SetActive(false);
    }
Example #4
0
    // Update is called once per frame
    public override void Update()
    {
        base.Update();

        if (isUpdate)
        {
            isUpdate = false;
            ResponseBaseDavincicode resBase = JsonUtility.FromJson <ResponseSelectFieldCard>(resString);

            List <UserGameData> userList      = resBase.userList;
            List <Card>         fieldCardList = resBase.fieldCardList;
            userListPanel.setData(resBase.userList, resBase.turnUserIndex);
            selectableCard.setData(fieldCardList, false);

            switch (resBase.identifier)
            {
            case DavinciCommon.IDENTIFIER_GAME_FINISH:
            {
                Debug.Log("finish game");
            }
            break;

            case DavinciCommon.IDENTIFIER_SELECT_FIELD_CARD:
            {
                //ResponseSelectFieldCard res = JsonUtility.FromJson<ResponseSelectFieldCard>(resString);
                if (resBase.isSuccess() == false)
                {
                    selectableCard.reload();
                    showAlert(resBase.identifier, resBase.message, false, false, (AlertData data, bool isOn, string fieldText) => {
                        });
                }
                else
                {
                    //selectableCard.updateData(res.fieldCardList, res.isSuccess(), selectableCard.gameObject.activeSelf);
                    userListPanel.reload();
                    if (isInit)
                    {
                        UserGameData player = resBase.userList[resBase.turnUserIndex];

                        if (player.email.Equals(UserManager.Instance().email))
                        {
                            IndicatorManager.Instance().hide();
                            selectableCard.setData(fieldCardList, true);
                        }
                        else
                        {
                            if (player.userType == (int)Common.USER_TYPE.COMPUTER)
                            {
                                if (isMaster)
                                {
                                    //autoSelectUserCard(resBase.userList, resBase.fieldCardList, player);
                                    StartCoroutine(waitAttack(resBase.userList, resBase.fieldCardList, player));
                                }
                            }
                        }
                    }
                    else
                    {
                        IndicatorManager.Instance().hide();
                        selectableCard.setData(fieldCardList, true);
                    }
                }
            }
            break;

            case DavinciCommon.IDENTIFIER_SELECT_USER_CARD:
            {
            }
            break;

            case DavinciCommon.IDENTIFIER_TURN:
            {
                if (isInit == false)
                {
                    isInit = true;
                    userListPanel.reload();
                }

                //ResponseTurn res = JsonUtility.FromJson<ResponseTurn>(resString);
                UserGameData player = resBase.userList[resBase.turnUserIndex];
                IndicatorManager.Instance().hide();
                userListPanel.attackGuide.gameObject.SetActive(false);
                turnMessage.gameObject.SetActive(true);
                turnMessage.show(() => {
                        userListPanel.setTrun(resBase.turnUserIndex);
                        if (player.email.Equals(UserManager.Instance().email))
                        {
                            IndicatorManager.Instance().hide();
                            if (resBase.fieldCardList.Count > 0)
                            {
                                selectableCard.show(1);
                            }
                            else
                            {
                                userListPanel.attackGuide.gameObject.SetActive(true);
                            }
                        }
                        else
                        {
                            IndicatorManager.Instance().show(player.nickName + " 님의 턴입니다.");
                            //showTurnMsg(player.nickName);

                            if (player.userType == (int)Common.USER_TYPE.COMPUTER)
                            {
                                if (isMaster)
                                {
                                    //autoSelectFieldCard(resBase.fieldCardList, player);
                                    if (resBase.fieldCardList.Count > 0)
                                    {
                                        StartCoroutine(waitSelectFieldCard(resBase.fieldCardList, player));
                                    }
                                    else
                                    {
                                        StartCoroutine(waitAttack(resBase.userList, resBase.fieldCardList, player));
                                    }
                                }
                            }
                        }
                    });
            }
            break;

            case DavinciCommon.IDENTIFIER_ATTACK:
            {
                ResponseAttack res    = JsonUtility.FromJson <ResponseAttack>(resString);
                UserGameData   player = res.userList[res.turnUserIndex];
                if (res.isSuccess() == false)
                {
                    if (player.email.Equals(UserManager.Instance().email))
                    {
                        showAlert(resBase.identifier, res.message, false, false, (AlertData data, bool isOn, string fieldText) => {
                            });
                    }
                }
                else
                {
                    userListPanel.attack(res.selectUser, res.selectIndex, res.attackValue, (bool isSuccess) => {
                            Debug.Log("attack result : " + isSuccess);
                            if (isSuccess)
                            {
                                userListPanel.reload();
                                userListPanel.checkLose(res.selectUser);

                                if (player.email.Equals(UserManager.Instance().email))
                                {
                                    showAlert("select", "공격을 계속 하시겠습니까?", true, false, (AlertData data, bool isOn, string fieldText) => {
                                        if (!isOn)
                                        {
                                            RequestNext req = new RequestNext(roomNo);
                                            SocketManager.Instance().sendMessage(req);
                                        }
                                        else
                                        {
                                            userListPanel.attackGuide.gameObject.SetActive(false);
                                        }
                                    });
                                }
                                else
                                {
                                    if (player.userType == (int)Common.USER_TYPE.COMPUTER)
                                    {
                                        if (isMaster)
                                        {
                                            if (rm.Next(3) > 2)
                                            {
                                                RequestNext req = new RequestNext(roomNo);
                                                SocketManager.Instance().sendMessage(req);
                                            }
                                            else
                                            {
                                                StartCoroutine(waitAttack(resBase.userList, resBase.fieldCardList, player));
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                userListPanel.attackGuide.gameObject.SetActive(false);
                                userListPanel.openCard(res.turnUserIndex, res.openIndex, () => {
                                    RequestNext req = new RequestNext(roomNo);
                                    SocketManager.Instance().sendMessage(req);
                                });
                            }
                        });
                }
            }
            break;
            }
        }

        if (IndicatorManager.Instance().isShow&& IndicatorManager.Instance().gameObject.activeSelf == false)
        {
            IndicatorManager.Instance().gameObject.SetActive(true);
        }
    }