Esempio n. 1
0
    // Update is called once per frame
    void LateUpdate()
    {
        if (anim.GetCurrentAnimatorClipInfo(0).Length > 0)
        {
            an = anim.GetCurrentAnimatorClipInfo(0)[0];
            if (anim.transform.parent.tag == "Player")
            {
                if (an.clip.name != "Reload")
                {
                    //Turns the weapon towards the current mouse position
                    Vector3 diff = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
                    diff.Normalize();
                    float rot_z = Mathf.Atan2(diff.y, diff.x) * Mathf.Rad2Deg;
                    transform.rotation = Quaternion.Euler(0f, 0f, rot_z - 90);

                    if (transform.localEulerAngles.z > 13f)
                    {
                        transform.localRotation = lastRotation;
                    }
                    else
                    {
                        lastRotation = transform.localRotation;
                    }
                }
            }
        }
    }
    public void PlayLoop()
    {
        ParticleSystem[] componentsInChildren = base.GetComponentsInChildren <ParticleSystem>(true);
        foreach (ParticleSystem particleSystem in componentsInChildren)
        {
            particleSystem.main.loop = true;
            particleSystem.Clear(true);
            particleSystem.time = 0f;
            particleSystem.Play();
        }
        Animation[] componentsInChildren2 = base.GetComponentsInChildren <Animation>(true);
        foreach (Animation animation in componentsInChildren2)
        {
            animation.wrapMode = WrapMode.Loop;
            animation.Play();
        }
        Animator componentInChildren = base.GetComponentInChildren <Animator>();

        if (null != componentInChildren)
        {
            AnimatorClipInfo[] currentAnimatorClipInfo = componentInChildren.GetCurrentAnimatorClipInfo(0);
            AnimatorClipInfo[] array3 = currentAnimatorClipInfo;
            int num = 0;
            if (num < array3.Length)
            {
                AnimatorClipInfo animatorClipInfo = array3[num];
                animatorClipInfo.clip.wrapMode = WrapMode.Loop;
                componentInChildren.Play(animatorClipInfo.clip.name, -1, 0f);
            }
        }
    }
Esempio n. 3
0
            private bool ApplyInterruptionAnimation(Skeleton skeleton,
                                                    bool interpolateWeightTo1, AnimatorClipInfo info, AnimatorStateInfo stateInfo,
                                                    int layerIndex, float layerWeight, MixBlend layerBlendMode, float interruptingClipTimeAddition,
                                                    bool useClipWeight1 = false)
            {
                float clipWeight = interpolateWeightTo1 ? (info.weight + 1.0f) * 0.5f : info.weight;
                float weight     = clipWeight * layerWeight;

                if (weight == 0)
                {
                    return(false);
                }

                var clip = GetAnimation(info.clip);

                if (clip == null)
                {
                    return(false);
                }

                var time = AnimationTime(stateInfo.normalizedTime + interruptingClipTimeAddition,
                                         info.clip.length, stateInfo.speed < 0);

                weight = useClipWeight1 ? layerWeight : weight;
                clip.Apply(skeleton, 0, time, info.clip.isLooping, null,
                           weight, layerBlendMode, MixDirection.In);
                if (_OnClipApplied != null)
                {
                    OnClipAppliedCallback(clip, stateInfo, layerIndex, time, info.clip.isLooping, weight);
                }
                return(true);
            }
Esempio n. 4
0
    void SimpleWallAnim(Wall[] movingElements, Wall wall, float speed)
    {
        if (speed == 0)
        {
            movingElements[wall.Index].Status = "None";
        }
        if (speed < 0)
        {
            movingElements[wall.Index].Status = "Open";
        }
        if (speed > 0)
        {
            movingElements[wall.Index].Status = "Close";
        }

        wall.DoorAnimation.enabled = true;

        AnimatorClipInfo[] temps    = wall.DoorAnimation.GetCurrentAnimatorClipInfo(0);
        AnimatorClipInfo   clipInfo = new AnimatorClipInfo();

        if (temps.Length > 0)
        {
            clipInfo = temps[0];
        }

        wall.DoorAnimation.StartPlayback();

        wall.DoorAnimation.speed = speed;

        wall.DoorAnimation.Play(clipInfo.clip.name, 0, speed < 0 ? 1 : 0);
    }
