IsTag() public method

Does tag match the tag of the active state in the statemachine.

public IsTag ( string tag ) : bool
tag string
return bool
Ejemplo n.º 1
0
    void FixedUpdate()
    {
        float h = Input.GetAxis("Horizontal");
        //float v = Input.GetAxis("Vertical");
        anim.SetFloat("Speed", h);							// set our animator's float parameter 'Speed' equal to the vertical input axis
        //anim.SetFloat("Direction", v);						// set our animator's float parameter 'Direction' equal to the horizontal input axis

        currentBaseState = anim.GetCurrentAnimatorStateInfo(0);

        if(currentBaseState.IsTag("Run"))
        {
            if(Input.GetButtonDown("Jump"))
            {
                anim.SetInteger("JumpType", UnityEngine.Random.Range(0,2));
                anim.SetBool("Jump", true);
            }

            if(Input.GetKeyDown (KeyCode.W))
            {
                //anim.SetInteger("JumpType", UnityEngine.Random.Range(0,3));
                anim.SetBool("JumpUp", true);
            }
        }

        else if(currentBaseState.IsTag("Jump") || currentBaseState.IsTag("Jumpup"))
        {
            if(!anim.IsInTransition(0))
            {
            anim.SetBool("Jump", false);
            anim.SetBool("JumpUp", false);
            }

        }
    }
Ejemplo n.º 2
0
    // OnStateUpdate is called before OnStateUpdate is called on any state inside this state machine
    //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}
    // OnStateExit is called before OnStateExit is called on any state inside this state machine
    public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if(stateInfo.IsTag("LAttackState"))
        {

        }
    }
Ejemplo n.º 3
0
 // OnStateEnter is called before OnStateEnter is called on any state inside this state machine
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (stateInfo.IsTag("DestroyState"))
     {
         animator.GetComponentInParent<BaseEnemy>().DestroyEnemy(stateInfo.length);
     }
 }
 public override void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex)
 {
     var fighter = animator.gameObject.GetComponent<Fighter> ();
     foreach (var tag in activeTags) {
         if (animatorStateInfo.IsTag(tag)) {
             fighter.SoftStun = false;
             return;
         }
     }
     foreach (var tag in inactiveTags) {
         if (animatorStateInfo.IsTag (tag)) {
             fighter.SoftStun = true;
             return;
         }
     }
 }
Ejemplo n.º 5
0
 //OnStateEnter is called before OnStateEnter is called on any state inside this state machine
 //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
 //
 //}
 // OnStateUpdate is called before OnStateUpdate is called on any state inside this state machine
 //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
 //
 //}
 // OnStateExit is called before OnStateExit is called on any state inside this state machine
 public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (stateInfo.IsTag ("Transition")) {
         animator.SetBool ("Done", true);
     } else {
         animator.SetBool ("Done", false);
     }
 }
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
 //
 //}
 // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
 public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     animator.GetComponent<Character>().Attack = false;
     if (stateInfo.IsTag("attack")) {
         animator.GetComponent<Character>().MeleeAttack();
     }
     animator.ResetTrigger("attack");
     animator.ResetTrigger("throw");
 }
Ejemplo n.º 7
0
 protected virtual void Update()
 {
     current_stateInfo = mAnimator.GetCurrentAnimatorStateInfo(0); 
     //受伤
     if (current_stateInfo.IsTag("Damage"))
     {
         mAnimator.SetBool("Damage", false);
         SetAttackMove(AttackMove_Speed);
     }
 }
