private void OnRedirectedCollision(ProjectileHit projectileHit) { if ((hitMask.value & 1 << projectileHit.hitObject.layer) != 0 && projectileHit.hitObject != owner && !_collisionComplete) { _collisionComplete = true; ProcessCollision(projectileHit); } }
public virtual void OnHit(ProjectileHit proj) { health -= proj.damage; healthBar.value = health; if (health <= 0) { Dead(); } }
private void SpawnProjectile() { GameObject projectile = GameObject.Instantiate(arrowPrefab); projectile.transform.position = projectilePosition.transform.position; projectile.transform.rotation = projectilePosition.transform.rotation; ProjectileHit hit = projectile.GetComponent <ProjectileHit>(); hit.Host = host; hit.SetBounces(host.Stats.ProjectileBounces); }
private void OnBulletHit(ProjectileHit projectileHitInfo) { if (projectileHitInfo.hitObject) { DamageInfo damageInfo = new DamageInfo(); damageInfo.originPoint = projectileHitInfo.originPoint; damageInfo.impactPoint = projectileHitInfo.hitPoint; damageInfo.normal = projectileHitInfo.normal; damageInfo.damageDone = pointBlankDamage; projectileHitInfo.hitObject.SendMessage(GameMessages.TAKE_DAMAGE, damageInfo, SendMessageOptions.DontRequireReceiver); } }
void OnCollisionEnter2D(Collision2D collision) { if (tempIFrames == 0) { if (collision.gameObject.tag == "Projectile") { ProjectileHit tempProjectile = collision.gameObject.GetComponent <ProjectileHit>(); ChangeHealth(-tempProjectile.damage); tempIFrames = tempProjectile.iFrames; } } }
private void OnTriggerEnter(Collider other) { if ((hitMask.value & 1 << other.gameObject.layer) != 0 && other.gameObject != owner && !_collisionComplete) { _collisionComplete = true; ProjectileHit projectileHit = new ProjectileHit(); projectileHit.originObject = owner; projectileHit.originPoint = originPoint; projectileHit.hitObject = other.gameObject; projectileHit.hitObjectLayer = other.gameObject.layer; ProcessTriggerHit(ref projectileHit); ProcessCollision(projectileHit); } }
private void OnCollisionEnter(Collision other) { if ((hitMask.value & 1 << other.gameObject.layer) != 0 && other.gameObject != owner && !_collisionComplete) { _collisionComplete = true; ProjectileHit projectileHit = new ProjectileHit(); projectileHit.originObject = owner; projectileHit.originPoint = originPoint; projectileHit.hitObject = other.gameObject; projectileHit.hitObjectLayer = other.gameObject.layer; projectileHit.normal = other.contacts[0].normal; projectileHit.hitPoint = other.contacts[0].point; ProcessCollision(projectileHit); } }
private void Update() { Vector3 newPos = transform.position + Velocity * Time.deltaTime; Velocity += Physics.gravity * Time.deltaTime; if (Physics.Linecast(transform.position, newPos, out RaycastHit hit, CollisionMask)) { PoolObject.Despawn(PoolObject); if (HitEffect != null) { var eff = PoolObject.Spawn(HitEffect); eff.transform.position = hit.point + hit.normal * 0.01f; eff.transform.forward = -hit.normal; eff.transform.parent = hit.collider.transform; } if (HitParticles != null) { var eff = PoolObject.Spawn(HitParticles); eff.transform.position = hit.point + hit.normal * 0.01f; eff.transform.forward = -hit.normal; } var phit = new ProjectileHit() { WorldPoint = hit.point, WorldNormal = hit.normal, Collider = hit.collider, IncomingVelocity = Velocity, HealthChange = -Damage }; LastHit = hit.point; hit.transform.SendMessageUpwards("UponProjectileHit", phit, SendMessageOptions.DontRequireReceiver); if (hit.collider.attachedRigidbody != null) { hit.collider.attachedRigidbody.AddForceAtPosition(Velocity.normalized * HitImpulse, hit.point, ForceMode.Impulse); } }
void CheckCollisions(Collider2D collision) { if (tempIFrames == 0) { if (collision.gameObject.tag == "Enemy") { Enemy tempEnemy = collision.GetComponent <Enemy>(); ChangeHealth(-tempEnemy.damage); tempIFrames = iFrames; } if (collision.gameObject.tag == "EnemyProjectile") { ProjectileHit tempProjectile = collision.GetComponent <ProjectileHit>(); ChangeHealth(-tempProjectile.damage); tempIFrames = tempProjectile.iFrames; } } }
public void UponProjectileHit(ProjectileHit hit) { if (IsDead && !CanChangeHealthWhenDead) { return; } int old = HP; HP += hit.HealthChange; if (HP > MaxHP) { HP = MaxHP; } if (HP < 0) { HP = 0; } if (old != HP) { UponHealthChange?.Invoke(this, HP - old, hit); } }
void OnCollisionEnter(Collision collision) { ContactPoint contact = collision.contacts[0]; if (GameObjectPoolManager.Instance.ProjectileHitDict.ContainsKey(ProjectileInfo.ProjectileType)) { ProjectileHit hit = GameObjectPoolManager.Instance.ProjectileHitDict[ProjectileInfo.ProjectileType].AllocateGameObject <ProjectileHit>(ProjectileManager.Instance.transform); hit.transform.position = contact.point + contact.normal * hitOffset; hit.transform.rotation = Quaternion.FromToRotation(Vector3.up, contact.normal); if (UseFirePointRotation) { hit.transform.rotation = gameObject.transform.rotation * Quaternion.Euler(0, 180f, 0); } else if (rotationOffset != Vector3.zero) { hit.transform.rotation = Quaternion.Euler(rotationOffset); } else { hit.transform.LookAt(contact.point + contact.normal); } hit.ParticleSystem.Play(true); hit.PoolRecycle(hit.ParticleSystem.main.duration); } foreach (GameObject detachedPrefab in Detached) { if (detachedPrefab != null) { detachedPrefab.transform.parent = null; } } PoolRecycle(); }
public void Shoot(Vector3 facing, float spe, float dam, ProjectileHit hit) { hitType = hit; velocity = facing * spe; damage = dam; }
private void ProcessCollision(ProjectileHit projectileHit) { ProcessBulletHit(projectileHit); }
private void ProcessBulletHit(ProjectileHit projectileHit) { SendMessage(GameMessages.BULLET_HIT, projectileHit, SendMessageOptions.DontRequireReceiver); }
private void ProcessTriggerHit(ref ProjectileHit projectileHit) { projectileHit.hitPoint = projectileHit.hitObject.collider.ClosestPointOnBounds(transform.position); projectileHit.hitObject.SendMessage(GameMessages.PROJECTILE_TRIGGER_HIT, projectileHit, SendMessageOptions.DontRequireReceiver); }
public override void OnHit(ProjectileHit proj) { base.OnHit(proj); CanadianFury(); }
public void Add(ProjectileHit hit) => m_ProjectileHit.Add(hit);
public void SetCallbackObject(ProjectileHit ph) { callback = ph; }
private void UponProjectileHit(ProjectileHit hit) { PoolObject.Despawn(this.PoolObject); Debug.Log("Nice shot!"); }