示例#1
0
 public bool PlayAnimation(string path, AnimPlayType type, float speed = 1.0f, bool loop = false, bool reverse = false, float fadeLength = 0.15f, float time = 0.0f, bool async = true)
 {
     if (type == AnimPlayType.Priority)
     {
         Debug.LogError("高优先级动画请用PlayPriorityAnimation播放!");
         return(false);
     }
     if (string.IsNullOrEmpty(path))
     {
         return(false);
     }
     if (async)
     {
         // 未来Lambda改成Request
         ResourceSystem.LoadAsync <AnimationClip>(path, (o) =>
         {
             AnimationClip c = o as AnimationClip;
             if (c == null)
             {
                 return;
             }
             PlayClipAnimation(c, c.name, type, speed * mAnimSpeed, loop, reverse, fadeLength, time);
         });
     }
     else
     {
         AnimationClip c = ResourceSystem.Load <AnimationClip>(path);
         if (c == null)
         {
             return(false);
         }
         PlayClipAnimation(c, c.name, type, speed * mAnimSpeed, loop, reverse, fadeLength, time);
     }
     return(true);
 }
示例#2
0
    public static void CreateSkillWarning(string path, SkillWarningType type, float data1, float data2, float duration, Vector3 pos, Quaternion rot, bool follow = false, Transform follower = null, System.Action <SkillWarning> callback = null)
    {
        ResourceSystem.LoadAsync <GameObject>(path, (o) => {
            GameObject go = o as GameObject;
            if (go == null)
            {
                return;
            }
            SkillWarning warning = go.GetComponent <SkillWarning>();
            if (warning == null)
            {
                return;
            }
            GameObject obj = GameObject.Instantiate(go);
            if (obj == null)
            {
                return;
            }
            obj.name = "skill_warning_" + type.ToString();
            warning  = obj.GetComponent <SkillWarning>();
            if (warning == null)
            {
                return;
            }
            warning.skillWarningType = type;
            warning.Data1            = data1;
            warning.Data2            = data2;
            warning.Duration         = duration;
            warning.Follow           = follow;
            warning.mFollower        = follower;

            warning.mStartTime = Time.realtimeSinceStartup;

            obj.transform.position = pos;
            obj.transform.rotation = rot;

            warning.Decal.upHeight   = 2.0f;
            warning.Decal.downHeight = 2.0f;
            warning.Decal.offsetY    = 0.2f;
            warning.Decal.BuildMesh();

            if (callback != null)
            {
                callback(warning);
            }
        });
    }
示例#3
0
    void OnInitHeadBar(params object[] param)
    {
        Character cha = param[0] as Character;

        ResourceSystem.LoadAsync <GameObject>("GUI/UI_HeadBar", (o) =>
        {
            GameObject go = GameObject.Instantiate(o) as GameObject;
            if (go == null)
            {
                return;
            }
            go.transform.parent        = transform;
            go.transform.localPosition = Vector3.zero;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = new Vector3(0.6f, 0.6f, 0.6f);

            UIHeadBar headBar = go.GetComponent <UIHeadBar>();
            if (headBar == null)
            {
                return;
            }
            headBar.UICamera = uiCamera;
            if (MobaMainCamera.MainCamera != null)
            {
                headBar.WorldCamera = MobaMainCamera.MainCamera;
            }
            headBar.Owner = cha;

            if (cha == null || cha.HingePoints == null)
            {
                return;
            }
            Transform hinge = cha.HingePoints.GetHingeName("HeadBar");
            if (hinge == null)
            {
                return;
            }
            headBar.Hinge  = hinge;
            headBar.UIRoot = this;

            cha.headBar = headBar;
        });
    }
示例#4
0
    public bool PlayPriorityAnimation(string name, AnimPriority priority, float speed = 1.0f, bool loop = false, bool reverse = false, float fadeLength = 0.15f, float time = 0.0f, bool async = true)
    {
        float curTime = Time.realtimeSinceStartup;

        for (int i = 0; i < (int)priority; ++i)
        {
            float length = mPriorityLength[i];
            if (length < 0)
            {
                return(false);
            }
            float startTime = mPriorityStartTimes[i];
            if (length >= curTime - startTime)
            {
                return(false);
            }
        }
        if (async)
        {
            // 未来Lambda改成Request
            ResourceSystem.LoadAsync <AnimationClip>(name, (o) => {
                AnimationClip c = o as AnimationClip;
                if (c == null)
                {
                    return;
                }
                if (loop)
                {
                    mPriorityLength[(int)priority] = -1.0f;
                }
                else
                {
                    mPriorityLength[(int)priority] = c.length;
                }
                mPriorityStartTimes[(int)priority] = Time.realtimeSinceStartup;
                var state = PlayClipAnimation(c, c.name, AnimPlayType.Priority, speed, loop, reverse, fadeLength, time);
                if (state != null)
                {
                    float sign = 1.0f;
                    if (state.speed < 0.0f)
                    {
                        sign = -1.0f;
                    }
                    state.speed = mAnimSpeed * sign;
                }
            });
        }
        else
        {
            AnimationClip c = ResourceSystem.Load <AnimationClip>(name);
            if (c == null)
            {
                return(false);
            }
            if (loop)
            {
                mPriorityLength[(int)priority] = -1.0f;
            }
            else
            {
                mPriorityLength[(int)priority] = c.length;
            }
            mPriorityStartTimes[(int)priority] = Time.realtimeSinceStartup;
            var state = PlayClipAnimation(c, c.name, AnimPlayType.Priority, speed, loop, reverse, fadeLength, time);
            if (state != null)
            {
                float sign = 1.0f;
                if (state.speed < 0.0f)
                {
                    sign = -1.0f;
                }
                state.speed = mAnimSpeed * sign;
            }
        }
        return(true);
    }