Ejemplo n.º 1
0
    /// <summary>
    /// 停止一个动画
    /// </summary>
    /// <param name="animGameObject">要停止的动画</param>
    /// <param name="isCallBack">是否触发回调</param>
    public static void StopAnim(AnimData animData, bool isCallBack = false)
    {
        if (GetInstance().animList.Contains(animData))
        {
            if (isCallBack)
            {
                animData.ExecuteCallBack();
            }

            GetInstance().animList.Remove(animData);
        }
    }
Ejemplo n.º 2
0
 public ArcingHitbox(Character user, Loc startPoint, AnimData anim, FiniteEmitter tileEmitter, AttachPointEmitter emitter, Loc endPoint, int speed, string item, int delay)
     : base(user, startPoint * GraphicsManager.TileSize, tileEmitter, delay)
 {
     StartPoint  = startPoint;
     EndPoint    = endPoint;
     ItemAnim    = item;
     MaxDistance = (int)Math.Sqrt(((EndPoint - StartPoint) * GraphicsManager.TileSize).DistSquared());
     Speed       = (speed > 0) ? speed : Math.Max(1, (int)Math.Ceiling((double)MaxDistance / GraphicsManager.TileSize * GraphicsManager.MAX_FPS));
     Anim        = new AnimData(anim);
     Emitter     = (AttachPointEmitter)emitter.Clone();
     Emitter.SetupEmit(User, MapLoc, User.MapLoc, user.CharDir, LocHeight);
 }
Ejemplo n.º 3
0
        private void UpdateMode()
        {
            string newMode = CalcMode();

            if (_mode != newMode)
            {
                _mode           = newMode;
                _animationFrame = 0;
                AnimData.Find(token + _mode + weaponClass, ref _animData);
                _animData.frameDuration = _animData.GetCorrectedFrameDuration(token, _mode);
            }
        }
Ejemplo n.º 4
0
 public override void SetSkin(Power power)
 {
     EnemyPower = power;
     if (power == Power.Hard)
     {
         HitPoints = 2;
     }
     base.SetSkin(power);
     m_runningAnim            = InitAnimData("sprites/werewolf/werewolfRunning", 6);
     m_risingAnim             = InitAnimData("sprites/werewolf/werewolfRising", 1);
     m_fallingAnim            = InitAnimData("sprites/werewolf/werewolfFalling", 1);
     m_spriteRenderer.enabled = true;
 }
Ejemplo n.º 5
0
    public static void ClearAllAnim(bool isCallBack = false)
    {
        for (int i = 0; i < GetInstance().animList.Count; i++)
        {
            AnimData animTmp = GetInstance().animList[i];
            if (isCallBack)
            {
                animTmp.ExecuteCallBack();
            }
        }

        GetInstance().animList.Clear();
    }
Ejemplo n.º 6
0
    protected override void Awake()
    {
        base.Awake();
        m_isTeleporting = false;
        m_rigidbody = GetComponent<Rigidbody2D>();

        m_walkAnimData = InitAnimData("sprites/player/playerWalk", 4);
        m_reverseWalkAnimData = InitAnimData("sprites/player/playerWalk", 4, 1, true);
        m_idleAnimData = InitAnimData("sprites/player/playerIdle", 4, 0.8f);
        m_riseAnimData = InitAnimData("sprites/player/playerRise", 1);
        m_fallAnimData = InitAnimData("sprites/player/playerFall", 1);
        m_activeAnimData = m_idleAnimData;
    }
