public override TaskStatus OnUpdate()
    {
        animatorInfo = anim.GetCurrentAnimatorStateInfo(0);

        if (animatorInfo.normalizedTime > 0.8f)
        {
            if (animatorInfo.IsTag("ComboAttackOne"))
            {
                anim.SetInteger("Combo", 0);
            }
        }

        if (cAttcak.Value == true)
        {
            anim.SetBool("Walk", false);
            if (Attack == false && animatorInfo.IsTag("Special") == false)
            {
                Attack = true;
                StartCoroutine(phaseTwoAttack());
            }

            return(TaskStatus.Success);
        }
        return(TaskStatus.Failure);
    }
示例#2
0
    public bool IsEnabled()
    {
        if (wepCtrl == null)
        {
            return(false);
        }

        if (!wepCtrl.IsEnableFire())
        {
            return(false);
        }

        if (charaAnimator != null && !playerStatus.IsNpc())
        {
            AnimatorStateInfo stateInfo = charaAnimator.GetCurrentAnimatorStateInfo(0);
            if (!stateInfo.IsTag(TAG_ANIMATION_WAIT) && !stateInfo.IsTag(TAG_ANIMATION_RUN))
            {
                return(false);
            }
        }

        if (!isActiveScene || !GameController.Instance.isGameStart)
        {
            return(true);
        }
        if (!IsLeftUsableCount())
        {
            return(false);
        }

        return(true);
    }
示例#3
0
    void Update()
    {
        // returns the current state of the Mecanim animator,
        animState = anim.GetCurrentAnimatorStateInfo(0);

        // "StartWalk" occurs during the first walk loop in a chain of walk sequences
        if (animState.IsTag("StartWalk"))
        {
            // ramp up the movement speed to look more natural in animation when moose starts walking
            speed = Mathf.Lerp(0.0f, MAX_SPEED, (Time.time - startTime) * 1.2f);
            transform.Translate(Vector3.forward * speed, Space.Self);
        }

        // "Walk" moves the moose at top speed
        if (animState.IsTag("Walk"))
        {
            transform.Translate(Vector3.forward * MAX_SPEED, Space.Self);
        }

        // "Look" triggers the moose to look to its left at the car
        if (animState.IsTag("Look"))
        {
            startTime = Time.time;
        }
    }
    private void Atirar()
    {
        AnimatorStateInfo temp_AnimatorStateInfo = meuAnimator.GetCurrentAnimatorStateInfo(3);

        if (minhaArma.PossoAtirar(true) && !recarregando && temp_AnimatorStateInfo.IsTag("Vazio"))
        {
            contador -= Time.deltaTime;

            if (contador <= 0)
            {
                minhaArma.Atirar(municaoprefab);
                contador = Random.Range(tempoTiroRange.x, tempoTiroRange.y);
                meuAnimator.SetTrigger("atirar");
            }
        }

        if (temp_AnimatorStateInfo.IsTag("Vazio") && !recarregando &&
            minhaArma.municoesNoPente <= 0 && minhaArma.TempoDeTiroPassou(true))
        {
            minhaArma.municoesQuardada += minhaArma.maxMunicao;
            meuAnimator.SetTrigger("recarregar");
            recarregando = true;
            StartCoroutine("Recarregar");
        }
    }
        void OnAnimatorIK()
        {
            if (headWeight == 0 || target == null)
            {
                return;
            }

            if (currentState == AIStates.Chase && onFovAngle() && !actions && target != null && baseLayerInfo.IsTag("HeadTrack"))
            {
                lookAtWeight += headTrackMultiplier * Time.deltaTime;
            }
            else
            {
                lookAtWeight -= headTrackMultiplier * Time.deltaTime;
            }

            lookAtWeight = Mathf.Clamp(lookAtWeight, 0f, 1f);
            if (OnStrafeArea)
            {
                animator.SetLookAtWeight(lookAtWeight, strafeBodyWeight, headWeight);
            }
            else
            {
                animator.SetLookAtWeight(lookAtWeight, freeBodyWeight, headWeight);
            }
            if (headTarget != null)
            {
                lookPos = Vector3.Lerp(lookPos, headTarget.position, 2f * Time.deltaTime);
                animator.SetLookAtPosition(lookPos);
            }
        }
