private void onCollision(ref FixtureProxy fixture1, ref FixtureProxy fixture2) { if (Collided != null) { Collided.Invoke(this, new PhysicsCollideEventArgs(naturalBodies[clippedBodies.IndexOf(fixture1.Fixture.Body)], naturalBodies[clippedBodies.IndexOf(fixture2.Fixture.Body)])); } }
private void CheckCollisions() { // Если танк столкнулся с препятствием на местности, инициируем событие столкновения foreach (Entity entity in _terrain) { if (sprite.Position == entity.Position) { Collided?.Invoke(this, new CollideEventArgs(entity)); } } // Если танк столкнулся с другим танком (исключая себя), инициируем событие столкновения foreach (Tank tank in _tanks) { if (sprite.Position == tank.sprite.Position && tank != this) { Collided?.Invoke(this, new CollideEventArgs(tank)); } } // Если танк вышел за пределы карты, инициируем событие if (sprite.Position.X > Utilities.GetInstance().TILE_SIZE *Utilities.GetInstance().WIDTH_TILE_COUNT || sprite.Position.X < 0 || sprite.Position.Y > Utilities.GetInstance().TILE_SIZE *Utilities.GetInstance().HEIGHT_TILE_COUNT || sprite.Position.Y < 0) { MapLeft?.Invoke(this, new MapLeftEventArgs()); } }
public void OnCollision(object sender, OnCollisionEventArgs e) { if (dangerous) { Collided?.Invoke(this, e); } }
public void Invoke(string arguments = "") { if (running) { return; } running = true; Collided?.Invoke(this, arguments); }
private void OnCollisionEnter(Collision other) { collisions++; Behavior.End(this); if (collisions <= 1) { Collided?.Invoke(this, new ProjectileCollisionEventArgs(other.gameObject.GetInstanceID(), projectileData.Value)); } }
public void HashTable_InsertCollidedItems_ShouldBeChained() { var table = new HashTable<Collided, string>(); var key = new Collided(); table.Add(key, "first"); table.Add(key, "second"); }
public void ClearEvents() { if (Collided == null) { return; } foreach (Delegate d in Collided.GetInvocationList()) { Collided -= (OnVoxelCollision)d; } }
public void Update(ElapsedTime elapsedTime) { if (!Enabled || Unphysical || IsFreeze || Parent.IsFreeze) { return; } int i = 0; while (i < CollisionDepth && _colliderManager.ResolveOneCollision(this, out Collision collision)) { Colliding?.Invoke(collision); ParentNode.Position += collision.Correction; Collided?.Invoke(collision); i++; } }
public virtual bool OnCollision() { if (InputManager.MousePosition.Y > screenPosition.Y + Offset.Y && InputManager.MousePosition.X > screenPosition.X + Offset.X && (InputManager.MousePosition.Y < screenPosition.Y + Offset.Y + dimensions.Y && InputManager.MousePosition.X < screenPosition.X + Offset.X + dimensions.X)) { Collided?.Invoke(this, EventArgs.Empty); Selected?.Invoke(this, EventArgs.Empty); IsSelected = true; return(true); } else { IsSelected = false; } return(false); }
private void Update() { if (_isActive) { var overlapCount = Physics.OverlapBoxNonAlloc( _transform.position + bounds.Extents, bounds.Offset / 2, _colliders, _transform.rotation, LayerMask.GetMask("VoxelVolume") ); if (overlapCount > 0) { Collided?.Invoke(_colliders[0]); } _transform.position = _transform.position + (Vector3.down * 15) * Time.deltaTime; } }
private void OnCollision(Vector2 lastValidPosition) { Collided?.Invoke(this, new CollisionEventArgs(lastValidPosition)); }
public void FireCollided(object sender, BlockCollisionEventArgs e) { Collided?.Invoke(sender, e); }
public void OnCollided(CollisionArgs args) { Collided?.Invoke(this, args); }
private void Collide(Collider other) { Collided.Invoke(other.gameObject); }
/// <summary> /// Kutsutaan kun törmätään. /// </summary> internal void OnCollided(IPhysicsObject part, IPhysicsObject target) { Collided?.Invoke(this, target); }
public Enemy(string enemyName, Texture2D t, Vector2 iPos, float enemyHealth, float enemyDamage, float enemySpeed, float drawDepth) { tex = t; attackPlayerLock = new object(); collidedLock = new object(); AIenabled = true; name = enemyName; depth = drawDepth; animationFrame = new Print((int)(Irbis.Irbis.font.charHeight * 2f * Irbis.Irbis.textScale), Irbis.Irbis.font, Color.White, true, Point.Zero, Direction.Left, drawDepth + 0.001f); climbablePixels = 3; position = iPos; direction = Direction.Forward; location = Location.Air; activity = Activity.Idle; AIactivity = AI.Wander; wanderSpeed = (2f / 3f) * enemySpeed; wanderTime = 0f; previouslyWandered = false; speed = defaultSpeed = enemySpeed; jumpTime = 0; jumpTimeMax = 0.06f; animationNoLoop = false; standardCollider = new Rectangle(22, 19, 19, 43); position -= standardCollider.Location.ToVector2(); maxHealth = health = enemyHealth; lastHitByAttackID = -1; stunned = 0; speedModifier = 1f; attackCollider = Rectangle.Empty; attackColliderWidth = 30; attackColliderHeight = 30; attackID = attackIDtracker = 0; lastAttackID = -1; attackDamage = 0f; attack1Damage = enemyDamage; attackCooldown = 2f; //how quickly enemies can attack attackCooldownTimer = 3f; combatCheckDistanceSqr = attackColliderWidth * attackColliderWidth; persueCheckDistanceSqr = 40000; combat = false; activeEffects = new List <Enchant>(); shockwaveStunTime = Irbis.Irbis.jamie.shockwaveStunTime; shockwaveKnockback = Irbis.Irbis.jamie.shockwaveKnockback; displayRect = new Rectangle((int)Position.X, (int)Position.Y, 128, 128); animationSourceRect = new Rectangle(0, 0, 64, 64); currentFrame = 0; currentAnimation = 0; animationSpeed[0] = 0.1f; for (int i = 1; i < 20; i++) { animationSpeed[i] = animationSpeed[0]; } animationFrames[0] = 2; //idleforward1 animationFrames[1] = 4; //idleforward2 animationFrames[2] = 2; //idleforward3 animationFrames[3] = 2; //idleleft animationFrames[4] = 2; //idleright animationFrames[5] = 2; //runleft animationFrames[6] = 2; //runright animationFrames[7] = 2; //jumpleft animationFrames[8] = 2; //jumpright //animationFrames[9] = 2; //fallleft //animationFrames[10] = 2; //fallright animationSourceRect = new Rectangle(64 * currentFrame, 64 * currentAnimation, 64, 64); collided = new Collided(); Irbis.Irbis.jamie.OnPlayerAttack += Enemy_OnPlayerAttack; Irbis.Irbis.jamie.OnPlayerShockwave += Enemy_OnPlayerShockwave; }
/// <summary> /// Used to play crash sound and cause player damage when colliding /// </summary> /// <param name="other">Other.</param> protected virtual void OnCollisionEnter(Collision other) { if (CrashSound != null) { if (other.gameObject.layer != LayerMask.NameToLayer("Ground")) { //----- Player health / collision code ----- if (other.gameObject.layer == LayerMask.NameToLayer("Actors") && !ActorHandled) { value = Collided.Actor; if (_soundManager != null) { _soundManager.PlaySound(CrashSound, transform.position, true); } //Debug.Log("Collided with an actor"); StartCoroutine(ActorCollided(0.5f)); //Have to use a coroutine to prevent the player from taking excess damage } else if (other.gameObject.layer == LayerMask.NameToLayer("Collideables") && !ActorHandled) { //Debug.Log("Collided with a collideable"); if (other.gameObject.tag != "PitStop") { if (_soundManager != null) { _soundManager.PlaySound(ExplosionSound, transform.position, true); } Destroy(other.gameObject, .1f); GameObject expl = Instantiate(Explosion, other.transform.position, other.transform.rotation); Destroy(expl, 2); } switch (other.gameObject.tag) { case "Tree": value = Collided.Tree; //Debug.Log("Collided with a tree"); break; case "Rock": value = Collided.Rock; //Debug.Log("Collided with a rock"); break; case "Building": value = Collided.Building; //Debug.Log("Collided with a building"); break; case "Bullet": value = Collided.Bullet; break; case "PitStop": value = Collided.PitStop; break; default: break; } StartCoroutine(ActorCollided(0.5f)); } } } }
static LocalVehicle() { Screen = new Screen(); HUD = new HUD(); Events.Car.PreExplode.SubscribeAll((sender, data) => { BeforeExploded?.Invoke(null, System.EventArgs.Empty); }); Events.Car.PreSplit.SubscribeAll((sender, data) => { BeforeSplit?.Invoke(null, System.EventArgs.Empty); }); Events.Car.CheckpointHit.SubscribeAll((sender, data) => { if (sender.GetComponent <PlayerDataLocal>()) { var eventArgs = new CheckpointHitEventArgs(data.checkpointIndex_, data.trackT_); CheckpointPassed?.Invoke(null, eventArgs); } }); Events.Car.Death.SubscribeAll((sender, data) => { if (sender.GetComponent <PlayerDataLocal>()) { var eventArgs = new DestroyedEventArgs((DestructionCause)data.causeOfDeath); Destroyed?.Invoke(null, eventArgs); } }); Events.Car.Explode.SubscribeAll((sender, data) => { if (sender.GetComponent <PlayerDataLocal>()) { var eventArgs = new DestroyedEventArgs((DestructionCause)data.causeOfDeath); Exploded?.Invoke(null, eventArgs); } }); Events.RaceEnd.LocalCarHitFinish.Subscribe(data => { BeforeFinished?.Invoke(null, System.EventArgs.Empty); }); Events.Player.Finished.SubscribeAll((sender, data) => { if (sender.GetComponent <PlayerDataLocal>() != null) { var eventArgs = new FinishedEventArgs((RaceEndType)data.finishType_, data.finishData_); Finished?.Invoke(null, eventArgs); } }); Events.Car.Horn.SubscribeAll((sender, data) => { if (sender.GetComponent <PlayerDataLocal>()) { var eventArgs = new HonkEventArgs(data.hornPercent_, new Position(data.position_.x, data.position_.y, data.position_.z)); Honked?.Invoke(null, eventArgs); } }); Events.Car.Impact.SubscribeAll((sender, data) => { if (sender.GetComponent <PlayerDataLocal>()) { var eventArgs = new ImpactEventArgs(data.speed_, new Position(data.pos_.x, data.pos_.y, data.pos_.z), data.impactedCollider_.name); Collided?.Invoke(null, eventArgs); } }); Events.Car.Jump.SubscribeAll((sender, data) => { if (sender.GetComponent <PlayerDataLocal>()) { Jumped?.Invoke(null, System.EventArgs.Empty); } }); Events.Car.ModeSpecial.SubscribeAll((sender, data) => { if (sender.GetComponent <PlayerDataLocal>()) { SpecialModeEvent?.Invoke(null, System.EventArgs.Empty); } }); Events.Player.CarRespawn.SubscribeAll((sender, data) => { if (sender.GetComponent <PlayerDataLocal>() != null) { var pos = new Position(data.position_.x, data.position_.y, data.position_.z); var rot = new Rotation(data.rotation_.x, data.rotation_.y, data.rotation_.z); var eventArgs = new RespawnEventArgs(pos, rot, data.fastRespawn_); Respawned?.Invoke(null, eventArgs); } }); Events.Car.Split.SubscribeAll((sender, data) => { if (sender.GetComponent <PlayerDataLocal>()) { var eventArgs = new SplitEventArgs(data.penetration, data.separationSpeed); Split?.Invoke(null, eventArgs); } }); Events.Car.TrickComplete.SubscribeAll((sender, data) => { if (sender.GetComponent <PlayerDataLocal>()) { var eventArgs = new TrickCompleteEventArgs(data.cooldownAmount_, data.points_, data.wallRideMeters_, data.ceilingRideMeters_, data.grindMeters_); TrickCompleted?.Invoke(null, eventArgs); } }); Events.Car.WingsStateChange.SubscribeAll((sender, data) => { if (sender.GetComponent <PlayerDataLocal>()) { if (data.open_) { WingsOpened?.Invoke(null, System.EventArgs.Empty); } else { WingsClosed?.Invoke(null, System.EventArgs.Empty); } } }); Events.Car.WingsAbilityStateChanged.SubscribeAll((sender, data) => { if (sender.GetComponent <PlayerDataLocal>()) { if (data.enabled_) { WingsEnabled?.Invoke(null, System.EventArgs.Empty); } else { WingsDisabled?.Invoke(null, System.EventArgs.Empty); } } }); }