public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { float t = stateInfo.normalizedTime; if (stage == AttackStage.enter || stage == AttackStage.end) { Attack(AttackStage.start); stage = AttackStage.start; attackTimer++; } else if (stage == AttackStage.start) { if (t - attackTimer + 1 > attackNormalizedTime) { Attack(AttackStage.tick); stage = AttackStage.update; } else { Attack(AttackStage.update); } } else if (stage == AttackStage.update) { if (t > attackTimer) { Attack(AttackStage.end); stage = AttackStage.end; } else { Attack(AttackStage.update); } } }
private void Move() { switch (attackStage) { case AttackStage.Attack: Vector2 direction = attack.Target.position - transform.position; float distance = direction.magnitude; float requiredAngle = MathHelpers.Vector2ToDegree(direction); float currentAngle = MathHelpers.LerpAngle(rigidbody.rotation, requiredAngle, rotationSpeed * Time.deltaTime); CanAttack = Mathf.Abs(requiredAngle - currentAngle) <= angleToAttack; Vector2 currentDirection = MathHelpers.DegreeToVector2(currentAngle); SetMovement(currentDirection, currentDirection); if (distance <= distanceToFlee) { attackStage = AttackStage.Flee; } break; case AttackStage.Flee: direction = transform.position - attack.Target.position; distance = direction.magnitude; requiredAngle = MathHelpers.Vector2ToDegree(direction); currentAngle = MathHelpers.LerpAngle(rigidbody.rotation, requiredAngle, rotationSpeed * Time.deltaTime); CanAttack = false; currentDirection = MathHelpers.DegreeToVector2(currentAngle); SetMovement(currentDirection, currentDirection); if (distance >= distanceToAttack) { attackStage = AttackStage.Attack; } break; } }
protected virtual IEnumerator IE_DoAttack() { var attackTimer = 0; // Startup Attacking = true; Hitbox.SetResponder(this); ApplyAttackMotion(); AtkStage = AttackStage.Startup; yield return(Utility.FrameTimer(Attacks[currentAttackIndex].Startup, attackTimer)); // Active Hitbox.SetActive(); AtkStage = AttackStage.Active; yield return(Utility.FrameTimer(Attacks[currentAttackIndex].Active, attackTimer)); // Recovery Hitbox.SetInactive(); AtkStage = AttackStage.Recovery; yield return(Utility.FrameTimer(Attacks[currentAttackIndex].Recovery, attackTimer)); // End GetComponent <BaseController>()?.SetState(BaseController.State.Ready); AtkStage = AttackStage.Ready; Attacking = false; }
protected virtual IEnumerator IE_DoRangedAttack() { var attackTimer = 0; // Startup Attacking = true; ApplyAttackMotion(); AtkStage = AttackStage.Startup; yield return(Utility.FrameTimer(Attacks[currentAttackIndex].Startup, attackTimer)); // Active projectiles[0].GetComponent <ProjectileController>().SetSign(Convert.ToInt32(transform.localScale.x)); projectiles[0].transform.position = transform.position; projectiles[0].SetActive(true); AtkStage = AttackStage.Active; yield return(Utility.FrameTimer(Attacks[currentAttackIndex].Active, attackTimer)); // Recovery AtkStage = AttackStage.Recovery; yield return(Utility.FrameTimer(Attacks[currentAttackIndex].Recovery, attackTimer)); while (GetComponent <BaseController>().CurrentState == BaseController.State.SuperStun) { yield return(new WaitForFixedUpdate()); } // End GetComponent <BaseController>().SetState(BaseController.State.Ready); AtkStage = AttackStage.Ready; Attacking = false; }
public void AttackProcess(AttackStage stage) { var w = equipment.currentWeapons; switch (stage) { case AttackStage.enter: w.AttackPrepare(); break; case AttackStage.start: w.AttackStart(); break; case AttackStage.update: w.AttackUpdate(); break; case AttackStage.tick: w.AttackTick(); if (w.RemainBullet <= 0) { ReloadBullets(); } break; case AttackStage.end: w.AttackEnd(); break; case AttackStage.exit: w.AttackExit(); break; } }
private void Count() { seconds++; if (seconds == 2) { Debug.Log("Standard (initial)"); attackStage = AttackStage.STAGE_1; } }
/// <summary> /// Resets the currentley ative attack. /// </summary> public virtual void StopAttack() { if (currentAttackRoutine != null) { StopCoroutine(currentAttackRoutine); } Hitbox.SetInactive(); AtkStage = AttackStage.Ready; Attacking = false; }
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (stage != AttackStage.end) { Attack(AttackStage.end); } stage = AttackStage.exit; Attack(AttackStage.exit); }
private void Start() { player = GameObject.FindWithTag("Player"); frozen = false; attackStage = AttackStage.PRE; InvokeRepeating("Count", 2.0f, 1.0f); InvokeRepeating("PickStage", 20.0f, 20.0f); InvokeRepeating("StandardAttack", 1.0f, 0.5f); InvokeRepeating("BurstAttack", 0.0f, 1.25f); }
void lazyRandomizer() { //int randomTimer = Random.Range(5, 10); int randomDecision = Random.Range(0, 9); //Debug.Log(randomDecision); if (randomDecision > 7) { attckStage = AttackStage.lazy; } else { attckStage = AttackStage.chase; } }
/// <summary> /// 切换动画速度 /// </summary> /// <param name="stage"></param> private void _OnNextSpeed(int stage) { if (stage != 2) { stage = stage + 1; _curAttackStage = (AttackStage)stage; } else { stage = 0; _curAttackStage = AttackStage.StageOne; } _curSpeed = _fireSpeed[stage]; }
private void _ExitAnimation(AttackStage stage) { if (_curAttackStage == stage && !_isTimerWorking) { //_animator.Play("Attack", 0, 0); _animator.SetTrigger("ExitAttack"); _isInAttackState = false; if (_bulletCount == 4) { _timer = 0f; _bulletCount = 0; _OnNextSpeed((int)_curAttackStage); _isTimerWorking = true; } } }
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { attackTimer = 0; animator.SetLayerWeight(1, 1); stage = AttackStage.enter; if (!animatorManager) { animatorManager = animator.GetComponent <PlayerAnimatorManager>(); } if (!characterController) { characterController = animator.GetComponent <STCharacterController>(); } Attack(AttackStage.enter); }
private void PickStage() { AttackStage currentStage = attackStage; if (currentStage == AttackStage.PRE) { attackStage = AttackStage.STAGE_1; } else { if (currentStage == AttackStage.STAGE_1) { attackStage = AttackStage.STAGE_2; } else { attackStage = AttackStage.STAGE_1; } } }
//================================= Animation Events ====================================== /// <summary> /// Permite obtener información del estado actual de la animación de combate. /// </summary> /// <param name="index"> Identificador de la animación de Ataque actual.</param> /// <param name="stage"> En que Stage de la animación de Combate está.</param> public void SetAttackState(int index, AttackStage stage) { CurrentAttackID = index; CurrentStage = stage; switch (stage) { case AttackStage.StartUp: LookTowardsPlayer = true; break; case AttackStage.Active: LookTowardsPlayer = false; break; case AttackStage.Recovery: LookTowardsPlayer = true; break; default: break; } }
void attackMode() { if (gameObject.tag == "Cat") { enemyArray = GameObject.FindGameObjectsWithTag("Dog"); } else { enemyArray = GameObject.FindGameObjectsWithTag("Cat"); } float closestDistance = 100000000; foreach (GameObject dog in enemyArray) { Vector3 currentPosition = transform.position; float distToTarget = Vector3.Distance(dog.transform.position, currentPosition); if (distToTarget < closestDistance) { closestDistance = distToTarget; enemy = dog; } } if (closestDistance < 1.0f && attckStage != AttackStage.lazy) { if (attackCooldown > 0) { attckStage = AttackStage.cooldown; attackCooldown -= Time.deltaTime * 1.0f; } else { attckStage = AttackStage.attack; attackCooldown = attackSpeed; } } else if (attckStage != AttackStage.lazy) { attckStage = AttackStage.chase; } if (attckStage == AttackStage.chase) { if (enemy != null) { agent.isStopped = false; agent.destination = enemy.transform.position; } } else if (attckStage == AttackStage.attack) { if (enemy != null) { agent.isStopped = true; enemy.GetComponent <CharMovement>().hurt(attackDamage);//inflict damage Vector3 charPosition = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z); Quaternion charRotation = new Quaternion(0, 0, 0, 0); GameObject unit = Instantiate(attckEffect, charPosition, charRotation); Destroy(unit, 0.15f); lazyRandomizer(); } } else if (attckStage == AttackStage.cooldown) { agent.isStopped = true; } else if (attckStage == AttackStage.lazy) { if (lazyDuration == 4.0f) { agent.SetDestination(RandomNavmeshLocation(10.0f)); } lazyDuration -= Time.deltaTime; if (lazyDuration <= 0.0f) { lazyDuration = 4.0f; lazyRandomizer(); } agent.isStopped = false; } }
protected override void Attack(AttackStage stage) { // characterController.UnarmAttackProcess(stage); }
protected virtual void Attack(AttackStage stage) { characterController.AttackProcess(stage); }
protected new void Awake() { base.Awake(); attack = GetComponent <ChaserAttack>(); attackStage = AttackStage.Flee; }