static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.AnimatorTransitionInfo o;
         o = new UnityEngine.AnimatorTransitionInfo();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Пример #2
0
    static void AnimatorTransitionInfo_userNameHash(JSVCall vc)
    {
        UnityEngine.AnimatorTransitionInfo _this = (UnityEngine.AnimatorTransitionInfo)vc.csObj;
        var result = _this.userNameHash;

        JSApi.setInt32((int)JSApi.SetType.Rval, (System.Int32)(result));
    }
Пример #3
0
    static void AnimatorTransitionInfo_normalizedTime(JSVCall vc)
    {
        UnityEngine.AnimatorTransitionInfo _this = (UnityEngine.AnimatorTransitionInfo)vc.csObj;
        var result = _this.normalizedTime;

        JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
    }
Пример #4
0
    static void AnimatorTransitionInfo_anyState(JSVCall vc)
    {
        UnityEngine.AnimatorTransitionInfo _this = (UnityEngine.AnimatorTransitionInfo)vc.csObj;
        var result = _this.anyState;

        JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
    }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.AnimatorTransitionInfo o;
         o = new UnityEngine.AnimatorTransitionInfo();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.AnimatorTransitionInfo o;
			o=new UnityEngine.AnimatorTransitionInfo();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
Пример #7
0
    static bool AnimatorTransitionInfo_IsUserName__String(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 1)
        {
            System.String arg0 = (System.String)JSApi.getStringS((int)JSApi.GetType.Arg);
            UnityEngine.AnimatorTransitionInfo argThis = (UnityEngine.AnimatorTransitionInfo)vc.csObj;                JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(argThis.IsUserName(arg0)));
            JSMgr.changeJSObj(vc.jsObjID, argThis);
        }

        return(true);
    }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.AnimatorTransitionInfo o;
         o=new UnityEngine.AnimatorTransitionInfo();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.AnimatorTransitionInfo o;
         o = new UnityEngine.AnimatorTransitionInfo();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Пример #10
