示例#1
0
    /// <summary>
    /// 播放出牌动作
    /// </summary>
    public IEnumerator PlayPutCard()
    {
        var        cardValue = battleProxy.GetPlayerActS2C().actCard;
        GameObject putCard   = null;

        if (getCard != null)
        {
            handCards.Add(getCard);
            getCard.transform.DOKill();
            getCard = null;
        }
        if (_data.userId == playerInfoProxy.userID || battleProxy.isReport)
        {
            for (int i = 0; i < handCards.Count; i++)
            {
                if (selectCardInstance == handCards[i].GetInstanceID() && BattleAreaUtil.GetMeshCardValue(handCards[i]) == battleProxy.GetPlayerActS2C().actCard)
                {
                    putCard = handCards[i];
                    handCards.RemoveAt(i);
                    break;
                }
            }
            if (putCard == null)
            {
                for (int i = 0; i < handCards.Count; i++)
                {
                    if (BattleAreaUtil.GetMeshCardValue(handCards[i]) == battleProxy.GetPlayerActS2C().actCard)
                    {
                        putCard = handCards[i];
                        handCards.RemoveAt(i);
                        break;
                    }
                }
            }
            if (_data.userId == playerInfoProxy.userID || battleProxy.isReport)
            {
                for (int i = 0; i < handCards.Count; i++)
                {
                    handCards[i].name = "HandCard" + i;
                }
                handCards.Sort(BattleAreaUtil.CompareCard);
            }
        }
        else
        {
            var randomIndex = Random.Range(0, handCards.Count - 1);
            putCard = handCards[randomIndex];
            handCards.RemoveAt(randomIndex);
            ResourcesMgr.Instance.SetCardMesh(putCard, cardValue);
        }
        putCards.Add(putCard);
        var selfInfoVO = battleProxy.playerIdInfoDic[playerInfoProxy.userID];
        var sitIndex   = (_data.sit - selfInfoVO.sit + GlobalData.SIT_NUM) % GlobalData.SIT_NUM;

        GameMgr.Instance.StartCoroutine(AudioSystem.Instance.PlayEffectAudio(string.Format("Voices/{0}/Card/{1}", _data.sex == 1 ? "Man" : "Woman", cardValue)));
        if (battleProxy.isSkipTween)
        {
            BattleAreaUtil.ResortCard(this);
            ApplicationFacade.Instance.SendNotification(NotificationConstant.TING_UPDATE);
            ApplicationFacade.Instance.SendNotification(NotificationConstant.SHOW_CARD_ARROW, this);
            yield break;
        }
        battleProxy.SetIsForbit(true);
        putCard.transform.DOKill();
        if (sitIndex == 1)
        {
            putCard.transform.localEulerAngles = new Vector3(0, -60, 90);
            putCard.transform.DOScale(Vector3.one * 3, 0.14f);
        }
        else if (sitIndex == 2)
        {
            putCard.transform.localEulerAngles = new Vector3(0, 0, 180);
            putCard.transform.DOScale(Vector3.one * 1.5f, 0.14f);
        }
        else if (sitIndex == 3)
        {
            putCard.transform.localEulerAngles = new Vector3(0, 60, -90);
            putCard.transform.DOScale(Vector3.one * 3, 0.14f);
        }
        else
        {
            putCard.transform.DOScale(Vector3.one * 1.5f, 0.14f);
        }
        putCard.transform.DOLocalMove(sendCard.localPosition, 0.14f);
        yield return(new WaitForSeconds(0.25f));

        putCard.transform.SetParent(putCardContainer);
        var anglePosition = BattleAreaUtil.GetPutCardPosition(this, putCards.Count - 1);

        putCard.transform.localEulerAngles = anglePosition[0];
        putCard.transform.DOLocalMove(anglePosition[1], 0.1f);
        putCard.transform.DOScale(Vector3.one, 0.1f);
        yield return(new WaitForSeconds(0.1f));

        GameMgr.Instance.StartCoroutine(AudioSystem.Instance.PlayEffectAudio("Voices/Effect/PutCard"));
        BattleAreaUtil.ResortCard(this);
        ApplicationFacade.Instance.SendNotification(NotificationConstant.TING_UPDATE);
        battleProxy.SetIsForbit(false);
        ApplicationFacade.Instance.SendNotification(NotificationConstant.SHOW_CARD_ARROW, this);

        if (PlayerPrefs.GetInt(battleProxy.GetPlayerActS2C().userId.ToString()) == 1)
        {
            SetHandCardsGray(null, true);
        }
    }