public static Entity AddBehavior(Engine engine, Entity entity, ProcessManager processManager)
        {
            entity.AddComponent(new ShootingEnemyComponent(CVars.Get <int>("shooting_enemy_projectile_ammo")));
            entity.AddComponent(new RotationComponent(CVars.Get <float>("shooting_enemy_rotational_speed")));
            float angle = entity.GetComponent <TransformComponent>().Rotation;

            entity.AddComponent(new MovementComponent(new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)), CVars.Get <float>("shooting_enemy_speed")));
            entity.AddComponent(new EnemyComponent());
            entity.AddComponent(new BounceComponent());
            entity.AddComponent(new QuadTreeReferenceComponent(new QuadTreeNode(new BoundingRect())));

            entity.AddComponent(new CollisionComponent(new PolygonCollisionShape(new Vector2[] {
                new Vector2(-2, 5),
                new Vector2(2, 4),
                new Vector2(4, 0),
                new Vector2(2, -4),
                new Vector2(-2, -5)
            })));
            entity.GetComponent <CollisionComponent>().CollisionGroup = Constants.Collision.COLLISION_GROUP_ENEMIES;

            FireProjectileProcess fpp = new FireProjectileProcess(entity, engine);

            processManager.Attach(fpp);
            entity.AddComponent(new ProjectileSpawningProcessComponent(fpp));

            return(entity);
        }
        public LaserShootProcess(Engine engine, Entity laserEnemyEntity)
        {
            Engine           = engine;
            LaserEnemyEntity = laserEnemyEntity;

            Timer = new Timer(CVars.Get <float>("laser_enemy_fire_duration"));
        }
        public void Draw(SpriteBatch spriteBatch)
        {
            if (!CVars.Get <bool>("particle_enable"))
            {
                return;
            }

            Vector2         origin  = Vector2.Zero;
            TextureRegion2D texture = null;

            for (int i = 0; i < _particles.Count; i++)
            {
                Particle particle = _particles[i];

                if (particle.Texture != texture)
                {
                    texture = _particles[i].Texture;
                    origin  = new Vector2(particle.Texture.Width / 2, particle.Texture.Height / 2);
                }

                spriteBatch.Draw(particle.Texture,
                                 particle.Position,
                                 particle.Color,
                                 particle.Rotation,
                                 origin,
                                 particle.Scale,
                                 SpriteEffects.None,
                                 0);
            }
        }
        private void DrawPlaybackControls()
        {
            if (CVars.Get <bool>("debug_show_playback_controls"))
            {
                ImGui.Begin("Playback Controls", ref CVars.Get <bool>("debug_show_playback_controls"), ImGuiWindowFlags.AlwaysAutoResize);

                // These events are trigger because when the game is paused,
                // events that are queued are not dispatched.

                if (ImGui.Button("Pause##Playback"))
                {
                    CVars.Get <bool>("debug_pause_game_updates") = true;
                }
                ImGui.SameLine();
                if (ImGui.Button("Resume##Playback"))
                {
                    CVars.Get <bool>("debug_pause_game_updates") = false;
                }
                ImGui.SameLine();
                if (ImGui.Button("Step##Playback"))
                {
                    EventManager.Instance.TriggerEvent(new StepGameUpdateEvent());
                }
                ImGui.SameLine();
                ImGui.SetNextItemWidth(100);
                ImGui.InputFloat("Time Scale##Playback", ref CVars.Get <float>("debug_update_time_scale"), 0.1f);

                ImGui.End();
            }
        }
        protected override void OnUpdate(float dt)
        {
            if (!CVars.Get <bool>("particle_enable"))
            {
                return;
            }

            int removalCount = 0;

            for (int i = 0; i < _particles.Count; i++)
            {
                Particle particle = _particles[i];
                _updateParticle(particle, dt);
                particle.Elapsed += dt;

                // Sift deleted particles to the end of the list
                _particles.Swap(i - removalCount, i);

                // If particle has expired, delete particle
                if (particle.Expired)
                {
                    removalCount++;
                }
            }
            _particles.Count -= removalCount;

            if (!CVars.Get <bool>("particle_gpu_accelerated"))
            {
                GameManager.StatisticsProfiler.PushParticleCount(_particles.Count);
            }
        }
