Beispiel #1
0
 public void EndTrackAnims(int trackIndex)
 {
     _animState.AddEmptyAnimation(trackIndex, 0.5f, 0);
     if (trackIndex < _freeTrackIndex)
     {
         _freeTrackIndex = trackIndex;
     }
     if (trackIndex < _freeTrackIndex)
     {
         _freeTrackIndex = trackIndex;
     }
 }
Beispiel #2
0
 static int AddEmptyAnimation(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 4);
         Spine.AnimationState obj = (Spine.AnimationState)ToLua.CheckObject(L, 1, typeof(Spine.AnimationState));
         int              arg0    = (int)LuaDLL.luaL_checknumber(L, 2);
         float            arg1    = (float)LuaDLL.luaL_checknumber(L, 3);
         float            arg2    = (float)LuaDLL.luaL_checknumber(L, 4);
         Spine.TrackEntry o       = obj.AddEmptyAnimation(arg0, arg1, arg2);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    IEnumerator CorAttack(float duration)
    {
        missileLauncher.Reset();
        //fireProjectile.Fire();
        bossFireProjectile.FireAll();

        //隐藏/显示
        spine_Boss.gameObject.SetActive(false);
        spine_BossAttack.gameObject.SetActive(true);
        //
        var track = state_BossAttack.SetAnimation(0, attack, false);

        state_BossAttack.AddEmptyAnimation(0, 0, track.AnimationEnd);
        //state_BossAttack.SetAnimation(0, attack, false);

        yield return(new WaitForSeconds(duration));

        //隐藏/显示
        spine_Boss.gameObject.SetActive(true);
        spine_BossAttack.gameObject.SetActive(false);

        CorePlayBossWar.BossAttackFinishEvent.Invoke();
    }
Beispiel #4
0
    public void RunAnimation(Animation state, bool loop, float timeScale, int trackIndex)
    {
        string anim = "";

        if (currentState != state)
        {
            switch (state)
            {
            case Animation.FALL:
                anim = fall;
                break;

            case Animation.FEAR:
                anim = fear;
                break;

            case Animation.IDLE:
                anim = idle;
                break;

            case Animation.WALK:
                anim = walk;
                break;

            case Animation.Tired:
                anim = tired;
                break;

            case Animation.RUN:
                anim = run;
                break;

            case Animation.BALLS:
                anim = balls;
                break;

            case Animation.AXE_ATTACK:
                anim = axeAttack;
                break;

            case Animation.JETPACK_UP:
                anim = jetpackUp;
                break;

            case Animation.JETPACK_DOWN:
                anim = jetpackDown;
                break;

            case Animation.JETPACK_LEFT:
                anim = jetpackLeft;
                break;

            case Animation.JETPACK_RIGHT:
                anim = jetpackRight;
                break;
            }
            if (state != Animation.AXE_ATTACK)
            {
                animationState.AddEmptyAnimation(1, 0.25f, 0);
            }
            currentState = state;
            var track = animationState.SetAnimation(trackIndex, anim, loop);
            track.timeScale = timeScale;
            if (state == Animation.Tired)
            {
                StartCoroutine(ResetAnimation());
            }
        }
    }
                private int GetFreeChannelBackgroundTrack(ChannelGroup channelGroup)
                {
                    //Find first empty channel thats not before any playing channels
                    int emptyChannelTrackIndex = -1;

                    TrackEntry[] tracks = _animationState.Tracks.Items;
                    bool         channelHasEmptyTracks = false;

                    for (int i = 0; i < channelGroup._backgroundTracks.Length; i++)
                    {
                        if (IsTrackPlaying(tracks[channelGroup._backgroundTracks[i]._trackIndex]))
                        {
                            emptyChannelTrackIndex = -1;
                        }
                        else
                        {
                            channelHasEmptyTracks = true;

                            if (emptyChannelTrackIndex == -1)
                            {
                                emptyChannelTrackIndex = i;
                            }
                            else
                            {
                                emptyChannelTrackIndex = Math.Min(emptyChannelTrackIndex, i);
                            }
                        }
                    }

                    //No valid empty channel found
                    if (emptyChannelTrackIndex == -1)
                    {
                        //If there are empty tracks just need to reorder tracks
                        if (channelHasEmptyTracks)
                        {
                            //Shift all tracks down into empty tracks
                            for (int i = 0; i < channelGroup._backgroundTracks.Length; i++)
                            {
                                if (!IsTrackPlaying(tracks[channelGroup._backgroundTracks[i]._trackIndex]))
                                {
                                    for (int j = i + 1; j < channelGroup._backgroundTracks.Length; j++)
                                    {
                                        int intoTrackIndex = channelGroup._backgroundTracks[j - 1]._trackIndex;
                                        //Update track entry track
                                        tracks[intoTrackIndex] = tracks[channelGroup._backgroundTracks[j]._trackIndex];
                                        //Update track entry index (if playing)
                                        if (tracks[intoTrackIndex] != null)
                                        {
                                            tracks[intoTrackIndex].trackIndex = intoTrackIndex;
                                        }
                                        //Update channel track entry's track index
                                        channelGroup._backgroundTracks[j]._trackIndex = intoTrackIndex;
                                    }
                                }
                            }

                            //Then get first free valid track
                            return(GetFreeChannelBackgroundTrack(channelGroup));
                        }
                        //Otherwise need to grow the tracks (and shift all channels after this one)
                        else
                        {
                            //Increase track size to include new channel track
                            _animationState.Tracks.GrowIfNeeded(_animationState.Tracks.Count + 1);

                            //Work out new index
                            int trackIndex = channelGroup._backgroundTracks[channelGroup._backgroundTracks.Length - 1]._trackIndex + 1;

                            //Add new track to channel group
                            ArrayUtils.Add(ref channelGroup._backgroundTracks, new ChannelTrack());

                            //Create empty track for it
                            tracks[trackIndex] = null;
                            tracks[trackIndex] = _animationState.AddEmptyAnimation(trackIndex, 0f, 0f);
                            channelGroup._backgroundTracks[channelGroup._backgroundTracks.Length - 1]._trackIndex = trackIndex;
                            trackIndex++;

                            //Loop through all channel groups after this one and set new track indices
                            for (int i = 0; i < _channels.Count; i++)
                            {
                                if (_channels[i]._channel > channelGroup._channel)
                                {
                                    for (int j = 0; j < _channels[i]._backgroundTracks.Length; j++)
                                    {
                                        //Update track entry track
                                        tracks[trackIndex] = tracks[_channels[i]._backgroundTracks[j]._trackIndex];
                                        //Update track entry index
                                        tracks[trackIndex].trackIndex = trackIndex;
                                        //Update channel track entry's track index
                                        _channels[i]._backgroundTracks[j]._trackIndex = trackIndex;

                                        trackIndex++;
                                    }

                                    //Update track entry track
                                    tracks[trackIndex] = tracks[_channels[i]._primaryTrack._trackIndex];
                                    //Update track entry index (if playing)
                                    if (tracks[trackIndex] != null)
                                    {
                                        tracks[trackIndex].trackIndex = trackIndex;
                                    }
                                    //Update primary track entry's track index
                                    _channels[i]._primaryTrack._trackIndex = trackIndex;

                                    trackIndex++;
                                }
                            }

                            //Index is the last added
                            return(channelGroup._backgroundTracks.Length - 1);
                        }
                    }
                    //Otherwise return the empty track
                    else
                    {
                        return(emptyChannelTrackIndex);
                    }
                }