0
 static public int IsUserName(IntPtr l)
 {
     try{
         UnityEngine.AnimatorTransitionInfo self = (UnityEngine.AnimatorTransitionInfo)checkSelf(l);
         System.String a1;
         checkType(l, 2, out a1);
         System.Boolean ret = self.IsUserName(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Пример #11
0
    void Update()
    {
        armsTransitionInfo = animator.GetAnimatorTransitionInfo(0);

        if(Input.GetMouseButton(0)) {
            Attack();
        }

        if(armsTransitionInfo.nameHash == Animator.StringToHash("Swing -> idle")) {
            attacking = false;
        }

        if(attacking)
            HitCheck();
    }
 static int _CreateAnimatorTransitionInfo(IntPtr L)
 {
     LuaScriptMgr.CheckArgsCount(L, 0);
     AnimatorTransitionInfo obj = new AnimatorTransitionInfo();
     LuaScriptMgr.PushValue(L, obj);
     return 1;
 }
Пример #13
0
    // Update is called once per frame
    void Update()
    {
        currentState = anim.GetCurrentAnimatorStateInfo(0);
        currentTransition = anim.GetAnimatorTransitionInfo(0);

        currentTime = Time.time;

        if (canDie)
        {
            if (Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.DownArrow) || Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.RightArrow))
            {
                anim.SetBool("isMove", false);
            }

            if (canMove)
            {
                // For attacking
                if (Input.GetKey(KeyCode.UpArrow) && Input.GetKey(KeyCode.RightArrow))
                {
                    this.gameObject.transform.eulerAngles = new Vector3(0, 45, 0);
                    anim.SetBool("isMove", true);
                }
                else if (Input.GetKey(KeyCode.RightArrow) && Input.GetKey(KeyCode.DownArrow))
                {
                    this.gameObject.transform.eulerAngles = new Vector3(0, 135, 0);
                    anim.SetBool("isMove", true);
                }
                else if (Input.GetKey(KeyCode.LeftArrow) && Input.GetKey(KeyCode.DownArrow))
                {
                    this.gameObject.transform.eulerAngles = new Vector3(0, 225, 0);
                    anim.SetBool("isMove", true);
                }
                else if (Input.GetKey(KeyCode.UpArrow) && Input.GetKey(KeyCode.LeftArrow))
                {
                    this.gameObject.transform.eulerAngles = new Vector3(0, 315, 0);
                    anim.SetBool("isMove", true);
                }
                else
                {
                    if (Input.GetKey(KeyCode.UpArrow))
                    {
                        this.gameObject.transform.eulerAngles = new Vector3(0, 0, 0);
                        anim.SetBool("isMove", true);
                    }

                    if (Input.GetKey(KeyCode.DownArrow))
                    {
                        this.gameObject.transform.eulerAngles = new Vector3(0, 180, 0);
                        anim.SetBool("isMove", true);
                    }
                    if (Input.GetKey(KeyCode.LeftArrow))
                    {
                        this.gameObject.transform.eulerAngles = new Vector3(0, 270, 0);
                        anim.SetBool("isMove", true);
                    }
                    if (Input.GetKey(KeyCode.RightArrow))
                    {
                        this.gameObject.transform.eulerAngles = new Vector3(0, 90, 0);
                        anim.SetBool("isMove", true);
                    }
                }
            }

            if (canAttack)
            {
                if (!canCombo)
                {
                    if (Input.GetKeyDown(KeyCode.F))
                    {
                        stopTime = currentTime;
                        canCombo = true;
                        combo++;
                        extraTime = 0.5f;
                    }
                }
                else
                {
                    if (currentTime - stopTime <= extraTime)
                    {
                        if (Input.GetKeyDown(KeyCode.F))
                        {
                            extraTime += 0.5f;
                            combo++;
                            if (combo > 3)
                            {
                                extraTime = 0;
                                combo = 0;
                                canCombo = false;
                                canAttack = false;
                            }
                        }
                    }
                    else
                    {
                        extraTime = 0;
                        combo = 0;
                        canCombo = false;
                    }
                }

            }

            if (currentState.nameHash == idleState)
            {
                canMove = true;
                canAttack = true;
                canSkill = true;
                att1 = true;
                att2 = true;
                att3 = true;
                skill = true;
                //--------------------------
                if (Input.GetKeyDown(KeyCode.F))
                {
                    anim.SetBool("isAtt1", true);
                    anim.SetBool("isMove", false);
                }
            }

            if (currentState.nameHash == moveState)
            {

                canAttack = true;
                canSkill = true;
                this.gameObject.transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);

                if (combo == 1)
                {

                    anim.SetBool("isAtt1", true);
                }

            }

            if (currentState.nameHash == att1State)
            {
                canMove = false;
                this.gameObject.transform.Translate(Vector3.forward * moveSpeed * 0.3f * Time.deltaTime);
                if (combo == 2)
                {
                    anim.SetBool("isAtt2", true);
                }

                if (att1)
                {
                    generateAttackCube();
                    att1 = false;
                }
            }

            if (currentState.nameHash == att2State)
            {
                canMove = false;
                this.gameObject.transform.Translate(Vector3.forward * moveSpeed * 0.3f * Time.deltaTime);
                if (combo == 3)
                {
                    anim.SetBool("isAtt3", true);
                }

                if (att2)
                {
                    generateAttackCube();
                    att2 = false;
                }
            }
            if (currentState.nameHash == att3State)
            {
                canMove = false;
                canAttack = true;
                anim.SetBool("isAtt1", false);
                anim.SetBool("isAtt2", false);
                anim.SetBool("isAtt3", false);

                //this.gameObject.transform.Translate(Vector3.forward * moveSpeed * 0.3f * Time.deltaTime);
                if (att3)
                {
                    generateAttackCube();
                    att3 = false;
                }
            }
            if (currentState.nameHash == skillState)
            {
                this.gameObject.transform.Translate(Vector3.forward * moveSpeed * 0.6f * Time.deltaTime);
                if (skill)
                {
                    skill = false;
                }
                canSkill = false;
                canAttack = false;
                canMove = false;
                anim.SetBool("isSkill", false);
            }

            if (currentTransition.nameHash == att1Transition)
            {
                anim.SetBool("isAtt1", false);
            }

            if (currentTransition.nameHash == att2Transition)
            {

                anim.SetBool("isAtt1", false);
                anim.SetBool("isAtt2", false);
            }

            if (currentTransition.nameHash == att3Transition)
            {
            }

            if (canSkill)
            {
                if (Input.GetKeyDown(KeyCode.G))
                {
                    goSkill();
                }
            }

        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            goDie();
        }

        if (Input.GetKeyDown(KeyCode.U))
        {
            revive();
        }

        if (Input.GetKeyDown(KeyCode.X))
        {
            generateAttackCube();
        }
    }
