void Update() { RaycastHit hit; if (lineRenderer.useWorldSpace) { endPoint = transform.position + transform.forward * maxLength; if (Physics.Raycast(transform.position, transform.forward, out hit, maxLength)) { endPoint = hit.point; onHit.Invoke(hit); } lineRenderer.SetPosition(0, transform.position); lineRenderer.SetPosition(1, endPoint); } else { endPoint = transform.forward * maxLength; if (Physics.Raycast(transform.position, transform.forward, out hit, maxLength)) { endPoint = transform.InverseTransformPoint(hit.point); onHit.Invoke(hit); } lineRenderer.SetPosition(1, endPoint); } onLengthChange.Invoke(endPoint); }
public void HitByExplotion(int playerIndex, Vector2 pos) { if (OnHit != null) { OnHit.Invoke(ConvertUnits.ToDisplayUnits(pos), 5, model.damagePoints, playerIndex, model.playerIndex, null); } }
void OnCollisionEnter2D(Collision2D collision) { if (collision.collider.GetComponent <Killer>().active == true) { OnHit.Invoke(); } }
/// <summary> /// When player get's hit. Called from a Bullet. /// </summary> /// <param name="damage">The damage.</param> /// <param name="hitFrom">The hit from.</param> public void Hit(float damage, float hitFrom, Player killedBy) { this.health -= damage; pulseRed = true; pulseRedTime = 0.0f; gotHitFrom = hitFrom; hitSound.Play(); if (OnHit != null) { OnHit.Invoke(this, new EventArgs()); } if (this.health <= 0) { if (killedBy != null) { OnKilled(killedBy); } else { OnKilled(); } } }
public void Damage(Vector3 pos, AttackData attackData) { if (isDead == true) return; DamageMessage msg = attackData.AttackProcessor.ProcessAttack(attackData.AttackDataStat, characterStatController); msg.SetDamagePosition(pos); if (OnHit != null) OnHit.Invoke(msg); shakeSprite.Shake(0.05f, 0.2f); if (characterStatController.Hp <= 0) { //Death(attackData); Destroy(this.gameObject); return; } float hpMax = characterStatController.GetHPMax(); for (int i = 0; i < healthPercentage.Length; i++) { if ((characterStatController.Hp / hpMax) >= healthPercentage[i]) { objectAtHealth[i].gameObject.SetActive(true); return; } else { objectAtHealth[i].gameObject.SetActive(false); } } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("SwipeTrail")) { Direction swipeDirection = CheckCollisionDirection(collision.transform.position); if (swipeDirection != Direction.Null) { if (ShieldHit != null) { ShieldHit.Invoke(); } StartCoroutine(Disable(.2f)); if (checkShield) { Time.timeScale = 0; col = collision.gameObject; } } } else if (collision.CompareTag("UpperBorder")) { transform.parent.GetComponent <Block>().Hit(false); } }
public void ApplyDamage(DamageMessage data) { if (currentHitPoints <= 0) { return; } if (isInvulnerable) { return; } isInvulnerable = true; currentHitPoints -= data.amount; if (currentHitPoints <= 0) { myEvent += OnDeath.Invoke; } else { OnHit.Invoke(); } var messageType = currentHitPoints <= 0 ? MessageType.DEAD : MessageType.DAMAGED; for (var i = 0; i < onDamageMessageReceivers.Count; ++i) { var receiver = onDamageMessageReceivers[i] as IMessageReceiver; receiver.OnReceiveMessage(messageType, this, data); } }
public virtual void Hit(RaycastHit hit, ProjectileBehaviour projectile) { if (OnHit != null) { OnHit.Invoke(hit); } }
public void Hit(HitInfo _hitInfo) { if (onHit != null) { onHit.Invoke(_hitInfo); } }
public void CheckIfhit() { if (GetComponent <TargetSelector>().hitBoxCollider&& tappable) { stockUp.Invoke(); tappable = false; } }
void OnTriggerEnter(Collider other) { if (other.CompareTag("Enemy")) { OnPlayerHit.Invoke(other); } else if (other.CompareTag("Pickup")) { OnItemPickup(other.GetComponent <ItemPickup>().CollectItem()); } }
private void OnTriggerEnter(Collider other) { var projectileController = other.GetComponent <ProjectileController>(); if (projectileController) { var dmg = projectileController.Damage; OnHit.Invoke(); OnDamageReceived.Invoke(dmg); executor.Hurt((uint)dmg); } }
public void OnWeakenedHit() { Hits++; if (Hits > 0) { OnHit.Invoke(Hits); anim.SetTrigger("Hit"); } if (Hits == 3) { DestructionBits.Play(this.gameObject.transform.position); } }
protected override void Update() { base.Update(); if (healthManager.hp != previousHP && healthManager.hp < previousHP) { int damage = previousHP - healthManager.hp; if (damage >= ignoreDamageDeltaUnder) { if (OnHit != null) { OnHit.Invoke(damage); } } } previousHP = healthManager.hp; }
public void Damage(Vector3 pos, AttackData attackData) { if (isDead == true) return; DamageMessage msg = attackData.AttackProcessor.ProcessAttack(attackData.AttackDataStat, characterStatController); msg.SetDamagePosition(pos); if (OnHit != null) OnHit.Invoke(msg); //shakeSprite.Shake(0.05f, 0.2f); if (characterStatController.Hp <= 0 || characterStatController.Scratch == characterStatController.Hp) { characterStatController.Hp = 0; Death(); //Destroy(this.gameObject); return; } }
void Tick(ref Vector3 position, ref Vector3 direction, ref float remainingDistance, ref int remainingBounces) { ray.origin = position; ray.direction = direction; Physics.Raycast(ray, out hit, remainingDistance, m_layer); //Debug.DrawRay(ray.origin, ray.direction, Color.cyan); if (hit.transform != null) { SolidMonoBehaviour hitObject = hit.collider.GetComponent <SolidMonoBehaviour>(); if (hitObject && OnHit != null) { OnHit.Invoke(hit, hitObject); gameObject.SetActive(false); } float angle = Vector3.Angle(-direction, hit.normal); //Debug.Log(angle); if (remainingBounces <= 0 || angle < 90 - m_bounceAngle) { gameObject.SetActive(false); return; } position = hit.point; direction = Vector3.Reflect(direction, hit.normal).normalized; remainingDistance -= hit.distance; prevPositions.Enqueue(position); //Debug.DrawLine(position, position + (direction * remainingDistance)); remainingBounces -= 1; Tick(ref position, ref direction, ref remainingDistance, ref remainingBounces); } else { position += direction * remainingDistance; } }
public void Damage(Vector3 pos, AttackData attackData) { if (isDead == true || isInvulnerable == true) return; /*if (characterAnimation.State == CharacterState.Dash) { OnInterrupt.Invoke(); }*/ DamageMessage msg = characterBodyPartController.Damage(attackData, characterMovement.CharacterDirection.DirectionTransform); //DamageMessage msg = attackData.AttackProcessor.ProcessAttack(attackData.AttackDataStat, characterStatController); msg.SetDamagePosition(pos); if (OnHit != null) OnHit.Invoke(msg); if(characterStatController.Hp <= 0) { Death(attackData); return; } if(msg.damageRaw + msg.damageScratch > 0) shakeSprite.Shake(0.05f, 0.2f); if(isInterruptable == true) { if (airborneClip != null) AudioManager.Instance.PlaySound(airborneClip); Knockback(); if(OnInterrupt != null) OnInterrupt.Invoke(); isInterruptable = false; } if (isKnockback == false && msg.knockback == true) Knockback(); else if (isKnockback == true) Knockback(); if (isKnockback == true && msg.launch == true) CheckLaunch(attackData); }
private void OnCollisionEnter(Collision collision) { // Return false if we can't be picked up at this moment if (picker != null && (PickableStates)currentState != PickableStates.Idle && (PickableStates)currentState != PickableStates.Thrown) { return; } picker = collision.gameObject.GetComponent <Picker>(); if (picker != null) { picker.TryPick(this); } else if ((PickableStates)currentState == PickableStates.Thrown) { OnHit.Invoke(this, collision.gameObject); currentState = PickableStates.Idle; } }
public IEnumerator ArrowFly(float startTime, Func <float, Vector3> trajectory) { bool hitted = false; float f = 0; if (OnShooted != null) { OnShooted.Invoke(); } HideBow(); while (f < 1f) { f = (Time.time - startTime) / FlyTimeout; var pos = trajectory(f); var future = trajectory(f + Time.deltaTime); var rel = future - pos; Arrow.position = pos; Arrow.rotation = Quaternion.LookRotation(rel); //Having hit half second before if (f > 0.95f && OnHit != null && !hitted) { OnHit.Invoke(); hitted = true; } yield return(null); } yield return(new WaitForSeconds(HitDelay)); ShowBow(); }
// Checks public override void OnDamaged(float damage) { if (!_boss.IsInvincible) { if (_boss.Health > damage) { _boss.SetHealth(_boss.Health - damage); AttackType = 0; _eraser.EraserWave(1.2f, 0.75f); _boss.IsInvincible = true; Invoke("Timer_InvincibleCool", 2.0f); CameraManager.Instance.ShakeCamera(1f, 0.1f); } else if (_boss.Health != 0) { _boss.SetHealth(0); _boss.IsDead = true; _eraser.EraserWave(3f, 0.25f); CameraManager.Instance.ShakeCamera(2f, 0.2f); } OnHit.Invoke(); } }
void OnTriggerEnter(Collider other) { if (IsInvalid(other)) { return; //Check Layers and Don't hit yourself } var Newenemy = other.GetComponentInParent <IMDamage>(); //Get the Animal on the Other collider if (!AlreadyHitted.Contains(other)) { AlreadyHitted.Add(other); //if the entering collider is not already on the list add it } Direction = (Owner.transform.position - other.bounds.center).normalized; //Calculate the direction of the attack TryInteract(other.gameObject); //Get the interactable on the Other collider TryPhysics(other.attachedRigidbody, other, Direction, Force); //If the other has a riggid body and it can be pushed if (enemy == Newenemy) { return; //if the animal is the same, do nothing we already in one of the Animal Colliders } else //Is a new Animal { if (enemy != null) { AlreadyHitted = new List <Collider>(); //Clean the colliders if you had a previus animal } enemy = Newenemy; //Get the Damager on the Other collider // enemyStats = other.GetComponentInParent<Stats>(); OnHit.Invoke(other.transform); TryDamage(enemy, statModifier); //if the other does'nt have the Damagable Interface dont send the Damagable stuff } }
private void pipeHit() { OnHit.Invoke(); setPosition(startPosition); transform.position = new Vector3(transform.position.x, pipeY + 0.5f, transform.position.z); }
private void Weapon_OnHit(IWeapon arg1, Projectile arg2, Collider arg3, Vector3 arg4, Vector3 arg5) { OnHit?.Invoke(arg1, arg2, arg3, arg4, arg5); }
public static void Hit(int damage) { OnHit?.Invoke(damage); }
private void OnTriggerEnter2D(Collider2D collider2D) { OscarRigidbody2D.bodyType = RigidbodyType2D.Static; SoundManager.PlaySound(SoundManager.Sound.Whine); OnHit?.Invoke(this, EventArgs.Empty); }
public void EventHit() { OnHit?.Invoke(); }
private void Hit() { setPosition(startPosition); OnHit.Invoke(); }
public void Hit(Hit type, Vector2 direction) { OnHit?.Invoke(type, direction); }
protected void RaiseOnHit(AttackPackage attack, AttackResult result) { OnHit?.Invoke(attack, result); _onHit.Invoke(); }
public void Hit() => OnHit?.Invoke();