示例#1
0
	// Use this for initialization
	void Start () {
		animator = GetComponent<Animator> ();

		if (animator.layerCount > 1) {
			int index = animator.GetLayerIndex("ArmLayer");
			animator.SetLayerWeight(index,1.0f);
		}
	}
示例#2
0
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (firstSetting)
     {
         this.shootingLayer = animator.GetLayerIndex("Shoot");
         this.firstSetting = false;
     }
     animator.SetLayerWeight(shootingLayer, 0.4f);
 }
示例#3
0
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (firstSetting)
     {
         this.controller = animator.GetComponent<ControllerAIHumanoid>();
         this.shootingLayer = animator.GetLayerIndex("Shoot");
         this.firstSetting = false;
     }
     animator.SetLayerWeight(shootingLayer, 1f);
 }
示例#4
0
        public override void OnEnter()
        {
            base.OnEnter();
            this.animator     = base.GetModelAnimator();
            this.childLocator = base.GetModelChildLocator();
            this.localUser    = LocalUserManager.readOnlyLocalUsersList[0];

            base.characterBody.hideCrosshair = true;

            if (base.GetAimAnimator())
            {
                base.GetAimAnimator().enabled = false;
            }
            this.animator.SetLayerWeight(animator.GetLayerIndex("AimPitch"), 0);
            this.animator.SetLayerWeight(animator.GetLayerIndex("AimYaw"), 0);

            if (this.animDuration == 0 && this.duration != 0)
            {
                this.animDuration = this.duration;
            }

            if (this.duration > 0)
            {
                base.PlayAnimation("FullBody, Override", this.animString, "Emote.playbackRate", this.duration);
            }
            else
            {
                base.PlayAnimation("FullBody, Override", this.animString, "Emote.playbackRate", this.animDuration);
            }

            this.activePlayID = Util.PlaySound(soundString, base.gameObject);

            if (this.normalizeModel)
            {
                if (base.modelLocator)
                {
                    base.modelLocator.normalizeToFloor = true;
                }
            }

            this.initialTime = Time.fixedTime;
        }
示例#5
0
 void Awake()
 {
     ani           = GetComponent <Animator>();
     mDefaultLayer = ani.GetLayerIndex("BaseCw");
     run_Hash      = Animator.StringToHash("BaseCw.Run");
     idle_Hash     = Animator.StringToHash("BaseCw.Idle");
     idle01_Hash   = Animator.StringToHash("BaseCw.Idle01");
     idle02_Hash   = Animator.StringToHash("BaseCw.Idle02");
     Init(nodeId, mCwType);
     mUImanager = Singleton <GUIManager> .Instance;
 }
        // Token: 0x060029E4 RID: 10724 RVA: 0x000AFEF0 File Offset: 0x000AE0F0
        protected static void PlayAnimationOnAnimator(Animator modelAnimator, string layerName, string animationStateName, string playbackRateParam, float duration)
        {
            int layerIndex = modelAnimator.GetLayerIndex(layerName);

            modelAnimator.SetFloat(playbackRateParam, 1f);
            modelAnimator.PlayInFixedTime(animationStateName, layerIndex, 0f);
            modelAnimator.Update(0f);
            float length = modelAnimator.GetCurrentAnimatorStateInfo(layerIndex).length;

            modelAnimator.SetFloat(playbackRateParam, length / duration);
        }
示例#7
0
    private void AnimationController()
    {
        ///TODO:
        ///Check movement states and adjust animator accordingly
        //Get current weapons Animator
        anim = CurrentWeapon.WeaponTransform.GetComponent <Animator>();

        if (PlayerMovementState == MovementState.Idle)
        {
            anim.SetBool("IsIdle", true);
        }
        else
        {
            anim.SetBool("IsIdle", false);
        }
        if (PlayerMovementState == MovementState.Walking)
        {
            anim.SetBool("IsWalking", true);
        }
        else
        {
            anim.SetBool("IsWalking", false);
        }
        if (PlayerMovementState == MovementState.Running)
        {
            anim.SetBool("IsRunning", true);
        }
        else
        {
            anim.SetBool("IsRunning", false);
        }

        //Shooting
        if (IsShooting && CanShoot && !IsReloading)
        {
            anim.Play(string.Format("{0}_shoot", CurrentWeapon.Name));
        }


        //manager gun postition if the weapon has an empty position
        int emptyWeaponIndex = anim.GetLayerIndex("EmptyWeapon");

        if (emptyWeaponIndex != -1)
        {
            if (CurrentWeapon.Clip == 0 && CurrentWeapon.Clips == 0)
            {
                anim.SetLayerWeight(emptyWeaponIndex, 1);
            }
            else
            {
                anim.SetLayerWeight(emptyWeaponIndex, 0);
            }
        }
    }