示例#6
0
        private void HandleEnemyShipOnPlayer(Entity playerEntity, Entity enemyShip)
        {
            Entity player;

            if (playerEntity.HasComponent <PlayerShieldComponent>())
            {
                player = playerEntity.GetComponent <PlayerShieldComponent>().ShipEntity;
            }
            else
            {
                player = playerEntity;
            }

            if (player.GetComponent <PlayerShipComponent>().IsCollidingWithWall == true)
            {
                return;
            }

            MovementComponent  movementComp          = player.GetComponent <MovementComponent>();
            TransformComponent shipTransformComp     = player.GetComponent <TransformComponent>();
            TransformComponent kamikazeTransformComp = enemyShip.GetComponent <TransformComponent>();

            Vector2 playerShipToEnemyShip = kamikazeTransformComp.Position - shipTransformComp.Position;

            playerShipToEnemyShip.Normalize();
            playerShipToEnemyShip *= -1;

            Vector2 combined = movementComp.MovementVector;

            combined += playerShipToEnemyShip * CVars.Get <float>("enemy_pushback_force");

            movementComp.MovementVector = combined;
        }
        private void GeneratePattern(int num)
        {
            // If all patterns of 'val' level are stale, swap allPatternsList and patternStaleList
            if (allPatternsList[num].Count == 0)
            {
                Console.WriteLine("allPatterns Count: " + allPatternsList[num].Count);
                Console.WriteLine("patternStale Count: " + patternStaleList[num].Count);
                allPatternsList[num].AddRange(patternStaleList[num]);
                patternStaleList[num].Clear();
            }
            if (allPatternsList[num].Count == 0)
            {
                return;
            }

            int ran = random.Next(0, allPatternsList[num].Count - 1);

            if (process == null)
            {
                process = (Process)Activator.CreateInstance(allPatternsList[num][ran], new object[] { Engine, ProcessManager, this });
                process.SetNext(new WaitForFamilyCountProcess(Engine, _enemyFamily, CVars.Get <int>("spawner_max_enemy_count")));
            }
            else
            {
                process.SetNext((Process)Activator.CreateInstance(allPatternsList[num][ran], new object[] { Engine, ProcessManager, this }));
                process.SetNext(new WaitForFamilyCountProcess(Engine, _enemyFamily, CVars.Get <int>("spawner_max_enemy_count")));
            }

            patternStaleList[num].Add(allPatternsList[num][ran]);
            allPatternsList[num].RemoveAt(ran);
        }
