Пример #1
0
    private void SendCardToBattlefield(CardVisual card)
    {
        if (owner == null)
        {
            owner = card.owner;
        }


        if (card.primaryCardType == Constants.CardType.Soul && owner.battleFieldManager.IsCollectionFull())
        {
            Debug.LogWarning("board is Full");
            //SendCardToHand(card);
            if (card.photonView.isMine)
            {
                RPCTransferCard(PhotonTargets.All, card, owner.myHand);
            }
            return;
        }

        //Debug.Log(card.gameObject.name + " is going to the battlefield");
        CheckAndActivateCard(card);

        switch (card.cardData.primaryCardType)
        {
        case Constants.CardType.Player:
            card.RPCChangeCardVisualState(PhotonTargets.All, CardVisual.CardVisualState.ShowBattleToken);

            if (card.photonView.isMine)
            {
                card.battlefieldPos = owner.battleFieldManager.AssignSpecificPosition(owner.battleFieldManager.transform.Find("PlayerBattlePos"), card);
            }

            break;

        case Constants.CardType.Soul:
            card.RPCChangeCardVisualState(PhotonTargets.All, CardVisual.CardVisualState.ShowBattleToken);

            if (card.photonView.isMine)
            {
                Transform desiredLocation = owner.battleFieldManager.GetNearestCardPosition(card.gameObject.transform.position);

                card.battlefieldPos = owner.battleFieldManager.AssignSpecificPosition(desiredLocation, card);
                owner.battleFieldManager.ClearAllHighlights();

                if (card.battlefieldPos == null)
                {
                    card.battlefieldPos = owner.battleFieldManager.GetFirstEmptyCardPosition(card);
                }


                card.transform.position = card.battlefieldPos.position;
                card.RPCSetCardAciveState(PhotonTargets.All, false);
                card.RPCSetCardPosition(PhotonTargets.Others, card.battlefieldPos.position);
                card.DisplaySummoneEffect();
            }

            break;

        case Constants.CardType.Support:
            card.RPCChangeCardVisualState(PhotonTargets.All, CardVisual.CardVisualState.ShowBattleToken);

            if (card.photonView.isMine)
            {
                //card.battlefieldPos = owner.battleFieldManager.GetFirstEmptyCardPosition();
                card.battlefieldPos = owner.supportPositionManager.GetFirstEmptyCardPosition(card);
            }


            break;

        case Constants.CardType.Spell:

            if (card.photonView.isMine)
            {
                StartCoroutine(SendSpellAway(card));
            }

            break;

        case Constants.CardType.Domain:

            card.RPCChangeCardVisualState(PhotonTargets.All, CardVisual.CardVisualState.ShowFront);
            if (decktype == DeckType.Domain && photonView.isMine)
            {
                DomainManager dm = GetComponent <DomainManager>();
                dm.RPCActivateDomainTile(PhotonTargets.All);
                card.transform.localPosition = new Vector3(60f, 60f, -60f);
            }


            break;

        default:

            break;
        }
    }