Ejemplo n.º 1
0
    void RoseAnimation(Sequence se, MsgProps type, Transform startPos, Transform endPos, float scale, string tweenName)
    {
        GameObject propTween1 = CreatePropsGm(type, startPos, GetScaleMutiple(type, 1), tweenName);

        propTween1.transform.localScale = Vector3.one * 0.3f;
        AudioManager.Instance.PlayPropsAudio((uint)MsgProps.MsgPropsRose);
        float destroyTime = GetAnimatorTime(propTween1);

        if (startPos == endPos)
        {
            se.AppendInterval(deltaTime);
        }
        else
        {
            se.Append(propTween1.transform.DOLocalMove(GetEndPostion(endPos), deltaTime * 16));
        }
        se.AppendCallback(delegate
        {
            propTween1.GetComponent <SkeletonAnimation>().AnimationName = "animation";
        });
        se.AppendInterval(destroyTime * 2);
        se.AppendCallback(
            delegate
        {
            DestroyTween(propTween1);
        });
    }
Ejemplo n.º 2
0
 bool isNeedMoveOfSelf(MsgProps type)
 {
     if (type == MsgProps.MsgPropsGod)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 3
0
    /// <summary>
    /// 三个预支体的组合
    /// </summary>
    /// <param name="toolParent"></param>
    /// <param name="type"></param>
    /// <param name="startPos"></param>
    /// <param name="endPos"></param>
    /// <param name="tweenName"></param>
    /// <param name="time"></param>
    void CretePropsTween_Three(MsgProps type, Transform startPos, Transform endPos, string tweenName, int time = 1)
    {
        Sequence se          = DOTween.Sequence();
        float    destroyTime = 0;
        float    deltaTime   = 0.04f;//按照一秒25帧计算

        GameObject propTween1 = CreatePropsGm(type, startPos, GetScaleMutiple(type, 1), tweenName + 1);

        //制作动画
        if (startPos == endPos)
        {
            se.Append(propTween1.transform.DOLocalMove(GetEndPostion(endPos), isNeedMoveOfSelf(type) == true ? deltaTime * 5 : 0));
        }
        else
        {
            se.Append(propTween1.transform.DOLocalMove(GetEndPostion(endPos), deltaTime * 24));
            if (type == MsgProps.MsgPropsGod)
            {
                se.AppendInterval(GetAnimatorTime(propTween1));
            }
        }
        //第二个动画制作
        GameObject propTween2 = CreatePropsGm(type, endPos, GetScaleMutiple(type, 2), tweenName + 2);

        destroyTime = GetAnimatorTime(propTween2);
        propTween2.SetActive(false);
        se.AppendCallback(delegate
        {
            DestroyTween(propTween1);
            //propTween2.transform.localPosition = endPos;
            AudioManager.Instance.PlayPropsAudio((uint)type);
            propTween2.SetActive(true);
        });
        //结束第一个动画,开始第二个动画
        se.AppendInterval(destroyTime);

        //第三个动画制作
        GameObject propTween3 = CreatePropsGm(type, endPos, GetScaleMutiple(type, 3), tweenName + 3);
        Animator   animator2  = propTween3.GetComponent <Animator>();

        destroyTime = GetAnimatorTime(propTween3);
        propTween3.SetActive(false);
        //结束第二个动画,开始第三个动画
        se.AppendCallback(delegate
        {
            DestroyTween(propTween2);
            propTween3.SetActive(true);
        });

        se.AppendInterval(destroyTime * time);
        se.AppendCallback(delegate
        {
            DestroyTween(propTween3);
        });
    }
Ejemplo n.º 4
0
    public void PlayPropsAnimation(ArgsPropsInfo propInfo, Transform toolParent, Transform startPos, Transform endPos)
    {
        MsgProps type = (MsgProps)propInfo.propsId;
        Sequence se   = DOTween.Sequence();

        string tweenName = "";

        switch (type)
        {
        case MsgProps.MsgPropsEgg:    //鸡蛋 >>ok
            tweenName = "AnimProp_jidan";
            CretePropsTween_Two(type, startPos, endPos, tweenName);
            break;

        case MsgProps.MsgPropsBeer:    //啤酒 >>Ok 修改 同玫,因为有动画状态机 两个动画中间有个转换
            tweenName = "AnimProp_pijiu";
            BeerAnimation(se, type, startPos, endPos, GetScaleMutiple(type, 1), tweenName);
            break;

        case MsgProps.MsgPropsBomb:    //炸弹 >>ok
            tweenName = "AnimProp_shoulei";
            CretePropsTween_Two(type, startPos, endPos, tweenName);
            break;

        case MsgProps.MsgPropsRose:    //玫瑰 >>修改 添加了一个预制体
            tweenName = "AnimProp_yizhihua";
            RoseAnimation(se, type, startPos, endPos, GetScaleMutiple(type, 1), tweenName);
            break;

        case MsgProps.MsgPropsKnife:    //刀子 >>修改 修改了刀光
            tweenName = "AnimProp_caidao";
            CretePropsTween_Two(type, startPos, endPos, tweenName);
            break;

        case MsgProps.MsgPropsBrick:    //板砖 >>Ok
            tweenName = "AnimProp_Tbanzhuan";
            CretePropsTween_Two(type, startPos, endPos, tweenName);
            break;

        case MsgProps.MsgPropsIncense:    //香炉 >>Ok  修改了烟雾
            tweenName = "AnimProp_xianglu";
            CretePropsTween_Two(type, startPos, endPos, tweenName, 4);
            break;

        case MsgProps.MsgPropsGod:    //财神  >>OK
            tweenName = "AnimProp_dushen";
            CretePropsTween_Three(type, startPos, endPos, tweenName, 15);
            break;
        }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 两个预支体的组合
    /// </summary>
    /// <param name="toolParent"></param>
    /// <param name="type"></param>
    /// <param name="startPos"></param>
    /// <param name="endPos"></param>
    /// <param name="tweenName"></param>
    /// <param name="time">第二动画重复的次数</param>
    void CretePropsTween_Two(MsgProps type, Transform startPos, Transform endPos, string tweenName, int time = 1)
    {
        Sequence   se          = DOTween.Sequence();
        float      destroyTime = 0;
        GameObject propTween1  = CreatePropsGm(type, startPos, GetScaleMutiple(type, 1), tweenName + 1);
        //只是获取时间用
        GameObject propTween2 = CreatePropsGm(type, endPos, GetScaleMutiple(type, 2), tweenName + 2);

        //propTween2.transform.localPosition = new Vector3(10000, 10000);
        destroyTime = GetAnimatorTime(propTween2);
        propTween2.SetActive(false);
        //制作动画
        if (startPos == endPos)
        {
            se.Append(propTween1.transform.DOLocalMove(GetEndPostion(endPos), isNeedMoveOfSelf(type) == true ? deltaTime * 5 : 0));
        }
        else
        {
            if (type == MsgProps.MsgPropsBomb || type == MsgProps.MsgPropsKnife || type == MsgProps.MsgPropsBrick)
            {
                se.Append(propTween1.transform.DOLocalMove(GetEndPostion(endPos), deltaTime * 16));
            }
            else
            {
                se.Append(propTween1.transform.DOLocalMove(GetEndPostion(endPos), deltaTime * 24));
            }
        }
        se.AppendCallback(delegate
        {
            DestroyTween(propTween1);
            AudioManager.Instance.PlayPropsAudio((uint)type);
            propTween2.SetActive(true);
        });

        //开始第二个动画
        if (type == MsgProps.MsgPropsBomb)
        {
            destroyTime += 8 * deltaTime;
        }
        se.AppendInterval(destroyTime * time);
        se.AppendCallback(delegate
        {
            DestroyTween(propTween2);
        });
    }
Ejemplo n.º 6
0
    /// <summary>
    /// 默认大小有改变
    /// </summary>
    /// <param name="type"></param>
    /// <param name="rank"></param>
    /// <returns></returns>
    float GetScaleMutiple(MsgProps type, int rank /*第几个动画*/)
    {
        //rank 1 默认100   rank=2  默认100
        float scale = 1;

        switch (type)
        {
        case MsgProps.MsgPropsBomb:
            if (rank == 2)
            {
                scale = 100;
            }
            break;

        case MsgProps.MsgPropsGod:
            scale = 0.9f;
            break;
        }
        return(scale);
    }
Ejemplo n.º 7
0
    public GameObject CreatePropsGm(MsgProps type, Transform createParent, float scale, string prefabname)
    {
        GameObject propTween = GameObject.Instantiate(ResourceManager.Instance.LoadAsset <GameObject>(GlobalData.mLocalPropPrefabPath + prefabname));

        if (GameManager.Instance.mCurGameStatus != EGameStatus.EPlaying)
        {
            propTween.transform.SetParent(createParent.parent);
            propTween.transform.localPosition = createParent.localPosition;
        }
        else
        {
            propTween.transform.SetParent(createParent);
            propTween.transform.localPosition = Vector3.zero;
            propTween.transform.localPosition = createParent.localPosition;
            propTween.transform.SetParent(createParent.parent.parent);
            propTween.transform.localPosition = createParent.localPosition + createParent.parent.localPosition;
        }
        propTween.transform.localScale = Vector3.one * scale;
        propList.Add(propTween);
        return(propTween);
    }
Ejemplo n.º 8
0
    void BeerAnimation(Sequence se, MsgProps type, Transform startPos, Transform endPos, float scale, string tweenName)
    {
        GameObject propTween1  = CreatePropsGm(type, startPos, GetScaleMutiple(type, 1), tweenName);
        float      playTimeOne = GetAnimatorTime(propTween1, "play1");
        float      playTimeTwo = GetAnimatorTime(propTween1, "play2");

        if (startPos == endPos)
        {
            propTween1.GetComponent <SkeletonAnimation>().AnimationName = "play2";
            AudioManager.Instance.PlayPropsAudio((uint)MsgProps.MsgPropsBeer);
        }
        else
        {
            propTween1.GetComponent <SkeletonAnimation>().AnimationName = "play1";
            se.Append(propTween1.transform.DOLocalMove(GetEndPostion(endPos), deltaTime * 16));
            se.AppendCallback(delegate
            {
                propTween1.GetComponent <SkeletonAnimation>().AnimationName = "play2";
                AudioManager.Instance.PlayPropsAudio((uint)MsgProps.MsgPropsBeer);
            });
        }
        se.AppendInterval(playTimeTwo);
        se.AppendCallback(delegate { DestroyTween(propTween1); });
    }