public IEnumerator Attack(EnemyController enemy) { Debug.Log("Player is Attacking " + enemy.gameObject.name); isMoving_ = true; ActiveEntity enemyStats = enemy.GetComponentInParent <ActiveEntity>(); // Attempt attack! float attackRoll = Random.Range(0f, 1f); int damage = playerStats_.damage_; int armorPierce = playerStats_.armorPiercing_; // Critical hit?! if (enemyStats.AttemptCritical(attackRoll, playerStats_.criticalChance_)) { damage *= 2; armorPierce = (armorPierce + 1) * 2; enemyStats.AttemptDoDamage(damage, armorPierce); characterAnimator_.SetTrigger("Critical"); enemy.characterAnimator_.SetTrigger("Stumble"); player_Attack.Invoke(enemy, "Critical"); } else { if (!enemyStats.AttemptDodge(attackRoll + playerStats_.attackRating_)) { enemyStats.AttemptDoDamage(damage, armorPierce); characterAnimator_.SetTrigger("Swing"); enemy.characterAnimator_.SetTrigger("Stumble"); player_Attack.Invoke(enemy, "Hit"); } else { characterAnimator_.SetTrigger("Swing"); enemy.characterAnimator_.SetTrigger("Dodge"); player_Attack.Invoke(enemy, "Dodge"); } }; if (enemyStats.health <= 0) { enemy.Die((playerObj_.transform.position - enemy.transform.position).normalized); PlayerManager.instance_.AddXP(enemyStats.reference_); } yield return(new WaitForSeconds(0.5f)); EndTurn(); isMoving_ = false; }
public void EnableAttacking() { //Debug.Log("ATTACK"); inAttack = true; hitbox.isActive = true; OnAttack.Invoke(); }
public override void OnPointerUp(PointerEventData eventData) { AttackEvent?.Invoke(); background.gameObject.SetActive(false); base.OnPointerUp(eventData); }
public void OnAttack(InputAction.CallbackContext context) { if (context.phase == InputActionPhase.Performed) { AttackEvent.Invoke(); } }
//need to proc when attack is cut too :x protected virtual void OnAttackEnd() { //Debug.Log("End"); m_animator.SetBool("Attacking", false); OnAttackStateEvent.Invoke(false); OnAttackEndEvent.Invoke(m_attackType); }
public void AddAmmo(float i) { currentAmmo += i; if (OnAddAmmo != null) { OnAddAmmo.Invoke(); } }
void Update() { if (!pauseManager.IsPaused() && attackQueue.Count > 0) { Attack attack = attackQueue[0]; attackQueue.Remove(attack); attackEvent.Invoke(attack); } }
protected virtual void OnAttackStart(AttackStruct newStruct) { //Debug.Log("Start"); m_attackType = (AttackType)m_animator.GetInteger("AttackType"); //Debug.Log("Attack type = " + m_attackType); m_currAttackStruct = newStruct; m_animator.SetBool("Attacking", true); OnAttackStateEvent.Invoke(true); OnAttackBeginEvent.Invoke(m_attackType); }
private void shoot() { if (Time.time > _nextFire) { if (AttackEvent != null) { AttackEvent.Invoke(); } _nextFire = Time.time + _fireRate; } }
public void Attack(MoveObject move) { print(Pokemon.name + " used " + move.name + "!"); OnAttack.Invoke(Pokemon, move); // // TODO remove null check // if(move != null) // { // print(Pokemon.name + " used " + move.name + "!"); // messageController.ShowMessage(Pokemon.name + " used " + move.name + "!"); // enemyBattlePokemon.TakeDamage(Pokemon, move); // } }
private void OnTriggerEnter2D(Collider2D collision) { Unit target = collision.gameObject.GetComponent <Unit>(); if (target != null) { if (_attakced.Contains(target) == false) { _attakced.Add(target); onAttack.Invoke(target); } } }
public void OnAttack(InputAction.CallbackContext context) { switch (context.phase) { case InputActionPhase.Performed: AttackEvent.Invoke(); break; case InputActionPhase.Canceled: AttackCanceledEvent.Invoke(); break; } }
private void OnTriggerEnter2D(Collider2D co) { if (exclusionTag.Equals(co.tag)) { return; } var attacked = co.gameObject.GetComponent <AttackableObject2D>(); if (attacked) { attacked.Attacked(this); onAttack.Invoke(attacked); } }
protected void FixedUpdate() { if (!GameManager.gameOver) // If the game isn't over { if (_timer <= 0) // If target is null and attack timer is done { _target = CheckForTarget(); // Try to set target if (_target != null) { OnAttack.Invoke(); _timer = _timeOut; } } else if (_timer > 0) // If the attack timer isn't done { _timer -= Time.deltaTime; // Decrease attack timer by the difference between the last and the current frame } } }
protected override void Attack() { // check if player is already attacking bool isAttacking = animHandler.IsStateByTag("Attack"); // REFACTOR: Use BusyState instead if (!canInitiateAttack(isAttacking)) { return; } CalculateAttackComboIndex(isAttacking); AttackEvent.Invoke(); if (CurrentBusyState == BusyState.ATTACK || CurrentBusyState == BusyState.NONE) { if (busyRoutine != null) { StopCoroutine(busyRoutine); } busyRoutine = StartCoroutine(processAction(attackCombo[AttackComboIndex], BusyState.ATTACK)); } }
protected virtual IEnumerator Attack() { WaitForSeconds Wait = new WaitForSeconds(AttackDelay); yield return(Wait); IDamageable closestDamageable = null; float closestDistance = float.MaxValue; while (Damageables.Count > 0) { for (int i = 0; i < Damageables.Count; i++) { Transform damageableTransform = Damageables[i].GetTransform(); float distance = Vector3.Distance(transform.position, damageableTransform.position); if (distance < closestDistance) { closestDistance = distance; closestDamageable = Damageables[i]; } } if (closestDamageable != null) { OnAttack?.Invoke(closestDamageable); closestDamageable.TakeDamage(Damage); } closestDamageable = null; closestDistance = float.MaxValue; yield return(Wait); Damageables.RemoveAll(DisabledDamageables); } AttackCoroutine = null; }
protected virtual void OnExchange2() { if (decision == Decision.Attack) { AttackEvent?.Invoke(); } if ((preCoeffs[1].exchangeResult == ExchangeResult.GetHit) && !m_dead) // если не помер после первого удара { GetHitEvent?.Invoke(2); // то принимаем второй if (_HP.TakeDamage(/*damage2*/ gotDamage)) { InvokeDeathEvent(); } } if (((decision == Decision.ChangeSwordShield) || (decision == Decision.ChangeSwordSword) || (decision == Decision.ChangeTwoHandedSword)) && !m_dead) { ChangeEvent?.Invoke(); } else { if (preCoeffs[1].exchangeResult == ExchangeResult.Parry) { ParryEvent?.Invoke(2); } if (preCoeffs[1].exchangeResult == ExchangeResult.Block) { BlockEvent?.Invoke(2); } } if (preCoeffs[1].exchangeResult == ExchangeResult.Evade) { EvadeEvent?.Invoke(2); } }
public void OnAttackRemoteEvent(SWNetworkMessage msg) { OnAttack.Invoke(msg); }
private void OnAttackBtnClicked(IPlayerUi playerUi) { playerUi.DisableAttackBtnForTime(AttackDelay); AttackEvent?.Invoke(this, playerUi.Id); }
public void DisableAttacking() { inAttack = false; hitbox.isActive = false; OnExitAttack.Invoke(); }
public void Damage() { this.health = GetDamage(this.health, damage); AttackEvent?.Invoke(); }
public void Attack(Unit target) { AttackEventArgs args = new AttackEventArgs(target, Damage); AttackEvent?.Invoke(this, args); }
public void OnAttack(float damage) { GetComponent <Animator>().SetTrigger("Attack"); AttackEvent?.Invoke(damage); }
public void Attack() { float dmg = 0; attackEvent.Invoke(dmg); }
// Calls PreAttack, Attack, and PostAttack events so they go in order public void AttackOrder(AttackEventArgs attackEventArgs) { PreAttackEvent?.Invoke(attackEventArgs); AttackEvent?.Invoke(attackEventArgs); PostAttackEvent?.Invoke(attackEventArgs); }
public void PlayAttackEvent() => AttackEvent?.Invoke();
public void Attack(Damageable _damageable) { m_attackEvent.Invoke(_damageable); _damageable.Damage(m_healthDamages, m_stunDamages); }
public void Attack(Vector2 direction) { AttackEvent?.Invoke(this); }