示例#8
0
        public override void Update(float dt)
        {
            foreach (Entity entity in _gravityHoleEntities)
            {
                GravityHoleEnemyComponent gravityHoleEnemyComp = entity.GetComponent <GravityHoleEnemyComponent>();
                TransformComponent        transformComp        = entity.GetComponent <TransformComponent>();

                transformComp.Rotate(CVars.Get <float>("gravity_hole_animation_rotation_speed") * dt);

                if (gravityHoleEnemyComp.ScalingAnimation)
                {
                    gravityHoleEnemyComp.ElapsedAliveTime += dt;
                    float scaleMin = CVars.Get <float>("gravity_enemy_size") * CVars.Get <float>("gravity_hole_animation_size_multiplier_min");
                    float scaleMax = CVars.Get <float>("gravity_enemy_size") * CVars.Get <float>("gravity_hole_animation_size_multiplier_max");
                    float alpha    = (float)(0.5f * Math.Cos(2 * MathHelper.Pi / CVars.Get <float>("gravity_hole_animation_size_period") * gravityHoleEnemyComp.ElapsedAliveTime) + 0.5f);
                    float scale    = MathHelper.Lerp(scaleMin, scaleMax, alpha);
                    transformComp.SetScale(scale);
                }

                if (gravityHoleEnemyComp.PingAnimation)
                {
                    gravityHoleEnemyComp.PingTimer.Update(dt);
                    if (gravityHoleEnemyComp.PingTimer.HasElapsed())
                    {
                        gravityHoleEnemyComp.PingTimer.Reset();

                        GravityHolePingEntity.Create(Engine, ProcessManager, ContentManager,
                                                     transformComp.Position, gravityHoleEnemyComp.radius);
                    }
                }
            }
        }
        public override bool Handle(IEvent evt)
        {
            if (CVars.Get <bool>("ui_auto_control_mode_switching"))
            {
                GamePadButtonDownEvent gamePadButtonDownEvent = evt as GamePadButtonDownEvent;
                if (gamePadButtonDownEvent != null)
                {
                    if (CVars.Get <bool>("ui_mouse_mode"))
                    {
                        CVars.Get <bool>("ui_mouse_mode") = false;
                        CVars.Get <int>("ui_gamepad_mode_current_operator") = (int)gamePadButtonDownEvent._playerIndex;
                        EventManager.Instance.QueueEvent(new EnterGamePadUIModeEvent(gamePadButtonDownEvent._playerIndex));
                        EventManager.Instance.QueueEvent(new GamePadUIModeOperatorChangedEvent(gamePadButtonDownEvent._playerIndex));
                        return(true);
                    }
                    if ((int)gamePadButtonDownEvent._playerIndex != CVars.Get <int>("ui_gamepad_mode_current_operator"))
                    {
                        CVars.Get <int>("ui_gamepad_mode_current_operator") = (int)gamePadButtonDownEvent._playerIndex;
                        EventManager.Instance.QueueEvent(new GamePadUIModeOperatorChangedEvent(gamePadButtonDownEvent._playerIndex));
                    }
                }
                if (evt is KeyboardKeyDownEvent ||
                    evt is MouseButtonEvent ||
                    evt is MouseMoveEvent)
                {
                    if (!CVars.Get <bool>("ui_mouse_mode"))
                    {
                        CVars.Get <bool>("ui_mouse_mode") = true;
                        EventManager.Instance.QueueEvent(new EnterMouseUIModeEvent());
                    }
                }
            }

            return(false);
        }
示例#10
0
        public static void UpdateParticle(ParticleManager <VelocityParticleInfo> .Particle particle, float dt)
        {
            Vector2 velocity = particle.UserInfo.Velocity;

            // If within tolerance, set the velocity to zero.
            // We don't have to use sqrt here, so we shouldn't
            if (Math.Abs(velocity.X) + Math.Abs(velocity.Y) < 0.1f)
            {
                velocity         = Vector2.Zero;
                particle.Expired = true;
            }

            particle.Position += velocity * dt;
            particle.Rotation  = (float)Math.Atan2(velocity.Y, velocity.X);

            float speed = velocity.Length();
            float alpha = Math.Min(1, speed * dt);

            alpha *= alpha;

            particle.Color.A = (byte)(255 * alpha); // This worked in LibGDX but not in MonoGame; probably won't fix

            particle.Scale.X = particle.UserInfo.LengthMultiplier * Math.Min(Math.Min(1, 0.2f * speed * dt + 0.1f), alpha);

            velocity *= (float)(Math.Pow(CVars.Get <float>("particle_explosion_decay_multiplier"), dt * 144));  // Decay multiplier was determined at 144Hz, this fixes the issue of explosion size being different on different refresh rates

            particle.UserInfo.Velocity = velocity;
        }