Ejemplo n.º 7
0
        public void StartAnimation(Model anim_model, string Anim)
        {
            AnimComponent ac = anim_model.Components[anim_model.animComponentID] as AnimComponent;
            AnimData      ad = ac.getAnimation(Anim);

            if (ad != null)
            {
                if (!ad.IsPlaying)
                {
                    ad.IsPlaying = true;
                }
            }
        }
    protected void StartQueuedAnim()
    {
        StopAnimEventSequence();
        previousFrame = -1;
        currentFrame  = -1;
        SuspendUpdates(false);
        stopped = false;
        OnStartQueuedAnim();
        AnimData animData = animQueue.Dequeue();

        while (animData.mode == KAnim.PlayMode.Loop && animQueue.Count > 0)
        {
            animData = animQueue.Dequeue();
        }
        if (overrideAnims == null || !overrideAnims.TryGetValue(animData.anim, out AnimLookupData value))
        {
            if (!anims.TryGetValue(animData.anim, out value))
            {
                bool flag = true;
                if ((UnityEngine.Object)showWhenMissing != (UnityEngine.Object)null)
                {
                    showWhenMissing.SetActive(true);
                }
                if (flag)
                {
                    TriggerStop();
                    return;
                }
            }
            else if ((UnityEngine.Object)showWhenMissing != (UnityEngine.Object)null)
            {
                showWhenMissing.SetActive(false);
            }
        }
        curAnim = GetAnim(value.animIndex);
        int num = 0;

        if (animData.mode == KAnim.PlayMode.Loop && randomiseLoopedOffset)
        {
            num = UnityEngine.Random.Range(0, curAnim.numFrames - 1);
        }
        prevAnimFrame   = -1;
        curAnimFrameIdx = GetFrameIdxFromOffset(num);
        currentFrame    = curAnimFrameIdx;
        mode            = animData.mode;
        playSpeed       = animData.speed * PlaySpeedMultiplier;
        SetElapsedTime((float)num / curAnim.frameRate + animData.timeOffset);
        synchronizer.Sync();
        StartAnimEventSequence();
        AnimEnter(animData.anim);
    }
