Exemplo n.º 1
0
    public void ReceiveNetworkCorrection(byte[] data)
    {
        int        x;
        int        y;
        int        type;
        int        selectEffectID;
        cardStates state;

        x              = System.BitConverter.ToInt16(data, 2);
        y              = System.BitConverter.ToInt16(data, 2 + 2);
        type           = System.BitConverter.ToInt16(data, 2 + 2 + 2);
        selectEffectID = System.BitConverter.ToInt16(data, 2 + 2 + 2 + 2);

        char cState = (char)data [2 + 2 + 2 + 2 + 2];

        switch (cState)
        {
        case cs_open:
            state = cardStates.open;
            break;

        case cs_close:
            state = cardStates.close;
            break;

        case cs_match:
            state = cardStates.matched;
            break;

        default:
            state = cardStates.close;
            break;
        }

        IndividualCard myCard = null;

        try{
            myCard = CardHandler.s.allCards [x, y];

            //these will unselect the card from respective places
            LocalPlayerController.s.ReceiveNetworkCorrection(myCard);
            PowerUpManager.s.ReceiveNetworkCorrection(myCard);
            NPCManager.s.ReceiveNetworkCorrection(myCard);
        } catch (Exception e) {
            DataLogger.LogMessage(e.Message + " - " + e.StackTrace);
        }

        if (myCard != null)
        {
            //after unselection is done, we will update the card type to be correct
            CardHandler.s.UpdateCardType(x, y, type);

            switch (state)
            {
            case cardStates.open:
                myCard.SelectCard(-1);
                if (selectEffectID > 0)
                {
                    myCard.DestroySelectedEfect();
                    myCard.selectedEffect = (GameObject)Instantiate(GS.a.gfxs.selectEffects[selectEffectID].gameObject, myCard.transform.position, Quaternion.identity);
                }
                break;

            case cardStates.close:
                myCard.UnSelectCard();
                break;

            case cardStates.matched:
                myCard.NetworkCorrectMatch();
                break;

            default:
                myCard.UnSelectCard();
                break;
            }
        }
    }