示例#8
0
    private void Start()
    {
        anim = GetComponent <Animator>();
        anim.SetLayerWeight(anim.GetLayerIndex(layerName), 1);

        emotionAnimationBind = new Dictionary <string, AnimationClip>();
        for (int i = 0; i < emotion.Length; i++)
        {
            emotionAnimationBind.Add(emotion[i], animations[i]);
        }
    }
示例#9
0
 void Init()
 {
     anim                 = GetComponent <Animator>();
     nav                  = GetComponent <UnityEngine.AI.NavMeshAgent>();
     run_Hash             = Animator.StringToHash("BaseCw.Run");
     idle01_Hash          = Animator.StringToHash("BaseCw.Idle01");
     layerIndex           = anim.GetLayerIndex("BaseCw");
     nav.stoppingDistance = 0.8f;
     nav.speed            = master.moveSpeed - 0.1f;
     CreateNameLabel();
 }
示例#10
0
        private void Start()
        {
            m_showAfterInputFocusAcquired = new List <Renderer>();

            // Collision starts disabled. We'll enable it for certain cases such as making a fist.
            m_colliders = this.GetComponentsInChildren <Collider>().Where(childCollider => !childCollider.isTrigger).ToArray();
            CollisionEnable(false);

            // Get animator layer indices by name, for later use switching between hand visuals
            m_animLayerIndexPoint = m_animator.GetLayerIndex(ANIM_LAYER_NAME_POINT);
            m_animLayerIndexThumb = m_animator.GetLayerIndex(ANIM_LAYER_NAME_THUMB);
            m_animParamIndexFlex  = Animator.StringToHash(ANIM_PARAM_NAME_FLEX);
            m_animParamIndexPose  = Animator.StringToHash(ANIM_PARAM_NAME_POSE);

            OVRManager.InputFocusAcquired += OnInputFocusAcquired;
            OVRManager.InputFocusLost     += OnInputFocusLost;
#if UNITY_EDITOR
            OVRPlugin.SendEvent("custom_hand", (SceneManager.GetActiveScene().name == "CustomHands").ToString(), "sample_framework");
#endif
        }
示例#11
0
    IEnumerator waitForMenuFadeout(Action callback)
    {
        int layerNum = animator.GetLayerIndex("Base Layer");

        while (animator.GetCurrentAnimatorStateInfo(layerNum).IsName("Menu_Exit_Anim") || animator.GetCurrentAnimatorStateInfo(layerNum).IsName("Menu_Idle"))
        {
            yield return(null);
        }

        callback();
    }
        // Token: 0x06001F62 RID: 8034 RVA: 0x000884FC File Offset: 0x000866FC
        public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            base.OnStateEnter(animator, stateInfo, layerIndex);
            int layerIndex2 = layerIndex;

            if (this.layerName.Length > 0)
            {
                layerIndex2 = animator.GetLayerIndex(this.layerName);
            }
            animator.SetLayerWeight(layerIndex2, 0f);
        }
示例#13
0
 /// <summary> Function to Activate the correct myAnimator Layers (String: Layer to Activate) </summary>
 public void ActivateLayer(string layerName)
 {
     // Go through all possible Layers
     for (int i = 0; i < myAnimator.layerCount; i++)
     {
         // Set all Layers in myAnimator to Disabled (0)
         myAnimator.SetLayerWeight(i, 0);
     }
     //Enable Layer on Given Index by Name
     myAnimator.SetLayerWeight(myAnimator.GetLayerIndex(layerName), 1);
 }
        // Token: 0x06002A5A RID: 10842 RVA: 0x000B2390 File Offset: 0x000B0590
        public override void OnEnter()
        {
            base.OnEnter();
            Animator modelAnimator = base.GetModelAnimator();

            if (modelAnimator)
            {
                int layerIndex = modelAnimator.GetLayerIndex("Body");
                modelAnimator.Play("Sleep", layerIndex, 0f);
            }
        }