示例#6
0
    // 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
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        // animator.GetComponent<ForEnemy>().Attack = false;
        //Player.Instance.Attack = false;

        //animator.GetComponent<Player>().MeleeAttack();
        //&& !stateInfo.IsTag("knife"))

        if (stateInfo.IsTag("sword"))// && !stateInfo.IsTag("knife"))

        {
            animator.GetComponent <Player>().MeleeAttack();
        }


        if (stateInfo.IsTag("knife"))
        {
            animator.GetComponent <Player>().MeleeAttack();
        }



        animator.ResetTrigger("attack");
        animator.ResetTrigger("throw");
    }
示例#7
0
    public void OnAnimatorStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (animator != this.animator)
        {
            return;
        }

        currentState = stateInfo;

        if (stateInfo.IsTag("Punching"))
        {
            Debug.Log("Animator:" + hitQuery);
            if (hitQuery > 0)
            {
                hitQuery--;
                hitCounter++;
            }
            if (hitCounter > 2)
            {
                hitCounter = 0;
            }
            activePunching = true;
            attackIsHit    = false;
        }
        if (stateInfo.shortNameHash == Animator.StringToHash("Locomotion"))
        {
            activeLocomotion = true;
        }
        if (stateInfo.IsTag("Roll"))
        {
            activeRoll = true;
        }
    }
示例#8
0
    // Update is called once per frame
    void Update()
    {
        currentAnimation = anim.GetCurrentAnimatorStateInfo(0);

        if (!currentAnimation.IsTag("Cutscene") && core.life > 0)
        {
            if (currentAnimation.IsTag("Idle"))
            {
                destination = StartPos + (range * Mathf.Sin(Time.time)) * Vector2.right;
                if (cd > 0)
                {
                    cd -= Time.deltaTime;
                }
                else
                {
                    Attack();
                }
            }
            else if (currentAnimation.IsTag("atk"))
            {
                if (currentAnimation.IsName("atk1"))
                {
                    destination = StartPos + (range * Mathf.Sin(Time.time)) * Vector2.right + Vector2.up * 10;
                }
            }
            trs.position = Vector2.MoveTowards(trs.position, destination, speed * Time.deltaTime);
        }
        else if (core.life <= 0)
        {
            Die();
        }
    }
示例#9
0
    void Start()
    {
        animator      = GetComponent <Animator>();
        animatorState = animator.GetCurrentAnimatorStateInfo(0);
        userInput     = GetComponent <IUserInput>();
        inputSkills   = GetComponent <IInputSkills>();

        inputSkills.OnShepsRun += Run;
        inputSkills.OnFire     += () => { StartCoroutine(Fire()); };
        inputSkills.OnJump     += () =>
        {
            if (animatorState.IsTag("Rest"))
            {
                StartCoroutine(Jump());
            }
        };
        inputSkills.OnRitual += () =>
        {
            if (animatorState.IsTag("Rest"))
            {
                StartCoroutine(Ritual());
            }
        };

        ShepsLiving.OnShepsDying += Dying;
    }
示例#10
0
    void Update()
    {
        stateInfo = ownerAnim.GetCurrentAnimatorStateInfo(0);
        if (stateInfo.IsTag("farEnemy_readyAttack"))
        {
            if (!oncePerAttack)
            {
                oncePerAttack     = true;
                attackTimeTrigger = Random.Range(attackTimeMin, attackTimeMax);
            }
            else
            {
                attackTimeTrigger -= Time.deltaTime;
            }
            ownerAnim.SetFloat("attackTimer", attackTimeTrigger);
        }
        else if (stateInfo.IsTag("farEnemy_attack"))
        {
            oncePerAttack = false;
        }

        if ((ownerEnemy.currentHealth <= 0) && (!stateInfo.IsTag("farEnemy_die")))
        {
            ownerAnim.SetTrigger("die");
            GM.main.scoreTotal += ownerEnemy.score;
        }
    }
