Exemple #1
0
        public GameScene(SpaceGame owner) : base(owner)
        {
            world = new World.World((0, 0), (owner.ScreenWidth, owner.ScreenHeight));

            uiManager = new UIManager(owner);
            uiManager.uiElements.Add(new HUD(world.player as World.Entities.Player));
        }
Exemple #2
0
        public override void LoadContent()
        {
            base.LoadContent();

            List <string> descriptionText = new List <string>(7);

            descriptionText.Add(String.Format("Model:              {0}", spaceShipDescription.Model));
            descriptionText.Add(String.Format("Category            {0}", spaceShipDescription.Category));
            descriptionText.Add(String.Format("Weight:             {0}", spaceShipDescription.Weight));
            descriptionText.Add(String.Format("Speed:              {0}", spaceShipDescription.GetSpeed()[0] * spaceShipDescription.GetSpeed()[1]));
            descriptionText.Add(String.Format("Primary weapon:     {0}", spaceShipDescription.PrimaryWeapons));
            descriptionText.Add(String.Format("Secondary weapon:   {0}", spaceShipDescription.SecondaryWeapons));
            descriptionText.Add(String.Format("Ship descrption:\n\n{0}", spaceShipDescription.Description));

            _shipImage.AssetName = spaceShipDescription.AssetName.Split(new char[] { '_' })[0].ToString();
            Add(_shipImage);

            _descriptions = new YnText[descriptionText.Count];
            for (int i = 0; i < descriptionText.Count; i++)
            {
                _descriptions[i]       = new YnText("Fonts/Messages", descriptionText[i], new Vector2(_container.X + 20, (_container.Y + 20) + 25 * i), Color.White);
                _descriptions[i].Scale = new Vector2(0.8f) * SpaceGame.GetScale();
                _descriptions[i].Color = Color.White;
                Add(_descriptions[i]);
            }
        }
Exemple #3
0
        public SettingsScene(SpaceGame owner) : base(owner)
        {
            uiManager = new UIManager(owner);
            TextButton backButton = new TextButton((10, 10), "back");

            backButton.OnMouseClicked += BackClicked;
            uiManager.uiElements.Add(backButton);
            uiManager.selected = backButton;

            TextButton saveButton = new TextButton(backButton.topRight + (1, 0), "save");

            saveButton.OnMouseClicked += SaveClicked;
            uiManager.uiElements.Add(saveButton);
            saveButton.left  = backButton;
            backButton.right = saveButton;

            TextButton lastButton = backButton;

            foreach (string action in owner.inputManager.bindings.Keys)
            {
                TextButton actionButton = new RebindButton(lastButton.bottomLeft + (0, 1), (180, 10), action);
                actionButton.OnMouseClicked += RebindClicked;
                uiManager.uiElements.Add(actionButton);
                lastButton.down = actionButton;
                actionButton.up = lastButton;
                lastButton      = actionButton;
            }

            foreach (UIElement element in uiManager.uiElements)
            {
                element.OnMouseHover += AnyElementHover;
            }
        }
Exemple #4
0
        public ShipProfileItem(SpaceShipType type, bool selected = false)
        {
            _shipType = type;
            Selected  = selected;

            int widthOverTwo  = YnG.Width / 2;
            int heightOverTwo = YnG.Height / 2;

            _border = new YnSprite(new Rectangle(
                                       (int)SpaceGame.GetScaleX(450),
                                       (int)SpaceGame.GetScaleY(150),
                                       (int)SpaceGame.GetScaleX(650),
                                       (int)SpaceGame.GetScaleY(400)),
                                   Color.White);

            Add(_border);

            _container = new YnSprite(new Rectangle(
                                          (int)_border.X + BorderSize,
                                          (int)_border.Y + BorderSize,
                                          _border.Width - BorderSize * 2,
                                          _border.Height - BorderSize - 2), new Color(0, 108, 165));
            Add(_container);

            _shipImage = new YnSprite();

            spaceShipDescription = Registry.SpaceShipDescriptions[(int)_shipType];
        }
        public ControlButton(SpaceGame game) : base(game)
        {
            this.IsVisible = true;

            this.text        = null;
            this.rectClicked = DefaultRectSource;
        }
Exemple #6
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (var game = new SpaceGame())
     {
         game.Run();
     }
 }
