public virtual void ReceiveHit(bool instakill, int damage, HitBox.DAMAGE_TYPE damageType, HitBox attackerActor, Vector3 hitSourcePosition, Collider2D collider2d) { Vector3 hitDirection = Utils.GetHitDirection(hitSourcePosition, transform); // stun effect if (damageType == HitBox.DAMAGE_TYPE.STUN) { // Event for Victim if (actorController != null) { actorController.ReactDizzy(damage / 1000); // damage = stun time in milliseconds } return; } // water splash effect if (damageType == HitBox.DAMAGE_TYPE.WATER && instakill && collider2d != null) { float y = collider2d.bounds.center.y + collider2d.bounds.extents.y; Vector3 effectPosition = new Vector3(transform.position.x, y, transform.position.z); InstantiateEffect(prefabWaterSplash, hitDirection.x, effectPosition, collider2d.transform); } if (currentHealth > 0) { if (instakill) { //instakill boxCollider.enabled = false; } if (!hitInProgress || instakill) { // receive damage from attacker if (instakill) { ModifyHealth(-currentHealth); } else { ModifyHealth(-damage); } // Event for Attacker if (attackerActor) { attackerActor.ReactHit(); } // Event for Victim if (actorController != null) { actorController.ReactHurt(currentHealth <= 0, this.pushedOnHit, instakill, hitSourcePosition, damageType); } ExecuteEffects(collider2d, hitDirection, instakill, damage, damageType); } } }
public void ReactHurt(bool dead, bool push, bool instakill, Vector3 hitSource, HitBox.DAMAGE_TYPE damageType) { lastHit.push = push; lastHit.instakill = instakill; lastHit.hitSource = hitSource; lastHit.damageType = damageType; InterruptState(AbstractState.ACTION.HIT); }
public override void ReceiveHit(bool instakill, int damage, HitBox.DAMAGE_TYPE damageType, HitBox attackerActor, Vector3 hitSourcePosition, Collider2D collider2d) { base.ReceiveHit(instakill, damage, damageType, attackerActor, hitSourcePosition, collider2d); if (pos >= 0 && pos < hurtText.Length) { textBox.gameObject.SetActive(true); textBox.ShowTextBox(hurtText[pos]); pos++; StartCoroutine(DeactivateTextBox(pos)); } }
public void ReactHurt(bool dead, bool push, bool instakill, Vector3 hitSource, HitBox.DAMAGE_TYPE damageType) { // look up if hit animation present if (Utils.HasParameter("HIT", animator)) { EnemyAction hitAction = new EnemyAction(EnemyAction.ACTION_EVENT.HIT); if (push && !instakill) { hitAction.hitTarget = hitSource; } else { hitAction.hitTarget = Vector3.positiveInfinity; } lastDamageType = damageType; currentAction = hitAction; isInterruptAction = true; } }
public DyingState(HitBox.DAMAGE_TYPE damageType, PlayerController playerController) : base(ACTION.DEATH, playerController) { this.damageType = damageType; }
private void ExecuteEffects(Collider2D collider2d, Vector3 hitDirection, bool instakill, int damage, HitBox.DAMAGE_TYPE damageType) { if (currentHealth <= 0 && destroyOnDeathImmediate) { DeathAction(hitDirection.x); } Debug.Log("ExecuteHurtEffect!"); if (prefabHitEffect != null) { InstantiateEffect(prefabHitEffect, hitDirection.x, transform.position); } // Spawn Effect on hit if (currentHealth > 0 && lootController != null) { lootController.SpawnChildrenOnHit(); } if (flashOnHit && !instakill) { FlashSprite(flashTime); } if (hitTime > 0 || currentHealth <= 0) { hitInProgress = true; } if (currentHealth <= 0 && !destroyOnDeathImmediate) { StartCoroutine(CoroutineDeath(hitDirection.x, flashTime)); } if (hitTime > 0 && currentHealth > 0) { // enable next hit StartCoroutine(HitInProgress(hitTime)); } }
// for bypassing collider activation (mainly squish actions) public void ReceiveHit(bool instakill, int damage, HitBox.DAMAGE_TYPE damageType, Vector3 hitSourcePosition) { ReceiveHit(instakill, damage, damageType, null, hitSourcePosition, null); }