public BepuBody(Entity realBody) { RealBody = realBody; RealBody.Tag = -1; RealBody.BecomeDynamic((float)_mass); //RealBody.CollisionInformation.LocalPosition = new Vector3(0, 0, -10); //center of mass? BepuEntityCollidableToBepuBody.Add(realBody.CollisionInformation, this); //TODO. fix after new bodies. /* RealBody.CollisionInformation.Events.InitialCollisionDetected += (thisBody, other, x)=> { if (other is EntityCollidable) Body.RaiseCollisionEvent(BepuEntityCollidableToBepuBody[other as EntityCollidable].Body); };*/ //IsStatic = false; }
public void tankCollision(Entity sender, Entity other, CollisionPair pair) { var enemy = other.Tag as TriangleMesh; if (enemy != null) { // Terrain was hit! } var enemy2 = other.Tag as Player; // Player tank was was hit! if (enemy2 != null) { if (!enemy2.EnemyCollision) enemy2.tank.Velocity = -enemy2.tank.Velocity; enemy2.EnemyCollision = true; } var enemy3 = other.Tag as Enemy; if (enemy3 != null) { } // Enemy was hit var enemy4 = other.Tag as Wall; if (enemy4 != null && (other.IsDynamic == false)) other.BecomeDynamic(1f); }
/// <summary> /// Handles what happens when an entity enters the wall's hit volume. /// If it's an enemy, boom!! /// </summary> /// <param name="toucher">Entity touching the volume.</param> /// <param name="volume">Volume being touched.</param> public void EntityEntersVolume(Entity sender, Entity other, CollisionPair pair) { var enemy = other.Tag as TriangleMesh; if (enemy != null) { // Terrain was hit! } var enemy2 = other.Tag as Player; if (enemy2 != null) { if (enemy2.Life < 100) // Player tank caught heath package! { space.Remove(body); game.Components.Remove(this); Random rand = new Random(0); ; enemy2.Life = Math.Min(100, enemy2.Life + (int)((float)rand.NextDouble() * 30f + 20f) ); } } var enemy3 = other.Tag as Enemy; if (enemy3 != null) // Enemy caught heath package! { if (enemy3.Life < 150) { space.Remove(body); game.Components.Remove(this); Random rand = new Random(0); enemy3.Life = Math.Min(150, enemy3.Life + Math.Min(150, enemy3.Life + (int)((float)rand.NextDouble() * 30f + 30f))); } } var enemy4 = other.Tag as Wall; if (enemy4 != null && (other.IsDynamic == false)) other.BecomeDynamic(1f); var enemy5 = other.Tag as Building; if (enemy5 != null) { } // Church was hit, not nice }
public void tankCollision(Entity sender, Entity other, CollisionPair pair) { var enemy = other.Tag as TriangleMesh; if (enemy != null) { // Terrain was hit! } var enemy2 = other.Tag as Player; if (enemy2 != null) { // Player tank was was hit! } var enemy3 = other.Tag as Enemy; if (enemy3 != null) { if (!player.EnemyCollision) player.tank.Velocity = -player.tank.Velocity; player.EnemyCollision = true; } // Enemy was hit var enemy4 = other.Tag as Wall; if (enemy4 != null && (other.IsDynamic == false)) other.BecomeDynamic(1f); var enemy5 = other.Tag as Building; if (enemy5 != null) { if (!player.EnemyCollision) player.tank.Velocity = -player.tank.Velocity; player.EnemyCollision = true; } var enemy6 = other.Tag as HardWall; if (enemy6 != null) { if (!player.EnemyCollision) player.tank.Velocity = -player.tank.Velocity; player.EnemyCollision = true; } }