示例#11
0
        public override bool Handle(IEvent evt)
        {
            KeyboardKeyDownEvent keyboardKeyDownEvent = evt as KeyboardKeyDownEvent;

            if (keyboardKeyDownEvent != null)
            {
                if (keyboardKeyDownEvent._key == (Keys)CVars.Get <int>("input_keyboard_pause"))
                {
                    EventManager.Instance.QueueEvent(new TogglePauseGameEvent());
                    return(true);
                }
            }

            GamePadButtonDownEvent gamePadButtonDownEvent = evt as GamePadButtonDownEvent;

            if (gamePadButtonDownEvent != null)
            {
                if (gamePadButtonDownEvent._pressedButton == (Buttons)CVars.Get <int>("input_controller_pause"))
                {
                    EventManager.Instance.QueueEvent(new TogglePauseGameEvent());
                    return(true);
                }
            }

            return(false);
        }
示例#12
0
        public static Entity Create(Engine engine, ProcessManager processManager, ContentManager contentManager,
                                    Vector2 position, float radius, Entity owner = null)
        {
            Entity entity = engine.CreateEntity();

            entity.AddComponent(new TransformComponent(position));

            /*entity.AddComponent(new VectorSpriteComponent(new RenderShape[] {
             *  PolyRenderShape.GenerateCircleRenderShape(1f,
             *      radius,
             *      CVars.Get<Color>("color_gravity_hole_enemy"),
             *      45)
             * }));
             * entity.GetComponent<VectorSpriteComponent>().RenderGroup = Constants.Render.RENDER_GROUP_GAME_ENTITIES;*/

            entity.AddComponent(new SpriteComponent(new TextureRegion2D(contentManager.Load <Texture2D>("texture_gravity_hole_circle")),
                                                    new Vector2(2 * CVars.Get <float>("gravity_hole_enemy_radius"), 2 * CVars.Get <float>("gravity_hole_enemy_radius"))));
            entity.GetComponent <SpriteComponent>().Color = CVars.Get <Color>("color_gravity_hole_enemy");

            entity.GetComponent <TransformComponent>().SetScale(radius, true);

            entity.AddComponent(new GravityHolePingComponent(owner));

            processManager.Attach(new EntityScaleProcess(engine, entity,
                                                         CVars.Get <float>("gravity_hole_animation_ping_duration"),
                                                         1, 0, Easings.Functions.Linear))
            .SetNext(new EntityDestructionProcess(engine, entity));

            return(entity);
        }
 public void PushParticleCount(int count)
 {
     Particles = count;
     _particles.Add(count);
     EnforceMaxListSize(_particles, CVars.Get <int>("debug_statistics_average_particle_sample"));
     AverageParticles = ComputeAverage(_particles);
 }
        private void Update(float dt)
        {
            _particleEffect.CurrentTechnique = _particleEffect.Techniques["Update"];

            int currentPositionSizeLifeTarget = _currentPositionVelocityTarget;
            int nextPositionSizeLifeTarget    = (_currentPositionVelocityTarget + 1) % _positionVelocityTargets.Length;

            GraphicsDevice.SetRenderTarget(_positionVelocityTargets[nextPositionSizeLifeTarget]);
            GraphicsDevice.BlendState = _particleUpdateBlendState;
            _particleEffect.Parameters["Dt"].SetValue(dt);
            _particleEffect.Parameters["PositionVelocity"].SetValue(_positionVelocityTargets[currentPositionSizeLifeTarget]);
            _particleEffect.Parameters["StaticInfo"].SetValue(_staticInfoTarget);
            _particleEffect.Parameters["VelocityDecayMultiplier"].SetValue(CVars.Get <float>("particle_explosion_decay_multiplier"));
            foreach (EffectPass pass in _particleEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                _screenQuad.Render(GraphicsDevice);
            }
            _currentPositionVelocityTarget = nextPositionSizeLifeTarget;

            if (CVars.Get <bool>("particle_gpu_accelerated"))
            {
                GameManager.StatisticsProfiler.PushParticleCount(ParticleCount);
            }
        }