Esempio n. 5
0
        /// <summary>
        /// Returns the frame the animation clip is at.
        /// </summary>
        /// <param name="anim"></param>
        /// <returns>
        /// returns an integer frame number
        /// </returns>
        public static int GetCurrentFrame(this Animator anim)
        {
            AnimatorClipInfo att = anim.GetCurrentAnimatorClipInfo(0)[0];
            int currentFrame     = (int)(anim.GetCurrentAnimatorStateInfo(0).normalizedTime % 1f * (att.clip.length * att.clip.frameRate));

            return(currentFrame);
        }
    // Token: 0x06000C0D RID: 3085 RVA: 0x00033718 File Offset: 0x00031918
    private void PlayOnce(GameObject obj)
    {
        if (obj == null)
        {
            return;
        }
        ParticleSystem[] componentsInChildren = obj.GetComponentsInChildren <ParticleSystem>(true);
        foreach (ParticleSystem particleSystem in componentsInChildren)
        {
            particleSystem.main.loop = false;
            particleSystem.Clear(true);
            particleSystem.time = 0f;
            particleSystem.Play();
        }
        Animation[] componentsInChildren2 = obj.GetComponentsInChildren <Animation>(true);
        foreach (Animation animation in componentsInChildren2)
        {
            animation.wrapMode = WrapMode.Once;
            animation.Play();
        }
        Animator componentInChildren = obj.GetComponentInChildren <Animator>();

        if (null != componentInChildren)
        {
            AnimatorClipInfo[] currentAnimatorClipInfo = componentInChildren.GetCurrentAnimatorClipInfo(0);
            AnimatorClipInfo[] array3 = currentAnimatorClipInfo;
            int num = 0;
            if (num < array3.Length)
            {
                AnimatorClipInfo animatorClipInfo = array3[num];
                animatorClipInfo.clip.wrapMode = WrapMode.Once;
                componentInChildren.Play(animatorClipInfo.clip.name, -1, 0f);
            }
        }
    }
Esempio n. 7
0
    IEnumerator WaitForPage(AnimatorClipInfo clip, int direction)
    {
        yield return(new WaitForSecondsRealtime(clip.clip.length));

        pageAnim.gameObject.SetActive(false);

        if (direction > 0)
        {
            if (currentState == MenuState.stats)
            {
                currentState = 0;
            }
            else
            {
                currentState++;
            }
        }
        else if (direction < 0)
        {
            if (currentState == 0)
            {
                currentState = MenuState.stats;
            }
            else
            {
                currentState--;
            }
        }

        menus[(int)currentState].SetActive(true);
    }
