SetPosition() public method

Remove all other image models and create new model with position
public SetPosition ( Vector2 pos ) : ImageModel
pos Vector2
return SmashBros.Models.ImageModel
Ejemplo n.º 1
0
        public override void Load(ContentManager content)
        {
            //Initialises the view for the menu entries
            menuView                  = new MenuView(FontDefualt);
            menuView.Layer            = 1001;
            menuView.StartingPosition = new Vector2(175, 0);
            menuView.StaticPosition   = true;

            //Loads the menu background
            bg = new ImageController(Screen, "Menu/PopupMenu", 1000, true);
            bg.SetPosition(175, -700);
            //content, "Menu/PopupMenu", 175, -700);
            bg.OnAnimationDone += OnAnimationDone;
            AddController(bg);

            //Create the menu models
            createGamePauseMenu(FontDefualt);
            createOptionsMenu(FontDefualt);
            createHelpMenu(FontDefualt);

            //Adds listeners to cursors
            Screen.cursorsController.OnCursorClick      += OnCursorClick;
            Screen.cursorsController.OnCursorCollision  += OnCursorCollision;
            Screen.cursorsController.OnCursorSeparation += OnCursorSeparation;

            SubscribeToGameState = true;
        }
Ejemplo n.º 2
0
        public override void Load(ContentManager content)
        {
            Screen.soundController.LoadGameSounds(content, this, map.CurrentMap.backgroundMusic);

            this.camera = new CameraController(Screen, map.Model.zoomBox);

            //The effects image for hits
            this.effectImg = new ImageController(Screen, "GameStuff/GameEffects", 110);
            this.effectImg.OriginDefault    = new Vector2(130 / 2, 130 / 2);
            this.effectImg.ScaleDefault     = 0.1f;
            this.effectImg.OnAnimationDone += OnHitAnimationDone;
            this.effectImg.SetFrameRectangle(200, 200);
            this.effectImg.FramesPerRow = 2;
            AddController(effectImg);

            //Creates the countdown before starting game
            countDown = new ImageController(Screen, "GameStuff/CountDown", 900, true);
            countDown.OriginDefault = new Vector2(150, 150);
            countDown.ScaleDefault  = 0;
            countDown.SetFrameRectangle(300, 300);
            countDown.FramesPerRow = 2;
            var imgModel = countDown.SetPosition(Constants.WindowWidth / 2, Constants.WindowHeight / 2);

            //Set callback to determin when the game is finished
            imgModel.Callback = countDownNext;
            countDown.AnimateScale(0.7f, (countDownTime / 4) * 1000, true);
            AddController(countDown);

            gameOver = new ImageController(Screen, "GameStuff/GameOver", 150, true);
            gameOver.OriginDefault = new Vector2(300, 100);
            gameOver.ScaleDefault  = 0;

            this.powerUps = new PowerUpController(Screen, map.Model.DropZone);
            AddController(powerUps);

            //Creates characterController, and PlayerStatsController
            createCharacters(content);

            if (!Screen.GameOptions.UseLifes)
            {
                timeLeft             = new TimeSpan(0, Screen.GameOptions.Minutes, 0);
                timer                = new TextBox(getTimeLeft(), FontDefualt, new Vector2(Constants.WindowWidth - 80, 10), Color.White);
                timer.Layer          = 150;
                timer.StaticPosition = true;
                AddView(timer);
            }

            AddController(camera);
            AddController(this.map);

            SubscribeToGameState = true;
        }
Ejemplo n.º 3
0
        public override void Load(ContentManager content)
        {
            Screen.soundController.LoadGameSounds(content, this, map.CurrentMap.backgroundMusic);

            this.camera = new CameraController(Screen, map.Model.zoomBox);

            //The effects image for hits
            this.effectImg = new ImageController(Screen, "GameStuff/GameEffects", 110);
            this.effectImg.OriginDefault = new Vector2(130 / 2, 130 / 2);
            this.effectImg.ScaleDefault = 0.1f;
            this.effectImg.OnAnimationDone += OnHitAnimationDone;
            this.effectImg.SetFrameRectangle(200, 200);
            this.effectImg.FramesPerRow = 2;
            AddController(effectImg);

            //Creates the countdown before starting game
            countDown = new ImageController(Screen, "GameStuff/CountDown", 900, true);
            countDown.OriginDefault = new Vector2(150, 150);
            countDown.ScaleDefault = 0;
            countDown.SetFrameRectangle(300, 300);
            countDown.FramesPerRow = 2;
            var imgModel = countDown.SetPosition(Constants.WindowWidth / 2, Constants.WindowHeight / 2);
            //Set callback to determin when the game is finished
            imgModel.Callback = countDownNext;
            countDown.AnimateScale(0.7f, (countDownTime/4) * 1000, true);
            AddController(countDown);

            gameOver = new ImageController(Screen, "GameStuff/GameOver", 150, true);
            gameOver.OriginDefault = new Vector2(300, 100);
            gameOver.ScaleDefault = 0;

            this.powerUps = new PowerUpController(Screen, map.Model.DropZone);
            AddController(powerUps);

            //Creates characterController, and PlayerStatsController
            createCharacters(content);

            if (!Screen.GameOptions.UseLifes)
            {
                timeLeft = new TimeSpan(0, Screen.GameOptions.Minutes, 0);
                timer = new TextBox(getTimeLeft(), FontDefualt, new Vector2(Constants.WindowWidth - 80, 10), Color.White);
                timer.Layer = 150;
                timer.StaticPosition = true;
                AddView(timer);
            }

            AddController(camera);
            AddController(this.map);

            SubscribeToGameState = true;
        }