Ejemplo n.º 9
0
 static int FinishAnim(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         AnimData arg0 = (AnimData)ToLua.CheckObject(L, 1, typeof(AnimData));
         AnimSystem.FinishAnim(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 10
0
    public static AnimData Rotate(GameObject animObject, Vector3?from, Vector3 to,

                                  float time             = 0.5f,
                                  float delayTime        = 0,
                                  bool isLocal           = true,
                                  InterpType interp      = InterpType.Default,
                                  bool IsIgnoreTimeScale = false,
                                  RepeatType repeatType  = RepeatType.Once,
                                  int repeatCount        = -1,

                                  AnimCallBack callBack = null, object[] parameter = null)
    {
        AnimType animType;
        Vector3  fromTmp;

        if (isLocal)
        {
            fromTmp  = from ?? animObject.transform.localEulerAngles;
            animType = AnimType.LocalRotate;
        }
        else
        {
            fromTmp  = from ?? animObject.transform.eulerAngles;
            animType = AnimType.Rotate;
        }

        AnimData l_tmp = new AnimData();;

        l_tmp.m_animGameObejct = animObject;
        l_tmp.m_animType       = animType;
        l_tmp.m_fromV3         = fromTmp;
        l_tmp.m_toV3           = to;

        l_tmp.m_isLocal = isLocal;

        l_tmp.m_delayTime         = delayTime;
        l_tmp.m_totalTime         = time;
        l_tmp.m_interpolationType = interp;
        l_tmp.m_repeatType        = repeatType;
        l_tmp.m_repeatCount       = repeatCount;
        l_tmp.m_ignoreTimeScale   = IsIgnoreTimeScale;
        l_tmp.m_callBack          = callBack;
        l_tmp.m_parameter         = parameter;

        l_tmp.Init();

        GetInstance().animList.Add(l_tmp);
        return(l_tmp);
    }
Ejemplo n.º 11
0
    static int CustomMethodToVector3(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 11);
            AnimCustomMethodVector3 arg0 = null;
            LuaTypes funcType1           = LuaDLL.lua_type(L, 1);

            if (funcType1 != LuaTypes.LUA_TFUNCTION)
            {
                arg0 = (AnimCustomMethodVector3)ToLua.CheckObject(L, 1, typeof(AnimCustomMethodVector3));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 1);
                arg0 = DelegateFactory.CreateDelegate(typeof(AnimCustomMethodVector3), func) as AnimCustomMethodVector3;
            }

            UnityEngine.Vector3 arg1 = (UnityEngine.Vector3)ToLua.CheckObject(L, 2, typeof(UnityEngine.Vector3));
            UnityEngine.Vector3 arg2 = (UnityEngine.Vector3)ToLua.CheckObject(L, 3, typeof(UnityEngine.Vector3));
            float        arg3        = (float)LuaDLL.luaL_checknumber(L, 4);
            float        arg4        = (float)LuaDLL.luaL_checknumber(L, 5);
            InterpType   arg5        = (InterpType)ToLua.CheckObject(L, 6, typeof(InterpType));
            bool         arg6        = LuaDLL.luaL_checkboolean(L, 7);
            RepeatType   arg7        = (RepeatType)ToLua.CheckObject(L, 8, typeof(RepeatType));
            int          arg8        = (int)LuaDLL.luaL_checknumber(L, 9);
            AnimCallBack arg9        = null;
            LuaTypes     funcType10  = LuaDLL.lua_type(L, 10);

            if (funcType10 != LuaTypes.LUA_TFUNCTION)
            {
                arg9 = (AnimCallBack)ToLua.CheckObject(L, 10, typeof(AnimCallBack));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 10);
                arg9 = DelegateFactory.CreateDelegate(typeof(AnimCallBack), func) as AnimCallBack;
            }

            object[] arg10 = ToLua.CheckObjectArray(L, 11);
            AnimData o     = AnimSystem.CustomMethodToVector3(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
            ToLua.PushObject(L, o);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 12
0
    /// <summary>
    /// 动画移动到某位置
    /// </summary>
    /// <param name="animObject">动画对象</param>
    /// <param name="from">起点位置(可空,如为空则从当前位置开始)</param>
    /// <param name="to">终点位置</param>
    /// <param name="time">动画时间</param>
    /// <param name="isLocal">是否是用相对位置</param>
    /// <param name="interp">插值类型</param>
    /// <param name="IsIgnoreTimeScale">是否忽略时间缩放</param>
    /// <param name="repeatType">重复类型</param>
    /// <param name="repeatCount">重复次数</param>
    /// <param name="callBack">动画完成回调函数</param>
    /// <param name="parameter">动画完成回调函数传参</param>
    /// <returns></returns>
    public static AnimData Move(GameObject animObject, Vector3?from, Vector3 to,
                                float delayTime        = 0,
                                float time             = 0.5f,
                                bool isLocal           = true,
                                InterpType interp      = InterpType.Default,
                                bool IsIgnoreTimeScale = false,
                                RepeatType repeatType  = RepeatType.Once,
                                int repeatCount        = -1,
                                Transform toTransform  = null,
                                AnimCallBack callBack  = null,
                                object[] parameter     = null)
    {
        Vector3  fromTmp;
        AnimType animType;

        if (isLocal)
        {
            fromTmp  = from ?? animObject.transform.localPosition;
            animType = AnimType.LocalPosition;
        }
        else
        {
            fromTmp  = from ?? animObject.transform.position;
            animType = AnimType.Position;
        }

        AnimData l_tmp = HeapObjectPool <AnimData> .GetObject();;

        l_tmp.m_animGameObejct = animObject;
        l_tmp.m_animType       = animType;
        l_tmp.m_fromV3         = fromTmp;
        l_tmp.m_toV3           = to;
        l_tmp.m_isLocal        = isLocal;
        l_tmp.m_toTransform    = toTransform;

        l_tmp.m_delayTime         = delayTime;
        l_tmp.m_totalTime         = time;
        l_tmp.m_interpolationType = interp;
        l_tmp.m_repeatType        = repeatType;
        l_tmp.m_repeatCount       = repeatCount;
        l_tmp.m_ignoreTimeScale   = IsIgnoreTimeScale;
        l_tmp.m_callBack          = callBack;
        l_tmp.m_parameter         = parameter;

        l_tmp.Init();

        GetInstance().animList.Add(l_tmp);
        return(l_tmp);
    }
Ejemplo n.º 13
0
        public float GetAnimationLength(AnimData anim)
        {
            var highFrame = anim.HighFrame;

            if (anim.HighFrame == -1)
            {
                // get the actual high frame from the animation length
                var animation = DatManager.PortalDat.ReadFromDat <Animation>(anim.AnimId);
                highFrame = (int)animation.NumFrames;
            }

            var numFrames = highFrame - anim.LowFrame;

            return(numFrames / Math.Abs(anim.Framerate)); // framerates can be negative, which tells the client to play in reverse
        }
Ejemplo n.º 14
0
 static int ValueTo(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         AnimSystem.AnimParamHash arg0 = (AnimSystem.AnimParamHash)ToLua.CheckObject(L, 1, typeof(AnimSystem.AnimParamHash));
         AnimData o = AnimSystem.ValueTo(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 15
0
        void OnPreprocessAnimation()
        {
            string jsonPath = BuildJsonPath(assetPath);

            if (!File.Exists(jsonPath))
            {
                return;
            }

            AnimData animData = ParseJson(jsonPath);

            if (animData == null || !animData.Events.Any())
            {
                return;
            }

            ModelImporter model = assetImporter as ModelImporter;

            BuildEventBank(model, out AnimEventBank);

            foreach (var @event in animData.Events)
            {
                var def = new AnimationEvent {
                    stringParameter = @event.comment
                };

                foreach (var take in model.importedTakeInfos)
                {
                    float eventTime = @event.frame / take.sampleRate;
                    if (EqualOrLarger(eventTime, take.startTime) &&
                        EqualOrSmaller(eventTime, take.stopTime))
                    {
                        AnimClipEvents target;
                        if (AnimEventBank.TryGetValue(take.name, out target))
                        {
                            def.time = eventTime - take.startTime;
                            target.Events.Add(def);
                        }
                        else
                        {
                            Debug.LogErrorFormat("Error: Got event for take {0} with no clip generated for!", take.name);
                        }
                    }
                }
            }

            SaveAnimEvents(model, AnimEventBank);
        }
Ejemplo n.º 16
0
    public void BeBarrierPass(Barrier barrier, Action reachEnd)//, AnimData[] animDatas, TweenData[] tweens)
    {
        float   goStartTime = Mathf.Clamp(Vector3.Distance(_mem.transform.position, barrier.passStartPosition), 0.5f, 0.7f);
        float   goEndTime   = (barrier.currentStepCount + 1) / 5f;
        Vector3 endPosition;

        TweenData[] passTweens =
            InteractBarrierBaseTweens(barrier, barrier.currentStepCount - 1, out endPosition, goStartTime, goEndTime);

        AnimData walkAnim = new AnimData(MemberAnimType.Locomotion, goStartTime);
        AnimData passAnim = new AnimData(MemberAnimType.Climb, goEndTime);

        MemberSequenceUtils.BuildTweenSequence(passTweens, (() => reachEnd()));

        _mem.StartCoroutine(DoAnimSequence(walkAnim, passAnim));
    }
Ejemplo n.º 17
0
        public override void OnImportAsset(AssetImportContext ctx)
        {
            stage = AnimData.LoadFromFile(ctx.assetPath);
            if (stage == null)
            {
                return;
            }

            MeshUtils.SimplifyStage(stage, Settings.SimplifyFactor);

            savedClips    = new Dictionary <AudioDataPool.AudioPoolKey, AudioClip>();
            totalVertices = 0;
            totalLines    = 0;
            HasFades      = false;
            m_Materials.Clear();

            PreviewTexture = new Texture2D(1, 1);
            PreviewTexture.LoadImage(stage.previewFrames[0], false);
            PreviewTexture.Apply();

            if (Settings.Shader == null || Settings.Shader == "AnimVR/Standard")
            {
                Debug.Log("Resetting shader");
                Settings.Shader = "AnimVR/ImportedLine";
            }

            baseMaterial = new Material(Shader.Find(Settings.Shader));
            baseMaterial.SetFloat("_Unlit", Settings.UnlitByDefault ? 1 : 0);
            baseMaterial.SetFloat("_Gamma", PlayerSettings.colorSpace == ColorSpace.Gamma ? 1.0f : 2.2f);
            baseMaterial.name = Path.GetFileNameWithoutExtension(ctx.assetPath) + "_BaseMaterial";

            needsAudioReimport = false;

            GenerateUnityObject(stage, ctx);

            //var externalObjects = GetExternalObjectMap();

            ctx.AddObjectToAsset(Path.GetFileNameWithoutExtension(ctx.assetPath) + "_BaseMaterial", baseMaterial);

            m_Materials.Add(new SerializableIdentifier(baseMaterial));

            InfoString = "FPS: " + stage.fps + ", " + stage.timelineLength + " frames \n"
                         + totalVertices + " verts, " + totalLines + " lines";

            savedClips = null;
            stage      = null;
        }
Ejemplo n.º 18
0
    private void InitializePresetData(SpritePreset preset)
    {
        preset.datas.Clear();

        foreach (var clip in preset.clips)
        {
            var animData = new AnimData {
                length    = clip.length,
                timelines = new List <AnimTimeline>()
            };

            foreach (var binding in AnimationUtility.GetObjectReferenceCurveBindings(clip))
            {
                foreach (var frame in AnimationUtility.GetObjectReferenceCurve(clip, binding))
                {
                    var sprite = (Sprite)frame.value;

                    animData.timelines.Add(new AnimTimeline {
                        start  = frame.time,
                        sprite = sprite
                    });
                }
            }

            if (0 == animData.timelines.Count)
            {
                continue;
            }

            for (var i = 0; i < animData.timelines.Count - 1; ++i)
            {
                animData.timelines[i].end = animData.timelines[i + 1].start;
            }

            animData.timelines[animData.timelines.Count - 1].end = clip.length;

            if (false == Enum.TryParse(clip.name.Substring(clip.name.LastIndexOf(".", StringComparison.Ordinal) + 1),
                                       out AnimUtility.AnimKey animID))
            {
                Debug.LogError("!!!! Check Anim Name");
            }
            else
            {
                preset.datas.Add(animID, animData);
            }
        }
    }
Ejemplo n.º 19
0
    /// <summary>
    /// 停止一个对象身上的所有动画
    /// </summary>
    /// <param name="animGameObject">要停止动画的对象</param>
    /// <param name="isCallBack">是否触发回调</param>
    public static void StopAnim(GameObject animGameObject, bool isCallBack = false)
    {
        for (int i = 0; i < GetInstance().animList.Count; i++)
        {
            if (GetInstance().animList[i].m_animGameObejct == animGameObject)
            {
                if (isCallBack)
                {
                    AnimData dataTmp = GetInstance().animList[i];
                    dataTmp.executeCallBack();
                }

                GetInstance().animList.RemoveAt(i);
                i--;
            }
        }
    }
Ejemplo n.º 20
0
 //the class will be in charge of its own hitbox movement
 //however, the current-action member of its owner may terminate early and remove this hitbox prematurely.
 //the owner class will guarantee that this hitbox will cover all the right places, as well as disposing this hitbox
 public AttachedCircleHitbox(Character user, Alignment targetAlignments, bool hitTiles, bool burstOnWall, Loc startPoint, AnimData anim, int animOffset,
                             FiniteEmitter tileEmitter, AttachPointEmitter emitter, int maxDistance, int dashTime, Dir8 dir, bool wide, int delay)
     : base(user, startPoint * GraphicsManager.TileSize, tileEmitter, delay)
 {
     TargetAlignments = targetAlignments;
     HitTiles         = hitTiles;
     BurstOnWall      = burstOnWall;
     StartPoint       = startPoint;
     MaxDistance      = maxDistance;
     DashTime         = dashTime;
     Dir        = dir;
     Wide       = wide;
     Anim       = new AnimData(anim);
     AnimOffset = animOffset;
     Emitter    = (AttachPointEmitter)emitter.Clone();
     Emitter.SetupEmit(User, MapLoc, MapLoc, user.CharDir, LocHeight);
 }
Ejemplo n.º 21
0
    public static AnimData BezierMove(GameObject animObject, Vector3?from, Vector3 to,
                                      Vector3[] bezier_contral,
                                      float time              = 0.5f,
                                      float delayTime         = 0,
                                      RepeatType repeatType   = RepeatType.Once,
                                      int repeatCount         = -1,
                                      InterpType interp       = InterpType.Default,
                                      bool isLocal            = true,
                                      PathType bezierMoveType = PathType.Bezier2,

                                      AnimCallBack callBack = null, object[] parameter = null)
    {
        AnimData l_tmp = new AnimData();;

        if (isLocal)
        {
            l_tmp.m_animType = AnimType.LocalPosition;
            l_tmp.m_fromV3   = from ?? animObject.transform.localPosition;
        }
        else
        {
            l_tmp.m_animType = AnimType.Position;
            l_tmp.m_fromV3   = from ?? animObject.transform.position;
        }

        l_tmp.m_animGameObejct = animObject;


        l_tmp.m_toV3      = to;
        l_tmp.m_isLocal   = isLocal;
        l_tmp.m_pathType  = bezierMoveType;
        l_tmp.m_v3Contral = bezier_contral;

        l_tmp.m_delayTime         = delayTime;
        l_tmp.m_totalTime         = time;
        l_tmp.m_interpolationType = interp;
        l_tmp.m_repeatType        = repeatType;
        l_tmp.m_repeatCount       = repeatCount;
        l_tmp.m_callBack          = callBack;
        l_tmp.m_parameter         = parameter;

        l_tmp.Init();

        GetInstance().animList.Add(l_tmp);
        return(l_tmp);
    }
Ejemplo n.º 22
0
    protected AnimData InitAnimData(string prefix, int spriteCount, float animSpeed = 1, bool invert = false)
    {
        AnimData data = new AnimData();

        data.m_animSpeed   = animSpeed;
        data.m_spriteCount = spriteCount;
        data.m_sprites     = new Sprite[spriteCount];
        for (int i = 0; i < data.m_spriteCount; ++i)
        {
            int index = i;
            if (invert)
            {
                index = (data.m_spriteCount - 1) - i;
            }
            data.m_sprites[index] = Resources.Load <Sprite>(prefix + m_variantId + (index + 1).ToString());
        }
        return(data);
    }
Ejemplo n.º 23
0
    public static void ClearAllAnim(bool isCallBack = false)
    {
        if (isCallBack)
        {
            for (int i = 0; i < GetInstance().animList.Count; i++)
            {
                AnimData dataTmp = GetInstance().animList[i];
                dataTmp.executeCallBack();

                GetInstance().animList.RemoveAt(i);
                i--;
            }
        }
        else
        {
            GetInstance().animList.Clear();
        }
    }
Ejemplo n.º 24
0
 public CircleSweepHitbox(Character user, Alignment targetAlignments, bool hitTiles, bool burstOnWall, Loc startPoint, AnimData anim, FiniteEmitter tileEmitter,
                          AttachPointEmitter emitter, int speed, int delay, Dir8 dir, int maxDistance, bool boomerang, int item)
     : base(user, startPoint * GraphicsManager.TileSize + dir.GetLoc() * GraphicsManager.TileSize / 2, tileEmitter, delay)
 {
     TargetAlignments = targetAlignments;
     HitTiles         = hitTiles;
     BurstOnWall      = burstOnWall;
     StartPoint       = startPoint;
     Dir = dir;
     DistanceTraveled = GraphicsManager.TileSize / 2;
     MaxDistance      = maxDistance;
     Boomerang        = boomerang;
     Speed            = (speed > 0) ? speed : Math.Max(1, (int)Math.Ceiling((double)(MaxDistance - 0.5 + (Boomerang ? MaxDistance : 0)) * GraphicsManager.MAX_FPS));
     ItemAnim         = item;
     reverse          = 1;
     Anim             = new AnimData(anim);
     Emitter          = (AttachPointEmitter)emitter.Clone();
     Emitter.SetupEmit(User, MapLoc, User.MapLoc, user.CharDir, LocHeight);
 }
Ejemplo n.º 25
0
        public void InitDefaults()
        {
            if (Setup.DefaultAnimID != 0)
            {
                Sequence.clear_animations();
                var animData = new AnimData();

                /*animData.AnimId = Setup.DefaultAnimID;
                 * animData.LowFrame = 0;
                 * animData.HighFrame = Int32.MaxValue;*/
                Sequence.append_animation(animData);
                WeenieDesc.Destroy(animData);
            }

            if (Owner != null)
            {
                Owner.InitDefaults(Setup);
            }
        }
Ejemplo n.º 26
0
        public void InitDefaults()
        {
            if (Setup.DefaultAnimID != 0)
            {
                Sequence.ClearAnimations();
                var animData      = new AnimData();
                var defaultAnimId = Setup.DefaultAnimID;
                animData.AnimId    = 0;
                animData.LowFrame  = -1;
                animData.HighFrame = 1106247680;
                Sequence.AppendAnimation(animData);
                WeenieDesc.Destroy(animData);
            }

            if (Owner != null)
            {
                Owner.InitDefaults(Setup);
            }
        }
Ejemplo n.º 27
0
    /// <summary>
    /// 动画过度到目标alpha
    /// </summary>
    /// <param name="animObject">动画对象</param>
    /// <param name="from">起始alpha(可空)</param>
    /// <param name="to">目标alpha</param>
    /// <param name="time">动画时间</param>
    /// <param name="isChild">是否影响子节点</param>
    /// <param name="interp">插值类型</param>
    /// <param name="IsIgnoreTimeScale">是否忽略时间缩放</param>
    /// <param name="repeatType">重复类型</param>
    /// <param name="repeatCount">重复次数</param>
    /// <param name="callBack">动画完成回调函数</param>
    /// <param name="parameter">动画完成回调函数传参</param>
    /// <returns></returns>
    public static AnimData UguiAlpha(GameObject animObject, float?from, float to,
                                     float time             = 0.5f,
                                     float delayTime        = 0,
                                     InterpType interp      = InterpType.Default,
                                     bool isChild           = true,
                                     bool IsIgnoreTimeScale = false,
                                     RepeatType repeatType  = RepeatType.Once,
                                     int repeatCount        = -1,
                                     AnimCallBack callBack  = null, object[] parameter = null)
    {
        float fromTmp = from ?? 1;

        if (from == null)
        {
            if (animObject.GetComponent <Graphic>() != null)
            {
                fromTmp = from ?? animObject.GetComponent <Graphic>().color.a;
            }
        }

        AnimData l_tmp = HeapObjectPool.GetObject <AnimData>("AnimData");

        l_tmp.m_animGameObejct = animObject;
        l_tmp.m_animType       = AnimType.UGUI_Alpha;
        l_tmp.m_fromFloat      = fromTmp;
        l_tmp.m_toFloat        = to;
        l_tmp.m_isChild        = isChild;

        l_tmp.m_delayTime         = delayTime;
        l_tmp.m_totalTime         = time;
        l_tmp.m_interpolationType = interp;
        l_tmp.m_repeatType        = repeatType;
        l_tmp.m_repeatCount       = repeatCount;
        l_tmp.m_ignoreTimeScale   = IsIgnoreTimeScale;
        l_tmp.m_callBack          = callBack;
        l_tmp.m_parameter         = parameter;

        l_tmp.Init();

        GetInstance().animList.Add(l_tmp);
        return(l_tmp);
    }
Ejemplo n.º 28
0
    /// <summary>
    /// 动画过度到目标颜色
    /// </summary>
    /// <param name="animObject">动画对象</param>
    /// <param name="from">起始颜色(可空)</param>
    /// <param name="to">目标颜色</param>
    /// <param name="time">动画时间</param>
    /// <param name="isChild">是否影响子节点</param>
    /// <param name="interp">插值类型</param>
    /// <param name="IsIgnoreTimeScale">是否忽略时间缩放</param>
    /// <param name="repeatType">重复类型</param>
    /// <param name="repeatCount">重复次数</param>
    /// <param name="callBack">动画完成回调函数</param>
    /// <param name="parameter">动画完成回调函数传参</param>
    /// <returns></returns>
    public static AnimData UguiColor(GameObject animObject, Color?from, Color to,
                                     float time             = 0.5f,
                                     float delayTime        = 0,
                                     InterpType interp      = InterpType.Default,
                                     bool isChild           = true,
                                     bool IsIgnoreTimeScale = false,
                                     RepeatType repeatType  = RepeatType.Once,
                                     int repeatCount        = -1,
                                     AnimCallBack callBack  = null, object[] parameter = null)
    {
        Color fromTmp = from ?? Color.white;

        if (from == null)
        {
            if (animObject.GetComponent <Graphic>() != null)
            {
                fromTmp = from ?? animObject.GetComponent <Graphic>().color;
            }
        }

        AnimData l_tmp = new AnimData();

        l_tmp.m_animGameObejct = animObject;
        l_tmp.m_animType       = AnimType.UGUI_Color;
        l_tmp.m_fromColor      = fromTmp;
        l_tmp.m_toColor        = to;
        l_tmp.m_isChild        = isChild;

        l_tmp.m_delayTime         = delayTime;
        l_tmp.m_totalTime         = time;
        l_tmp.m_interpolationType = interp;
        l_tmp.m_repeatType        = repeatType;
        l_tmp.m_repeatCount       = repeatCount;
        l_tmp.m_ignoreTimeScale   = IsIgnoreTimeScale;
        l_tmp.m_callBack          = callBack;
        l_tmp.m_parameter         = parameter;

        l_tmp.Init();

        GetInstance().animList.Add(l_tmp);
        return(l_tmp);
    }
Ejemplo n.º 29
0
    public static bool Find(string name, ref AnimData animData)
    {
        name = name.ToUpper();
        byte hash = Hash(name);

        if (buckets[hash].data == null)
        {
            return(false);
        }

        foreach (var data in buckets[hash].data)
        {
            if (data.cofName == name)
            {
                animData = data;
                return(true);
            }
        }
        return(false);
    }
Ejemplo n.º 30
0
    //outInExpo,
    //inBack,
    //outBack,
    //inOutBack,
    //outInBack,

    #endregion

    #region Debug


    public void ShowDebug()
    {
        AnimData data = new AnimData();

        Type type = data.GetType();

        System.Reflection.FieldInfo[] infos = type.GetFields();

        for (int i = 0; i < infos.Length; i++)
        {
            if (
                (infos[i].GetValue(this) == null && infos[i].GetValue(data) != null) ||
                (infos[i].GetValue(this) != null && infos[i].GetValue(data) == null) ||
                (infos[i].GetValue(this) != null && !infos[i].GetValue(this).Equals(infos[i].GetValue(data)))
                )
            {
                Debug.Log(" " + infos[i].Name + " is not equal ! this value : " + infos[i].GetValue(this) + " data Value :" + infos[i].GetValue(data));
            }
        }
    }
Ejemplo n.º 31
0
    void Start()
    {
        mDefaultStateId = !string.IsNullOrEmpty(defaultState) ? sprite.GetClipIdByName(defaultState) : 0;

        foreach(StateData state in states) {
            int stateInd = (int)state.state;

            string moveName = state.moveName;
            string stopName = state.stopName;

            //omni dir
            if(state.dirs.Length == 0) {
                mAnim[stateInd] = new AnimData[1];
                mAnim[stateInd][0] = new AnimData(sprite, mDefaultStateId, moveName, stopName, Dir.NumDir);
                mAnim[stateInd][0].sticky = state.sticky;
            }
            else {
                mAnim[stateInd] = new AnimData[(int)Dir.NumDir];

                for(int i = 0; i < state.dirs.Length; i++) {
                    StateDir stateDir = state.dirs[i];

                    mAnim[stateInd][i] = new AnimData(sprite, mDefaultStateId, moveName, stopName, stateDir.dir);
                    mAnim[stateInd][i].horzFlipped = stateDir.horzFlipped;
                    mAnim[stateInd][i].vertFlipped = stateDir.vertFlipped;
                    mAnim[stateInd][i].sticky = state.sticky;
                }
            }
        }
    }