示例#15
0
        public LaserWarmUpProcess(Engine engine, Entity laserEnemyEntity)
        {
            Engine           = engine;
            LaserEnemyEntity = laserEnemyEntity;

            Timer = new Timer(CVars.Get <float>("laser_enemy_warm_up_anim_duration"));
        }
        public static Entity Create(Engine engine, Vector2 position, bool includeCollision)
        {
            Entity entity = engine.CreateEntity();

            entity.AddComponent(new TransformComponent(position));
            entity.AddComponent(new EnemyComponent());
            entity.AddComponent(new LaserBeamComponent());

            entity.AddComponent(new VectorSpriteComponent(new RenderShape[] {
                new QuadRenderShape(new Vector2(10, -10),
                                    new Vector2(10, 10),
                                    new Vector2(-10, 10),
                                    new Vector2(-10, -10), CVars.Get <Color>("color_laser_beam"))
            }));
            entity.GetComponent <VectorSpriteComponent>().RenderGroup = Constants.Render.RENDER_GROUP_GAME_ENTITIES;

            if (includeCollision)
            {
                entity.AddComponent(new CollisionComponent(new PolygonCollisionShape(new Vector2[] {
                    new Vector2(10, -10),
                    new Vector2(10, 10),
                    new Vector2(-10, 10),
                    new Vector2(-10, -10)
                })));
                entity.GetComponent <CollisionComponent>().CollisionGroup = Constants.Collision.COLLISION_GROUP_ENEMIES;
            }
            entity.AddComponent(new QuadTreeReferenceComponent(new QuadTreeNode(new BoundingRect())));

            return(entity);
        }
        protected override void OnInitialize()
        {
            PostProcessor = new PostProcessor(GameManager.GraphicsDevice,
                                              CVars.Get <float>("screen_width"),
                                              CVars.Get <float>("screen_height"));
            PostProcessor.RegisterEvents(); // Responds to ResizeEvent; keep outside of RegisterListeners

            Camera = new Camera(CVars.Get <float>("screen_width"), CVars.Get <float>("screen_height"));
            Camera.RegisterEvents();
            DebugCamera = new DebugCamera(CVars.Get <float>("screen_width"), CVars.Get <float>("screen_height"));
            DebugCamera.RegisterEvents();

            VelocityParticleManager = new ParticleManager <VelocityParticleInfo>(1024 * 20, VelocityParticleInfo.UpdateParticle);
            ProcessManager.Attach(VelocityParticleManager);
            GPUParticleManager = new GPUParticleManager(GameManager.GraphicsDevice,
                                                        Content,
                                                        "effect_gpu_particle_velocity");
            GPUParticleManager.RegisterListeners();

            Engine = new Engine();
            InitSystems();
            InitDirectors();

            LoadContent();

            CreateEntities();

            base.OnInitialize();
        }
示例#18
0
        private void UpdateLaserBeam(float alpha)
        {
            LaserEnemyComponent laserEnemyComp = LaserEnemyEntity.GetComponent <LaserEnemyComponent>();
            LaserBeamComponent  laserBeamComp  = laserEnemyComp.LaserBeamEntity.GetComponent <LaserBeamComponent>();

            laserBeamComp.Thickness = MathHelper.Lerp(0, CVars.Get <float>("laser_enemy_warm_up_thickness"), Easings.QuadraticEaseIn(alpha));
        }
示例#19
0
        public static Entity Create(Engine engine, Vector2 position, Vector2 direction)
        {
            Entity entity = engine.CreateEntity();

            entity.AddComponent(new TransformComponent(position));
            entity.AddComponent(new ProjectileComponent(CVars.Get <int>("shooting_enemy_projectile_bounces"), CVars.Get <Color>("color_projectile")));
            entity.AddComponent(new BounceComponent());
            entity.AddComponent(new MovementComponent(direction, CVars.Get <float>("shooting_enemy_projectile_speed")));
            entity.AddComponent(new EnemyComponent());

            entity.AddComponent(new VectorSpriteComponent(new RenderShape[] {
                new QuadRenderShape(new Vector2(3, -1), new Vector2(3, 1),
                                    new Vector2(-3, 1), new Vector2(-3, -1),
                                    Color.White)
            }));
            entity.GetComponent <VectorSpriteComponent>().RenderGroup = Constants.Render.RENDER_GROUP_GAME_ENTITIES;
            entity.GetComponent <TransformComponent>().SetScale(CVars.Get <float>("projectile_size"), false);
            entity.AddComponent(new QuadTreeReferenceComponent(new QuadTreeNode(new BoundingRect())));

            entity.AddComponent(new CollisionComponent(new PolygonCollisionShape(new Vector2[] {
                new Vector2(3, -1),
                new Vector2(3, 1),
                new Vector2(-3, 1),
                new Vector2(-3, -1)
            })));
            ConvertToEnemyProjectile(entity);

            entity.AddComponent(new ColoredExplosionComponent(entity.GetComponent <ProjectileComponent>().Color));

            return(entity);
        }