Ejemplo n.º 4
0
        private void LoadCharacters(ContentManager content)
        {
            //Loads the characters from the xml files
            characterModels = Serializing.LoadCharacters();

            characterThumbs = new List <ImageController>();
            characterImages = new List <ImageController>();

            int i = 0;
            int row = 0, col = 0;

            //Create textures for thumb and image for every character model
            foreach (CharacterStats character in characterModels)
            {
                ImageController thumb = new ImageController(Screen, character.thumbnail, 3, true);
                thumb.OriginDefault = new Vector2(Constants.ThumbWith - 10, Constants.ThumbHeight - 10) / 2;
                thumb.IsVisible     = false;
                thumb.ScaleDefault  = 0.1f;

                ImageModel thumbModel = thumb.SetPosition(col * Constants.ThumbWith + 200, row * Constants.ThumbHeight + 210);
                thumbModel.SetBoundBox(World, Constants.ThumbWith - 20, Constants.ThumbHeight - 20, new Vector2(10, 0),
                                       Category.Cat5, Category.Cat4, true);
                thumbModel.BoundBox.IsSensor = true;
                thumbModel.BoundBox.Enabled  = false;
                thumbModel.BoundBox.UserData = i;

                AddController(thumb);
                characterThumbs.Add(thumb);

                //Check if new row
                if (i == 4)
                {
                    row++;
                    col = 0;
                }
                else
                {
                    col++;
                }
                i++;

                //Creates the images for every texture
                var img = new ImageController(Screen, character.image, 4, true);
                AddController(img);
                characterImages.Add(img);
            }
        }
Ejemplo n.º 5
0
        private void LoadMaps(ContentManager content)
        {
            //Loads all the map models from json textfiles
            mapModels = Serializing.LoadMaps();
            mapThumbs = new List <ImageController>();

            int row = 0, column = 0, i = 0;

            foreach (var map in mapModels)
            {
                ImageController thumb = new ImageController(Screen, map.thumbImage, 3, true);
                thumb.IsVisible     = false;
                thumb.ScaleDefault  = 0.1f;
                thumb.OriginDefault = new Vector2(300, 230) / 2;

                ImageModel img = thumb.SetPosition(300 * column + 200, row * 230 + 180);
                img.SetBoundBox(World, 280, 210, Vector2.Zero, Category.Cat5, Category.Cat4, true);
                img.BoundBox.IsSensor = true;
                img.BoundBox.Enabled  = false;
                img.BoundBox.UserData = i;

                AddController(thumb);
                mapThumbs.Add(thumb);

                if (column == 3)
                {
                    row++;
                    column = 0;
                }
                else
                {
                    column++;
                }

                i++;
            }
        }
Ejemplo n.º 6
0
        public override void Load(ContentManager content)
        {
            //Initialises the view for the menu entries
            menuView = new MenuView(FontDefualt);
            menuView.Layer = 1001;
            menuView.StartingPosition = new Vector2(175, 0);
            menuView.StaticPosition = true;

            //Loads the menu background
            bg = new ImageController(Screen, "Menu/PopupMenu", 1000, true);
            bg.SetPosition(175, -700);
            //content, "Menu/PopupMenu", 175, -700);
            bg.OnAnimationDone += OnAnimationDone;
            AddController(bg);

            //Create the menu models
            createGamePauseMenu(FontDefualt);
            createOptionsMenu(FontDefualt);
            createHelpMenu(FontDefualt);

            //Adds listeners to cursors
            Screen.cursorsController.OnCursorClick += OnCursorClick;
            Screen.cursorsController.OnCursorCollision += OnCursorCollision;
            Screen.cursorsController.OnCursorSeparation += OnCursorSeparation;

            SubscribeToGameState = true;
        }
