public override void OnHit(CollisionResult?result) { if (result.HasValue && result.Value.Collider.Entity is Truck) { (result.Value.Collider.Entity as Truck).Damage(damage); } }
public override void OnHit(CollisionResult?result) { // Death by timeout if (!result.HasValue) { Pool <BananaSmall> .Free(this); } }
public override void OnHit(CollisionResult?result) { base.OnHit(result); // Death by timeout if (!result.HasValue) { Pool <BananaBig> .Free(this); } }
public override void OnHit(CollisionResult?result) { HealthComponent health; if (result.HasValue) { if ((health = result.Value.Collider.Entity.GetComponent <HealthComponent>()) != null) { health.Damage(damage); } } }
public void Update(GameTime gameTime) { // If window is focused if (Game1.Instance.IsActive) { GetInput(); MouseControl(); } else { First = true; } if (InputManager.IsKeyDown(Keys.F1)) { IsFlying = true; } if (InputManager.IsKeyDown(Keys.F2)) { IsFlying = false; } KeyboardControl(); if (!IsFlying) { GroundRay.Start = Position; GroundRay.End = Position - new Vector3(0, HEIGHT, 0); CollisionResult?result = CollisionHelper.IsCollidingWithWorld(GroundRay); IsGrounded = result != null; if (IsGrounded) { Position = Vector3.Lerp(Position, new Vector3(Position.X, result.Value.VoxelPosition.Y + HEIGHT, Position.Z), 0.2f); Velocity.Y = 0; } else { Velocity -= GRAVITY * Up * (float)gameTime.ElapsedGameTime.TotalSeconds; } } Direction = Vector3.Lerp(Direction, TargetDirection, Smoothing); DestroyRaycast(25f); Position += Velocity * (float)gameTime.ElapsedGameTime.TotalSeconds; this.Right = Vector3.Normalize(Vector3.Cross(Up, Direction)); this.View = Matrix.CreateLookAt(Position, Position + Direction, Up); }
/// <summary> /// Override this to instantiate sub-projectiles /// </summary> public virtual void OnHit(CollisionResult?result) { if (result.HasValue && result.Value.Collider.Entity is Enemy) { (result.Value.Collider.Entity as Enemy).Damage(damage); } if (result.HasValue && result.Value.Collider.Entity is EnemyProjectile) { (result.Value.Collider.Entity as EnemyProjectile).OnHit(null); OnHit(null); } // Pool<T>.Free(this); // ^^ Every projectile must have this! }
public override void OnHit(CollisionResult?result) { base.OnHit(result); var hitFX = Scene.AddEntity(new AnimatedEntity()); hitFX.Position = this.Position; hitFX.Rotation = Random.NextAngle(); var texture = Scene.Content.LoadTexture(ContentPaths.Scoop_Splat); var sprites = Sprite.SpritesFromAtlas(texture, 25, 25); hitFX.animator.AddAnimation("hit", Constants.GlobalFPS * 2, sprites.GetRange(TypeIndex(type) * 6, 6).ToArray() ); hitFX.animator.Play("hit", SpriteAnimator.LoopMode.ClampForever); hitFX.animator.OnAnimationCompletedEvent += (s) => hitFX.Destroy(); // Free this projectile Pool <Scoop> .Free(this); }
public override void OnHit(CollisionResult?result) { base.OnHit(result); var hitFX = Scene.AddEntity(new AnimatedEntity()); var dir = CalculateVector(); hitFX.Rotation = Mathf.Atan2(dir.Y, dir.X); hitFX.Position = this.Position; var texture = Scene.Content.LoadTexture(ContentPaths.Popsicle_Shatter); var sprites = Sprite.SpritesFromAtlas(texture, 32, 23); hitFX.animator.RenderLayer = Constants.RenderLayer_Bullets; hitFX.animator.LayerDepth = 0.4f; hitFX.animator.AddAnimation("hit", Constants.GlobalFPS * 4, sprites.ToArray()); hitFX.animator.Play("hit", SpriteAnimator.LoopMode.ClampForever); hitFX.animator.OnAnimationCompletedEvent += (s) => hitFX.Destroy(); Pool <Popsicle> .Free(this); }
public override void OnHit(CollisionResult?result) { base.OnHit(result); Pool <DoctorKnife> .Free(this); }
public override void OnHit(CollisionResult?result) { base.OnHit(result); }