Exemple #7
0
        public MainGame(SpaceGame game)
        {
            //start the SpaceGame by settings up the hud
            manager = game;

            //load the hud
            hud = new TouchHUD(game, manager.GameContent.Load <Texture2D>("FireButton"), manager.Content.Load <Texture2D>("Joystick"));

            player = new Player(manager.GameContent.Load <Model>("PlayerShip"), new Place());

            player.Magnitude = 2f;



            //set up the camera to have it look at the player
            camera = new Camera(game.Width, game.Height);

            //set the game state to default
            state = GameState.IN_MENU;

            //set up the start menu
            startMenu = new MainMenu(manager.GameContent.Load <Texture2D>("Play"),
                                     manager.GameContent.Load <Texture2D>("Title"), new Vector2(manager.Width, manager.Height), this);

            //load the font
            font = game.GameContent.Load <SpriteFont>("Font");

            //load the file text
            testText = MainActivity.getInstance().readTxtFromAssets("Level1.txt");
        }
        public MenuScene(SpaceGame owner) : base(owner)
        {
            uiManager = new UIManager(owner);

            TextButton playButton = new TextButton((10, 10), "play");

            playButton.OnMouseClicked += PlayClicked;
            uiManager.uiElements.Add(playButton);

            TextButton settingsButton = new TextButton(playButton.bottomLeft + (0, 1), "settings");

            settingsButton.OnMouseClicked += SettingsClicked;
            uiManager.uiElements.Add(settingsButton);

            TextButton quitButton = new TextButton(settingsButton.bottomLeft + (0, 1), "quit");

            quitButton.OnMouseClicked += QuitClicked;
            uiManager.uiElements.Add(quitButton);

            uiManager.selected  = playButton;
            playButton.down     = settingsButton;
            settingsButton.down = quitButton;
            settingsButton.up   = playButton;
            quitButton.up       = settingsButton;
        }
Exemple #9
0
        public SelectLevelState(int shipType)
            : base("Select a level", 3)
        {
            _selectedShip  = shipType;
            _selectedLevel = 0;

            spaceLevelImage       = new YnEntity("Backgrounds/selectStars");
            spaceLevelImage.Scale = SpaceGame.GetScale();
            Add(spaceLevelImage);

            escapeLevelImage       = new YnEntity("Backgrounds/selectEscape");
            escapeLevelImage.Scale = SpaceGame.GetScale();
            Add(escapeLevelImage);

            Rectangle rectangle = new Rectangle(
                YnG.Width / 2 - MenuItem.SmallItemWidth / 2,
                YnG.Height - (int)SpaceGame.GetScaleY(75),
                MenuItem.SmallItemWidth,
                MenuItem.SmallItemHeight);

            MenuItem backItem = new MenuItem("Back", rectangle, 2, false);

            backItem.ItemTextSize = SpaceGame.GetScale();

            backItem.MouseClicked += new EventHandler <MouseClickEntityEventArgs>(item_MouseJustClicked);
            backItem.MouseLeave   += new EventHandler <MouseLeaveEntityEventArgs>(item_MouseLeave);
            backItem.MouseOver    += new EventHandler <MouseOverEntityEventArgs>(item_MouseOver);
            Add(backItem);

            items.Add(backItem);
        }
Exemple #10
0
        private Texture2D TryLoadPNG(FileInfo finfo)
        {
            Stream fileStream = finfo.Open(FileMode.Open, FileAccess.Read);
            var    texture    = Texture2D.FromStream(SpaceGame.GetGraphicsDevice(), fileStream);

            fileStream.Close();
            return(texture);
        }
Exemple #11
0
        public override void Draw(SpaceGame target)
        {
            base.Draw(target);

            target.FillRect(bounds.topLeft, bounds.bottomRight, currentColours.fill);
            target.DrawRect(bounds.topLeft, bounds.bottomRight, currentColours.outline);
            target.DrawText(bounds.topLeft + (1, 1), text, currentColours.foreground);
        }
 public ControlRadar(SpaceGame game)
     : base(game)
 {
     this.IsVisible = true;
     this.text      = null;
     this.textColor = WhiteTextColor;
     this.textAlign = TextAlign.MiddleLeft;
     color          = Color.White;
 }
