public void HitEffectTaken(HitTrigger hitTrigger, HitTargetEffect targetEffect) { foreach (var effect in takeHitEffects) { effect.HitEffectTaken(this, hitTrigger, targetEffect); } }
public void HitTaken(HitTrigger hitTrigger) { foreach (var effect in takeHitEffects) { effect.HitTaken(this, hitTrigger); } }
private void SwapWeapon() { GameObject obj; if (isLeft) { obj = bruce.GetLNextWeapon(); } else { obj = bruce.GetRNextWeapon(); } if (null != currentWeapon) { currentWeapon.GetComponent <HitTrigger>().OnDrop(trackedObj, GetComponent <FixedJoint>()); } currentWeapon = Instantiate(obj); var rig = GetComponent <Rigidbody>(); HitTrigger hittrigger = currentWeapon.GetComponent <HitTrigger>(); if (hittrigger.IsUsingJoint) { currentWeapon.transform.position = rig.transform.position; currentWeapon.transform.rotation = rig.transform.rotation; hittrigger.OnPickUp(trackedObj, GetComponent <FixedJoint>()); } else { //hittrigger.transform.parent = transform; hittrigger.transform.SetParent(transform, false); hittrigger.OnPickUp(trackedObj, GetComponent <FixedJoint>()); } }
public override void HitTaken(HitTarget target, HitTrigger trigger) { if (target.HP <= 0) { var scrap = GameObject.Instantiate(scrapPrefabs.PickRandom <CollectableScrap>(), target.transform.position, Random.rotation); scrap.rigidbody.AddForce(scrap.rigidbody.velocity + Random.onUnitSphere * randomVelocity, ForceMode.VelocityChange); scrap.rigidbody.AddTorque(3 * Random.onUnitSphere, ForceMode.VelocityChange); } }
public override void HitTaken(HitTarget target, HitTrigger trigger) { if (trigger.source != null) { var playerMotor = trigger.source.GetComponent <PlayerMotor>(); if (playerMotor != null) { playerMotor.FillSteam(2); } } }
/// <summary> /// 当物体进入被击 /// </summary> public void OnColliderHit(HitTrigger rCol) { rCol.mParent.SetState(eState.Hit); rCol.SetColActive(false); if (OnHitEvent != null) { OnHitEvent(rCol); } }
public void TakeDamage(int damage, HitTrigger hitTrigger = null) { HP = HP - damage; if (HP <= 0) { Kill(hitTrigger); } else if (hurtSound != null) { hurtSound.Play(transform.position); } }
public override void Hit(HitTrigger trigger, HitTarget target) { if (trigger.source != null) { var rigidbody = trigger.source.GetComponent <Rigidbody>(); if (rigidbody != null) { var bouncedVelocity = rigidbody.velocity; bouncedVelocity.y = Mathf.Abs(bouncedVelocity.y) + bouncedVelocity.magnitude / 3; rigidbody.velocity = bouncedVelocity; } } }
public void Kill(HitTrigger hitTrigger = null) { if (deathSound != null) { deathSound.Play(transform.position); } if (sliceable != null) { sliceable.SliceAndDestroy(hitTrigger); } else { Destroy(gameObject); } }
public override void Hit(HitTrigger trigger, HitTarget target) { var scrapComponent = trigger.GetComponent <CollectableScrap>(); if (scrapComponent == null) { trigger.Destroy(); } var playerMotor = target.GetComponent <PlayerMotor>(); if (playerMotor != null) { playerMotor.scrap.Value += scrap; playerMotor.AddSteam(1); if (pickupSound != null) { pickupSound.Play(target.transform.position); } trigger.Destroy(); } }
public void SliceAndDestroy(HitTrigger hitTrigger = null) { GameObject objectToSlice = new GameObject(); objectToSlice.transform.position = transform.position; objectToSlice.transform.rotation = transform.rotation; var meshFilter = objectToSlice.AddComponent <MeshFilter>(); var meshRenderer = objectToSlice.AddComponent <MeshRenderer>(); if (skinnedMeshRenderer) { Mesh mesh = new Mesh(); skinnedMeshRenderer.BakeMesh(mesh); meshFilter.sharedMesh = mesh; meshRenderer.sharedMaterial = skinnedMeshRenderer.sharedMaterial; } else if (GetComponent <MeshRenderer>()) { meshRenderer.sharedMaterial = GetComponent <MeshRenderer>().sharedMaterial; meshFilter.sharedMesh = GetComponent <MeshFilter>().sharedMesh; objectToSlice.transform.localScale = transform.localScale; } else { Debug.Log("Error>> No MeshRenderer or SkinnedMeshRenderer on DestroyableObject" + gameObject); Destroy(); return; } var meshCollider = objectToSlice.AddComponent <MeshCollider>(); meshCollider.convex = true; SliceInternal(objectToSlice, 2, new Vector3(Random.value, Random.value, Random.value), hullMaterial, hitTrigger); Destroy(); }
// called once after all hit effects are processed public virtual void HitTaken(HitTarget target, HitTrigger trigger) { }
// called after each hit effect is processed on this target public virtual void HitEffectTaken(HitTarget target, HitTrigger trigger, HitTargetEffect targetEffect) { }
public virtual void Hit(HitTrigger trigger, Rigidbody rigidbody) { }
public override void Hit(HitTrigger trigger, HitTarget target) { target.TakeDamage(damage, trigger); }
private void SliceInternal(GameObject o, int recurse, Vector3 direction, Material crossSectionMat, HitTrigger hitTrigger = null) { var center = o.transform.position; var collider = o.GetComponent <Collider>(); if (collider) { center = collider.bounds.center; } var slicedObjects = o.SliceInstantiate( center, direction, crossSectionMat); if (slicedObjects != null) { Destroy(o); foreach (var sliced in slicedObjects) { sliced.transform.position = transform.position; sliced.transform.rotation = transform.rotation * Quaternion.Euler(0, -90, 0); // because the mesh was baked from the scaled skinnedMeshRenderer, we don't need to scale it sliced.transform.localScale = Vector3.one; if (recurse > 0) { SliceInternal(sliced, recurse - 1, new Vector3(Random.value, Random.value, Random.value), crossSectionMat, hitTrigger); Destroy(sliced.gameObject); } else { sliced.layer = LayerManager.I.EffectMask.ToLayer(); var hitRigidbody = sliced.AddComponent <Rigidbody>(); var meshCollider = sliced.AddComponent <MeshCollider>(); meshCollider.convex = true; sliced.AddComponent <Debris>(); if (hitTrigger != null) { foreach (var effect in hitTrigger.hitRigidbodyEffects) { effect.Hit(hitTrigger, hitRigidbody); } } } } } }
public override void Hit(HitTrigger trigger, Rigidbody target) { target.AddForce(trigger.transform.forward * velocityChange + Vector3.up * upwardsModifier + Random.onUnitSphere * 5, ForceMode.VelocityChange); }
public override void Hit(HitTrigger trigger, HitTarget target) { target.HP += heal; }
public virtual void Hit(HitTrigger trigger, HitTarget target) { }