示例#11
0
    void Death()
    {
        if (isDead)
        {
            if (_animatorStateInfo.IsTag("Dead"))
            {
                dead_time += Time.deltaTime;
                if (dead_time > 4)
                {
                    this.transform.localScale *= 0.9f;
                }
            }

            return;
        }
        OffCollider();
        animator.SetBool("Dead", true);
        animator.SetTrigger("DeadTrigger");
        Destroy(this.gameObject, 5);
        Destroy(agent);
        isDead = true;
        //  AudioPlay(0);
        dead_particle.SetActive(true);



        DropItem();
    }
示例#12
0
        /// <summary>
        /// HIT REACTION - it's activate on the TakeDamage() method by a trigger
        /// </summary>
        void HitReactionAnimation()
        {
            hitReaction = baseLayerInfo.IsTag("HitReaction");

            if (hitReaction)
            {
                jump = false;
            }
            isJumping = false;
        }
示例#13
0
    void FixedUpdate()
    {
        h = CrossPlatformInputManager.GetAxis("Horizontal");
        float v = CrossPlatformInputManager.GetAxis("Vertical");

        Vector2           movimiento    = new Vector2(h, v);
        AnimatorStateInfo animatorState = animator.GetCurrentAnimatorStateInfo(0);

        if (CrossPlatformInputManager.GetButton("Horizontal") || CrossPlatformInputManager.GetButton("Vertical"))
        {
            mirando = (int)Mathf.Sign(h);
            mirada  = new Vector2(h, v);
            ActualizarXYAnimator();
        }
        ///-------Atacar-----///
        if (ArmaEquipado && CrossPlatformInputManager.GetButtonDown("Atacar") && !animatorState.IsTag("Atacando"))
        {
            DeterminarDirecciónMirada(mirada);
            animator.SetBool("Corriendo", false);
            animator.SetTrigger("Atacando");
            atacante.Atacar(direcciónMirada, AtributosJugador.atributosJugador.Fuerza);
            Debug.Log(direcciónMirada);
        }


        ///----------Skill 1 --------///
        if (usarSkill.dashReady && CrossPlatformInputManager.GetButton("Skill1") && !animatorState.IsTag("Atacando") && AtributosJugador.atributosJugador.MagiaActual > 0)
        {
            usarSkill.UsarDash(mirada);
        }

        ///----------Skill 2 --------///
        if (CrossPlatformInputManager.GetButtonDown("Skill2"))
        {
            usarSkill.UsarBolaDeFuego(AtributosJugador.atributosJugador.Inteligencia, mirada, rb);
        }
        else if (!usarSkill.dashing && !animatorState.IsTag("Atacando") && movimiento.magnitude > 0)
        {
            VoltearSprite();
            DeterminarDirecciónMirada(mirada);
            animator.SetBool("Corriendo", true);
            rb.AddForce(movimiento * velocidad * 20);
        }
        else
        {
            animator.SetBool("Corriendo", false);
        }
        //Debug.DrawRay(transform.position,mirada.normalized*(distanciaInteración+ GetComponent<BoxCollider2D>().size.y / 2), Color.red);
        //Debug.DrawLine(transform.position, transform.position + mirada * 0.2f,Color.green);
        if (CrossPlatformInputManager.GetButtonDown("Inventario"))
        {
            Debug.Log("Desactivando Inventario");
            PanelesInventario.panelesInventario.AbrirCerrarInventario();
        }
    }
示例#14
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (stateInfo.IsTag("PlaneEating"))
     {
         animator.SetBool("eating", false);
     }
     else if (stateInfo.IsTag("PlaneUnderAttack"))
     {
         animator.SetBool("underAttack", false);
     }
     ;
 }