Exemple #13
0
        public MenuState()
            : base("Codename : SpaceGame", 6)
        {
            // Les elements qui passent sous le menu
            _planetLogo = new YnEntity(Assets.PlanetRed);
            Add(_planetLogo);

            _shipSprite = new YnSprite(Assets.PlayerShipA);
            Add(_shipSprite);

            _kinectLogo = new YnEntity("Misc/kinect");
            Add(_kinectLogo);

            // 3 - Le menu
            string[] itemNames = { "Arcade", "Multiplayers", "Scores", "Options", "Credits", "Exit" };

            int x = (YnG.Width / 2) - MenuItem.BigItemWidth / 2;
            int y = 0;

            for (int i = 0; i < 3; i++)
            {
                y = (int)SpaceGame.GetScaleY(185) + i * MenuItem.BigItemHeight * 2;

                MenuItem item = new MenuItem(itemNames[i], new Rectangle(
                                                 (int)(x),
                                                 (int)(y),
                                                 MenuItem.BigItemWidth,
                                                 MenuItem.BigItemHeight),
                                             i,
                                             i == 0 ? true : false);

                item.ItemTextSize  = SpaceGame.GetScale();
                item.MouseClicked += new EventHandler <MouseClickEntityEventArgs>(item_MouseJustClicked);
                item.MouseLeave   += new EventHandler <MouseLeaveEntityEventArgs>(item_MouseLeave);
                item.MouseOver    += new EventHandler <MouseOverEntityEventArgs>(item_MouseOver);
                Add(item);

                items.Add(item);
            }

            x = 0;
            y = YnG.Height - (MenuItem.SmallItemHeight + MenuItem.SmallItemHeight / 3);

            for (int j = 3; j < 6; j++)
            {
                x = (int)SpaceGame.GetScaleX(350) + (j - 3) * MenuItem.SmallItemWidth * 2;

                MenuItem item = new MenuItem(itemNames[j], new Rectangle(x, y, MenuItem.SmallItemWidth, MenuItem.SmallItemHeight), j, false);
                item.ItemTextSize  = new Vector2(0.6f) * SpaceGame.GetScale();
                item.MouseClicked += new EventHandler <MouseClickEntityEventArgs>(item_MouseJustClicked);
                item.MouseLeave   += new EventHandler <MouseLeaveEntityEventArgs>(item_MouseLeave);
                item.MouseOver    += new EventHandler <MouseOverEntityEventArgs>(item_MouseOver);
                Add(item);

                items.Add(item);
            }
        }
        public SelectShipState()
            : base("Space ship selection", 4)
        {
            _selectedShip = 0;

            string[] itemsText = { "ZX Thunder 4", "Pulsar X6", "MRC-A1", "Mantra N4", "Back", "Ready" };

            shipProfileItem = new ShipProfileItem[4];

            for (int i = 0; i < 4; i++)
            {
                int y = (int)SpaceGame.GetScaleY(150) + i * ItemHeight + (int)SpaceGame.GetScaleY(10);

                MenuItem item = new MenuItem(itemsText[i], new Rectangle(
                                                 (int)SpaceGame.GetScaleX(50),
                                                 y,
                                                 ItemWidth,
                                                 ItemHeight),
                                             i,
                                             i == 0 ? true : false);

                item.ItemTextSize = SpaceGame.GetScale();

                item.ItemTextSize  = new Vector2(0.6f) * SpaceGame.GetScale();
                item.MouseOver    += item_MouseOver;
                item.MouseLeave   += item_MouseLeave;
                item.MouseClicked += item_MouseJustClicked;
                Add(item);

                items.Add(item);

                shipProfileItem[i]        = new ShipProfileItem((SpaceShipType)i, i == 0 ? true : false);
                shipProfileItem[i].Active = ((i == 0) ? true : false);
                Add(shipProfileItem[i]);
            }

            for (int j = 4; j < 6; j++)
            {
                int x = (int)SpaceGame.GetScaleX(50);

                if (j > 4)
                {
                    x = YnG.Width - MenuItem.SmallItemWidth - 50;
                }

                int y = YnG.Height - (MenuItem.SmallItemHeight + (MenuItem.SmallItemHeight / 3));

                MenuItem item = new MenuItem(itemsText[j], new Rectangle(x, y, MenuItem.SmallItemWidth, MenuItem.SmallItemHeight), j, false);
                item.ItemTextSize  = new Vector2(0.6f) * SpaceGame.GetScale();
                item.MouseOver    += item_MouseOver;
                item.MouseLeave   += item_MouseLeave;
                item.MouseClicked += item_MouseJustClicked;
                Add(item);

                items.Add(item);
            }
        }
