private void DestroySelf() { DestroyEntity destroyEntityEvent = DestroyEntity.Create(); destroyEntityEvent.Entity = entity; destroyEntityEvent.Send(); }
IEnumerator SelfDestruct(float wallDuration) { yield return(new WaitForSeconds(wallDuration)); DestroyEntity destroyEntityEvent = DestroyEntity.Create(); destroyEntityEvent.Entity = GetComponent <BoltEntity>(); destroyEntityEvent.Send(); }
private IEnumerator DestroyAfterXSeconds(float x) { yield return(new WaitForSeconds(x)); DestroyEntity destroyEntityEvent = DestroyEntity.Create(); destroyEntityEvent.Entity = entity; destroyEntityEvent.Send(); }
/* * private void OnTriggerEnter(Collider other) * { * if (BoltNetwork.IsServer && entity.isAttached) * { * if (other.gameObject.CompareTag(Constants.Tag.ItemCollisionHitBox)) // It is an item collision * { * var itemCollisionTrigger = other.GetComponent<ItemCollisionTrigger>(); * * if (itemCollisionTrigger.ItemCollision.HitsPlayer) // It is an item that damages the player * { * BoltEntity itemEntity = other.GetComponentInParent<BoltEntity>(); * Ownership itemOwnership = itemEntity.GetComponent<Ownership>(); * * if (itemEntity.isAttached) // It is a concrete item & it is attached * { * // Hit Ourself * // if (itemState.OwnerID == state.OwnerID) * // { * // if (itemCollisionTrigger.ItemCollision.ItemName == ItemCollisionName.Disk) * // { * // if (other.GetComponentInParent<DiskBehaviour>().CanHitOwner) * // { * // if (!_health.IsInvincible) // The server checks that this kart is not invincible * // { * // SendPlayerHitEvent(itemState); * // } * // DestroyColliderObject(other); * // } * // } * // } * * if ((int)itemOwnership.Team != state.Team) * { * if (!_health.IsInvincible) // The server checks that this kart is not invincible * { * SendPlayerHitEvent(itemOwnership); * } * DestroyColliderObject(other); * } * } * } * } * } * } */ private void DestroyColliderObject(Collider other) { var otherItemCollision = other.GetComponent <ItemCollisionTrigger>().ItemCollision; if (otherItemCollision.ShouldBeDestroyed(_itemCollision) && otherItemCollision.ItemName != ItemCollisionName.IonBeamLaser) // The item should be destroyed { DestroyEntity destroyEntityEvent = DestroyEntity.Create(); destroyEntityEvent.Entity = other.GetComponentInParent <BoltEntity>(); destroyEntityEvent.Send(); } }
//PRIVATE private void OnTriggerEnter(Collider other) { if (BoltNetwork.IsServer) { if (other.gameObject.CompareTag(Constants.Tag.ItemCollisionHitBox)) // It is an item collision { if (other.GetComponentInParent <NetworkDestroyable>()) { var itemNetworkDestroyable = other.GetComponentInParent <NetworkDestroyable>(); itemNetworkDestroyable.DestroyObject(); } StopAllCoroutines(); DestroyEntity destroyEntityEvent = DestroyEntity.Create(); destroyEntityEvent.Entity = GetComponent <BoltEntity>(); destroyEntityEvent.Send(); } } }
public void DestroyObject(float timeBeforeDestroy = 0f) { if (BoltNetwork.IsConnected && entity.isAttached && BoltNetwork.IsServer) { if (timeBeforeDestroy != 0) { StartCoroutine(DestroyAfterXSeconds(timeBeforeDestroy)); } else { DestroyEntity destroyEntityEvent = DestroyEntity.Create(); destroyEntityEvent.Entity = entity; destroyEntityEvent.Send(); } } else if (!BoltNetwork.IsConnected) { MonoBehaviour.Destroy(gameObject, timeBeforeDestroy); } }
//PRIVATE private void OnCollisionEnter(Collision collision) { if (BoltNetwork.IsServer) { if (collision.gameObject.layer == LayerMask.NameToLayer(Constants.Layer.Ground)) { CanHitOwner = true; Vector3 contactPoint = collision.contacts[0].point; CollisionParticles.transform.position = contactPoint; CollisionParticles.Emit(ParticlesToEmit); ReboundsBeforeEnd--; PlayCollisionSound(); if (ReboundsBeforeEnd <= 0) { DestroyEntity destroyEntityEvent = DestroyEntity.Create(); destroyEntityEvent.Entity = entity; destroyEntityEvent.Send(); } } } }
private IEnumerator LaserDuration(float duration) { yield return(new WaitForSeconds(_laserSettings.CollisionDuration)); if (_laserCollider) { _laserCollider.enabled = false; } yield return(new WaitForSeconds(_laserSettings.FlashDuration)); if (_laserRenderer) { _laserRenderer.enabled = false; } // if (_laserColliderBack) // _laserColliderBack.enabled = false; yield return(new WaitForSeconds(duration)); DestroyEntity destroyEntityEvent = DestroyEntity.Create(); destroyEntityEvent.Entity = entity; destroyEntityEvent.Send(); }