示例#15
0
 // OnStateMove is called right after Animator.OnAnimatorMove(). Code that processes and affects root motion should be implemented here
 override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (stateInfo.IsTag("NakedWalk"))
     {
         animator.transform.position += animator.transform.forward * 0.9f * Time.deltaTime;
         animator.transform.GetChild(0).localPosition = Vector3.zero;
     }
     if (stateInfo.IsTag("GoDown"))
     {
         animator.transform.localPosition += animator.transform.up * -0.8f * Time.deltaTime;
     }
 }
    private void Atirar()
    {
        tempoAtirando += Time.deltaTime;

        AnimatorStateInfo temp_AnimatorStateInfo = meuAnimator.GetCurrentAnimatorStateInfo(3);

        if (minhasArmas [armaAtiva].tipoDeFogo == 0)
        {
            if (Input.GetKey(KeyCode.Z))
            {
                tempoAtirando = 0;

                if (meuAnimator.GetFloat("teclaCorrendo") < 1.1f &&
                    temp_AnimatorStateInfo.IsTag("Vazio") && !recarregando && minhasArmas [armaAtiva].PossoAtirar(abaixado))
                {
                    minhasArmas [armaAtiva].Atirar();
                    meuAnimator.SetTrigger("atirar");
                    meuAnimator.SetBool("atirando", true);
                }
            }
            if (tempoAtirando > maxTempoAtirando || minhasArmas [armaAtiva].municoesNoPente == 0)
            {
                meuAnimator.SetBool("atirando", false);
            }
        }
        else
        {
            if (Input.GetKeyDown(KeyCode.Z))
            {
                tempoAtirando = 0;

                if (meuAnimator.GetFloat("teclaCorrendo") < 1.1f &&
                    temp_AnimatorStateInfo.IsTag("Vazio") && !recarregando && minhasArmas [armaAtiva].PossoAtirar(abaixado))
                {
                    minhasArmas [armaAtiva].Atirar();
                    meuAnimator.SetTrigger("atirar");
                    meuAnimator.SetBool("atirando", true);
                }
            }
            if (tempoAtirando > maxTempoAtirando || minhasArmas [armaAtiva].municoesNoPente == 0)
            {
                meuAnimator.SetBool("atirando", false);
            }
        }

        if (Input.GetKeyDown(KeyCode.R) && minhasArmas [armaAtiva].PossoRecarregar() && minhasArmas [armaAtiva].TempoDeTiroPassou(abaixado) &&
            temp_AnimatorStateInfo.IsTag("Vazio") && !recarregando)
        {
            StartCoroutine("Recarregar");
            meuAnimator.SetTrigger("recarregar");
            recarregando = true;
        }
    }
示例#17
0
 /// <summary>
 /// 攻撃ステートの最初25%の時間内は回転することができます
 /// </summary>
 void EnemyTurning()
 {
     targetDirector.forward = playerTrans.position - transform.position;
     if (m_CurrentStateInfo.IsTag("Hit"))
     {
         return;
     }
     if ((m_CurrentStateInfo.IsTag("Attack") && m_StateTime <= 0.25) || !m_CurrentStateInfo.IsTag("Attack"))
     {
         transform.rotation = Quaternion.RotateTowards(transform.rotation, targetDirector.rotation, rotationSpeed * Time.deltaTime);
     }
 }
示例#18
0
    void Update()
    {
        m_currentState = m_animtor.GetCurrentAnimatorStateInfo(0);

        if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            m_shift = true;
        }

        if (Input.GetKeyUp(KeyCode.LeftShift))
        {
            m_shift = false;
        }

        m_animtor.SetBool("Running", m_shift);

        float x = Input.GetAxisRaw("Horizontal");
        float y = Input.GetAxisRaw("Vertical");

        if (x != 0 || y != 0)
        {
            ResetTriggers();
            m_animtor.SetTrigger("Move");
        }

        bool running = false;

        if (m_currentState.IsTag("Walk"))
        {
            UpdateMove(m_role.WalkSpeed);
        }
        else if (m_currentState.IsTag("Run"))
        {
            running = true;
            UpdateMove(m_role.RunSpeed);
        }

        if (!running)
        {
            if (Input.GetMouseButtonUp(0))
            {
                ResetUpperTriggers();
                m_animtor.SetTrigger("Fire");
            }

            if (Input.GetKeyUp(KeyCode.R))
            {
                ResetUpperTriggers();
                m_animtor.SetTrigger("Reload");
            }
        }
    }