Ejemplo n.º 8
0
    void Update()
    {
        state = animator.GetCurrentAnimatorStateInfo(0);

        if (state.IsTag("Jump"))
        {
            if (animator.GetFloat("Height") > 0.5f && animator.GetBool("AttackKeyDown"))
            {
                animator.SetInteger("ActionCMD", 1);
            }
        }
    }
 // OnStateEnter is called before OnStateEnter is called on any state inside this state machine
 //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
 //
 //}
 // OnStateUpdate is called before OnStateUpdate is called on any state inside this state machine
 //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
 //
 //}
 // OnStateExit is called before OnStateExit is called on any state inside this state machine
 public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (stateInfo.IsTag("Attack"))
     {
         animator.SendMessageUpwards("AttackAnimationComplete", SendMessageOptions.DontRequireReceiver);
     }
     else if (stateInfo.IsTag("LongAttack"))
     {
         animator.SendMessageUpwards("LongAttackAnimationComplete", SendMessageOptions.DontRequireReceiver);
     }
     else if (stateInfo.IsTag("ConeAttack"))
     {
         animator.SendMessageUpwards("ConeAttackAnimationComplete", SendMessageOptions.DontRequireReceiver);
     }
     else if (stateInfo.IsTag("Bite"))
     {
         animator.SendMessageUpwards("BiteAnimationComplete", SendMessageOptions.DontRequireReceiver);
     }
     else if (stateInfo.IsTag("SwingOpen"))
     {
         Debug.Log("upwards " + animator);
         animator.SendMessageUpwards("SwingOpenAnimationComplete", SendMessageOptions.DontRequireReceiver);
     }
     else if (stateInfo.IsTag("SwingClose"))
     {
         Debug.Log("upwards " + animator);
         animator.SendMessageUpwards("SwingCloseAnimationComplete", SendMessageOptions.DontRequireReceiver);
     }
 }
Ejemplo n.º 10
0
 public new void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (stateInfo.IsTag("held"))
     {
         if (!this.playerEvents)
         {
             this.playerEvents = animator.transform.GetComponent<animEventsManager>();
         }
         if (this.playerEvents)
         {
             this.playerEvents.enableSpine();
         }
     }
 }