Пример #14
0
    public virtual void Animate(Vector3 movement, bool atking, bool[] skills)
    {
        #region AnimatorStateInfo
        m_anmSttInfo = m_animator.GetCurrentAnimatorStateInfo(0);

        if (m_anmSttInfo.IsName("0.idle"))
        {
            m_agent.Stop();
            m_animator.SetBool("moving", movement.magnitude > 0.1f);
            m_animator.SetBool("atk", atking);
            m_animator.speed = 1;
        }
        else if (m_anmSttInfo.IsName("0.run"))
        {
            m_agent.Resume();
            m_animator.SetBool("moving", movement.magnitude > 0.1f);
            m_animator.SetBool("atk", atking);
            m_animator.speed = PlayerData.GetInstance().moveSpeed / m_baseMoveSpeed;
            m_agent.speed = PlayerData.GetInstance().moveSpeed;
            m_agent.angularSpeed = 99999999;
        }
        else if (m_anmSttInfo.IsName("0.atk0"))
        {
            AtkAnimate(atking, m_anmSttInfo.normalizedTime, 0);
        }
        else if (m_anmSttInfo.IsName("0.atk1"))
        {
            AtkAnimate(atking, m_anmSttInfo.normalizedTime, 0);
        }
        else if (m_anmSttInfo.IsName("0.atk2"))
        {
            AtkAnimate(atking, m_anmSttInfo.normalizedTime, 1);
        }
        else if (m_anmSttInfo.IsName("0.atk3"))
        {
            AtkAnimate(atking, m_anmSttInfo.normalizedTime, 2);
            if (m_anmSttInfo.normalizedTime > 0.5f)
                m_animator.SetBool("moving", movement.magnitude > 0.1f);
        }
        #endregion

        #region AnimatorTransitionInfo
        m_anmTraInfo = m_animator.GetAnimatorTransitionInfo(0);

        if (m_anmTraInfo.IsUserName("2a"))
        {
            m_animator.SetBool("atk", false);
            m_hasAtked = false;
            m_agent.angularSpeed = 0;
            m_agent.speed = 0;
            Vector3 direction = Vector3.Lerp(transform.position + transform.forward, transform.position + movement, Time.deltaTime * 10);
            transform.LookAt(direction);
            m_agent.Stop();
        }
        else if (m_anmTraInfo.IsUserName("a2i") && m_anmTraInfo.IsUserName("a2r"))
        {
            m_animator.SetBool("atk", false);
            m_agent.angularSpeed = 9999999999;
            m_agent.Resume();
        }
        #endregion
    }
Пример #15
0
 static public int get_userNameHash(IntPtr l)
 {
     UnityEngine.AnimatorTransitionInfo o = (UnityEngine.AnimatorTransitionInfo)checkSelf(l);
     pushValue(l, o.userNameHash);
     return(1);
 }
Пример #16
0
 static public int get_normalizedTime(IntPtr l)
 {
     UnityEngine.AnimatorTransitionInfo o = (UnityEngine.AnimatorTransitionInfo)checkSelf(l);
     pushValue(l, o.normalizedTime);
     return(1);
 }
    // Update is called once per frame
    void Update()
    {
        // If new wave GUI is showing, don't update player
        if (!wc.IsNewWave())
        {
            ControlMouse();
            //ControlWASD();

            // Get animation info
            armsTransitionInfo = GetComponent<Animator>().GetAnimatorTransitionInfo(1);

            if (currentGun)
            {
                if (Input.GetButtonDown("Shoot"))
                    currentGun.Shoot();
                else if (Input.GetButton("Shoot"))
                    currentGun.ShootAuto();

                if (Input.GetButtonDown("Reload"))
                {
                    if (currentGun.Reload())
                    {
                        GetComponent<Animator>().SetTrigger("Reload");
                        reloading = true;
                    }
                }

                // Finish reloading
                if (reloading)
                {
                    if (armsTransitionInfo.nameHash == Animator.StringToHash("Reload -> Weapon Hold"))
                    {
                        currentGun.FinishReload();
                        reloading = false;
                    }
                }
            }

            for (int i = 0; i < guns.Length; i++)
            {
                if (Input.GetKeyDown((i + 1) + "") || Input.GetKeyDown("[" + (i + 1) + "]"))
                {
                    EquipGun(i);
                    break;
                }
            }
        }
    }
 private void Update()
 {
     transInfo = animator.GetAnimatorTransitionInfo (0);
 }
