public ActionMenuItem(Game2D game, string text, Action onAction, ActionTriggerKind actionTriggerKind = ActionTriggerKind.None)
     : base(game)
 {
     Text       = text;
     OnAction  += onAction;
     ActionKind = actionTriggerKind;
 }
        public InputMenuItem(Game2D game, string text, int maxInputTextLength, InputType inputType, bool normalText = false) : base(game)
        {
            Text        = text;
            _normalText = normalText;

            _inputController = new StringInputController(inputType, maxInputTextLength);
        }
Exemple #3
0
 public ToggleActionMenuItem(Game2D game, string trueText, string falseText, bool isTrue, Action onAction) :
     base(game, string.Empty, onAction, ActionTriggerKind.None)
 {
     TrueText  = trueText;
     FalseText = falseText;
     IsTrue    = isTrue;
 }
        public void Initialize(Game2D game, ILevelDataProvider levelDataProvider)
        {
            _gameInformation = new GameInformation(game, levelDataProvider)
            {
                Width = BombGame.Tilesize * 15
            };

            _graphicsDevice  = game.GraphicsDevice;
            _levelData       = levelDataProvider;
            _context         = new Render3DContext(game);
            _objectsToRender = new List <IRenderObject> {
                new Level(game.GraphicsDevice, game.Content, levelDataProvider)
            };
            _bombGeometry             = new ModelGeometry(this, game.GraphicsDevice, game.Content.Load <Model>("Models/Bomb/BombMesh"), _context.ToonEffect);
            _playerGeometry           = new ModelGeometry(this, game.GraphicsDevice, game.Content.Load <Model>("Models/Player/bomberman"), _context.ToonEffect);
            _baseItemGeometry         = new ModelGeometry(this, game.GraphicsDevice, game.Content.Load <Model>("Models/items/itemBase"), _context.ToonEffect);
            _fireOverlayGeometry      = new ModelGeometry(this, game.GraphicsDevice, game.Content.Load <Model>("Models/items/fireoverlay"), _context.ToonEffect);
            _explosionFragmentManager = new ExplosionFragmentManager(game, _levelData);

            _players = new List <Player>();
            foreach (var figure in _levelData.Figures)
            {
                var player = new Player(figure, _playerGeometry);
                AddRenderObject(player);
                _players.Add(player);
            }

            foreach (var itemDataProvider in _levelData.ItemData)
            {
                AddRenderObject(new Item3D(itemDataProvider, _baseItemGeometry, _fireOverlayGeometry));
            }
        }
Exemple #5
0
 public TableView(Game2D game) : base(game)
 {
     _columnHeaders = new List <ColumnHeader>();
     HeaderColor    = Color.White;
     ContentColor   = Color.White;
     _rows          = new List <Row>();
 }
Exemple #6
0
 public void Update(float elapsedTime, Game2D game)
 {
     _dialog.Update(elapsedTime);
     if (game.Keyboard.IsKeyDownOnce(Keys.Space) && _dialog.State == DialogState.Shown)
     {
         _dialog.Hide();
     }
 }
Exemple #7
0
        public RemoteGameCreationSession(Game2D game) : base(game)
        {
            State           = GameCreationSessionState.Disconnected;
            _messageTypeMap = new MessageTypeMap();

            _gameInstances       = new List <GameInstance>();
            RunningGameInstances = _gameInstances.AsReadOnly();
        }
Exemple #8
0
        public TitledBorder(Game2D game, string title = "", int width = 100, int height = 100, int minUserOffsetY = int.MinValue) : base(game)
        {
            _contentBorder = new Border(game);
            _titleBorder   = new Border(game);
            Title          = title;

            SetSize(width, height, minUserOffsetY);
        }
Exemple #9
0
 public ExplosionManager(Game2D game) : base(game)
 {
     _texture                 = Game.Content.Load <Texture2D>("textures/explosion");
     _explosionInstances      = new List <ExplosionInstance>();
     _soundEffect             = Game.Content.Load <SoundEffect>("sounds/explosion");
     _instanceEffect          = _soundEffect.CreateInstance();
     _instanceEffect.IsLooped = false;
 }
 public Dialog(Game2D game, Texture2D ninePatchTexture, Rectangle?sourceRectangle, SpriteFont font) : base(game)
 {
     _ninePatch       = new NinePatchSprite(ninePatchTexture, sourceRectangle, 16);
     _font            = font;
     State            = DialogState.Hidden;
     _transitionDelta = 0;
     TransitDuration  = 0.25f;
 }
