示例#1
0
    public void TurnDeck()
    {
        if (deckCards.Count == 0)
        {
            return;
        }

        int deckCnt = deckCards.Count;

        deckCards[deckCnt - 1].frontFace = true;
        deckCards.MoveTo(ref fieldCards, deckCnt - 1);
        fieldCards.ListView();
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        //Firebase.Database.DataSnapshot snapshot = null;
        switch (stateNo)
        {
        case (int)PlayerState.SetUp:

            if (myDB.SnapData == null)
            {
                return;
            }

            handCards.allFront = isPlayable;
            heartBox.allFront  = true;
            DownloadMyHandDB(myDB.SnapData);
            myDB.RemoveReadData();
            if (handCards.Count == 0)
            {
                myDB.ReadQuery(handDBname);
                return;
            }
            Debug.Log("read!");

            PrepareNewPlay();
            stateNo = (int)PlayerState.Idle;
            break;

        case (int)PlayerState.BeginMyPhase:
            if (isPlayable)
            {
                GetSelectableIndexes();
                handCards.Highlight(selectableIndexes);
                handCards.EmphasizeOne(selectableIndexes[selectIndex]);
            }
            else
            {
                myDB.ReadQuery(selectDBname);
            }
            stateNo = (int)PlayerState.MyPhase;
            break;

        case (int)PlayerState.MyPhase:
            if (isPlayable)
            {
                if (SelectCard())
                {
                    stateNo = (int)PlayerState.EndMyPhase;
                    myDB.AddAsync(selectDBname, selectableIndexes[selectIndex]);
                    myDB.Push(queryCountDBname, master.ClientNo.ToString());
                    myDB.ReadQuery(queryCountDBname);
                }
            }
            else
            {
                if (myDB.SnapData == null)
                {
                    return;
                }
                if (int.Parse(myDB.SnapData.GetRawJsonValue()) == -1)
                {
                    myDB.ReadQuery(selectDBname);
                }
                else
                {
                    stateNo = (int)PlayerState.EndMyPhase;
                    handCards.MoveTo(ref fieldBox,
                                     int.Parse(myDB.SnapData.GetRawJsonValue()));
                    fieldBox.ListView();
                    handCards.ListView();
                    myDB.Push(queryCountDBname, master.ClientNo.ToString());
                    myDB.ReadQuery(selectDBname);
                }
                myDB.RemoveReadData();
            }
            break;

        case (int)PlayerState.EndMyPhase:
            //return;
            if (myDB.SnapData == null)
            {
                return;
            }
            if (isPlayable)
            {
                if (myDB.SnapData.ChildrenCount < master.PlayerCnt)
                {
                    myDB.ReadQuery(queryCountDBname);
                }
                else
                {
                    selectIndex = 0;
                    Debug.Log("idle");
                    stateNo = (int)PlayerState.Idle;
                    myDB.AddAsync(selectDBname, -1);
                    Debug.Log(myDB.SnapData.ChildrenCount);
                }
            }
            else
            {
                if (int.Parse(myDB.SnapData.GetRawJsonValue()) != -1)
                {
                    myDB.ReadQuery(selectDBname);
                }
                else
                {
                    stateNo = (int)PlayerState.Idle;
                }
            }
            myDB.RemoveReadData();
            break;

        case (int)PlayerState.Idle:

            break;
        }
    }