Ejemplo n.º 11
0
 static public int IsTag(IntPtr l)
 {
     try{
         UnityEngine.AnimatorStateInfo self = (UnityEngine.AnimatorStateInfo)checkSelf(l);
         System.String a1;
         checkType(l, 2, out a1);
         System.Boolean ret = self.IsTag(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Ejemplo n.º 12
0
	void Update ()
	{	
		foreach (AnimEvent animEvent in Events) {
			stateInfo = animator.GetCurrentAnimatorStateInfo (animEvent.layer);

			if (stateInfo.IsTag (animEvent.animationTag)) {
				if (stateInfo.normalizedTime >= animEvent.fireTime) {
					if (animEvent.eventType == AE_EventType.Instantiate)
						CreateInstance (animEvent);
					else if (animEvent.eventType == AE_EventType.FireMethod)
						FireMethod (animEvent);
				}
			} else animEvent.Reset ();
		}
	}
Ejemplo n.º 13
0
    // Update is called once per frame
    void Update()
    {
        _info = _anim.GetCurrentAnimatorStateInfo(0); //what animation is playing?

        //////////////////////MOVEMENT//////////////////////

        float _x, _y, _r; // local variables get deleted at the function's end
        _x = Input.GetAxis("Horizontal"); // the horizontal axis (1 or -1)
        _y = Input.GetAxis("Vertical"); // the vertical axis
        _r = Input.GetAxis("Rotate"); // the rotation axis

        Vector3 moveDir = new Vector3 (_x, 0, _y)*(moveSpeed*Time.deltaTime); // the inputs multiplying the movement speed (1 * 30 or -1 * 30)
        moveDir.y = gravity*Time.deltaTime; //apply gravity
        moveDir = transform.TransformDirection (moveDir); //MY direction not the world direction
        _char.Move (moveDir); //apply movement

        float _curRot = transform.eulerAngles.y; //my y rotation
        float _wantRot = _curRot += ((rotSpeed * Time.deltaTime) * _r); //apply rotation to new var

        transform.rotation = Quaternion.Euler(0f,_wantRot, 0f); //rotation

        _anim.SetFloat ("Y", _y);//send the inputs to animator
        _anim.SetFloat ("X", _x);

        //////////////////////COMBAT//////////////////////

        if (!_info.IsTag ("InAttack")) { //am i not attacking?
            if(AttFlag != 0) //I'm not, but I have a flag remaining?
            {
                AttFlag=0; //remove the flag ready for the next attack
                _anim.SetInteger("AttackIdx", AttFlag);
            }
        }

        if (Input.GetButtonDown ("Fire1")) { //player has asked to attack
            _anim.SetBool("Down1", true);
            if(AttFlag == 0) //am I ready to attack?
            {
                AttFlag=1; //send the flag to the animator
                _anim.SetInteger("AttackIdx", AttFlag);
            }
        }

        if (Input.GetButtonUp ("Fire1")) { //player has released the mouse btn
            _anim.SetBool("Down1", false);
        }
    }
Ejemplo n.º 14
0
 static int IsTag(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.AnimatorStateInfo obj = (UnityEngine.AnimatorStateInfo)ToLua.CheckObject(L, 1, typeof(UnityEngine.AnimatorStateInfo));
         string arg0 = ToLua.CheckString(L, 2);
         bool   o    = obj.IsTag(arg0);
         LuaDLL.lua_pushboolean(L, o);
         ToLua.SetBack(L, 1, obj);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 15
0
    void Update()
    {
        // Save the state in playing now.
        // 再生中のステートの情報を入れる。.
        // 재생중인 스테이트를 저장.
        stateInfo = chrAnimator.GetCurrentAnimatorStateInfo(0);

        // Bool parameter reset to false.
        if(!stateInfo.IsTag("InIdle")){
            chrAnimator.SetBool("LookAround", false);
            chrAnimator.SetBool("Attack", false);
            chrAnimator.SetBool("Jiggle", false);
            chrAnimator.SetBool("Dead", false);
        }

        // reaction of key input.
        // キー入力に対するリアクションを起こす。.
        // 키입력에 대한 반응.
        // for Attack
        if(Input.GetButtonDown("Fire1"))	chrAnimator.SetBool("Attack", true);
        // LookAround
        if(Input.GetKeyDown("z"))	chrAnimator.SetBool("LookAround", true);
        // Jiggle
        if(Input.GetKeyDown("x"))	chrAnimator.SetBool("Jiggle", true);
        // Happy!!
        if(Input.GetKeyDown("c"))
        {
            chrAnimator.SetBool("Happy", !chrAnimator.GetBool("Happy"));
            if(chrAnimator.GetBool("Happy") == true)	chrAnimator.SetBool("Sad", false);
        }
        // Sad
        if(Input.GetKeyDown("v"))
        {
            chrAnimator.SetBool("Sad", !chrAnimator.GetBool("Sad"));
            if(chrAnimator.GetBool("Sad") == true)	chrAnimator.SetBool("Happy", false);
        }
        // for Dead
        if(Input.GetKeyDown("b"))	chrAnimator.SetBool("Dead", true );

        // movement.
        // Input of character moves
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");

        Vector3 axisInput = new Vector3(h, 0, v);
        float axisInputMag = axisInput.magnitude;
        if(axisInputMag > 1){
            axisInputMag = 1;
            axisInput.Normalize();
        }
        runParam = 0f;
        if(axisInputMag != 0){
            // for run
            if(Input.GetButton("Fire2")){
                runParam = 1.0f;
            }
            // character rotate
            axisInput = Camera.main.transform.rotation * axisInput;
            axisInput.y = 0;
            transform.forward = axisInput;
        }
        chrAnimator.SetFloat("Speed", (axisInputMag + runParam));

        // Jump
        // while in jump, I am using Character Controller instead Root Motion, to move the Character.
        // ジャンプ時は、キャラクターコントローラを使ってキャラクターを移動させます。.
        // 점프시에는 캐릭터 컨트롤러를 이용하여 캐릭터를 이동시키고 있습니다.
        // in ground.
        if(chrController.isGrounded){
            // jump parameter set to false.
            chrAnimator.SetInteger("Jump", 0);
            // moveDirection set 0, to prevent to move by Character controller.
            // moveDirectionはゼロにして、キャラクターコントローラがキャラクターを動かさないように。.
            // moveDirection은 0으로 돌려서, 캐릭터 컨트롤러가 캐릭터를 움직이지 않도록한다.
            moveDirection = new Vector3(0, jumpInput, 0);

            // press Jump button. make jump
            // if Animator parameter "Jump" is true,
            // animator will play state of "na_Jump_00" and "na_Jump_00_up"
            // then animation event of "na_Jump_00_up" will call SetJump()
            // Jumpパラメータからアニメーションが遷移し、.
            // "na_Jump_00_up"のときにイベントでSetJump()ファンクションを呼ぶ。.
            // Jump파라메터를 통해 스테이트가 점프애니메이션을 재생하고,
            // "na_Jump_00_up"스테이트를 재생할때 SetJump()를 부른다.
            if(Input.GetButtonDown("Jump"))
                SetJump ();
        }
        // While in Air
        else if(!chrController.isGrounded){
            // press Jump button. can jump once more.
            if(Input.GetButtonDown("Jump"))
                SetJump ();

            // It is moved with Character Controller while in the air,
            // moveDirection is use Axis Input.
            // 空中にいるときはmoveDirectionを使って移動するので、.
            // 方向キーの入力を渡しておく。.
            // 공중에 있는 동안은 캐릭터 컨트롤러를 사용하여 이동하기때문에.
            // 방향키의 입력을 moveDirection에게 전달해준다.
            moveDirection = new Vector3(transform.forward.x * axisInputMag * 4, moveDirection.y, transform.forward.z * axisInputMag * 4);
            moveDirection.y -= gravity * Time.deltaTime;
        }

        // character is move by moveDirection.
        chrController.Move(moveDirection * Time.deltaTime);
    }
    //=================================================================================================================o
    //===============================================Combat============================================================o
    //=================================================================================================================o
    void _Combat()
    {
        // Combat Stance / Out
        if (doCombat && canDrawHolster)
        {
            // Coroutine draw motion finished -> switch
            if (weaponState == WeaponState.None)
            {
                return;
            }
            /*else if(weaponState == WeaponState.Unarmed)
            {
                return;
            }*/
            else if (weaponState == WeaponState.Sword)
            {
                StartCoroutine(DrawHolster(0.3f, weapons.sword_Holster.GetComponent<Renderer>(), weapons.sword_Hand.GetComponent<Renderer>()));
                animator.SetBool("Sword", false);
                baseState = BaseState.Base;
            }
            else if (weaponState == WeaponState.Bow)
            {
                StartCoroutine(DrawHolster(0.6f, weapons.bow_Holster.GetComponent<Renderer>(), weapons.bow_Hand.GetComponent<Renderer>()));
                animator.SetBool("Bow", false);
                baseState = BaseState.Base;
            }
            else if (weaponState == WeaponState.Rifle)
            {
                StartCoroutine(DrawHolster(0.9f, weapons.rifle_Holster.GetComponent<Renderer>(), weapons.rifle_Hand.GetComponent<Renderer>()));
                animator.SetBool("Rifle", false);
                baseState = BaseState.Base;
            }
            else if (weaponState == WeaponState.Pistol)
            {
                StartCoroutine(DrawHolster(0.6f, weapons.pistol_Holster.GetComponent<Renderer>(), weapons.pistol_Hand.GetComponent<Renderer>()));
                animator.SetBool("Pistol", false);
                baseState = BaseState.Base;
            }
        }

        // Double Tap - Evade takes tapSpeed & coolDown in seconds
        if (canEvade)
        {
            if (!isDoubleTap) StartCoroutine(DoubleTap(doubleTapSpeed, 1));
        }

        // Current state info for layer Base
        animatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);

        if (grounded)
        {
            if (doJumpDown /*&& canJump */&& !animatorStateInfo.IsTag("Jump") && !animatorStateInfo.IsTag("Land"))
            {
                animator.SetBool("Jump", true);
                //add extra force to main jump
                rigidbody.velocity = hero.up * jumpHeight;
                // Start cooldown until we can jump again
                //StartCoroutine (JumpCoolDown(0.5f));
            }

            // Don't slide
            if (!rigidbody.isKinematic)
                rigidbody.velocity = new Vector3(0, rigidbody.velocity.y, 0);

            // Extra rotation
            if (canRotate)
            {
                if (!doLShift)
                    hero.Rotate(0, mX * rotSpeed / 2 * Time.deltaTime, 0);
            }

            // Punch, Kick
            if (doAtk1Down && !animatorStateInfo.IsTag("Attack1"))
            {
                animator.SetBool("Attack1", true);
                animator.SetBool("Walking", false); // RESET
                animator.SetBool("Sprinting", false); // RESET
                animator.SetBool("Sneaking", false); // RESET
            }
            else if (doAtk2Down && !animatorStateInfo.IsTag("Attack2"))
            {

                animator.SetBool("Attack2", true);
                animator.SetBool("Walking", false); // RESET
                animator.SetBool("Sprinting", false); // RESET
                animator.SetBool("Sneaking", false); // RESET
            }

            // Walk
            if (doWalk)
            {
                if (!animatorStateInfo.IsTag("WalkTree"))//IsName("WalkTree.TreeW"))
                {
                    animator.SetBool("Walking", true);
                    animator.SetBool("Sneaking", false); // RESET
                    animator.SetBool("Sprinting", false); // RESET
                }
                else
                {
                    animator.SetBool("Walking", false); // RESET
                }
            }

            // Sprint
            else if (doSprint)
            {
                if (!animatorStateInfo.IsTag("SprintTree"))
                {
                    animator.SetBool("Sprinting", true);
                    animator.SetBool("Walking", false); // RESET
                    animator.SetBool("Sneaking", false); // RESET
                }
                else
                {
                    animator.SetBool("Sprinting", false); // RESET
                }
            }

            // Sneak
            else if (doSneak)
            {
                if (!animatorStateInfo.IsTag("SneakTree"))
                {
                    animator.SetBool("Sneaking", true);
                    animator.SetBool("Walking", false); // RESET
                    animator.SetBool("Sprinting", false); // RESET
                }
                else
                {
                    animator.SetBool("Sneaking", false); // RESET
                }
            }

            WallGround();

            // -----------AirTime--------- //
            if (!animator.GetBool("CanLand")) // Very short air time
            {
                groundTime += Time.deltaTime;
                if (groundTime >= 0.4f)
                {
                    animator.SetBool("CanLand", true);
                }
            }
            else
                groundTime = 0;

            // -----------AirTime--------- //

        }
        else // In Air
        {
            // -----------AirTime--------- //
            if (groundTime <= 0.3f)
            {
                groundTime += Time.deltaTime;
                if (groundTime >= 0.2f)
                {
                    animator.SetBool("CanLand", true);
                }
                else
                    animator.SetBool("CanLand", false);
            }
            // -----------AirTime--------- //

            if (canRotate)
                hero.Rotate(0, mX * rotSpeed / 2 * Time.deltaTime, 0);

            WallRun();
        }

        // Resetting--------------------------------------------------
        if (!animator.IsInTransition(0))
        {
            if (animatorStateInfo.IsTag("Jump") || animatorStateInfo.IsTag("LedgeJump"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Jump", false); // RESET
            }

            if (animatorStateInfo.IsTag("Shoot") && !doAtk1)
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack1", false); // RESET
            }

            if ((animatorStateInfo.IsName("SwordCombo_L.slash1")
                || animatorStateInfo.IsName("SwordCombo_L.slash2")) && animatorStateInfo.normalizedTime > 0.4f && !doAtk1)
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack1", false); // RESET
            }
            else if (animatorStateInfo.IsName("SwordCombo_L.slash2.5"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack1", false); // RESET
            }

            if ((animatorStateInfo.IsName("SwordCombo_R.slash3")
                || animatorStateInfo.IsName("SwordCombo_R.slash4")) && animatorStateInfo.normalizedTime > 0.4f && !doAtk2)
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack2", false); // RESET
            }
            else if (animatorStateInfo.IsName("SwordCombo_R.slash5"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack2", false); // RESET
            }

            if (animatorStateInfo.IsTag("Evade"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Evade_F", false); // RESET
                animator.SetBool("Evade_B", false); // RESET
                animator.SetBool("Evade_L", false); // RESET
                animator.SetBool("Evade_R", false); // RESET
            }

            if (animatorStateInfo.IsTag("WallRun") && grounded) // No instant reset
            {
                animator.SetBool("WallRunL", false); // RESET
                animator.SetBool("WallRunR", false); // RESET
                animator.SetBool("WallRunUp", false); // RESET
            }
        }
    }
    //=================================================================================================================o
    //==================================================Climb==========================================================o
    //=================================================================================================================o
    void _Climb()
    {
        // Current state info for layer Base
        animatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);

        // Switch climb states
        switch (climbState)
        {
            case ClimbState.None:
                if (!reset)
                {
                    ExitClimb();
                }
                CheckClimb();
                break;

            case ClimbState.Climb:
                ClimbTo();
                reset = false;
                break;

            case ClimbState.Top:
                isTop = false;
                PullUp();
                reset = false;
                break;

            case ClimbState.Wall:
                WallClimb();
                reset = false;
                break;

            case ClimbState.Area:
                ClimbTo();
                reset = false;
                break;

            case ClimbState.Edge:
                EdgeClimb();
                reset = false;
                break;

            case ClimbState.Corner:
                CornerLerp(climbSpeed);
                reset = false;
                break;
        }

        if (doJumpDown)
        {
            if (v != 0)
                jumpOffNext = true;
            else
                jumpOffNext = false;

            climbState = ClimbState.None;
        }

        if (!animator.IsInTransition(0))
        {
            // Resetting--------------------------------------------------
            if (animatorStateInfo.IsTag("Jump"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Jump", false); // RESET
            }
            if (animatorStateInfo.IsTag("Oh"))
            {
                animator.SetBool("Overhang", false); // RESET
                isOverhang = false;
            }
        }
    }
    //=================================================================================================================o
    //================================================Base=============================================================o
    //=================================================================================================================o
    void _Base()
    {
        // Next Weapon
        if (doNextWeapon && canNextWeapon)
        {
            StartCoroutine(NextWeapon());
        }

        // Combat Stance / Out
        else if (doCombat && canDrawHolster)
        {
            // Coroutine draw motion finished -> switch
            if (weaponState == WeaponState.None)
            {
                return;
            }
            /*else if(weaponState == WeaponState.Unarmed)
            {
                return;
            }*/
            else if (weaponState == WeaponState.Sword)
            {
                StartCoroutine(DrawHolster(0.3f, weapons.sword_Hand.GetComponent<Renderer>(), weapons.sword_Holster.GetComponent<Renderer>()));
                animator.SetBool("Sword", true);
                baseState = BaseState.Combat;
            }
            else if (weaponState == WeaponState.Bow)
            {
                StartCoroutine(DrawHolster(0.3f, weapons.bow_Hand.GetComponent<Renderer>(), weapons.bow_Holster.GetComponent<Renderer>()));
                animator.SetBool("Bow", true);
                baseState = BaseState.Combat;
            }
            else if (weaponState == WeaponState.Rifle)
            {
                StartCoroutine(DrawHolster(0.3f, weapons.rifle_Hand.GetComponent<Renderer>(), weapons.rifle_Holster.GetComponent<Renderer>()));
                animator.SetBool("Rifle", true);
                baseState = BaseState.Combat;
            }
            else if (weaponState == WeaponState.Pistol)
            {
                StartCoroutine(DrawHolster(0.2f, weapons.pistol_Hand.GetComponent<Renderer>(), weapons.pistol_Holster.GetComponent<Renderer>()));
                animator.SetBool("Pistol", true);
                baseState = BaseState.Combat;
            }
        }

        // Dance
        else if (doDance1)
        {
            animator.SetBool("Dance", true);
            animator.SetInteger("RandomM", 1);
        }
        else if (doDance2)
        {
            animator.SetBool("Dance", true);
            animator.SetInteger("RandomM", 2);
        }
        else if (doDance3)
        {
            animator.SetBool("Dance", true);
            animator.SetInteger("RandomM", 3);
        }

        // Pull Push
        else if (doPullLever)
        {
            animator.SetBool("Pull", true);
        }
        else if (doPushButton)
        {
            animator.SetBool("Push", true);
        }

        // Throw
        else if (doThrow)
        {
            animator.SetBool("Throw", true);
        }

        // Fly
        else if (doFly)
        {
            if (!canFly)
                return;
            rigidbody.useGravity = false;
            animator.SetBool("Jump", true);
            rigidbody.velocity = Vector3.up * 5; // Up in fast

            // Fly State
            if (animCtrl.fly)
            {
                animator.runtimeAnimatorController = animCtrl.fly;
                StartCoroutine(JustHolster());
                baseState = BaseState.Fly;
            }
        }

        // Climb
        else if (doClimb)
        {
            if (!canClimb)
                return;
            CheckClimb();

            if (climbState != ClimbState.None)
            {
                // Climb State
                if (animCtrl.climb)
                {
                    animator.runtimeAnimatorController = animCtrl.climb;
                    StartCoroutine(JustHolster());
                    baseState = BaseState.Climb; // Out
                }
            }
        }

        // Double Tap - Evade takes tapSpeed & coolDown in seconds
        if (canEvade)
        {
            if (!isDoubleTap) StartCoroutine(DoubleTap(doubleTapSpeed, 1));
        }

        // Start Radoll modus
        if (canRagdoll)
        {
            // When falling for time
            if (animatorStateInfo.IsTag("Fall") && animator.enabled)
            {
                float nTime = animatorStateInfo.normalizedTime;

                if (nTime > startRagTime && !animator.IsInTransition(0))
                {
                    StartRagdoll();
                }
            }
            else if (startRagdoll) // Manual switch
            {
                StartRagdoll();
            }
        }

        // Current state info for layer Base
        animatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);

        if (grounded)
        {
            if (doJumpDown && canJump && !animatorStateInfo.IsTag("Jump") && !animatorStateInfo.IsTag("Land"))
            {
                animator.SetBool("Jump", true);
                //add extra force to main jump
                if (!animatorStateInfo.IsTag("LedgeJump"))
                    rigidbody.velocity = hero.up * jumpHeight;
                // Start cooldown until we can jump again
                //StartCoroutine (JumpCoolDown(0.5f));
            }

            // Don't slide
            if (!rigidbody.isKinematic)
                rigidbody.velocity = new Vector3(0, rigidbody.velocity.y, 0);

            // Extra rotation
            if (canRotate)
            {
                if (!doLShift)
                    hero.Rotate(0, mX * rotSpeed / 2 * Time.deltaTime, 0);
            }

            // Punch, Kick if weapon state is not = None
            if (weaponState != WeaponState.None)
            {
                if (doAtk1Down && !animatorStateInfo.IsName("PunchCombo.Punch1"))
                {
                    animator.SetBool("Attack1", true);
                    animator.SetBool("Walking", false); // RESET
                    animator.SetBool("Sprinting", false); // RESET
                    animator.SetBool("Sneaking", false); // RESET
                }
                else if (doAtk2Down && !animatorStateInfo.IsName("KickCombo.Kick1"))
                {
                    animator.SetBool("Attack2", true);
                    animator.SetBool("Walking", false); // RESET
                    animator.SetBool("Sprinting", false); // RESET
                    animator.SetBool("Sneaking", false); // RESET
                }
            }

            // Walk
            if (doWalk)
            {
                if (!animatorStateInfo.IsName("WalkTree.TreeW"))
                {
                    animator.SetBool("Walking", true);
                    animator.SetBool("Sneaking", false); // RESET
                    animator.SetBool("Sprinting", false); // RESET
                }
                else
                {
                    animator.SetBool("Walking", false); // RESET
                }
            }

            // Sprint
            else if (doSprint)
            {
                if (!animatorStateInfo.IsName("SprintTree.TreeS"))
                {
                    animator.SetBool("Sprinting", true);
                    animator.SetBool("Walking", false); // RESET
                    animator.SetBool("Sneaking", false); // RESET
                }
                else
                {
                    animator.SetBool("Sprinting", false); // RESET
                }
            }

            // Sneak
            else if (doSneak)
            {
                if (!animatorStateInfo.IsName("SneakTree.TreeSn"))
                {
                    animator.SetBool("Sneaking", true);
                    animator.SetBool("Walking", false); // RESET
                    animator.SetBool("Sprinting", false); // RESET
                }
                else
                {
                    animator.SetBool("Sneaking", false); // RESET
                }
            }

            WallGround();

            // Balanceing trigger
            if (groundHit.transform && groundHit.transform.gameObject.layer == 9)
            {
                // Layer 9 should be Climb
                animator.SetBool("Balancing", true);
            }
            else
                animator.SetBool("Balancing", false); // RESET

            // -----------AirTime--------- //
            if (!animator.GetBool("CanLand")) // Very short air time
            {
                groundTime += Time.deltaTime;
                if (groundTime >= 0.4f)
                {
                    animator.SetBool("CanLand", true);
                }
            }
            else
                groundTime = 0;

            // -----------AirTime--------- //

        }
        else // In Air
        {
            // -----------AirTime--------- //
            if (groundTime <= 0.3f)
            {
                groundTime += Time.deltaTime;
                if (groundTime >= 0.2f)
                {
                    animator.SetBool("CanLand", true);
                }
                else
                    animator.SetBool("CanLand", false);
            }
            // -----------AirTime--------- //

            if (canRotate)
                hero.Rotate(0, mX * rotSpeed / 2 * Time.deltaTime, 0);

            WallRun();

            // After jumping off from climb state controller
            if (jumpOffNext)
            {
                animator.SetBool("Jump", true);
                jumpOffNext = false;
            }
        }

        // Resetting--------------------------------------------------
        if (!animator.IsInTransition(0))
        {
            if (animatorStateInfo.IsTag("Jump") || animatorStateInfo.IsTag("LedgeJump"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Jump", false); // RESET LedgeJump
            }

            else if (animatorStateInfo.IsTag("Dance"))
            {
                animator.SetBool("Dance", false);
            }

            else if (animatorStateInfo.IsTag("Action"))
            {
                animator.SetBool("Pull", false);
                animator.SetBool("Push", false);
                animator.SetBool("Throw", false);
            }

            else if (animatorStateInfo.IsTag("StandUp"))
            {
                animator.SetInteger("RandomM", 3); // 0 or 1 are triggers
                animator.SetBool("StandUp", false); // RESET
            }

            if (animatorStateInfo.IsName("PunchCombo.Punch1") && animatorStateInfo.normalizedTime > 0.7f && !doAtk1)
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack1", false); // RESET
            }
            else if (animatorStateInfo.IsName("PunchCombo.Punch2"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack1", false); // RESET
            }

            if (animatorStateInfo.IsName("KickCombo.Kick1") && animatorStateInfo.normalizedTime > 0.7f && !doAtk2)
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack2", false); // RESET
            }
            else if (animatorStateInfo.IsName("KickCombo.Kick2"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack2", false); // RESET
            }

            if (animatorStateInfo.IsTag("Evade"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Evade_F", false); // RESET
                animator.SetBool("Evade_B", false); // RESET
                animator.SetBool("Evade_L", false); // RESET
                animator.SetBool("Evade_R", false); // RESET
            }

            if (animatorStateInfo.IsTag("WallRun") && grounded) // No instant reset
            {
                animator.SetBool("WallRunL", false); // RESET
                animator.SetBool("WallRunR", false); // RESET
                animator.SetBool("WallRunUp", false); // RESET
            }
        }
    }
Ejemplo n.º 19
0
    static bool AnimatorStateInfo_IsTag__String(JSVCall vc, int argc)
    {
        int len = argc;

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

        return(true);
    }
Ejemplo n.º 20
0
    void FixedUpdate()
    {
        asi = anim.GetCurrentAnimatorStateInfo(0);

        //		if (Input.GetButton ("Fire1")) {
        //			Debug.Log("yaaaaar");
        //		}

        if (Input.GetButton ("Fire1") && Time.time > nextAttack && !anim.GetBool(hash.stoppedAttackBool)) {
            nextAttack = Time.time + attackRate;
            Attack ();
        }
        //if Scavenger is not in idle position (or moving) AND not engaged in battle, sheath Scavenger's sword.
        if (!engagedIntoBattle && !asi.IsTag (Tags.idle)) {
            SheathSword();
        }

        if (asi.IsTag (Tags.idle)) {
            returnToIdle();
        }
    }
Ejemplo n.º 21
0
    // Update is called once per frame
    void Update()
    {
        distanceToPlayer = Vector2.Distance(this.transform.position, playerRef.transform.position);

        aiAnimatorState =  aiAnimator.GetCurrentAnimatorStateInfo (0);
        //if((distanceToPlayer>distanceToAttack)  )
        switch(aiBehaviour)
        {
        case AIBehaviour.ATTACK:
            if(  (!GameGlobalVariablesManager.isBombActivated)&& !aiAnimatorState.IsTag (("DeathTag")))// && !GameGlobalVariablesManager.isKnifeThrow )
            MoveTowardsPlayer ();
            break;

        case AIBehaviour.RANGED:
            if(  (!GameGlobalVariablesManager.isBombActivated)&& !aiAnimatorState.IsTag (("DeathTag") ))//&& !GameGlobalVariablesManager.isKnifeThrow )
            MoveTowardsPlayerToThrow ();
            break;
        }

        if (GameGlobalVariablesManager.isBombActivated)
        {
            canStun = true;
            bTimer -= Time.deltaTime;
            Stun ();

        }
        /*
        if(Input.GetMouseButtonDown(1))
        {
            React();
        }*/
    }