示例#19
0
    //  OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (stateInfo.IsTag("CloseShades"))
        {
            animator.transform.parent.GetChild(0).GetComponent <Animation> ().Play();
            Destroy(animator.transform.gameObject, 4f);
        }

        if (stateInfo.IsTag("GoDown"))
        {
            animator.GetComponentInChildren <SkinnedMeshRenderer> ().SetBlendShapeWeight(3, 100);
        }
    }
示例#20
0
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        // Debug.Log(MegaAi);

        if (stateInfo.IsTag("MegaShoot"))
        {
            MegaAi.ShootAt.Shoot();
        }
        else if (stateInfo.IsTag("MegaDeath"))
        {
            // For some reason MegaAi is always null here, fix this
            // Destroy(MegaAi.gameObject);
        }
    }
示例#21
0
    private void Update()
    {
        Animator          anim         = transform.parent.parent.GetComponent <Animator>();
        AnimatorStateInfo curBaseState = anim.GetCurrentAnimatorStateInfo(1);

        if (curBaseState.IsTag("attack"))
        {
            attacking = true;
        }

        if (attacking && curBaseState.IsTag("after attack") && pro != null)
        {
            if (Target != null)
            {
                attacking = false;

                Vector3 newPos    = Target.position + Vector3.forward * 0.3f;
                float   timeZero  = Time.time - startTime;
                Vector3 speedZero = (newPos - lastPos) / timeZero;

                Vector3 toTar0 = newPos - transform.parent.position;
                //float angle0 =  (float)(Math.PI - Math.Asin(toTar0.magnitude * SM.g / (projSpeed * projSpeed)))/2;
                float angle0 = (float)(Math.Asin(toTar0.magnitude * SM.g / (projSpeed * projSpeed))) / 2;
                float time   = (float)(2 * projSpeed * Math.Sin(angle0) / SM.g);
                newPos += time * speedZero;

                Vector3 deltaVector = new Vector3((float)(SM._rnd.NextDouble() * 2 - 1), (float)(SM._rnd.NextDouble() * 2 - 1), 0f).normalized *(float)(SM._rnd.NextDouble()) * (newPos - transform.parent.parent.position).magnitude * deltaTar;
                newPos += deltaVector;

                Vector3 toTar = newPos - transform.parent.position;
                //float angle = (float)(Math.PI - Math.Asin(toTar.magnitude * SM.g / (projSpeed * projSpeed))) / 2;
                float   angle = (float)(Math.Asin(toTar.magnitude * SM.g / (projSpeed * projSpeed))) / 2;
                Vector3 speed = projSpeed * ((toTar.normalized * (float)Math.Cos(angle)) - (Vector3.forward * (float)Math.Sin(angle)));

                pro.GetComponent <Collider2D>().enabled = true;
                pro.transform.parent   = SM.trash.transform;
                pro.transform.rotation = Quaternion.LookRotation(Vector3.Cross(speed, Vector3.Cross(toTar, Vector3.forward)), speed);

                pro.GetComponent <Projectile_Weapon>().SetSpeed(speed);

                pro = null;
            }
            else
            {
                GameObject.Destroy(pro);
                pro = null;
            }
        }
    }
