コード例 #1
0
ファイル: UIMiniGameDebate.cs プロジェクト: wobushiren79/IL
    /// <summary>
    /// 创建卡片
    /// </summary>
    /// <param name="position"></param>
    /// <param name="itemType"></param>
    /// <param name="objContainer"></param>
    /// <returns></returns>
    public GameObject CreateCardItem(int position, ItemMiniGameDebateCardCpt.DebateCardTypeEnun itemType, GameObject objContainer)
    {
        GameObject    objItem = Instantiate(objContainer, objDebateCardModel);
        RectTransform rtfItem = (RectTransform)objItem.transform;

        //初始默认不可点击
        ItemMiniGameDebateCardCpt cardItem = objItem.GetComponent <ItemMiniGameDebateCardCpt>();

        cardItem.ClosePointerListener();
        //设置初始透明度
        CanvasGroup cgItem = objItem.GetComponent <CanvasGroup>();

        cgItem.alpha = 0;

        if (objContainer == objUserDebateCardContainer)
        {
            cardItem.SetData(itemType, 1);
            rtfItem
            .DOLocalMoveY(120, 1)
            .From()
            .SetEase(Ease.OutBack)
            .SetDelay(position * 0.2f)
            .OnStart(
                delegate()
            {
                cgItem.alpha = 1;
                AudioHandler.Instance.PlaySound(AudioSoundEnum.GetCard);
            })
            .OnComplete(
                delegate()
            {
                cardItem.OpenPointerListener();
            });
            miniGameData.listUserCard.Add(cardItem);
        }
        else if (objContainer == objEnemyDebateCardContainer)
        {
            cardItem.SetData(itemType, 2);
            rtfItem
            .DOLocalMoveY(120, 1)
            .From()
            .SetEase(Ease.OutBack)
            .SetDelay(position * 0.2f)
            .OnStart(
                delegate()
            {
                cgItem.alpha = 1;
            })
            .OnComplete(
                delegate()
            {
                cardItem.OpenPointerListener();
            });
            miniGameData.listEnemyCard.Add(cardItem);
        }
        return(objItem);
    }
コード例 #2
0
ファイル: UIMiniGameDebate.cs プロジェクト: wobushiren79/IL
    /// <summary>
    /// 创建战斗卡牌
    /// </summary>
    /// <param name="userCard"></param>
    /// <param name="enemyCard"></param>
    public void CreateCombatAnim(
        ItemMiniGameDebateCardCpt userCard, ItemMiniGameDebateCardCpt enemyCard,
        ItemMiniGameDebateCardCpt winnerCard, ItemMiniGameDebateCardCpt loserCard,
        float preCombatTime, float combatTime)
    {
        enemyCard.transform.SetParent(objCombatContainer.transform);
        enemyCard.ClosePointerListener();
        enemyCard.transform.DOMove(objCombatEnemyPosition.transform.position, preCombatTime).OnComplete(delegate()
        {
            enemyCard.transform.DOMove(objCombatEnemyEndPosition.transform.position, combatTime).SetEase(Ease.InOutBack);
        });

        userCard.transform.SetParent(objCombatContainer.transform);
        userCard.ClosePointerListener();
        userCard.transform.DOMove(objCombatUserPosition.transform.position, preCombatTime).OnComplete(delegate()
        {
            userCard.transform.DOMove(objCombatUserEndPosition.transform.position, combatTime).SetEase(Ease.InOutBack).OnComplete(delegate()
            {
                if (winnerCard == null || loserCard == null)
                {
                    AudioHandler.Instance.PlaySound(AudioSoundEnum.CardDraw);
                    //平手 都删除
                    CardDestroyAnim(userCard);
                    CardDestroyAnim(enemyCard);
                }
                else
                {
                    //败者先删除动画
                    CardDestroyAnim(loserCard);
                    //卡牌特效
                    psCombat.Play();
                    CardDestroyAnim(winnerCard, 1f);
                    //输赢
                    if (userCard == winnerCard)
                    {
                        AudioHandler.Instance.PlaySound(AudioSoundEnum.CardWin);
                    }
                    else
                    {
                        AudioHandler.Instance.PlaySound(AudioSoundEnum.CardLose);
                    }
                }
                //通知动画结束
                if (mCallBack != null)
                {
                    mCallBack.CombatAnimEnd();
                }
            });
        });
    }