示例#20
0
        private void CreateEntities()
        {
            // TODO: This should be passed in from the lobby, most likely just have the Player object contain the color
            // These would _normally_ be CVars, but this will be okay for now because it will give us an excuse to move
            // these to the lobby menu.
            Color[] colors = new Color[]
            {
                Color.White,
                Color.Blue,
                Color.Orange,
                Color.Magenta
            };

            for (int p = 0; p < Players.Length; p++)
            {
                SpawnPlayer(Players[p],
                            ComputePlayerShipSpawnPosition(p, Players.Length),
                            colors[p]);
            }

            EdgeEntity.Create(SharedState.Engine, new Vector2(0, CVars.Get <float>("play_field_height") / 2), new Vector2(CVars.Get <float>("play_field_width"), 5), new Vector2(0, -1));
            EdgeEntity.Create(SharedState.Engine, new Vector2(-CVars.Get <float>("play_field_width") / 2, 0), new Vector2(5, CVars.Get <float>("play_field_height")), new Vector2(1, 0));
            EdgeEntity.Create(SharedState.Engine, new Vector2(0, -CVars.Get <float>("play_field_height") / 2), new Vector2(CVars.Get <float>("play_field_width"), 5), new Vector2(0, 1));
            EdgeEntity.Create(SharedState.Engine, new Vector2(CVars.Get <float>("play_field_width") / 2, 0), new Vector2(5, CVars.Get <float>("play_field_height")), new Vector2(-1, 0));
        }
        public static Entity Create(Engine engine, Entity shipEntity, float angle, bool isActive)
        {
            Entity entity = engine.CreateEntity();

            entity.AddComponent(new TransformComponent());
            entity.AddComponent(new PlayerShieldComponent(shipEntity, angle, CVars.Get <float>("player_shield_radius"), isActive));

            entity.AddComponent(new VectorSpriteComponent(new RenderShape[] {
                new QuadRenderShape(new Vector2(6, -1),
                                    new Vector2(6, 1),
                                    new Vector2(-6, 1),
                                    new Vector2(-6, -1),
                                    Color.White)
            }));
            entity.GetComponent <VectorSpriteComponent>().RenderGroup = Constants.Render.RENDER_GROUP_GAME_ENTITIES;
            entity.GetComponent <VectorSpriteComponent>().ChangeColor(CVars.Get <Color>("color_player_shield_high"));
            entity.GetComponent <VectorSpriteComponent>().Hidden = !isActive;
            entity.GetComponent <TransformComponent>().SetScale(CVars.Get <float>("player_shield_size"), true);
            entity.AddComponent(new QuadTreeReferenceComponent(new QuadTreeNode(new BoundingRect())));

            entity.AddComponent(new CollisionComponent(new PolygonCollisionShape(new Vector2[] {
                new Vector2(6, -1),
                new Vector2(6, 1),
                new Vector2(-6, 1),
                new Vector2(-6, -1)
            })));
            entity.GetComponent <CollisionComponent>().CollisionGroup = Constants.Collision.COLLISION_GROUP_PLAYER;
            entity.GetComponent <CollisionComponent>().CollisionMask  =
                (isActive) ? (byte)(Constants.Collision.GROUP_MASK_ALL & ~Constants.Collision.COLLISION_GROUP_PLAYER) :
                (byte)(Constants.Collision.GROUP_MASK_NONE);

            return(entity);
        }
 private void HandlePlayerLostEvent(PlayerLostEvent playerLostEvent)
 {
     if (_playerShipEntities.Count == 0 ||
         !CVars.Get <bool>("player_individual_deaths"))
     {
         EventManager.Instance.QueueEvent(new GameOverEvent());
     }
 }
 public void EndUpdate()
 {
     _updateStopwatch.Stop();
     UpdateTime = (float)_updateStopwatch.Elapsed.TotalSeconds;
     _updateTimes.Add(UpdateTime);
     EnforceMaxListSize(_updateTimes, CVars.Get <int>("debug_statistics_average_update_sample"));
     AverageUpdateTime = ComputeAverage(_updateTimes);
 }