Пример #19
0
	/// <summary>
	/// Update is called once per frame.
	/// </summary>
	void Update() 
	{
		if (animator && gamecam.CamState != CamaraJugador.CamStates.FirstPerson)
		{
			stateInfo = animator.GetCurrentAnimatorStateInfo(0);
			transInfo = animator.GetAnimatorTransitionInfo(0);
			
			// Press A to jump
			/*if (Input.GetButton("Jump"))
			{
				animator.SetBool("Jump", true);
			}
			else
			{
				animator.SetBool("Jump", false);
			}*/	
			
			// Pull values from controller/keyboard
			leftX = Input.GetAxis("Horizontal");
			leftY = Input.GetAxis("Vertical");	
			//float leftZ = Input.GetKeyDown(KeyCode.Space) == true ? 1 : 0;
			float leftZ = 0;

			charAngle = 0f;
			direction = 0f;	
			float charSpeed = 0f;
		
			/*Vector3 resultantVelocity = transform.forward * leftY * 10f + transform.right * leftX * 10f;
			resultantVelocity.y = Physics.gravity.y;
            

			float animSpeed = Mathf.Abs ( leftY );

			animator.SetFloat("Speed", animSpeed);

			rb3d.velocity = resultantVelocity;*/

            float animSpeed = Mathf.Abs(leftY);

            animator.SetFloat("Speed", animSpeed);

            rb3d.AddForce( (transform.forward * leftY * 20f + transform.right * leftX * 20f));

            Vector3 finalVelocity = rb3d.velocity;

            if ( Mathf.Abs(finalVelocity.x) > 10f)
                finalVelocity.x = finalVelocity.x < 0 ? -10 : 10;
            if ( Mathf.Abs(finalVelocity.z) > 10f)
                finalVelocity.z = finalVelocity.z < 0 ? -10 : 10;

            rb3d.velocity = finalVelocity;

			// Translate controls stick coordinates into world/cam/character space
            StickToWorldspace(this.transform, gamecam.transform, ref direction, ref charSpeed, ref charAngle, IsInPivot());		
			
			// Press B to sprint
			/*if (Input.GetButton("Sprint"))
			{
				speed = Mathf.Lerp(speed, SPRINT_SPEED, Time.deltaTime);
				gamecam.GetComponent<Camera>().fieldOfView = Mathf.Lerp(gamecam.GetComponent<Camera>().fieldOfView, SPRINT_FOV, fovDampTime * Time.deltaTime);
			}
			else
			{*/
				speed = charSpeed;
				gamecam.GetComponent<Camera>().fieldOfView = Mathf.Lerp(gamecam.GetComponent<Camera>().fieldOfView, NORMAL_FOV, fovDampTime * Time.deltaTime);		
			//}
			
			//animator.SetFloat("Speed", speed, speedDampTime, Time.deltaTime);
			//animator.SetFloat("Direction", direction, directionDampTime, Time.deltaTime);
			
			if (speed > LocomotionThreshold)	// Dead zone
			{
				if (!IsInPivot())
				{
					//Animator.SetFloat("Angle", charAngle);
				}
			}
			if (speed < LocomotionThreshold && Mathf.Abs(leftX) < 0.05f)    // Dead zone
			{
				//animator.SetFloat("Direction", 0f);
				//animator.SetFloat("Angle", 0f);
			}		
		} 
	}
