private void Attack(GameObject warriorObject) { var lifeController = warriorObject.GetComponent <LifeController>(); var warrior = warriorObject.GetComponent <Warrior>(); if (!lifeController || !warrior) { return; } if (_warrior.Team == warrior.Team) { return; } _animator.SetTrigger("Attack"); lifeController.Attack(.35f); if (lifeController.Life <= 0f) { _lifeController.AddLife(.3f); OnKill?.Invoke(); } OnAttack?.Invoke(); }
private void OnArrowCollision(GameObject obj) { var lifeController = obj.GetComponent <LifeController>(); var warrior = obj.GetComponent <Warrior>(); if (!lifeController || !warrior || _warrior.Team == warrior.Team) { _missed++; if (_missed > 4) { _missed = 0; //OnMissed?.Invoke(); } return; } lifeController.Attack(.35f); if (lifeController.Life <= 0f) { _lifeController.Attack(-1f); OnKill?.Invoke(); } OnAttack?.Invoke(); }
public void BasicAttackOnPosition(Vector3Int position) { CanAttack = false; movement.CanMove = false; world.UnitManager.GetUnitAt <UnitEntity>(position).Combat.DealDamage(attack, this, true); OnAttack?.Invoke(); }
public void Activate() { collider.enabled = false; waitCountdown = waitDuration; attackCountdown = attackDuration; OnAttack?.Invoke(direction); }
/// <summary> /// Get if the animal is currently attacking. This called form the animator when an attack animation started /// </summary> /// <param name="attack"></param> public void Attacking(bool attack) { isAttacking = attack; if (attack) { OnAttack.Invoke(); } }
public void Attack() { if (OnAttack != null) { OnAttack.Invoke(); } animator.SetTrigger("attack"); }
public void CastAbility(Ability ability, Vector3Int target) { ability.Cast(Unit, target, world); UseMana(ability.ManaCost); movement.CanMove = false; CanAttack = false; OnAttack?.Invoke(); }
public void Attack() { if (selected != null) { selected.Attack(_characterController); OnAttack?.Invoke(); } }
///<summary> /// Changing enemyacter state by detecting what kind of layer it touches ///</summary> protected virtual void ChangeState(EnemyState state) { if (enemyState == state || IsDead()) { return; } if (IsAttacking()) { OnAttackEnd.Invoke(); } if (IsPatrolling()) { OnPatrolEnd.Invoke(); } if (IsChasing()) { OnChaseEnd.Invoke(); } if (IsIdling()) { OnIdleEnd.Invoke(); } // set new state var prevState = enemyState; enemyState = state; if (!IsAttacking()) { m_General.canFlip = true; } if (IsAttacking()) { OnAttack.Invoke(); } if (IsPatrolling()) { OnPatrol.Invoke(); } if (IsChasing()) { OnChase.Invoke(); } if (IsIdling()) { OnIdle.Invoke(); } OnMotorStateChanged.Invoke(prevState, enemyState); }
public bool CallBack(EventType type, object[] args) { switch (type) { case EventType.OnAttack: if (OnAttack != null) { return(OnAttack.Invoke(args)); } else { return(false); } case EventType.OnAttackDefault: if (OnAttackDefault != null) { return(OnAttackDefault.Invoke(args)); } else { return(false); } case EventType.TryAttack: if (TryAttack != null) { return(TryAttack.Invoke(args)); } else { return(false); } case EventType.OnActiveCursor: if (OnActiveCursor != null) { return(OnActiveCursor.Invoke(args)); } else { return(false); } case EventType.OnCrystalize: if (OnCrystalize != null) { return(OnCrystalize.Invoke(args)); } else { return(false); } } return(false); }
/// <summary> /// Activate an Attack by his Animation State Name /// </summary> public virtual void SetAttack(string animation) { attack1 = true; if (!isAttacking) { Anim.Play(animation); } OnAttack.Invoke(); }
private void ProcessAttack() { if (_timeToNextAttack >= _attackRate && !_isThrowingBack) { OnAttack?.Invoke(); _timeToNextAttack = 0; } }
protected virtual void TryAttack() { if (attackTimer <= 0) { attackTimer = stats.attackSpeed; Attack(); OnAttack?.Invoke(); } }
protected virtual void Attacked(AttackArgs.HitByAttack attackHit, Fighter target, int damage) { AttackArgs attackArgs = new AttackArgs() { AttackHit = attackHit, Target = target, Attacker = this, Damage = damage }; OnAttack?.Invoke(this, attackArgs); FighterEffectManager.GetDamageFromAttack(attackArgs); }
public void Attack(PlayerStat target) { if (attackCountdown <= 0f) { attackCountdown = 1f / attackRate; target.TakeDamage(myStats.damage.GetValue()); OnAttack?.Invoke(); } }
private void Attack() { if (isAnimating) { return; } OnAttack?.Invoke(); isAnimating = true; animationTimer = 0f; }
public void Attack(AttackType type) { ActivateCoolDown(type); var hit = _castHandler.Cast(); if (hit) { DoAttack(hit.collider, type); } OnAttack?.Invoke(type); }
public void Attack(CharacterStats targetStats) { if (attackCooldown <= 0) { enemyStats = targetStats; OnAttack?.Invoke(); attackCooldown = 1 / attackSpeed; InCombat = true; lastAttackTime = Time.time; } }
public IEnumerator AttackCoroutine() { if (GameManager.Instance.CharacterBases.Count > 0) { _mrDudesModel.Target = GameManager.Instance.CharacterBases[0].gameObject; } OnAttack?.Invoke(); yield return(new WaitForSeconds(2)); _mrDudesModel.EndState(); }
protected virtual void Attack(bool triggering = true) { if (LockedTarget == null) { return; } if (triggering) { OnAttack?.Invoke(LockedTarget); } InitializeAttack(); }
protected override IEnumerator Attack() { WaitForSeconds Wait = new WaitForSeconds(AttackDelay); yield return(Wait); while (Damageables.Count > 0) { for (int i = 0; i < Damageables.Count; i++) { if (HasLineOfSightTo(Damageables[i].GetTransform())) { targetDamageable = Damageables[i]; OnAttack?.Invoke(Damageables[i]); Agent.enabled = false; break; } } if (targetDamageable != null) { PoolableObject poolableObject = BulletPool.GetObject(); if (poolableObject != null) { bullet = poolableObject.GetComponent <Bullet>(); bullet.Damage = Damage; bullet.transform.position = transform.position + BulletSpawnOffset; bullet.transform.rotation = Agent.transform.rotation; bullet.Rigidbody.AddForce(Agent.transform.forward * BulletPrefab.MoveSpeed, ForceMode.VelocityChange); } } else { Agent.enabled = true; // no target in line of sight, keep trying to get closer } yield return(Wait); if (targetDamageable == null || !HasLineOfSightTo(targetDamageable.GetTransform())) { Agent.enabled = true; } Damageables.RemoveAll(DisabledDamageables); } Agent.enabled = true; AttackCoroutine = null; }
public void Attack(CharacterStats targetStats) { if (attackCooldown <= 0f) { StartCoroutine(DoDamage(targetStats, attackDelay)); if (onAttack != null) { onAttack.Invoke(); } attackCooldown = 1f / attackSpeed; } }
public void Attack(Characters.Character targetStats) { if (targetStats.CanAttack && _attackCooldown <= 0f) { Attacked = true; enemyCurrentlyFightingWith = targetStats.GetComponent <GameObject>(); StartCoroutine(DealBasicAttackDamage(targetStats, attackDelay)); OnAttack?.Invoke(); _attackCooldown = 1f / _myStats.stats[5].GetValue(); } }
protected override void Attacking() { if (!PlayerOnAttackRange()) { actualTime = 0; OnEnemyOutOfAttackRange(); return; } if (actualTime <= 0) { OnAttack.Invoke(); actualTime = fireRate; nav.speed = 0; attackFSM.Attack(); } actualTime -= Time.deltaTime; }
public bool attack(Entity entity) { if (entity != null) { OnAttack?.Invoke(entity); entity.TakeDamage(TotalDamage); _grid.EnqueueEvent(new GameEvent(GameEvent.EventType.DAMAGE_DEALT, this)); if (FreeAttacks > 0) { FreeAttacks -= 1; return(false); } return(true); } return(false); }
public void Attack(CharacterStatsBin targetStats) { // if it's time to attack then attack if (attackCooldown <= 0f) { // delaying the animation StartCoroutine(DoDamage(targetStats, attackDelay)); // start the attack animation OnAttack?.Invoke(); // bigger is the attackspeed, smaller the cooldown is attackCooldown = 1f / attackSpeed; // still in combat InCombat = true; lastAttackTime = Time.time; } }
public void UseCard(Guid targetId, CardData card, Action callBack) { if (UnitState == UnitState.Exhausted) { UnitState = UnitState.Normal; OnExhausted?.Invoke(this, callBack); return; } // Temp if (card.Name == "Tail Attack") { Debug.LogWarning("Tail attack!!!!!"); UnitState = UnitState.Exhausted; } // var cf = new CardFactory(); // var act = cf.GetAction(card.CardClass); isInAction = true; var target = GameObject.Find(targetId.ToString()).GetComponent <UnitManager>(); var args = new CardArgs(this, target, card, callBack); switch (card.CardClass) { case CardClass.Damage: OnAttack?.Invoke(this, args); break; case CardClass.Heal: this.HP += card.Amount; if (this.HP >= UnitData.HP) { this.HP = UnitData.HP; } OnGetHeal?.Invoke(this, args); break; default: break; } }
private void OnCollisionEnter2D(Collision2D other) { GameObject otherGameObject = other.gameObject; if ((1 << otherGameObject.layer & attackTargetLayer) == 0) { return; // return if the other game object is not in the layer } CombatEntity otherCombatEntity = otherGameObject.GetComponent <CombatEntity>(); if (otherCombatEntity == null) { return; // return if the other game object does not have a `CombatEntity` component } // This method will be called on the other side (other `CombatEntity`), too. // Therefore, there is no need to call `GetAttacked` of the other one here. rigidBody.AddForce(other.relativeVelocity.normalized * settings.pushBackForce, ForceMode2D.Impulse); GetAttacked(otherCombatEntity.CurrentAttack); onAttack.Invoke(other, this, otherCombatEntity); }
public void Attack(Container target) { if (target == null) { throw new ArgumentNullException(nameof(target)); } Destroyable destr; if ((destr = target.GetComponent <Destroyable>()) == null) { throw new ArgumentException("target have'nt Destroyable component"); } if (OnAttack != null) { OnAttack.Invoke(new SessionChange()); //TODO } int attackPower = this.attackPower; destr.DeltaHealth(-attackPower); }
public void Attack(Container target) { if (target == null) { throw new ArgumentNullException(nameof(target)); } if (target.Owner == Container.Owner) { throw new ArgumentException("One team players"); } Destroyable destr; if ((destr = target.GetComponent <Destroyable>()) == null) { throw new ArgumentException("target have'nt Destroyable component"); } if (OnAttack != null) { OnAttack.Invoke(new SessionChange("Attacks ", Container.ID)); } destr.DeltaHealth(-attackPower); }