Esempio n. 8
0
 virtual public void OnClipEnter(Animator animator, AnimatorClipInfo clipInfo, int layerIndex)
 {
     //if (clipInfo.clip)
     //    _logger.Debug(animator.name + "  AnimationClipName   ************Enter:  " + clipInfo.clip.name);
     //else
     //    _logger.Debug(animator.name + "  AnimatorEnterClipNull*******************************");
 }
        virtual public void OnClipExit(Animator animator, AnimatorClipInfo clipInfo, AnimatorStateInfo stateInfo, int layerIndex)
        {
            //if (clipInfo.clip)
            //    _logger.Debug(animator.name + "  AnimationClipName   ---------------Exit:  " + clipInfo.clip.name);
            //else
            //    _logger.Debug(animator.name + "  AnimatorExitClipNull-----------------------------------");

            // 动画结束(可能是中途打断)时
            // 判断当前动画结束时间,与动画上的AnimationEvent中的Time做比较(得知打断是否在Event之前)
            // AnimationEvent分两种  1.正常操作 2.复位操作
            var clip = clipInfo.clip;

            if (null != animator && null != clip)
            {
                // 动画结束时当前播放时间
                var normlizeTime = stateInfo.normalizedTime;
                var aimEvents    = clip.events;
                var eventTimeNor = (aimEvents.Length > 0 ? aimEvents[aimEvents.Length - 1].time : 0) / clip.length;
                if (normlizeTime < eventTimeNor)
                {
                    for (var i = 0; i < aimEvents.Length; ++i)
                    {
                        var aimEvent = aimEvents[i];
                        var isClean  = Matcher.Match(aimEvent.stringParameter).Equals(_cleanStr, StringComparison.Ordinal);
                        if (isClean)
                        {
                            if (null != AnimationCleanEventCallback)
                            {
                                AnimationCleanEventCallback.Invoke(aimEvent);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Plays the clip named [name] at frame [frame].
        /// </summary>
        /// <param name="anim"></param>
        /// <param name="name"></param>
        /// <param name="frame"></param>
        public static void PlayAt(this Animator anim, string name, int frame)
        {
            AnimatorClipInfo att      = anim.GetCurrentAnimatorClipInfo(0)[0];
            float            normTime = frame / (att.clip.length * att.clip.frameRate);

            anim.Play(name, 0, normTime);
        }
Esempio n. 11
0
    public void setSleep()// this gets the length of the animation clip and sets the game object to disable itself when it ends.
    {
        AnimatorClipInfo  currInfo  = anim.GetCurrentAnimatorClipInfo(0)[0];
        AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0);

        Invoke("sleepAfterDelay", currInfo.clip.length - waitForClipDelay);
    }
Esempio n. 12
0
    void RemoveIndustryOptions()
    {
        if (pos == "01b-01")
        {
            GlitchText();
        }

        RemoveIndustryLinks();

        Animator industry = canvas.transform.Find("Industry Options").GetComponent <Animator>();

        industry.transform.Find("Security").GetComponent <Button>().colors = colorBlock;
        industry.SetTrigger("remove");

        AnimatorClipInfo info    = industry.GetCurrentAnimatorClipInfo(0)[0];
        float            seconds = info.clip.length;

        StartCoroutine(DisableGameObject(industry.gameObject, seconds, false));

        Animator displayText = canvas.transform.Find("Display Text").GetComponent <Animator>();

        displayText.SetTrigger("slideDown");

        isAnimating = false;
    }
Esempio n. 13
0
            private bool ApplyAnimation(Skeleton skeleton, AnimatorClipInfo info, AnimatorStateInfo stateInfo,
                                        int layerIndex, float layerWeight, MixBlend layerBlendMode, bool useClipWeight1 = false)
            {
                float weight = info.weight * layerWeight;

                if (weight < WeightEpsilon)
                {
                    return(false);
                }

                var clip = GetAnimation(info.clip);

                if (clip == null)
                {
                    return(false);
                }

                var time = AnimationTime(stateInfo.normalizedTime, info.clip.length,
                                         info.clip.isLooping, stateInfo.speed < 0);

                weight = useClipWeight1 ? layerWeight : weight;
                clip.Apply(skeleton, 0, time, info.clip.isLooping, null,
                           weight, layerBlendMode, MixDirection.In);
                if (_OnClipApplied != null)
                {
                    OnClipAppliedCallback(clip, stateInfo, layerIndex, time, info.clip.isLooping, weight);
                }
                return(true);
            }
Esempio n. 14
0
    public void GetAnimationsData()
    {
        // get animations data
        animInfo    = anim.GetCurrentAnimatorClipInfo(0)[0];
        currentClip = animInfo.clip.name;

        if (currentClip == "attack1" || currentClip == "attack2" || currentClip == "attack3")
        {
            data.animationState = PlayerState.Attack;
        }
        else if (currentClip == "slide")
        {
            data.animationState = PlayerState.Slide;
        }
        else if (currentClip == "stand")
        {
            data.animationState = PlayerState.Stand;
        }
        else if (currentClip == "move")
        {
            data.animationState = PlayerState.Move;
        }
        else if (currentClip == "idle")
        {
            data.animationState = PlayerState.Idle;
        }
    }
Esempio n. 15
0
 void PrintAnimatorClipInfo(AnimatorClipInfo info)
 {
     Debug.Log(string.Format("AnimatorClipInfo clip={0}, weight={1}", info.clip, info.weight));
     if (info.clip != null)
     {
         PrintAnimationClip(info.clip);
     }
 }
Esempio n. 16
0
 /// <summary>
 /// _clips 변수를 사용하는 척합니다.
 /// </summary>
 void TestAnimatorClips()
 {
     foreach (string clipKey in _clips.Keys)
     {
         AnimatorClipInfo clipInfo = _clips[clipKey];
         Console.WriteLine(clipInfo.clip.length);
     }
 }
Esempio n. 17
0
    string GetCurrentAnimationName(Animator anim)
    {
        var currAnimName     = "";
        var clipInfo         = anim.GetCurrentAnimatorClipInfo(0);
        AnimatorClipInfo aci = clipInfo[0];

        currAnimName = aci.clip.name;
        return(currAnimName);
    }
Esempio n. 18
0
 private void SaveAnimationName()
 {
     if (animator)
     {
         clipInfo = animator.GetCurrentAnimatorClipInfo(0)[0];
         clipName = clipInfo.clip.name.Substring(clipInfo.clip.name.IndexOf("@") + 1, clipInfo.clip.name.IndexOf("_") - clipInfo.clip.name.IndexOf("@") - 1); // charaName@animeName_hogehogeのように出力されるので@から_だけ出力するように整形
         cubemanController[searchNearPlayer.userNumber].useAnimationName = clipName;
     }
 }
        private IEnumerator HideView()
        {
            m_IsCoroutineRunning = true;

            UI.DeactivateEventTriggers(gameObject);
            UI.RemoveFocusFrom(gameObject);

            OnExit();

            DisableCanvasGroup();

            if (m_Animator != null)
            {
                m_Animator.SetBool(s_OpenBoolId, false);

                yield return(null);

                AnimatorClipInfo[] animatorClipsInfo = m_Animator.GetCurrentAnimatorClipInfo(0);
                if (animatorClipsInfo != null && animatorClipsInfo.Length > 0)
                {
                    AnimatorClipInfo animatorClipInfo = animatorClipsInfo[0];
                    AnimationClip    clip             = animatorClipInfo.clip;
                    if (clip != null)
                    {
                        if (clip.length > 0f)
                        {
                            AnimatorStateInfo animatorStateInfo = m_Animator.GetCurrentAnimatorStateInfo(0);
                            float             normalizedTime    = animatorStateInfo.normalizedTime;
                            while (normalizedTime < 1f)
                            {
                                yield return(null);

                                animatorStateInfo = m_Animator.GetCurrentAnimatorStateInfo(0);
                                normalizedTime    = animatorStateInfo.normalizedTime;
                            }
                        }
                    }
                }
            }

            MoveOutView();

            yield return(null);

            // MoveInView();

            SetRootActive(false);

            yield return(null);

            m_IsOpen = false;

            m_IsCoroutineRunning = false;

            Callback();
        }
Esempio n. 20
0
 void DoJump()//ジャンプ処理
 {
     nowAnm = animator.GetCurrentAnimatorClipInfo(0)[0];
     if (nowAnm.clip.name != "BasicMotions@Jump01" && interbal > 0.5)
     {
         interbal = 0;
         animator.SetTrigger("jumpTrigger");
         rb.AddForce(transform.up * jumpForce, ForceMode.Impulse);
     }
 }
Esempio n. 21
0
    void Scan()
    {
        Animator scanline = canvas.transform.Find("Scanline").GetComponent <Animator>();

        scanline.gameObject.SetActive(true);

        AnimatorClipInfo info    = scanline.GetCurrentAnimatorClipInfo(0)[0];
        float            seconds = info.clip.length;

        StartCoroutine(DisableGameObject(scanline.gameObject, seconds, true));
    }
        /// <summary>
        /// Plays the clip named [name] at frame [frame].
        /// </summary>
        /// <param name="anim"></param>
        /// <param name="name"></param>
        /// <param name="frame"></param>
        public static void PlayAt(this Animator anim, string name, int frame)
        {
            AnimatorClipInfo att = anim.GetCurrentAnimatorClipInfo(0)[0];

            Modding.Logger.Log("frameR " + att.clip.frameRate);
            Modding.Logger.Log("length " + att.clip.length);
            float normTime = frame / (att.clip.length * att.clip.frameRate);

            Modding.Logger.Log("time " + normTime);
            anim.Play(name, 0, normTime);
        }
Esempio n. 23
0
 private bool IsAnAttackingClip(AnimatorClipInfo curClip)
 {
     foreach (var clip in attackingAnims)
     {
         if (curClip.clip == clip)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 24
0
        public override float GetCurrentClipDuration(Agent agent, int layerIndex)
        {
            // Get the first clip of the current state in layerIndex
            if (animators[agent].GetCurrentAnimatorClipInfoCount(layerIndex) > 0)
            {
                AnimatorClipInfo animatorClipInfo = animators[agent].GetCurrentAnimatorClipInfo(layerIndex)[0];

                return(animatorClipInfo.clip.length);
            }

            return(-1f);
        }
Esempio n. 25
0
    //----------------------------------------------------------------------
    //! @brief ポーズの変更処理
    //!
    //! @param[in] ポーズの名前
    //!
    //! @return なし
    //----------------------------------------------------------------------
    public void ChangePose(string pose)
    {
        AnimatorClipInfo clipInfo = anim.GetCurrentAnimatorClipInfo(0)[0];

        if (pose != clipInfo.clip.name)
        {
            //ポーズ名
            int hash = Animator.StringToHash(pose);

            //ハッシュ、レイヤー、正規化された時間(0-1)
            anim.Play(hash, -1, 0);
        }
    }
    void Update()
    {
        if (Input.GetKeyDown(switchChat))
        {
            SwitchChat();
        }
        if (Input.GetKeyDown(switchStats))
        {
            SwitchStats();
        }
        if (Input.GetKeyDown(switchOptions))
        {
            SwitchSoundOptions();
        }
        if (Input.GetKeyUp(switchTutorial))
        {
            SwitchTutorialWindow();
        }
        if (Input.GetKeyDown(switchExit))
        {
            SwitchExit();
        }


        Money.text = "£" + System.Math.Round(Stats.Money, 2).ToString();

        actionBar.fillAmount = GameLibOfMethods.progress;

        var layer    = 0; // 0 if you only use the Base Layer
        var animator = GameLibOfMethods.animator;
        var clipInfo = animator.GetCurrentAnimatorClipInfo(layer);

        if (clipInfo.Length >= 1)
        {
            AnimatorClipInfo clip = clipInfo[0]; // I haven't seen clipInfo be larger than one before
            if (clip.clip.name != "Idle" && clip.clip.name != "IdleRight" && clip.clip.name != "IdleLeft" && clip.clip.name != "IdleBack" &&
                clip.clip.name != "WalkRight" && clip.clip.name != "WalkLeft" && clip.clip.name != "WalkDown" && clip.clip.name != "WalkUp" &&
                clip.clip.name != "PrepareToSleep" && clip.clip.name != "PrepareToPassOut" && clip.clip.name != "PrepareToTakeADump" && clip.clip.name != "Jumping")
            {
                actionBar.transform.parent.gameObject.SetActive(true);
                ActionText.text = clip.clip.name;
            }
            else
            {
                actionBar.transform.parent.gameObject.SetActive(false);
            }
        }

        //VitText.text = "Vitality: " + ThePS.currentLevelVit +"   "+ "exp until next lvl: " + (ThePS.toLevelUpVit[ThePS.currentLevelVit] - ThePS.currentExpVit);
    }
Esempio n. 27
0
    //----------------------------------------------------------------------
    //! @brief ポーズの変更処理
    //!
    //! @param[in] ポーズの名前
    //!
    //! @return なし
    //----------------------------------------------------------------------
    public void ChangePose(string pose)
    {
        AnimatorClipInfo clipInfo = anim.GetCurrentAnimatorClipInfo(0)[0];

        if (pose != clipInfo.clip.name)
        {
            //ポーズ名
            int hash = Animator.StringToHash(pose);

            //ハッシュ、レイヤー、正規化された時間(0-1)
            anim.Play(hash, -1, 0);
        }

        // キャラクリ用カメラとViewPointを特定の位置に移動させる
        aCCamera.GetComponent <AppreciationCameraCtr>().CameraSetPos(aCCSetPosNum);
    }
    public static int constructor(IntPtr l)
    {
        int result;

        try
        {
            AnimatorClipInfo animatorClipInfo = default(AnimatorClipInfo);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, animatorClipInfo);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
    private void LateUpdate()
    {
        var info = _animator.GetCurrentAnimatorClipInfo(0)[0];

        if (info.Equals(lastState))
        {
            return;
        }
        _animator.SetInteger("State", -1);
        lastState = info;
        var capture = FindObjectOfType <UnityMotionCapture>();

        if (capture != null)
        {
            capture.AnimationName = info.clip.name;
        }
    }
Esempio n. 30
0
    /// <summary>
    /// ロボットの腕の攻撃
    /// </summary>
    /// <returns>終わったかどうか</returns>
    public Func <bool> RobotArmAttack()
    {
        Func <bool> armAttack = () =>
        {
            bool             endAnim  = true;
            AnimatorClipInfo clipInfo = m_Animator.GetCurrentAnimatorClipInfo(0)[0];
            if (clipInfo.clip.name == "Attack")
            {
                endAnim = m_Animator.GetCurrentAnimatorStateInfo(0).normalizedTime < 1.0f;
            }
            m_RobotState = RobotState.ROBOT_ARM_ATTACK;
            m_Animator.SetInteger("RobotAnimNum", (int)m_RobotState);
            return(endAnim);
        };

        return(armAttack);
    }