示例#15
0
        private void PlayAnimation(string layerName, string animationStateName, string playbackRateParam, float duration, Animator animator)
        {
            int layerIndex = animator.GetLayerIndex(layerName);

            animator.SetFloat(playbackRateParam, 1f);
            animator.PlayInFixedTime(animationStateName, layerIndex, 0f);
            animator.Update(0f);
            float length = animator.GetCurrentAnimatorStateInfo(layerIndex).length;

            animator.SetFloat(playbackRateParam, length / duration);
        }
示例#16
0
    void Start()
    {
        if (firstPersonArm != null)
        {
            armUpPos   = firstPersonArm.localPosition;
            armDownPos = armUpPos - new Vector3(0, 1, 0);
            firstPersonArm.localPosition = armDownPos;
        }
        anim             = GetComponent <Animator>();
        animLayerForward = anim.GetLayerIndex("Forward");
        animLayerStrafe  = anim.GetLayerIndex("Strafe");
        animBoolRun      = Animator.StringToHash("Running");
        animBoolCrouch   = Animator.StringToHash("Crouching");
        animBoolOrb      = Animator.StringToHash("HasOrb");
        animFloatDir     = Animator.StringToHash("Direction");
        Transform spawnPos = GameObject.Find("Human Spawn Location").transform;

        controller.position = transform.position = spawnPos.position;
        controller.rotation = transform.rotation = spawnPos.rotation;
    }
示例#17
0
    void StartAtnimation()
    {
        an = GetComponent <Animator>();
        GetComponent <Animator>().enabled = true;

        an.speed = TL_TimeLineMng.mult;

        float ratio = 1.0f / AnimationSet.Count;

        foreach (var b in AnimationSet)
        {
            an.SetLayerWeight(an.GetLayerIndex(b.name), ratio);
            Debug.Log(an.GetLayerWeight(an.GetLayerIndex(b.name)));

            an.Play(b.name);
        }

        FindObjectOfType <Cam_EffectPlayer>().DispatchEffect(this);
        an = null;
    }
示例#18
0
    protected virtual void Awake()
    {
        _animator       = GetComponent <Animator>();
        _steeringHashID = Animator.StringToHash("Steering");
        _thrustXHashID  = Animator.StringToHash("ThrustX");
        _thrustYHashID  = Animator.StringToHash("ThrustY");
        _shieldHashID   = _animator.GetLayerIndex("Shield");

        _weapons = new List <Weapon>();
        _weapons.Add(Weapon);
    }
示例#19
0
    public void Play()
    {
        Animator anim = GameObject.Find("Main Camera").GetComponent <Animator>();

        MenuManager._instance.BackScreen(() => {
            anim.Play("MoveCamera", anim.GetLayerIndex("SecondPosition"));
        });
        StartCoroutine(WaitFor(2.7f, () => {
            GetComponent <LevelPresenter>().ShowLevels();
        }));
    }
示例#20
0
 void Update()
 {
     if (CanFire == true)
     {
         if (TheAnimator.GetCurrentAnimatorStateInfo(TheAnimator.GetLayerIndex("Gun")).normalizedTime % 1 >= FireOnAnimationTime)
         {
             GameObject bullet = (GameObject)Instantiate(ProjectilePrefab, transform.position, transform.rotation);
             bullet.GetComponent <PlayerBullet>().Direction = new Vector3(transform.forward.x, 0, transform.forward.z);
             //transform.rotation = Quaternion.Euler(transform.forward.x, transform.forward.y, transform.forward.z);
             CanFire = false;
         }
     }
     else
     {
         if (TheAnimator.GetCurrentAnimatorStateInfo(TheAnimator.GetLayerIndex("Gun")).normalizedTime % 1 <= FireOnAnimationTime)
         {
             CanFire = true;
         }
     }
 }