Ejemplo n.º 7
0
        private void LoadMaps(ContentManager content)
        {
            //Loads all the map models from json textfiles
            mapModels = Serializing.LoadMaps();
            mapThumbs = new List<ImageController>();

            int row = 0, column = 0, i = 0;
            foreach (var map in mapModels)
            {
                ImageController thumb = new ImageController(Screen, map.thumbImage, 3, true);
                thumb.IsVisible = false;
                thumb.ScaleDefault = 0.1f;
                thumb.OriginDefault = new Vector2(300, 230)/2;

                ImageModel img = thumb.SetPosition(300 * column + 200, row * 230 + 180);
                img.SetBoundBox(World, 280, 210, Vector2.Zero, Category.Cat5, Category.Cat4, true);
                img.BoundBox.IsSensor = true;
                img.BoundBox.Enabled = false;
                img.BoundBox.UserData = i;

                AddController(thumb);
                mapThumbs.Add(thumb);

                if (column == 3)
                {
                    row++;
                    column = 0;
                }else
                    column++;

                i++;
            }
        }
Ejemplo n.º 8
0
        private void LoadCharacters(ContentManager content)
        {
            //Loads the characters from the xml files
            characterModels = Serializing.LoadCharacters();

            characterThumbs = new List<ImageController>();
            characterImages = new List<ImageController>();

            int i = 0;
            int row = 0, col = 0;

            //Create textures for thumb and image for every character model
            foreach (CharacterStats character in characterModels)
            {

                ImageController thumb = new ImageController(Screen, character.thumbnail, 3, true);
                thumb.OriginDefault = new Vector2(Constants.ThumbWith - 10, Constants.ThumbHeight - 10) / 2;
                thumb.IsVisible = false;
                thumb.ScaleDefault = 0.1f;

                ImageModel thumbModel = thumb.SetPosition(col * Constants.ThumbWith + 200, row * Constants.ThumbHeight + 210);
                thumbModel.SetBoundBox(World, Constants.ThumbWith - 20, Constants.ThumbHeight - 20, new Vector2(10, 0),
                    Category.Cat5, Category.Cat4, true);
                thumbModel.BoundBox.IsSensor = true;
                thumbModel.BoundBox.Enabled = false;
                thumbModel.BoundBox.UserData = i;

                AddController(thumb);
                characterThumbs.Add(thumb);

                //Check if new row
                if (i == 4)
                {
                    row++;
                    col = 0;
                }
                else col++;
                i++;

                //Creates the images for every texture
                var img = new ImageController(Screen, character.image, 4, true);
                AddController(img);
                characterImages.Add(img);
            }
        }
Ejemplo n.º 9
0
        public override void OnNext(GameStateManager value)
        {
            ImageController animateIn = null, animateOut = null;

            switch (value.PreviousState)
            {
            case GameState.StartScreen:
                if (value.CurrentState != GameState.StartScreen)
                {
                    animateOut = startScreen;
                    RemoveView(tipsText);
                }
                break;

            case GameState.CharacterMenu:
                CharacterSelectionVisible = false;
                break;

            case GameState.MapsMenu:
                MapSelectionVisible = false;
                break;

            case GameState.GameOver:
                GameStatsVisible      = false;
                continueText.Position = new Vector2(250, 320);
                foreach (var pad in GamePadControllers)
                {
                    pad.PlayerModel.SelectedCharacter = null;
                }
                break;
            }

            switch (value.CurrentState)
            {
            case GameState.StartScreen:
                startScreen.IsVisible = true;
                animateOut            = selectionScreen;
                animateIn             = startScreen;
                AddView(tipsText);
                break;

            case GameState.CharacterMenu:
                selectionScreen.IsVisible = true;
                if (value.PreviousState != GameState.MapsMenu)
                {
                    animateIn = selectionScreen;
                }
                //Loads the sounds for the menu
                CharacterSelectionVisible = true;

                Screen.soundController.PlaySound("Menu/chooseCharacter");
                break;

            case GameState.MapsMenu:
                selectionScreen.IsVisible = true;
                //if selection screen not has position
                //then the gameplay has exited to mapselection
                if (selectionScreen.GetAt(0) == null)
                {
                    animateIn = selectionScreen;
                }
                MapSelectionVisible = true;
                break;

            case GameState.GamePlay:
                AddController(new GamePlayController(Screen, selectedMap));
                DisposeController(this);

                break;

            case GameState.GamePause:
                break;

            case GameState.GameOver:
                selectionScreen.IsVisible = true;
                animateIn        = selectionScreen;
                GameStatsVisible = true;
                Screen.popupMenuController.Disabled = false;
                break;
            }

            if (animateIn != null)
            {
                animateIn.Layer = 2;
                animateIn.SetPosition(-1280, 0);
                animateIn.AnimatePos(0, 0, 600, false);
            }
            if (animateOut != null)
            {
                animateOut.Layer = 1;
                animateOut.SetPosition(0, 0);
                animateOut.AnimatePos(1280, 0, 600, false);
            }
        }