public void Draw(GameTime gameTime, IDrawableEntity[] drawables) { spriteBatch.Begin(); foreach (IDrawableEntity drawable in drawables) drawable.Draw(gameTime, this); spriteBatch.End(); }
public static CollisionType HandleCollision(IEnemy enemy, IDrawableEntity item, Rect collisionRect) { if (!(enemy is Spider && item is Snake) && collisionRect.Width >= 10) { return(CollisionType.EnemyGotItem); } return(CollisionType.None); }
public void ExecuteOnDeath(IDrawableEntity ship) { if (deathMethodInfo != null) { controller.IsEvent = true; deathMethodInfo.Invoke(classInstance, new object[] { ship }); controller.IsEvent = false; } }
public void ExecuteOnHitByBullet(IDrawableEntity bullet) { if (hitByBulletMethodInfo != null) { controller.IsEvent = true; hitByBulletMethodInfo.Invoke(classInstance, new object[] { bullet }); controller.IsEvent = false; } }
public void ExecuteOnCollideWithShip(IDrawableEntity ship) { if (collideWithShipMethodInfo != null) { controller.IsEvent = true; collideWithShipMethodInfo.Invoke(classInstance, new object[] { ship }); controller.IsEvent = false; } }
/// <summary> /// Create CameraTranslation for an IDrawableEntity /// </summary> /// <param name="entity">IDrawableEntity to create CamereTranslation from</param> /// <returns>new CameraTranslation</returns> private CameraTranslation ToCT(IDrawableEntity entity) { var ct = new CameraTranslation { LocationTranslation = new Point(entity.X, entity.Y), SizeTranslation = new Point(entity.Width, entity.Height) }; return(ct); }
private void DrawEntity(IDrawableEntity entity) { entity.GetVertexData(out VertexPositionColorTexture[] verticies, out short[] indicies, out Texture2D texture); effect.Texture = texture; IndexBuffer indexBuffer = new IndexBuffer(GraphicsDevice, typeof(short), indicies.Length, BufferUsage.WriteOnly); indexBuffer.SetData(indicies); GraphicsDevice.Indices = indexBuffer; VertexBuffer vertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColorTexture), verticies.Length, BufferUsage.WriteOnly); vertexBuffer.SetData <VertexPositionColorTexture>(verticies); GraphicsDevice.SetVertexBuffer(vertexBuffer); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, verticies.Length / 2); } vertexBuffer.Dispose(); indexBuffer.Dispose(); }
public static CollisionType HandlePlayerCollision(IPlayer player, IDrawableEntity entity, Rect collisionRect) { if (entity is IFruit) { if (collisionRect.Height >= 23) { Debug.WriteLine("YUMMIE"); return(CollisionType.PlayerGotFruit); } } else if (entity is IEnemy e) { if (collisionRect.Height >= 23 && collisionRect.Width >= 15) { return(CollisionType.EnemyGotPlayer); } else if (collisionRect.Height >= 10 && collisionRect.Width >= 10) { Debug.WriteLine("Near miss..."); return(CollisionType.NearMiss); } } return(CollisionType.None); }
/// <summary> /// Raised when your ship collides with another ship /// </summary> /// <param name="ship"> The ship that collided with you.</param> public void OnCollideWithShip(IDrawableEntity ship) { }
/// <summary> /// Raised when a bullet hits another bullet /// </summary> /// <param name="bullet"> The bullet that was hit.</param> public void OnBulletHitBullet(IDrawableEntity bullet) { }
/// <summary> /// Raised when a bullet hits a ship /// </summary> /// <param name="ship"> The ship that was hit.</param> public void OnBulletHit(IDrawableEntity ship) { }
/// <summary> /// Raised when a ship has been detected /// </summary> /// <param name="ship"> The ship that was detected.</param> public void OnScannedShip(IDrawableEntity ship) { }
/// <summary> /// Raised when a bullet hits your ship /// </summary> /// <param name="bullet"> The bullet that hit.</param> public void OnHitByBullet(IDrawableEntity bullet) { }
public void ExecuteOnScannedShip(IDrawableEntity ship) { if (scannedShipMethodInfo != null) { controller.IsEvent = true; scannedShipMethodInfo.Invoke(classInstance, new object[] { ship }); controller.IsEvent = false; } }
public void Draw(GameTime gameTime, IDrawableEntity drawableEntity) => _spriteBatchService.Draw(drawableEntity.Texture, drawableEntity.Position, drawableEntity.Color);
public void SetShip(IDrawableEntity ship) { Ship = ship as Ship; }
/// <summary> /// Raised when your ship is destroyed /// </summary> /// <param name="ship"> The ship that destroyed you.</param> public void OnDeath(IDrawableEntity ship) { }