Exemple #11
0
        public override void OnLoad()
        {
            var game = new Game2D("DefaultScene", LoadLoadingScreen());

            game.AddSystems += Game_AddSystems;
            PushLayer(game);
            //var renderingTest = new RenderingTest();
            //PushLayer(renderingTest);
        }
 public NumericMenuItem(Game2D game, string text, int min, int max, bool jumOnEnd = false) : base(game)
 {
     Text         = text;
     MinValue     = min;
     MaxValue     = max;
     CurrentValue = MinValue;
     JumpOnEnd    = jumOnEnd;
     Step         = 1;
 }
Exemple #13
0
        public GameInformation(Game2D game, Level level) : base(game)
        {
            _border = new Border(game);
            _font   = Resources.NormalFont;
            _level  = level;

            _defaultSizeForNumber = (int)Math.Ceiling(_font.MeasureString("99").X);
            _border.Height        = Height;
            _border.Y             = 0;
        }
Exemple #14
0
 public StackedMenu(Game2D game) : base(game)
 {
     _menuItems               = new List <MenuItem>();
     _animatedBomb            = new AnimatedBomb(game.Content);
     _titledBorder            = new TitledBorder(game);
     Height                   = int.MinValue;
     Width                    = int.MinValue;
     FirstMenuItemStartOffset = 0;
     CancelKey                = Keys.Escape;
 }
Exemple #15
0
 public CarManager(Game2D game) : base(game)
 {
     _lastGeneratedLane         = -1;
     _spawnTime                 = 0;
     _player                    = Game.GetGlobalObject <Player>("Player");
     _player.OnRespawnFinished += () => _pauseRespawn = false;
     _player.OnDied            += () => _pauseRespawn = true;
     _pauseRespawn              = true;
     spawnTime                  = 60;
 }
Exemple #16
0
 public EnumMenuItem(Game2D game, string text, IEnumerable <string> data, string selectedItem = "") : base(game)
 {
     Text          = text;
     _values       = new List <string>(data);
     _currentIndex = 0;
     if (!string.IsNullOrEmpty(selectedItem))
     {
         SetCurrentItem(selectedItem);
     }
 }
 public GuiSystem(Game2D game) : base(game)
 {
     _itemDescriptors = new List <SkinItemDescriptor>
     {
         new FrameSkinItemDescriptor(),
         new TextBlockSkinItemDescriptor(),
         new ButtonSkinItemDescriptor(),
         new TextBoxSkinItemDescriptor(),
     };
 }
 public ExplosionFragmentManager(Game2D game, ILevelDataProvider level)
 {
     _level                  = level;
     _texture                = game.Content.Load <Texture2D>("Textures/explosionparticle");
     _particleEffect         = game.Content.Load <Effect>("Effects/ParticleEffect");
     _worldViewProjParameter = _particleEffect.Parameters["WorldViewProjection"];
     _textureParameter       = _particleEffect.Parameters["DiffuseTexture"];
     _instances              = new List <ExplosionFragment>();
     _quadVertexBuffer       = new VertexBuffer(game.GraphicsDevice, VertexPositionNormalTexture.VertexDeclaration, 4, BufferUsage.WriteOnly);
     _quadVertexBuffer.SetData(GeometryCreator.GenerateQuad(QuadOrientation.UnitY, Vector3.Zero));
 }
Exemple #19
0
        static void Main(string[] args)
        {
            string server = "";

            if (args != null && args.Length > 0)
            {
                server = args[0];
            }
            using (var game = new Game2D(server))
                game.Run();
        }
 public Weather(Game2D game)
     : base(game)
 {
     _cloud      = new Cloud(game, new Vector2(400f, 100f));
     _sun        = new Sun(game, new Vector2(700f, 100f));
     _sun._cloud = _cloud;
     _state      = WeatherState.CLOUD;
     _suntex     = game.Content.Load <Texture2D>("Textures\\sun_icon");
     _cloudtex   = game.Content.Load <Texture2D>("Textures\\rain_icon");
     _font       = game.Content.Load <SpriteFont>("Fonts\\Font");
 }
Exemple #21
0
        public TextBox(Game2D game, int width, int height) : base(game)
        {
            _frameBorder = new Border(game)
            {
                Width  = width,
                Height = height
            };
            _textInputFont = Resources.NormalFont;

            _inputController = new StringInputController(InputType.AlphaNumeric, 20);
        }
        private static Keys[] GetKeysFromGameProperty(Game2D game, string propertyName)
        {
            var data = game.GetPropertyStringOrDefault(propertyName);
            var k    = new Keys[5];
            var i    = 0;

            foreach (var s in data.Split(new[] { ',' }))
            {
                k[i++] = (Keys)Enum.Parse(typeof(Keys), s);
            }
            return(k);
        }