示例#24
0
 public QuadTreeNode(BoundingRect bounds, QuadTreeNode parent)
 {
     this.parent             = parent;
     boundingRect            = bounds;
     leaves                  = new List <Entity>();
     maxLeavesBeforeSubTrees = CVars.Get <int>("quad_tree_max_references");
     subNodes                = new List <QuadTreeNode>(4);
 }
 public void EndDraw()
 {
     _drawStopwatch.Stop();
     DrawTime = (float)_drawStopwatch.Elapsed.TotalSeconds;
     _drawTimes.Add(DrawTime);
     EnforceMaxListSize(_drawTimes, CVars.Get <int>("debug_statistics_average_draw_sample"));
     AverageDrawTime = ComputeAverage(_drawTimes);
 }
示例#26
0
        protected override void OnComputeProperties()
        {
            float value = CVars.Get <float>(cvar);

            SliderButton.HorizontalValue = new FixedValue(MathHelper.Clamp(-this.Width / 2 + (value * this.Width), -this.Width / 2, this.Width / 2));

            SliderButton.ComputeProperties();
        }
示例#27
0
        public GravityEnemySpawner(Engine engine, ProcessManager processManager)
            : base(CVars.Get <float>("spawner_gravity_enemy_initial_period"))
        {
            Engine         = engine;
            ProcessManager = processManager;

            _playerShipEntities = engine.GetEntitiesFor(_playerShipFamily);
            _enemyEntities      = engine.GetEntitiesFor(_enemyFamily);
        }
        public SpawnGravityConstellation(Engine engine, ProcessManager processManager, SpawnPatternManager spm)
        {
            Engine         = engine;
            ProcessManager = processManager;
            SPM            = spm;

            maxWidth  = CVars.Get <float>("play_field_width");
            maxHeight = CVars.Get <float>("play_field_height");
        }
示例#29
0
        public static Entity ConvertToFriendlyProjectile(Entity entity)
        {
            entity.GetComponent <CollisionComponent>().CollisionGroup = Constants.Collision.COLLISION_GROUP_PLAYER;
            // Collide with everything except enemies
            entity.GetComponent <CollisionComponent>().CollisionMask = (byte)(Constants.Collision.GROUP_MASK_ALL & (~Constants.Collision.COLLISION_GROUP_PLAYER));
            entity.GetComponent <ProjectileComponent>().Color        = CVars.Get <Color>("color_projectile_friendly");

            return(entity);
        }
示例#30
0
        public static Entity ConvertToEnemyProjectile(Entity entity)
        {
            entity.GetComponent <CollisionComponent>().CollisionGroup = Constants.Collision.COLLISION_GROUP_ENEMIES;
            // Only collide with things that are not enemies
            entity.GetComponent <CollisionComponent>().CollisionMask = (byte)(Constants.Collision.GROUP_MASK_ALL & (~Constants.Collision.COLLISION_GROUP_ENEMIES));
            entity.GetComponent <ProjectileComponent>().Color        = CVars.Get <Color>("color_projectile");

            return(entity);
        }