示例#21
0
    void AnimationUpdate()
    {
        if (hurtCountdown > 0f)
        {
            hurtCountdown -= Time.deltaTime;
        }

        if (!endingLevel)
        {
            anim.SetFloat("speed", Mathf.Abs(Input.GetAxis("Horizontal")));


            //Facing direction
            if (facingRight && (Input.GetAxis("Horizontal") < 0))
            {
                facingRight = false;
                FlipSprite();
            }
            else if (!facingRight && (Input.GetAxis("Horizontal") > 0))
            {
                facingRight = true;
                FlipSprite();
            }
        }

        anim.SetBool("grounded", grounded);

        if (currentMehrio == PlayerWeaponStates.small)
        {
            anim.SetLayerWeight(anim.GetLayerIndex("Small Layer"), 1);
            anim.SetLayerWeight(anim.GetLayerIndex("Fire Layer"), 0);
            anim.SetLayerWeight(anim.GetLayerIndex("Base Layer"), 0);
        }
        else if (currentMehrio.Equals(PlayerWeaponStates.fireball))
        {
            anim.SetLayerWeight(anim.GetLayerIndex("Small Layer"), 0);
            anim.SetLayerWeight(anim.GetLayerIndex("Fire Layer"), 1);
            anim.SetLayerWeight(anim.GetLayerIndex("Base Layer"), 0);
        }
        else
        {
            anim.SetLayerWeight(anim.GetLayerIndex("Small Layer"), 0);
            anim.SetLayerWeight(anim.GetLayerIndex("Fire Layer"), 0);
            anim.SetLayerWeight(anim.GetLayerIndex("Base Layer"), 1);
        }
    }
示例#22
0
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (Mathf.Abs(animatorAI.transform.rotation.eulerAngles.y - animatorAI.rotateAngle) > 1f)
     {
         float angle = Mathf.MoveTowardsAngle(animatorAI.transform.rotation.eulerAngles.y, animatorAI.rotateAngle, animatorAI.rotateSpeed * Time.deltaTime);
         animatorAI.transform.rotation = Quaternion.Euler(0, angle, 0);
     }
     else
     {
         animator.Play("Move", animator.GetLayerIndex("Behaviors"));
     }
 }
示例#23
0
        private void Awake()
        {
            InitializeInput();

            animator         = GetComponent <Animator>();
            combatLayerIndex = animator.GetLayerIndex("Combat");

            m_ComboTree.SetAnimator(animator, combatLayerIndex);
            m_ComboTree.Initialize(this);

            m_DamageTrigger.Initialize(this);
        }
示例#24
0
        void ActivateLayer(string layerName)
        {
            if (gearSlotAnimator != null)
            {
                for (int i = 0; i < gearSlotAnimator.layerCount; i++)
                {
                    gearSlotAnimator.SetLayerWeight(i, 0);
                }

                gearSlotAnimator.SetLayerWeight(gearSlotAnimator.GetLayerIndex(layerName), 1);
            }
        }
示例#25
0
 void Start()
 {
     _animatorLayer = _animator.GetLayerIndex(_animatorLayerName);
     if (_animatorLayer == -1)
     {
         _animatorLayer = 0;
     }
     if (_checkOnStart)
     {
         StartChecking();
     }
 }
示例#26
0
    void Animate()
    {
        if (playerController.movementDirection != Vector2.zero)
        {
            animator.SetFloat("Horizontal", playerController.movementDirection.x);
            animator.SetFloat("Vertical", playerController.movementDirection.y);
        }
        animator.SetFloat("Speed", playerController.movementSpeed);

        if (gpm.playerInWater)
        {
            animator.SetLayerWeight(animator.GetLayerIndex("Walking"), 0f);
            animator.SetLayerWeight(animator.GetLayerIndex("Swimming"), 1f);
        }

        else if (!gpm.playerInWater)
        {
            animator.SetLayerWeight(animator.GetLayerIndex("Walking"), 1f);
            animator.SetLayerWeight(animator.GetLayerIndex("Swimming"), 0f);
        }
    }
示例#27
0
 void Awake()
 {
     _npcData                  = new NpcData();
     _agentCollider            = GetComponent <Collider>();
     _rigidbody                = GetComponent <Rigidbody>();
     _animator                 = GetComponent <Animator>();
     _audioSource              = GetComponent <AudioSource>();
     _npcData.StateMachine     = GetComponent <NPCStateMachine>();
     _punchLayerIndex          = _animator.GetLayerIndex("Punch Layer");
     _npcData.PreviousLocation = transform.position;
     InvokeRepeating("GotStuck", 0.5f, 1f);
 }
