Esempio n. 1
0
 public InputManager(IntentManager intentManager)
 {
     this.intentManager       = intentManager;
     this.keyMapping          = new Keys[(int)Intent.Size];
     this.alternateKeyMapping = new Keys[(int)Intent.Size];
     this.SetKeyMapping();
 }
Esempio n. 2
0
        public virtual void AddSpaceship(Entity e, Vector2 position, float rotation, IntentManager intentManager)
        {
            e.AddComponent(new TransformComponent(position, rotation, Vector2.One));
            e.AddComponent(new MotionComponent(Vector2.Zero, 0, GameConfig.Spaceship.MaxVelocity, GameConfig.Spaceship.MaxAngularVelocity));
            e.AddComponent(new ScoreComponent(GameConfig.Spaceship.Score));
            e.AddComponent(new LifeComponent(GameConfig.Spaceship.Lives));
            e.AddComponent(new RespawnComponent(position, GameConfig.Spaceship.RespawnTimeout));
            e.AddComponent(new ShieldComponent());
            e.AddComponent(new IntentComponent(intentManager));
            e.AddComponent(new GunComponent(GameConfig.Spaceship.GunCooldown, GameConfig.Spaceship.GunPosition));
            e.AddComponent(new AccelerationComponent(GameConfig.Spaceship.AccelerationRate, GameConfig.Spaceship.AngularAccelerationRate));
            e.AddComponent(new TagComponent(GameConfig.Spaceship.Tag));

            if (GameConfig.Spaceship.DefaultTexture == "spaceship_type_1")
            {
                // hack: use hardcoded values for now
                Vector2[] vertices = GameConfig.Spaceship.PolygonCollider;

                for (int i = 0; i < vertices.Length; i++)
                {
                    vertices[i] *= GameConfig.Spaceship.Size;   //HACK: apply scale to all vertices for originalvertices in polygon, to match size and scale of entity
                }

                e.AddComponent(new CollidableComponent(this.LayerManager.GetBit(GameConfig.Spaceship.CollisionLayer),
                                                       this.LayerManager.GetBit(GameConfig.Asteroid.CollisionLayer),
                                                       new PolygonCollider(vertices), e.EntityId));
            }
            else
            {
                e.AddComponent(new CollidableComponent(this.LayerManager.GetBit(GameConfig.Spaceship.CollisionLayer),
                                                       this.LayerManager.GetBit(GameConfig.Asteroid.CollisionLayer),
                                                       new CircleCollider(GameConfig.Spaceship.Size / 2f), e.EntityId));
            }
        }
Esempio n. 3
0
        public MultiplayerGameScene(Game game, NetworkManager networkManager, BaseConnection connectionInfo) : base(game, networkManager, connectionInfo)
        {
            this.scene      = new GUIScene();
            this.background = new Background(Assets.Get <Texture2D>(GameConfig.Folders.Particles, "circle"), new Rectangle(Point.Zero, GameConfig.WorldSize));

            this.intentManager      = new IntentManager();
            this.clientInputManager = new ClientInputManager(this.connectionInfo, this.intentManager);

            List <Texture2D> list = new List <Texture2D>
            {
                Assets.Get <Texture2D>(GameConfig.Folders.Particles, "circle")
            };

            this.particleEngine = new ParticleEngine(list, Vector2.Zero, 0, 50, false);

            this.entityWorld   = new EntityWorld();
            this.entityFactory = new ClientEntityFactory(this.entityWorld);

            this.scoreboardUI = new Scoreboard(GameConfig.Fonts.Medium, true);
            this.scoreboardUI.Hide();
            this.scene.AddChild(this.scoreboardUI);

            this.entityWorld.SystemManager.AddSystem(new MotionSystem(this.entityWorld)); //dead reckoning (for client side prediction)
            this.entityWorld.SystemManager.AddSystem(new RespawnTimeoutSystem(this.entityWorld));
            this.entityWorld.SystemManager.AddSystem(new TextureRenderSystem(this.entityWorld));
            this.entityWorld.SystemManager.AddSystem(new ScoreboardSystem(this.entityWorld, this.scoreboardUI));
            this.entityWorld.SystemManager.AddSystem(new ParticleSystem(this.entityWorld, this.particleEngine));

            this.CreateScene();

            this.CreateEscMenu();
        }
Esempio n. 4
0
        public SingleplayerGameScene(Game game) : base(game)
        {
            this.Camera.SetBounds(Vector2.Zero, (GameConfig.WorldSize - WindowSettings.RenderArea.Size + WindowSettings.RenderArea.Location).ToVector2());
            this.background = new Background(Assets.Get <Texture2D>(GameConfig.Folders.Particles, "circle"), new Rectangle(Point.Zero, GameConfig.WorldSize));

            this.signalManager = new SignalManager();
            this.intentManager = new IntentManager();
            this.inputManager  = new InputManager(this.intentManager);
            this.scene         = new GUIScene();

            List <Texture2D> list = new List <Texture2D>
            {
                Assets.Get <Texture2D>(GameConfig.Folders.Particles, "circle")
            };

            this.particleEngine = new ParticleEngine(list, Vector2.Zero, 0, 50, false);

            this.scoreboardUI = new Scoreboard(GameConfig.Fonts.Medium, false);
            this.scoreboardUI.Hide();
            this.scene.AddChild(scoreboardUI);

            this.spaceShipSpawnPosition = GameConfig.PlayArea.Center.ToVector2();
            this.entityWorld            = new EntityWorld();
            this.entityFactory          = new ClientEntityFactory(this.entityWorld);

            this.entityWorld.SystemManager.AddSystem(new MotionControlSystem(this.entityWorld));
            this.entityWorld.SystemManager.AddSystem(new LifetimeSystem(this.entityWorld, this.signalManager));
            this.entityWorld.SystemManager.AddSystem(new ShootSystem(this.entityWorld, this.entityFactory));
            this.entityWorld.SystemManager.AddSystem(new MotionSystem(this.entityWorld));
            this.entityWorld.SystemManager.AddSystem(new CollisionDetectionSystem(this.entityWorld));
            this.entityWorld.SystemManager.AddSystem(new CollisionResponseSystem(this.entityWorld, this.entityFactory, this.signalManager));
            this.entityWorld.SystemManager.AddSystem(new RespawnTimeoutSystem(this.entityWorld));
            this.entityWorld.SystemManager.AddSystem(new TargetingSystem(this.entityWorld));
            this.entityWorld.SystemManager.AddSystem(new TextureRenderSystem(this.entityWorld));
            //this.entityWorld.SystemManager.AddSystem(new ParticleSystem(this.entityWorld, this.particleEngine));
            this.entityWorld.SystemManager.AddSystem(new ScoreboardSystem(this.entityWorld, scoreboardUI));
            this.entityWorld.SystemManager.AddSystem(new SpriteAnimationRenderSystem(this.entityWorld));
            this.tagCountSystem = (TagCountSystem)this.entityWorld.SystemManager.AddSystem(new TagCountSystem(this.entityWorld));

            this.CreateScene();

            this.CreatePauseMenu();
        }
Esempio n. 5
0
 public override void AddSpaceship(Entity e, Vector2 position, float rotation, IntentManager intentManager)
 {
     base.AddSpaceship(e, position, rotation, intentManager);
     this.SendCreateEntity(e.EntityId, (byte)EntityType.Spaceship, position, rotation, Vector2.Zero);
 }
Esempio n. 6
0
 public IntentComponent(IntentManager intentManager)
 {
     this.IntentManager = intentManager;
 }