상속: Artemis.ComponentPoolable
예제 #1
0
        /// <summary>The render.</summary>
        /// <param name="spriteBatch">The sprite batch.</param>
        /// <param name="contentManager">The content manager.</param>
        /// <param name="transformComponent">The TransformComponent.</param>
        public static void Render(SpriteBatch spriteBatch, ContentManager contentManager, TransformComponent transformComponent)
        {
            if (ship == null)
            {
                ship = contentManager.Load<Texture2D>("player");
            }

            spriteBatch.Draw(ship, new Vector2(transformComponent.X - (ship.Width * 0.5f), transformComponent.Y - (ship.Height * 0.5f)), ship.Bounds, Color.White);
        }
예제 #2
0
        /// <summary>The render.</summary>
        /// <param name="spriteBatch">The sprite batch.</param>
        /// <param name="contentManager">The content manager.</param>
        /// <param name="transformComponent">The TransformComponent.</param>
        public static void Render(SpriteBatch spriteBatch, ContentManager contentManager, TransformComponent transformComponent)
        {
            if (bullet == null)
            {
                bullet = contentManager.Load<Texture2D>("bullet");
            }

            spriteBatch.Draw(bullet, new Vector2(transformComponent.X - (bullet.Width * 0.5f), transformComponent.Y - (bullet.Height * 0.5f)), bullet.Bounds, Color.White);
        }
        /// <summary>The render.</summary>
        /// <param name="spriteBatch">The sprite batch.</param>
        /// <param name="contentManager">The content manager.</param>
        /// <param name="transformComponent">The TransformComponent.</param>
        /// <param name="color">The color.</param>
        /// <param name="radius">The radius.</param>
        public static void Render(SpriteBatch spriteBatch, ContentManager contentManager, TransformComponent transformComponent, Color color, int radius)
        {
            if (circle == null)
            {
                circle = contentManager.Load<Texture2D>("explosion");
            }

            spriteBatch.Draw(circle, new Vector2(transformComponent.X - (circle.Width * 0.5f), transformComponent.Y - (circle.Height * 0.5f)), circle.Bounds, Color.White);
        }
예제 #4
0
        /// <summary>The render.</summary>
        /// <param name="spriteBatch">The sprite batch.</param>
        /// <param name="contentManager">The content manager.</param>
        /// <param name="transformComponent">The TransformComponent.</param>
        /// <param name="color">The color.</param>
        /// <param name="radius">The radius.</param>
        public static void Render(SpriteBatch spriteBatch, ContentManager contentManager, TransformComponent transformComponent, Color color, int radius)
        {
            if (circle == null)
            {
                circle = contentManager.Load<Texture2D>("explosion");
            }

            spriteBatch.Draw(circle, new Vector2(transformComponent.X - radius, transformComponent.Y - radius), null, Color.White, 0, Vector2.Zero, 0.3f, SpriteEffects.None, 0);
        }
        /// <summary>Adds the missile.</summary>
        /// <param name="transformComponent">The transform component.</param>
        /// <param name="angle">The angle.</param>
        /// <param name="offsetX">The offset X.</param>
        private void AddMissile(TransformComponent transformComponent, float angle = 90.0f, float offsetX = 0.0f)
        {
            Entity missile = this.EntityWorld.CreateEntityFromTemplate(MissileTemplate.Name);

            missile.GetComponent<TransformComponent>().X = transformComponent.X + 1 + offsetX;
            missile.GetComponent<TransformComponent>().Y = transformComponent.Y - 20;

            missile.GetComponent<VelocityComponent>().Speed = -0.5f;
            missile.GetComponent<VelocityComponent>().Angle = angle;
        }
예제 #6
0
        /// <summary>Processes the specified entity.</summary>
        /// <param name="entity">The entity.</param>
        public override void Process(Entity entity)
        {
            this.transformComponent = this.transformMapper.Get(entity);
            SpatialFormComponent spatialFormComponent = this.spatialFormMapper.Get(entity);

            if (spatialFormComponent != null)
            {
                this.spatialName = spatialFormComponent.SpatialFormFile;

                if (this.transformComponent.X >= 0 &&
                    this.transformComponent.Y >= 0 &&
                    this.transformComponent.X < this.spriteBatch.GraphicsDevice.Viewport.Width &&
                    this.transformComponent.Y < this.spriteBatch.GraphicsDevice.Viewport.Height)
                {
                    this.CreateSpatial();
                }
            }
        }