示例#28
0
    IEnumerator waitForCreditsFadeOut(Animator creditsAnimator, Action callback)
    {
        int layerNumber = creditsAnimator.GetLayerIndex("Base Layer");

        while (creditsAnimator.GetCurrentAnimatorStateInfo(layerNumber).IsName("Credits_Fade_out") || creditsAnimator.GetCurrentAnimatorStateInfo(layerNumber).IsName("Idle"))
        {
            yield return(null);
        }

        creditsAnimator.gameObject.SetActive(false);
        callback();
    }
        // Token: 0x06002C0B RID: 11275 RVA: 0x000BA20C File Offset: 0x000B840C
        protected void AuthorityFixedUpdate()
        {
            Animator modelAnimator = base.GetModelAnimator();

            if (modelAnimator)
            {
                int layerIndex = modelAnimator.GetLayerIndex("Base");
                if (layerIndex != -1 && modelAnimator.GetCurrentAnimatorStateInfo(layerIndex).IsName("Idle"))
                {
                    this.TransitionIntoNextState();
                }
            }
        }
        // Token: 0x060004A5 RID: 1189 RVA: 0x00013550 File Offset: 0x00011750
        public override void OnEnter()
        {
            base.OnEnter();
            Animator modelAnimator = base.GetModelAnimator();

            if (modelAnimator)
            {
                int layerIndex = modelAnimator.GetLayerIndex("Body");
                modelAnimator.Play("EmoteSurprise", layerIndex, 0f);
                modelAnimator.Update(0f);
                this.duration = modelAnimator.GetCurrentAnimatorStateInfo(layerIndex).length;
            }
        }
    private void OnEnable()
    {
        if (characterAnimator == null)
        {
            characterAnimator = GetComponent <Animator>();
        }
        if (rb == null)
        {
            rb = GetComponent <Rigidbody>();
        }
        //if (rightHandIKAnimator == null) rightHandIKAnimator = rightHandIK.GetComponent<Animator>();

        cameraRig.gameObject.SetActive(true);
        characterAnimator.SetBool("Aiming", true);
        //characterAnimator.SetLayerWeight(characterAnimator.GetLayerIndex("Right Hand IK"), 1f);
        //characterAnimator.SetLayerWeight(characterAnimator.GetLayerIndex("Left Hand IK"), 1f);
        characterAnimator.SetLayerWeight(characterAnimator.GetLayerIndex("Legs"), 1f);

        aimingRigAnimator.Play("Vertical Aiming", 0, verticalAngle);
        aimingRigAnimator.Update(1f);

        if (aimIK == null)
        {
            aimIK = GetComponent <AimIK>();
        }
        if (fbbIK == null)
        {
            fbbIK = GetComponent <FullBodyBipedIK>();
        }
        if (lookAtIK == null)
        {
            lookAtIK = GetComponent <LookAtIK>();
        }
        aimIK.enabled    = false;
        fbbIK.enabled    = false;
        lookAtIK.enabled = false;

        fbbIK.solver.leftArmChain.bendConstraint.weight = 1f;
    }
示例#32
0
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (animatorAI == null)
        {
            animatorAI = animator.gameObject.GetComponent <AnimatorAI>();
        }

        timeEnteredState = Time.time;

        animatorAI.topText.SetText("CurrentBehavior:" + this.GetType().ToString());

        animator.Play("Attack01", animator.GetLayerIndex("Base Layer"));
    }
示例#33
0
    //----------------------------Use this for initialization---------------------------------------------------------------------------------------
    void Start()
    {
        SetAnimator();
        hashs      = GetComponent <HashIDs>();
        Col        = GetComponent <CapsuleCollider>();
        RigidRider = GetComponent <Rigidbody>();
        MountLayer = anim.GetLayerIndex("Mounted");

        if (CharacterCamera)
        {
            CharacterCamera.SetTarget(transform);
        }
    }
示例#34
0
 public EnemyAnimation(Animator animator)
 {
     if (animator == null) Debug.Log("Enemy has been created without an animator on it blud");
     _animator = animator;
     _baseLayer = _animator.GetLayerIndex("Base Layer");
 }