示例#22
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}

    // 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
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (stateInfo.IsTag("attack1"))
        {
            //Debug.Log("stop attack1");
            GameObject.FindObjectOfType <PlayerMovements>().GetComponent <PlayerMovements>().canFire1 = true;
            animator.SetBool("Fire1", false);
        }
        else if (stateInfo.IsTag("attack2"))
        {
            //Debug.Log("stop attack2");
            GameObject.FindObjectOfType <PlayerMovements>().GetComponent <PlayerMovements>().canFire2 = true;
            animator.SetBool("Fire2", false);
        }
    }
    void UpdateAnima()
    {
        playerAnima.SetBool(Animator.StringToHash("IsAlive"), PlayerInfoManager.Instance.PlayerInfo.IsAlive);
        if (!PlayerInfoManager.Instance.PlayerInfo.IsAlive)
        {
            return;
        }
        AnimatorStateInfo = playerAnima.GetCurrentAnimatorStateInfo(0);
        //AnimatorTransitionInfo = playerAnima.GetAnimatorTransitionInfo(0);
        PlayerInfoManager.Instance.PlayerInfo.IsBlocking = AnimatorStateInfo.IsTag("Blocking");
        playerAnima.SetBool(Animator.StringToHash("Fighting"), PlayerInfoManager.Instance.PlayerInfo.IsFighting);
        playerAnima.SetBool(Animator.StringToHash("HaveWeapon"), PlayerWeaponManager.Instance.currentWeaponTag != string.Empty);
        playerAnima.SetBool(Animator.StringToHash("IsDown"), PlayerInfoManager.Instance.PlayerInfo.IsDown);
        playerAnima.SetBool(Animator.StringToHash("IsGiddy"), PlayerInfoManager.Instance.PlayerInfo.IsGiddy);
        switch (PlayerWeaponManager.Instance.currentWeaponTag)
        {
        case "Halberd": playerAnima.SetInteger(Animator.StringToHash("WeaponType"), 1); break;

        case "Spear": playerAnima.SetInteger(Animator.StringToHash("WeaponType"), 2); break;

        case "Sword": playerAnima.SetInteger(Animator.StringToHash("WeaponType"), 3); break;

        case "Blade": playerAnima.SetInteger(Animator.StringToHash("WeaponType"), 4); break;

        default: playerAnima.SetInteger(Animator.StringToHash("WeaponType"), -1); break;
        }
    }
示例#24
0
    private Vector3 GetClosestEnemyDirection()
    {
        Vector3 D                 = moveDir; //initial directia de privire coincide cu cea de deplasare
        float   minDist           = float.MaxValue;
        int     closestEnemyIndex = -1;

        for (int i = 0; i < enemies.Count; i++)
        {//compara distantele dintre player si fiecare inamic ca sa obtii cel mai apropiat inamic
            float dist = Vector3.Distance(transform.position, enemies[i].position);
            if (dist < 4f && dist < minDist)
            {
                minDist           = dist;
                closestEnemyIndex = i;
            }
        }
        if (closestEnemyIndex != -1)
        {                                   //daca exista cel mai apropiat inamic la mai putin de 4 metri
            if (!stateInfo.IsTag("attack")) //nu schimba inamicul in timp ce loveste
            {
                enemy = enemies[closestEnemyIndex];
            }
            D   = enemy.position - transform.position; //directia de privire pointeaza la inamic
            D.y = 0f;                                  //directie in plan orizontal
            D   = D.normalized;
        }
        return(D);
    }
示例#25
0
        protected IEnumerator CheckReloadAmmoAnimationEnd()
        {
            while (true)
            {
                yield return(null);

                GunStateInfo = GunAnimator.GetCurrentAnimatorStateInfo(GunAnimator.GetLayerIndex("Reload Layer"));
                if (GunStateInfo.IsTag("ReloadAmmo"))
                {
                    if (GunStateInfo.normalizedTime >= 0.9f)
                    {
                        int tmp_NeedAmmoCount = AmmoInMag - CurrentAmmo;
                        int tmp_RemainingAmmo = CurrentMaxAmmoCarried - tmp_NeedAmmoCount;
                        if (tmp_RemainingAmmo <= 0)
                        {
                            CurrentAmmo += CurrentMaxAmmoCarried;
                        }
                        else
                        {
                            CurrentAmmo = AmmoInMag;
                        }

                        CurrentMaxAmmoCarried = tmp_RemainingAmmo <= 0 ? 0 : tmp_RemainingAmmo;

                        yield break;
                    }
                }
            }
        }
示例#26
0
    private void HandleHeadTurn()
    {
        if (!enemy || stateInfo.IsTag("attack"))
        {
            return;
        }
        Vector3 lookAtPoint   = enemy.position + Vector3.up * 1.4f;
        Vector3 lookDir       = (lookAtPoint - headTransform.position).normalized;
        float   fwdDotLookDir = Vector3.Dot(transform.forward, lookDir);

        if (fwdDotLookDir > 0f)
        {
            Quaternion lookRot = Quaternion.LookRotation(lookDir);
            headTransform.rotation = Quaternion.Slerp(headTransform.rotation, lookRot, fwdDotLookDir);
        }
    }
