private void NPC_OnTriggerEnter(object sender, CollisionArgs e) { if (e.CollisionObject.Name == "Noise") { if (e.CollisionObject.TeamId != teamId) { bool hidden = false; float distanceToNoise = Vector2.Distance(Center, e.CollisionObject.Center); Vector2 direction = Center - e.CollisionObject.Center; direction.Normalize(); Ray ray = new Ray(new Vector3(Center, 0), new Vector3(direction, 0)); for (int i = 0; i < collidables.Length; i++) { if (collidables[i] != player && collidables[i] != this) { float?distance = Helpers.Raycast2D(collidables[i].CollisionBox, ray); if (distance.HasValue && distance < distanceToNoise) { hidden = true; break; } } } if (!hidden) { lastKnownPosition = e.CollisionObject.Center; elapsedTimeSinceContact = 0f; } } } }
private void Player_OnTriggerEnter(object sender, CollisionArgs e) { if (e.CollisionObject is InteractivObject && e.CollisionObject.Name == "RescueZone") { if (hostagesGrabbed >= numberOfHostages) { hostagesRescued = true; Console.WriteLine("Hostages rescued!"); } } }
private void Player_OnCollisionEnter(object sender, CollisionArgs e) { if (e.CollisionObject is Character) { if (e.CollisionObject.Name == "Hostage") { hostagesGrabbed++; e.CollisionObject.Destroy(); } } }
private void KI_OnTriggerEnter(object sender, CollisionArgs e) { if (e.CollisionObject.Name == "Noise") { if (e.CollisionObject.TeamId != teamId) { lastKnownPosition = e.CollisionObject.Center; } elapsedTimeSinceContact = 0f; } }
private void Character_OnCollisionEnter(object sender, CollisionArgs e) { if (direction != Vector2.Zero) { Vector2 newPos = Position; if (direction.X != 0) { if (CollisionBox.X < e.CollisionObject.CollisionBox.X + e.CollisionObject.CollisionBox.Width && CollisionBox.X + CollisionBox.Width > e.CollisionObject.CollisionBox.X) { if (direction.X < 0) { newPos = new Vector2(e.CollisionObject.CollisionBox.X + e.CollisionObject.CollisionBox.Width, Position.Y); } else { newPos = new Vector2(e.CollisionObject.CollisionBox.X - CollisionBox.Width, Position.Y); } } } else if (direction.Y != 0) { if (CollisionBox.Y < e.CollisionObject.CollisionBox.Y + e.CollisionObject.CollisionBox.Height && CollisionBox.Y + CollisionBox.Height > e.CollisionObject.CollisionBox.Y) { if (direction.Y < 0) { newPos = new Vector2(Position.X, e.CollisionObject.CollisionBox.Y + e.CollisionObject.CollisionBox.Height); } else { newPos = new Vector2(Position.X, e.CollisionObject.CollisionBox.Y - CollisionBox.Height); } } } if (Position != newPos) { Position = newPos; } } }
private void Projectile_OnTriggerEnter(object sender, CollisionArgs e) { if (e.CollisionObject != Owner && e.CollisionObject.Blocking) { if (!rayCastShot) { DamageAbleObject health = e.CollisionObject.GetComponent <DamageAbleObject>(); if (health != null) { health.ChangeHealth(this, suspressed ? -suspressedDamage : -damage); } if (e.CollisionObject.Name != "Cover") { Destroy(); } else { crossedCover = true; } } } }