예제 #1
0
        public GameObject Create(string key, string name, BeatEmUpGame game)
        {
            ObjectModel model = models.Find(m => string.Equals(m.Key, key, StringComparison.OrdinalIgnoreCase) &&
                                            string.Equals(m.Name, name, StringComparison.OrdinalIgnoreCase));

            return(CreateFromModel(model, game));
        }
예제 #2
0
        private GameObject CreateFromModel(ObjectModel model, BeatEmUpGame game)
        {
            if (model == null)
            {
                return(null);
            }

            GameObject gameObject = new GameObject(game)
            {
                Position = new Vector2(model.X, model.Y),
                Size     = new Vector2(model.Width, model.Height),
                Name     = model.Name
            };

            if (!model.Enabled)
            {
                gameObject.Disable();
            }

            if (!model.Visible)
            {
                gameObject.Hide();
            }

            AddTags(model, gameObject);

            AddComponents(model, game, gameObject);

            AddBehaviours(model, gameObject);

            CreateChilds(model, game, gameObject);

            return(gameObject);
        }
예제 #3
0
        private void start_ButtonPressed(GuiButtonEventArgs e, object sender)
        {
            BeatEmUpGame game = this.game as BeatEmUpGame;

            GameStateManager gameStateManager = game.StateManager;

            // Alustetaan transition.
            Texture2D blank = game.Content.Load <Texture2D>("blank");

            Fade fadeIn  = new Fade(Color.Black, blank, new Rectangle(0, 0, 1280, 720), FadeType.In, 10, 10, 255);
            Fade fadeOut = new Fade(Color.Black, blank, new Rectangle(0, 0, 1280, 720), FadeType.Out, 10, 10, 0);

            fadeOut.StateFininshed += (s, a) =>
            {
                gameStateManager.SwapStates();
            };

            // Alustetaan player.
            TransitionPlayer player = new TransitionPlayer();

            player.AddTransition(fadeOut);
            player.AddTransition(fadeIn);

            gameStateManager.ChangeState(new HowManyPlayersState(), player);
        }
예제 #4
0
        public GameObject(BeatEmUpGame game)
        {
            this.game = game;

            behaviours       = new TypeSortedContainer <Behaviour>();
            componentManager = new ComponentManager(this);
            tags             = new TagContainer();

            string stateName = game.StateManager.CurrentName;

            tags.AddTag(stateName);

            OnDestroy += delegate { };
            OnDisable += delegate { };
            OnEnable  += delegate { };
            OnShow    += delegate { };
            OnHide    += delegate { };

            size   = new Vector2(1f);
            body   = new Body(this, new BoxShape(size.X, size.Y), Vector2.Zero);
            childs = new List <GameObject>();

            enabled = true;
            visible = true;

            name = this.GetType().Name;
        }
예제 #5
0
파일: Wave.cs 프로젝트: siquel/BeatEmUp
        public List <GameObject> Release(BeatEmUpGame game)
        {
            if (!CanRelease())
            {
                return(null);
            }

            return(CreateMonsters(game));
        }
예제 #6
0
            public HowManyPlayersController(List <PlayerIndex> players, HowManyPlayersMenu gui, BeatEmUpGame game)
            {
                this.players = players;
                this.gui     = gui;
                this.game    = game;

                labels = gui.Labels;
                gui.Start.ButtonPressed += Start_ButtonPressed;
            }
예제 #7
0
파일: HUD.cs 프로젝트: siquel/BeatEmUp
        public HUD(Game game)
            : base(game)
        {
            huds = new List <PlayerHUD>();

            this.game = game as BeatEmUpGame;

            Name = "Main";

            OnInitialize();
        }
예제 #8
0
        public Scene(BeatEmUpGame game, List <Wave> waves, List <GameObject> sceneObjects, string topAssetName, string bottomAssetName)
        {
            this.game            = game;
            this.waves           = waves;
            this.sceneObjects    = sceneObjects;
            this.topAssetName    = topAssetName;
            this.bottomAssetName = bottomAssetName;

            random = new Random();

            aliveObjects = new List <GameObject>();
        }
예제 #9
0
        public GameStateManager(BeatEmUpGame game)
            : base(game)
        {
            this.game = game;

            spriteBatch = new SpriteBatch(game.GraphicsDevice);

            GameStateChanging  += delegate { };
            GameStateChanged   += delegate { };
            OnGameStatePopped  += delegate { };
            OnGameStatePushing += delegate { };
            OnGameStatePushed  += delegate { };
            OnGameStatePopping += delegate {  };
        }
예제 #10
0
        public void Initialize(BeatEmUpGame game, GameStateManager gameStateManager)
        {
            if (Initialized)
            {
                return;
            }

            Game             = game;
            GameStateManager = gameStateManager;

            OnInitialize();

            Initialized = true;
        }
예제 #11
0
        private void AddComponents(ObjectModel model, BeatEmUpGame game, GameObject gameObject)
        {
            if (model.HasComponents())
            {
                for (int i = 0; i < model.ComponentNames.Length; i++)
                {
                    GameObjectComponent component = game.CreateComponent(model.ComponentNames[i], gameObject);

                    if (component != null)
                    {
                        gameObject.AddComponent(component);
                    }
                }
            }
        }
예제 #12
0
        public static GameObject CreatePlayer(PlayerIndex?index, BeatEmUpGame game)
        {
            GameObject player = game.CreateGameObjectFromName("Player");

            // keyboard
            if (index == null)
            {
                player.AddComponent(new KeyboardInputController(player));
            }
            else
            {
                player.AddComponent(new GamepadInputController(player, index.Value));
            }
            player.InitializeComponents();
            return(player);
        }
예제 #13
0
파일: Wave.cs 프로젝트: siquel/BeatEmUp
        private List <GameObject> CreateMonsters(BeatEmUpGame game)
        {
            List <GameObject> monsters = new List <GameObject>();

            float x = direction == WaveDirection.Left ? x = game.View.Position.X - 100f : game.View.Position.X + game.Window.ClientBounds.Width + 100f;

            for (int i = 0; i < monsterCount; i++)
            {
                GameObject monster = game.CreateGameObjectFromName(monsterName);

                float y = random.Next(game.Window.ClientBounds.Height / 2 + 200, (int)(game.Window.ClientBounds.Height - monster.Size.Y));

                Vector2 position = new Vector2(x, y);
                monster.Position = position;

                monsters.Add(monster);
            }

            return(monsters);
        }
예제 #14
0
        private void CreateChilds(ObjectModel model, BeatEmUpGame game, GameObject gameObject)
        {
            if (model.HasChilds())
            {
                for (int i = 0; i < model.ChildNames.Length; i++)
                {
                    ObjectModel childModel = models.Find(m => string.Equals(m.Name, model.ChildNames[i], StringComparison.OrdinalIgnoreCase));

                    if (childModel == null)
                    {
                        // TODO: log warning.

                        continue;
                    }

                    GameObject child = CreateFromModel(childModel, game);

                    gameObject.AddChild(child);
                }
            }
        }