示例#27
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
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (stateInfo.IsTag("punch"))
        {
            RockBoss boss = animator.GetComponent <RockBoss>();
            boss.LastAttackTime = Time.time;
            if (animator.GetBool("rockstorm"))
            {
                return;
            }

            if (boss.Cycle == RockBoss.AttackCycle.OnePunch)
            {
                boss.Cycle = RockBoss.AttackCycle.ThrowDebris;
            }
            else if (boss.Cycle == RockBoss.AttackCycle.MultiplePunches && animator.GetBool("punching") == false)
            {
                boss.Cycle = RockBoss.AttackCycle.OnePunch;
            }
        }
        else if (stateInfo.IsName("throwDebris"))
        {
            RockBoss boss = animator.GetComponent <RockBoss>();
            boss.LastAttackTime = Time.time;

            if (animator.GetBool("rockstorm"))
            {
                return;
            }

            boss.Cycle = RockBoss.AttackCycle.MultiplePunches;
            boss.ChangePhase(RockBoss.AttackPhase.Punch);
        }
    }
示例#28
0
 public bool InAnimatorStateWithTag(string tag)
 {
     if (anim == null)
     {
         return(false);
     }
     RefreshAnimatorState();
     if (baseLayerInfo.IsTag(tag))
     {
         return(true);
     }
     if (underBodyInfo.IsTag(tag))
     {
         return(true);
     }
     if (rightArmInfo.IsTag(tag))
     {
         return(true);
     }
     if (leftArmInfo.IsTag(tag))
     {
         return(true);
     }
     if (upperBodyInfo.IsTag(tag))
     {
         return(true);
     }
     if (fullBodyInfo.IsTag(tag))
     {
         return(true);
     }
     return(false);
 }
    void PlayerMove()
    {
        if (characterController.isGrounded && currStateInfo.IsName("IdleWalk"))
        {
            float x = Input.GetAxis("Horizontal");
            float z = Input.GetAxis("Vertical");

            dir = new Vector3(x, 0, z);

            dir = transform.TransformDirection(dir);
            PlayerRotate();
            dir         = dir * speed;
            canAirCombo = true;
            if (Input.GetButton("Jump"))
            {
                dir.y = jumpspeed;
                animator.SetTrigger("Jump");
            }
        }

        if (characterController.isGrounded && !currStateInfo.IsName("IdleWalk"))
        {
            canAirCombo = true;
            dir         = new Vector3(0, 0, 0);
        }

        if (currStateInfo.IsTag("InAir"))
        {
            dir = new Vector3(0, 0, 0);
        }

        dir.y -= gravity * Time.deltaTime;
        characterController.Move(dir * Time.deltaTime);
    }
    private void  Move()
    {
        AnimatorStateInfo temp_State = myComponents.myAnimator.GetCurrentAnimatorStateInfo(1);

        if (temp_State.IsTag("attacking") || timerAtk <= maxTimerAtk + 0.5f)
        {
            return;
        }

        horizontalForward = Input.GetAxis("Horizontal");

        //Running system
        if (Input.GetKey(KeyCode.LeftShift))
        {
            myComponents.myAnimator.SetBool("Running", true);
            runningVeloPass = Mathf.Lerp(runningVeloPass, runningVelocity, 2f * Time.deltaTime);
        }
        else
        {
            myComponents.myAnimator.SetBool("Running", false);
            runningVeloPass = Mathf.Lerp(runningVeloPass, 1f, 2f * Time.deltaTime);
        }

        //Jump system
        if (Input.GetKeyDown(KeyCode.UpArrow) && myComponents.canJump)
        {
            StartCoroutine("TimerBeforeJumpDelay");
            myComponents.myAnimator.SetTrigger("Jump");
            myComponents.canJump = false;
        }
    }