Exemple #15
0
        public override void Update(SpaceGame target, float elapsed)
        {
            base.Update(target, elapsed);

            lifetime -= elapsed;
            if (lifetime < 0)
            {
                wantToDie = true;
            }
        }
Exemple #16
0
        public Bar(SpaceGame game) : base(game)
        {
            this.IsVisible = true;
            this.text      = null;
            this.textAlign = TextAlign.MiddleLeft;

            value    = game.utilities.minusInf;
            MaxWidth = 0;

            color = Color.White;
        }
Exemple #17
0
        public override void Initialize()
        {
            base.Initialize();

            _title.Position = new Vector2(50, 25);

            Registry.AudioManager.SpeakAsync("Who are behind, this awesome game ?");

            background.Scale    = SpaceGame.GetScale();
            background.Position = new Vector2(YnG.Width / 2 - background.Width / 2, YnG.Height / 2 - background.Height / 2);
        }
Exemple #18
0
        public override void Update(SpaceGame target)
        {
            base.Update(target);

            int scroll = (int)target.MouseScroll;

            scrollLocation -= scroll * 5;

            scrollLocation           = scrollLocation.Constrain(0, bounds.Height - scrollBar.bounds.Height);
            scrollbarPositionChanged = true;
        }
        private void Load(ResourceDefinition def)
        {
            Texture2D sprite;

            using (FileStream fileStream =
                       new FileStream(def.PathToTexture.FullName, FileMode.Open))
            {
                sprite = Texture2D.FromStream(SpaceGame.GetGraphicsDevice(), fileStream);
            }
            def.SetRenderable(sprite);
        }
Exemple #20
0
        public Asteroids(SpaceGame game)
        {
            this.game = game;
            asteroids = new LinkedList <Asteroid>();

            damageParticleSystem         = new Particle3D.ExplosionParticleSystem(game, game.Content, 4, Color.White);
            explosionParticleSystem      = new Particle3D.ExplosionParticleSystem(game, game.Content, 8, Color.White);
            explosionSmokeParticleSystem = new Particle3D.ExplosionSmokeParticleSystem(game, game.Content, 5, Color.White);
            game.Components.Add(damageParticleSystem);
            game.Components.Add(explosionParticleSystem);
            game.Components.Add(explosionSmokeParticleSystem);
        }
        public InputManager(SpaceGame owner)
        {
            this.owner = owner;

            Bind("fire", Key.Space);
            Bind("cancel", Key.Escape);
            Bind("confirm", Key.Enter);
            Bind("up", Key.W);
            Bind("down", Key.S);
            Bind("left", Key.A);
            Bind("right", Key.D);
            Load();
        }
Exemple #22
0
        public override void Initialize()
        {
            base.Initialize();

            Vector2 scale = new Vector2(1.3f) * SpaceGame.GetScale();

            _shipImage.Origin = new Vector2(_shipImage.Width / (2 * scale.X), _shipImage.Height / (2 * scale.Y));
            _shipImage.Scale  = scale;

            _shipImage.Position = new Vector2(
                ((_container.X + _container.Width) - _shipImage.Width / (2 * scale.Y)) - 50,
                _container.Y + _shipImage.Height / (2 * scale.Y));
        }