Exemple #23
0
        public static IInputDevice CreateKeyboardInputDevice(Game2D game, Keys left, Keys right, Keys up, Keys down, Keys action, Keys cancel)
        {
            var keyboardInputDevice = new KeyboardInputDevice(game);

            keyboardInputDevice._keyMapping[InputKey.Action]    = action;
            keyboardInputDevice._keyMapping[InputKey.Back]      = cancel;
            keyboardInputDevice._keyMapping[InputKey.MoveUp]    = up;
            keyboardInputDevice._keyMapping[InputKey.MoveDown]  = down;
            keyboardInputDevice._keyMapping[InputKey.MoveLeft]  = left;
            keyboardInputDevice._keyMapping[InputKey.MoveRight] = right;
            return(keyboardInputDevice);
        }
Exemple #24
0
        static void TestGame2d_01()
        {
            //Scene2D scene = TestCase.SpinOffTest();
            //Scene2D scene = TestCase.SpinStateTest();
            //Scene2D scene = TestCase.SpinStateKeyBoardTest();
            //Scene2D scene = TestCase.StillTest();
            //Scene2D scene = TestCase.FlipBookTest();
            //Scene2D scene = new PlayerJumpOverChest();
            Scene2D scene = new IdleMoveLeftRight();

            Game2D game = new Game2D("Leo Client ...", scene);
        }
Exemple #25
0
 public GamePadInputDevice(Game2D game, PlayerIndex playerIndex) : base(game)
 {
     _playerIndex = playerIndex;
     _keyMapping  = new Dictionary <InputKey, GamePadButton>
     {
         [InputKey.Action]    = GamePadButton.A,
         [InputKey.Back]      = GamePadButton.B,
         [InputKey.MoveUp]    = GamePadButton.DigitalUp,
         [InputKey.MoveDown]  = GamePadButton.DigitalDown,
         [InputKey.MoveLeft]  = GamePadButton.DigitalLeft,
         [InputKey.MoveRight] = GamePadButton.DigitalRight
     };
 }
 public Sun(Game2D game, Vector2 initPos)
     : base(game)
 {
     isFinishedWithWork = true;
     _sunTexture        = game.Content.Load <Texture2D>("Textures\\Sun");
     _position          = initPos;
     disable            = true;
     _blendVal          = 0.0f;
     isBlending         = false;
     energy             = 1;
     IsFullyChanged     = false;
     scale = 0.95f;
 }
Exemple #27
0
        public Button2(Game2D game, string text, Rectangle rectangle, Action onClick)
        {
            _onClick = onClick;
            Text     = text;
            Bounds   = rectangle;

            _currentSprite   = new NinePatchSprite(game.Content.Load <Texture2D>("textures/selector"), new Rectangle(0, 0, 32, 32), 15, 15);
            FocusedAnimation = new UiDiscreteAnimation <NinePatchSprite>(0.5f, new []
            {
                _currentSprite,
                new NinePatchSprite(game.Content.Load <Texture2D>("textures/selector"), new Rectangle(32, 0, 32, 32), 15, 15)
            }, c => _currentSprite = c, true);
        }
 public Player(Game2D game, Vector2 initPos)
     : base(game)
 {
     _tachotexture     = Game.Content.Load <Texture2D>("textures/tacho");
     _font             = Game.Content.Load <SpriteFont>("Fonts/Font");
     _explosionManager = Game.GetGlobalObject <ExplosionManager>("ExplosionManager");
     PlayerState       = PlayerState.UserControl;
     _playerTexture    = game.Content.Load <Texture2D>("Textures\\Player");
     Position          = initPos;
     Energy            = 100;
     Lifes             = 3;
     Respawn();
 }
Exemple #29
0
 public GameBackground(Game2D game) : base(game)
 {
     _backgroundTextures = new[]
     {
         Game.Content.Load <Texture2D>("textures/backgrounds/bg1"),
         Game.Content.Load <Texture2D>("textures/backgrounds/bg2"),
         Game.Content.Load <Texture2D>("textures/backgrounds/bg3"),
         Game.Content.Load <Texture2D>("textures/backgrounds/bg4"),
         Game.Content.Load <Texture2D>("textures/backgrounds/bg5"),
         Game.Content.Load <Texture2D>("textures/backgrounds/bg6"),
         Game.Content.Load <Texture2D>("textures/backgrounds/bg7"),
         Game.Content.Load <Texture2D>("textures/backgrounds/bg8")
     };
 }
Exemple #30
0
        public ItemRenderer(Game2D game, Vector2 centeringOffset) : base(game)
        {
            _tileset         = Game.Content.Load <Texture2D>("textures/tileset");
            _centeringOffset = centeringOffset;

            _itemAnimationTimes = new Dictionary <Point, float>();
            for (var y = 0; y < BombGame.GameLevelWidth; y++)
            {
                for (var x = 0; x < BombGame.GameLevelHeight; x++)
                {
                    _itemAnimationTimes.Add(new Point(x, y), 0);
                }
            }
        }
Exemple #31
0
 static void Main(string[] args)
 {
     using (var game = new Game2D()) game.Run(60, 60);
 }