Пример #1
0
 public void Draw(GameTime gameTime, IDrawableEntity[] drawables)
 {
     spriteBatch.Begin();
     foreach (IDrawableEntity drawable in drawables)
         drawable.Draw(gameTime, this);
     spriteBatch.End();
 }
Пример #2
0
 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);
 }
Пример #3
0
 public void ExecuteOnDeath(IDrawableEntity ship)
 {
     if (deathMethodInfo != null)
     {
         controller.IsEvent = true;
         deathMethodInfo.Invoke(classInstance, new object[] { ship });
         controller.IsEvent = false;
     }
 }
Пример #4
0
 public void ExecuteOnHitByBullet(IDrawableEntity bullet)
 {
     if (hitByBulletMethodInfo != null)
     {
         controller.IsEvent = true;
         hitByBulletMethodInfo.Invoke(classInstance, new object[] { bullet });
         controller.IsEvent = false;
     }
 }
Пример #5
0
 public void ExecuteOnCollideWithShip(IDrawableEntity ship)
 {
     if (collideWithShipMethodInfo != null)
     {
         controller.IsEvent = true;
         collideWithShipMethodInfo.Invoke(classInstance, new object[] { ship });
         controller.IsEvent = false;
     }
 }
Пример #6
0
        /// <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);
        }
Пример #7
0
        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();
        }
Пример #8
0
 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);
 }
Пример #9
0
 /// <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)
 {
 }
Пример #10
0
 /// <summary>
 ///  Raised when a bullet hits another bullet
 /// </summary>
 /// <param name="bullet"> The bullet that was hit.</param>
 public void OnBulletHitBullet(IDrawableEntity bullet)
 {
 }
Пример #11
0
 /// <summary>
 ///  Raised when a bullet hits a ship
 /// </summary>
 /// <param name="ship"> The ship that was hit.</param>
 public void OnBulletHit(IDrawableEntity ship)
 {
 }
Пример #12
0
 /// <summary>
 ///  Raised when a ship has been detected
 /// </summary>
 /// <param name="ship"> The ship that was detected.</param>
 public void OnScannedShip(IDrawableEntity ship)
 {
 }
Пример #13
0
 /// <summary>
 ///  Raised when a bullet hits your ship
 /// </summary>
 /// <param name="bullet"> The bullet that hit.</param>
 public void OnHitByBullet(IDrawableEntity bullet)
 {
 }
Пример #14
0
 /// <summary>
 ///  Raised when a bullet hits a ship
 /// </summary>
 /// <param name="ship"> The ship that was hit.</param>
 public void OnBulletHit(IDrawableEntity ship)
 {
 }
Пример #15
0
 public void ExecuteOnScannedShip(IDrawableEntity ship)
 {
     if (scannedShipMethodInfo != null)
     {
         controller.IsEvent = true;
         scannedShipMethodInfo.Invoke(classInstance, new object[] { ship });
         controller.IsEvent = false;
     }
 }
Пример #16
0
 /// <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)
 {
 }
Пример #17
0
 /// <summary>
 ///  Raised when a bullet hits another bullet
 /// </summary>
 /// <param name="bullet"> The bullet that was hit.</param>
 public void OnBulletHitBullet(IDrawableEntity bullet)
 {
 }
Пример #18
0
 public void Draw(GameTime gameTime, IDrawableEntity drawableEntity)
 => _spriteBatchService.Draw(drawableEntity.Texture, drawableEntity.Position, drawableEntity.Color);
Пример #19
0
 public void SetShip(IDrawableEntity ship)
 {
     Ship = ship as Ship;
 }
Пример #20
0
 /// <summary>
 ///  Raised when a bullet hits your ship
 /// </summary>
 /// <param name="bullet"> The bullet that hit.</param>
 public void OnHitByBullet(IDrawableEntity bullet)
 {
 }
Пример #21
0
 public void ExecuteOnDeath(IDrawableEntity ship)
 {
     if (deathMethodInfo != null)
     {
         controller.IsEvent = true;
         deathMethodInfo.Invoke(classInstance, new object[] { ship });
         controller.IsEvent = false;
     }
 }
Пример #22
0
 public void SetShip(IDrawableEntity ship)
 {
     Ship = ship as Ship;
 }
Пример #23
0
 public void ExecuteOnHitByBullet(IDrawableEntity bullet)
 {
     if (hitByBulletMethodInfo != null)
     {
         controller.IsEvent = true;
         hitByBulletMethodInfo.Invoke(classInstance, new object[] { bullet });
         controller.IsEvent = false;
     }
 }
Пример #24
0
 /// <summary>
 ///  Raised when your ship is destroyed
 /// </summary>
 /// <param name="ship"> The ship that destroyed you.</param>
 public void OnDeath(IDrawableEntity ship)
 {
 }
Пример #25
0
 /// <summary>
 ///  Raised when a ship has been detected
 /// </summary>
 /// <param name="ship"> The ship that was detected.</param>
 public void OnScannedShip(IDrawableEntity ship)
 {
 }
Пример #26
0
 /// <summary>
 ///  Raised when your ship is destroyed
 /// </summary>
 /// <param name="ship"> The ship that destroyed you.</param>
 public void OnDeath(IDrawableEntity ship)
 {
 }