Exemple #23
0
        public override void Draw(SpaceGame target)
        {
            target.PixelMode = Pixel.Mode.Alpha;

            // motion information
            // box
            vf boxTopLeft     = bounds.bottomRight - 60;
            vf boxBottomRight = boxTopLeft + 50;
            vf boxMiddle      = boxTopLeft + 25;

            target.FillRect(boxTopLeft, boxBottomRight, new Pixel(200, 100, 100, 100));

            vf dirOfVel  = player.vel.Normalized() * Math.Min(player.vel.Length * 10, 23);
            vf dirOfShip = vf.Along(default, 10, -player.rotation + (float)Math.PI / 2);
Exemple #24
0
        public GameUI(SpacePlayer [] players)
        {
            int nbPlayer = players.Length;

            minutes      = 0;
            seconds      = 0;
            milliseconds = 0;

            Vector2 scale = SpaceGame.GetScale();

            _guiGroup        = new YnGroup(2);
            _scoreText       = new YnText("Fonts/ScoresUI", "0");
            _scoreText.Color = Color.Wheat;
            Add(_scoreText);

            _timeText       = new YnText("Fonts/ScoresUI", "00:00:000");
            _timeText.Color = Color.Wheat;
            Add(_timeText);

            _playerWeaponBox = new PlayerWeaponBox[nbPlayer];

            for (int i = 0; i < nbPlayer; i++)
            {
                // Si 2 joueurs on a un alignement en bas
                int x = (i * 1100) + 25;
                int y = 700;

                // Sinon les joueurs 1 et 2 sont en haut
                // Et les autres en bas
                if (nbPlayer > 2)
                {
                    // Joueurs 1 et 2
                    if (i < 2)
                    {
                        y = 25;
                    }

                    // Joueurs 3 et 4
                    else
                    {
                        x = ((i - 2) * 1100) + 25;
                        y = 700;
                    }
                }

                _playerWeaponBox[i] = new PlayerWeaponBox(x, y, players[i], ref scale);
                Add(_playerWeaponBox[i]);
            }
        }
Exemple #25
0
        public override void Draw(SpaceGame target)
        {
            base.Draw(target);
            AABB contentRect = GetContentAABB();

            int runningHeight = padding;

            runningHeight -= (int)(scrollLocation / bounds.Height * contentRect.Height);

            foreach (UIElement element in contents)
            {
                AABB bounds = element.bounds.AtOrigin;
                element.bounds.topLeft     = topLeft + (padding, runningHeight);
                element.bounds.bottomRight = element.bounds.topLeft + bounds.bottomRight;
                runningHeight += (int)element.bounds.Height + padding;
            }

            // use back buffer for clipping
            target.DrawTarget = backBuffer;
            target.Clear(PixelEngine.Pixel.Empty);

            foreach (UIElement element in contents)
            {
                element.Update(target);

                if (bounds.Overlaps(element.bounds))
                {
                    element.Draw(target);
                }
            }

            scrollbarHeight = bounds.Height / contentRect.Height * bounds.Height;
            AABB scrollbarRect = new AABB(topRight + (-10, scrollLocation), topRight + (0, scrollbarHeight + scrollLocation));

            scrollBar.bounds = scrollbarRect;

            // only draw scrollbar if scrolling is required
            if (scrollbarHeight != size.y)
            {
                scrollBar.Update(target);
                scrollBar.Draw(target);
            }

            // switch back to main buffer
            PixelEngine.Sprite scrollContainerSurface = target.DrawTarget;
            target.DrawTarget = null;

            target.DrawPartialSprite(topLeft, scrollContainerSurface, topLeft, (int)bounds.Width, (int)bounds.Height);
        }
Exemple #26
0
        public ShipDesignerGameState(SpaceGame game)
            : base(game)
        {
            game.Resized += OnResized;

            Map = new ShipDesignerMap(game.Data);
            ShipDesignerMapView mapView     = new ShipDesignerMapView(Map);
            UIViewport          mapViewport = new UIViewport(96, 0, UI.Width - 96, UI.Height, mapView, game);

            mapViewport.IsAlwaysAtBottom = true;
            ShipDesignerModuleView moduleView     = new ShipDesignerModuleView(Map);
            UIViewport             moduleViewport = new UIViewport(0, 0, 96, UI.Height, moduleView, game);

            moduleViewport.IsAlwaysAtBottom = true;

            SpriteData     testSprite = game.Data.Sprites["TestIcon"];
            UIButtonSimple testButton = new UIButtonSimple(
                mapViewport.Bounds.Right - testSprite.Width * 4, mapViewport.Bounds.Bottom - testSprite.Height, testSprite.Width, testSprite.Height,
                Map.TestShip, testSprite.Base);
            //testButton.Tooltip = "Test the ship";

            SpriteData     newSprite = game.Data.Sprites["NewIcon"];
            UIButtonSimple newButton = new UIButtonSimple(
                mapViewport.Bounds.Right - newSprite.Width * 3, mapViewport.Bounds.Bottom - newSprite.Height, newSprite.Width, newSprite.Height,
                Map.NewShip, newSprite.Base);
            //newButton.Tooltip = "Create a new ship";

            SpriteData     saveSprite = game.Data.Sprites["SaveIcon"];
            UIButtonSimple saveButton = new UIButtonSimple(
                mapViewport.Bounds.Right - saveSprite.Width * 2, mapViewport.Bounds.Bottom - saveSprite.Height, saveSprite.Width, saveSprite.Height,
                Map.SaveShip, saveSprite.Base);
            //saveButton.Tooltip = "Save the current ship";

            SpriteData     loadSprite = game.Data.Sprites["LoadIcon"];
            UIButtonSimple loadButton = new UIButtonSimple(
                mapViewport.Bounds.Right - loadSprite.Width, mapViewport.Bounds.Bottom - loadSprite.Height, loadSprite.Width, loadSprite.Height,
                Map.LoadShip, loadSprite.Base);

            //loadButton.Tooltip = "Load a ship";

            UI.Add(testButton, newButton, saveButton, loadButton, moduleViewport, mapViewport);
        }
Exemple #27
0
    public static void Main()
    {
        Window    _window    = new Window("SpaceGame", 800, 800);
        SpaceGame _SpaceGame = new SpaceGame(_window);

        while (!_window.CloseRequested && !_SpaceGame.ESC)
        {
            if (_SpaceGame.Restart)
            {
                _SpaceGame = new SpaceGame(_window);
            }
            SplashKit.ProcessEvents();
            _window.Clear(Color.RGBColor(193, 154, 107));
            _SpaceGame.Update();
            _SpaceGame.Draw();
            _window.Refresh();
        }
        _window.Close();
        _window = null;
    }
Exemple #28
0
        public virtual void Update(SpaceGame target, float elapsed)
        {
            graphics.position_w = position_w;

            // a = F / m
            vel   += forces / mass * elapsed;
            forces = (0, 0);

            position_w += vel;

            // rotation hack
            rotationVel   += rotationForces / mass * elapsed;
            rotationForces = 0;

            if (rotationVel >= rotationVelCap || rotationVel <= -rotationVelCap)
            {
                rotationVel = rotationVelCap * System.Math.Sign(rotationVel);
            }
            rotation   += rotationVel;
            rotationVel = rotationVel.TowardsButNotPass(0, rotationalDecayAmount * elapsed);
        }
Exemple #29
0
        public MyObject(SpaceGame game)
        {
            this.game = game;
            Vector3 axis = new Vector3(0, 0, 0);
            int     dir  = RandomNumber(1, 3);

            switch (dir)
            {
            case 1:
                axis.X = 1;
                break;

            case 2:
                axis.Y = 1;
                break;

            case 3:
                axis.Z = 1;
                break;
            }
            this.Orientation = Quaternion.CreateFromAxisAngle(axis, RandomNumber(-PI, PI));
        }
        public GameLevel1(SpaceGame game) : base(game)
        {
            /*Neutral Objects*/
            asteroids           = new Asteroids(game);
            backgroundAsteroids = new Asteroids(game);
            backgroundPlanets   = new Planets(game);
            //aircrafts = new Aircrafts(game);
            bullets = new Bullets(game);

            /*Players*/
            player1 = new Player1(game);
            player2 = new Player2(game);
            pilots  = new Pilots(game);

            // questStage = Level1Quests.START;
            questStage     = Level1Quests.ENEMYFOCUS;
            startQuest     = false;
            StartQuestTime = 0;

            destroyedAsteroids     = 0;
            destroyedEnemyAircraft = 0;
        }
Exemple #31
0
        public ScoreState(bool saveScore = false)
            : base("Scores", 1)
        {
            //background = new YnEntity("Backgrounds/options");
            //Add(background);

            int scoreSize = Registry.ScoreManager.GameScores.Count;
            int x         = (int)SpaceGame.GetScaleX(150);

            for (int i = 0; i < scoreSize; i++)
            {
                YnText text = new YnText("Fonts/Menu", String.Format("{0}", _playerScore[i].GetDetailedMenuString(7, 7)), new Vector2(x, 130 + i * 55), Color.White);
                text.Scale = new Vector2(1.2f) * SpaceGame.GetScale();
                Add(text);
            }

            Rectangle rectangle = new Rectangle(
                YnG.Width / 2 - (int)SpaceGame.GetScaleX(MenuItem.SmallItemWidth) / 2,
                YnG.Height - (int)SpaceGame.GetScaleY(75),
                (int)SpaceGame.GetScaleX(MenuItem.SmallItemWidth),
                (int)SpaceGame.GetScaleY(MenuItem.SmallItemHeight));

            MenuItem item = new MenuItem("Menu", rectangle, 0, false);

            item.ItemTextSize  = SpaceGame.GetScale();
            item.MouseClicked += new EventHandler <MouseClickEntityEventArgs>(item_MouseJustClicked);
            item.MouseLeave   += new EventHandler <MouseLeaveEntityEventArgs>(item_MouseLeave);
            item.MouseOver    += new EventHandler <MouseOverEntityEventArgs>(item_MouseOver);
            Add(item);

            items.Add(item);

            if (saveScore)
            {
                _playerScore.Update();
                _playerScore.Record();
            }
        }
Exemple #32
0
        public GUI(SpaceGame.units.Spaceman player, SpaceGame.units.BlackHole blackhole)
        {
            this.screenHeight = Game1.SCREENHEIGHT;
            this.screenWidth = Game1.SCREENWIDTH;

            targetWheelRec.X = (screenWidth / 2) - 32;
            targetWheelRec.Y = screenHeight - targetWheel.Height;
            targetWheelRec.Width = targetWheel.Width;
            targetWheelRec.Height = targetWheel.Height;

            leftClickRec.X = (screenWidth / 2) - 99;
            leftClickRec.Y = screenHeight - leftClick.Height;
            leftClickRec.Width = leftClick.Width;
            leftClickRec.Height = leftClick.Height;

            rightClickRec.X = (screenWidth / 2) + 148;
            rightClickRec.Y = screenHeight - rightClick.Height;
            rightClickRec.Width = rightClick.Width;
            rightClickRec.Height = rightClick.Height;

            spaceClickRec.X = (screenWidth / 2) + 256;
            spaceClickRec.Y = screenHeight - spaceClick.Height;
            spaceClickRec.Width = spaceClick.Width;
            spaceClickRec.Height = spaceClick.Height;

            shiftClickRec.X = (screenWidth / 2) - 340;
            shiftClickRec.Y = screenHeight - shiftClick.Height;
            shiftClickRec.Width = shiftClick.Width;
            shiftClickRec.Height = shiftClick.Height;

            button1Rec.X = (screenWidth / 2) - 412;
            button1Rec.Y = screenHeight - button1.Height;
            button1Rec.Width = button1.Width;
            button1Rec.Height = button1.Height;

            button3Rec.X = button1Rec.X;
            button3Rec.Y = button1Rec.Y - button1.Height - 5;
            button3Rec.Width = button3.Width;
            button3Rec.Height = button3.Height;

            button5Rec.X = button1Rec.X;
            button5Rec.Y = button1Rec.Y - 2*button1.Height - 2*5;
            button5Rec.Width = button5.Width;
            button5Rec.Height = button5.Height;

            button2Rec.X = (screenWidth / 2) - 484;
            button2Rec.Y = screenHeight - button2.Height;
            button2Rec.Width = button2.Width;
            button2Rec.Height = button2.Height;

            button4Rec.X = button2Rec.X;
            button4Rec.Y = button2Rec.Y - button2.Height - 5;
            button4Rec.Width = button4.Width;
            button4Rec.Height = button4.Height;

            button6Rec.X = button2Rec.X;
            button6Rec.Y = button2Rec.Y - 2 * button2.Height - 2 * 5;
            button6Rec.Width = button6.Width;
            button6Rec.Height = button6.Height;

            voidWheelRec.X = targetWheelRec.X + targetWheel.Width / 2 - voidWheel.Width / 2;
            voidWheelRec.Y = 0;
            voidWheelRec.Width = voidWheel.Width;
            voidWheelRec.Height = voidWheel.Height;

            this.player = player;
            this.blackhole = blackhole;

            //Initialize health bar in its location
            Vector2 healthBarLoc = new Vector2(targetWheelRec.X + targetWheelRec.Width / 2, (int)(targetWheelRec.Y + HEIGHT_ADJUST * targetWheelRec.Height));
            healthBar = new RadialBar(healthBarLoc, targetWheelRec.Width / RADIUS_ADJUST, 25, -(float)Math.PI / ARC_ADJUST, (float)Math.PI / ARC_ADJUST, Color.Red);

            //Initialize void bar in its location
            Vector2 voidBarLoc = new Vector2(voidWheelRec.X + voidWheelRec.Width / 2, (int)(voidWheelRec.Y + voidWheelRec.Height - 10));
            voidBar = new RadialBar(voidBarLoc, voidWheelRec.Width / RADIUS_ADJUST, 25, (float)(2 * Math.PI - (float)Math.PI / VOID_ARC_ADJUST), (float)Math.PI / VOID_ARC_ADJUST, Color.Purple);
        }
Exemple #33
0
 protected State()
 {
     this._game = SpaceGame.Instance;
 }