Пример #20
0
    /// <summary>
    /// Update is called once per frame.
    /// </summary>
    void Update()
    {
        stateInfo = animator.GetCurrentAnimatorStateInfo(0);
            transInfo = animator.GetAnimatorTransitionInfo(0);

            /* Press A to jump
            if (Input.GetButton("Jump"))
            {
                animator.SetBool("Jump", true);
            }
            else
            {
                animator.SetBool("Jump", false);
            }
        */
            // Pull values from controller/keyboard
            leftX = Input.GetAxis("Horizontal")+gazeInput;
            leftY = Input.GetAxis("Vertical");

            charAngle = 0f;
            direction = 0f;
            float charSpeed = 0f;

            // Translate controls stick coordinates into world/cam/character space
            StickToWorldspace(this.transform, gamecam.transform, ref direction, ref charSpeed, ref charAngle, IsInPivot());

            /* Press B to sprint
            if (Input.GetButton("Sprint"))
            {
                speed = Mathf.Lerp(speed, SPRINT_SPEED, Time.deltaTime);
                gamecam.camera.fieldOfView = Mathf.Lerp(gamecam.camera.fieldOfView, SPRINT_FOV, fovDampTime * Time.deltaTime);
            }
            else
            {
           }
        */
            speed = charSpeed;
            gamecam.camera.fieldOfView = Mathf.Lerp(gamecam.camera.fieldOfView, NORMAL_FOV, fovDampTime * Time.deltaTime);

            animator.SetFloat("Speed", speed, speedDampTime, Time.deltaTime);
            animator.SetFloat("Direction", direction, directionDampTime, Time.deltaTime);

            if (speed > LocomotionThreshold)	// Dead zone
            {
                if (!IsInPivot())
                {
                    Animator.SetFloat("Angle", charAngle);
                }
            }
            if (speed < LocomotionThreshold && Mathf.Abs(leftX) < 0.05f)    // Dead zone
            {
                animator.SetFloat("Direction", 0f);
                animator.SetFloat("Angle", 0f);
            }
    }
    void Update()
    {
        stateInfo = animator.GetCurrentAnimatorStateInfo(0);
        transInfo = animator.GetAnimatorTransitionInfo(0);

        if (Input.GetButton("Jump"))
        {
            animator.SetFloat("Jump", 1);
        }
        else
        {
            animator.SetFloat("Jump", 1);
        }

        leftX = Input.GetAxis("Horizontal");
        leftY = Input.GetAxis("Vertical");

        charAngle = 0f;
        direction = 0f;

        float charSpeed = 0f;
        StrickToWorldspace(this.transform, gameCam.transform, ref direction, ref charSpeed, ref charAngle, IsInPivot());

        speed = charSpeed;
        Debug.Log("Speed:" + speed);
        animator.SetFloat("Speed", speed, speedDampTime, Time.deltaTime);
        animator.SetFloat("Forward", direction, directionDampTime, Time.deltaTime);

        if (speed > LocomotionThreshold)
        {
            if (!IsInPivot())
            {
                Animator.SetFloat("Turn", charAngle);
            }
        }
        if (speed < LocomotionThreshold && Mathf.Abs(leftX) < 0.05)
        {
            animator.SetFloat("Forward", 0f);
            animator.SetFloat("Turn", 0f);
        }
    }
    private void RootMotionMovement()
    {
        _stateInfo = _animator.GetCurrentAnimatorStateInfo(0);
        _transInfo = _animator.GetAnimatorTransitionInfo(0);

        StickToWorldspace();

        float speed = _input.sqrMagnitude;

        _animator.SetFloat(speedFloat, speed, speedDamp, Time.deltaTime);

        if(speed < speedThreshold)
        {
            _direction = 0;
        }

        _animator.SetFloat(directionFloat, _direction, directionDamp, Time.deltaTime);

        if(!IsInPivot())
        {
            if(speed > speedThreshold)
            {
                _animator.SetFloat(angleFloat, _angle);
            }
            else
            {
                _animator.SetFloat(directionFloat, 0);
                _animator.SetFloat(angleFloat, 0);
            }
        }
    }
Пример #23
0
 void Start()
 {
     controller = GetComponent<CharacterController>();
     cam = Camera.main;
     anim = GetComponentInChildren<Animator>();
     armsTransitionInfo = anim.GetAnimatorTransitionInfo(1);
     EquipGun(0);
 }
Пример #24
0
 private extern void GetAnimatorTransitionInfo(int layerIndex, out AnimatorTransitionInfo info);
Пример #25
0
        /// <summary>
        /// Convert the animator hash ID to a readable string
        /// </summary>
        /// <param name="rStateID"></param>
        /// <param name="rTransitionID"></param>
        /// <returns></returns>
        private string AnimatorHashToString(AnimatorStateInfo rState, AnimatorTransitionInfo rTransition)
        {
            string lStateName = "0";
            string lTransitionName = "0";

            #if UNITY_4_0 || UNITY_4_0_1 ||UNITY_4_1|| UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6
            lStateName = (AnimatorStateNames.ContainsKey(rState.nameHash) ? AnimatorStateNames[rState.nameHash] : rState.nameHash.ToString());
            lTransitionName = (AnimatorStateNames.ContainsKey(rTransition.nameHash) ? AnimatorStateNames[rTransition.nameHash] : rTransition.nameHash.ToString());
            #else
            int lStateID = rState.fullPathHash;

            if (lStateID != 0)
            {
                lStateName = (AnimatorStateNames.ContainsKey(lStateID) ? AnimatorStateNames[lStateID] : lStateID.ToString());
            }

            int lTransitionID = rTransition.fullPathHash;
            if (lTransitionID != 0)
            {
                if (AnimatorStateNames.ContainsKey(lTransitionID))
                {
                    lTransitionName = AnimatorStateNames[lTransitionID];
                }
                else
                {
                    lTransitionID = rTransition.nameHash;
                    if (AnimatorStateNames.ContainsKey(lTransitionID))
                    {
                        lTransitionName = AnimatorStateNames[lTransitionID];
                    }
                }
            }
            #endif

            return String.Format("state:{0} trans:{1}", lStateName, lTransitionName);
        }