Beispiel #1
0
 void LoadNewAnimation(int animIndex)
 {
     if (animIndex != this.animIndex || forceAnimUpdate)
     {
         forceAnimUpdate = false;
         this.animIndex  = animIndex;
         DeinitAnimation();
         currentFrame = 0;
         anim         = null;
         if (animIndex >= 0 && animIndex < perso.p3dData.family.animations.Length)
         {
             anim           = perso.p3dData.family.animations[animIndex];
             animationSpeed = anim.speed;
             //print(animCuts.Length);
             forceAnimUpdate = true;
             InitAnimation();
         }
     }
 }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        if (IsLoaded)
        {
            if (hasStates)
            {
                if (stateIndex != currentState)
                {
                    currentState = stateIndex;
                    SetState(currentState);
                }
            }
        }
        if (!IsLoaded || !(controller.LoadState == Controller.State.Finished || controller.LoadState == Controller.State.Error))
        {
            return;
        }
        bool sectorActive = false, insideSectors = false;

        if (sector == null || IsAlways || sector.Loaded)
        {
            sectorActive = true;
        }
        if (sector == null || IsAlways || controller.sectorManager.activeSector != null)
        {
            insideSectors = true;
        }
        if (controller.playAnimations && playAnimation && sectorActive)
        {
            updateCounter += Time.deltaTime * animationSpeed;
            // If the camera is not inside a sector, animations will only update 1 out of 2 times (w/ frameskip) to avoid lag
            if ((!insideSectors && updateCounter >= 2f) || (insideSectors && updateCounter >= 1f))
            {
                uint passedFrames = (uint)Mathf.FloorToInt(updateCounter);
                updateCounter %= 1;
                currentFrame  += passedFrames;
                if (anim != null && currentFrame >= anim.num_frames && anim.num_frames != 0)
                {
                    if (autoNextState)
                    {
                        PS1Animation prevAnim = anim;
                        GotoAutoNextState();
                        if (anim == prevAnim)
                        {
                            currentFrame = currentFrame % anim.num_frames;
                            UpdateAnimation();
                        }
                    }
                    else
                    {
                        currentFrame = currentFrame % anim.num_frames;
                        UpdateAnimation();
                    }
                }
                else
                {
                    UpdateAnimation();
                }
            }
        }
    }