Пример #1
0
 /// <summary>
 /// Draws the content on the specified spriteBatch.
 /// </summary>
 /// <param name="spriteBatch">Sprite batch.</param>
 public virtual void Draw(SpriteBatch spriteBatch)
 {
     foreach (GuiElement guiElement in GuiElements.Where(w => w.Visible))
     {
         guiElement.Draw(spriteBatch);
     }
 }
Пример #2
0
        protected SCOR.AScorItem GetGuiElement(string name, byte[] data)
        {
            SCOR.AScorItem ret = null;
            if (GuiElements.ContainsKey(name))
            {
                ret = System.Activator.CreateInstance(GuiElements[name], new object[] { this }) as SCOR.AScorItem;
            }
            if (ret == null)
            {
                ret = new SCOR.ScoreItemDefault(this);
            }
            if (data != null)
            {
                System.IO.BinaryReader br = new System.IO.BinaryReader(new System.IO.MemoryStream(data));
                ret.SetData(name, br);
                br.Close();
            }

            return(ret);
        }
Пример #3
0
        /// <summary>
        /// Updates the content.
        /// </summary>
        /// <param name="gameTime">Game time.</param>
        public virtual void Update(GameTime gameTime)
        {
            GuiElements.RemoveAll(e => e.IsDisposed);

            foreach (GuiElement guiElement in GuiElements.Where(e => e.Enabled).Reverse())
            {
                if (InputManager.Instance.MouseButtonInputHandled)
                {
                    break;
                }

                guiElement.HandleInput();
            }

            InputManager.Instance.MouseButtonInputHandled = false;

            foreach (GuiElement guiElement in GuiElements.Where(e => e.Enabled))
            {
                guiElement.Update(gameTime);
            }
        }
Пример #4
0
 /// <summary>
 /// Unloads the content.
 /// </summary>
 public virtual void UnloadContent()
 {
     GuiElements.ForEach(w => w.UnloadContent());
     GuiElements.Clear();
 }
Пример #5
0
 /// <summary>
 /// Loads the content.
 /// </summary>
 public void LoadContent()
 {
     GuiElements.ToList().ForEach(w => w.LoadContent());
 }
Пример #6
0
 /// <summary>
 /// Focuses the input on the element with the specified identifier.
 /// </summary>
 /// <param name="id">Element identifier.</param>
 public void FocusElement(string id)
 {
     GuiElements.ForEach(e => e.InputFocus = false);
     GuiElements.FirstOrDefault(e => e.Id == id).InputFocus = true;
 }
Пример #7
0
 public BaseGui()
 {
     GuiElements.Add(this);
 }
Пример #8
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            screencentre = new Vector2(graphics.GraphicsDevice.Viewport.Width / 2, graphics.GraphicsDevice.Viewport.Height / 2);

            Pop = Content.Load<SoundEffect>(".\\Sound\\BruitSec");
            Enemy = new Jets();
            for (int i = 0; i < Enemy.jets.Length; i++)
            {
                Enemy.jets[i].charModel = Content.Load<Model>(".\\Models\\balloonRed");
            }
            Jet = Content.Load<Model>(".\\Models\\eurofighter fbx");

            player = new mainPlayer(cameraPosition, screencentre, aspectRatio);
            player.charModel = Content.Load<Model>(".\\Models\\RedBalloon");

            newcamera = new Camera(campos2, Vector3.Zero, Vector3.Up, screencentre);
            newcamera.setPerspectiveProjection(45.0f, aspectRatio, 1.0f, 1000.0f);
            thirdPerCamera = new Camera(player.Position + thirdPerOffset, player.Position,Vector3.Up,screencentre);
            thirdPerCamera.setPerspectiveProjection(45.0f, aspectRatio , 1.0f, 1000.0f);

            physics = new Physics(player.bulletlist.Length, redballoon.Length);

            Font = Content.Load<SpriteFont>(".\\Fonts\\Basic");

            Button = Content.Load<Texture2D>(".\\Textures\\Button");
            StartButton = new GuiElements((screencentre - new Vector2(Button.Width - 100 ,Button.Height + 120)));
            Medium = new GuiElements((screencentre - new Vector2(Button.Width - 100, Button.Height - 120)));
            Hard = new GuiElements((screencentre - new Vector2(Button.Width - 100, Button.Height)));

            //Textures For Weapon Equip Gui
            WeaponGUI[0] = Content.Load<Texture2D>(".\\Textures\\KnifeSelected");
            WeaponGUI[1] = Content.Load<Texture2D>(".\\Textures\\KnifeUnSelected");
            WeaponGUI[2] = Content.Load<Texture2D>(".\\Textures\\GunSlelected");
            WeaponGUI[3] = Content.Load<Texture2D>(".\\Textures\\GunUnslelected");
            WeaponGUI[4] = Content.Load<Texture2D>(".\\Textures\\goldenBulletsel");
            WeaponGUI[5] = Content.Load<Texture2D>(".\\Textures\\goldenBulletUnsel");

            WeaponsState[0] = new GuiElements(new Vector2(screencentre.X - (2.0f * (WeaponGUI[0].Width) / 2), 350.0f));
            WeaponsState[1] = new GuiElements(new Vector2(screencentre.X -  (0.5f * (WeaponGUI[0].Width) / 2), 350.0f));
            WeaponsState[2] = new GuiElements ( new Vector2(screencentre.X +  (2.0f * (WeaponGUI[0].Width) / 2),350.0f));

            crosshair = Content.Load<Texture2D>(".\\Textures\\crosshair");
            crosshairpos = new Vector2((screencentre.X - (crosshair.Width / 2)), (screencentre.Y - (crosshair.Height / 2)));

            XboxController = Content.Load<Texture2D>(".\\Textures\\Contorller");
            controllerSelectScreem = Content.Load<Texture2D>(".\\Textures\\ControllerSelection");
            KeyBoardController = Content.Load<Texture2D>(".\\Textures\\keyboard");

            player.available = mainPlayer.Weapons.shortRange;

            currentcamera = player.eyes;

            icounter = 99;

            for (int i = 0; i < player.bulletlist.Length; i++)
            {
                player.bulletlist[i].charModel = Content.Load<Model>(".\\Models\\Bullet");
                player.bulletlist[i].charRotation += MathHelper.Pi;

            }

            player.shortRange.charModel = Content.Load<Model>(".\\Models\\Short");
            player.LongRange.charModel = Content.Load<Model>(".\\Models\\Untitled");

            for (int i = 0; i < redballoon.Length; i++)
            {

                balloonPos = new Vector3(random.Next(playfield), 0.0f, random.Next(playfield));
                redballoon[i] = new Luft(balloonPos);
                redballoon[i].charModel = Content.Load<Model>(".\\Models\\RedBalloon");

            }
            GreenBalloon = new Character( new Vector3(80.0f,40.0f,120.0f));
            GreenBalloon.charModel = Content.Load<Model>(".\\Models\\balloonGreen");
            BlueBalloon = new Character( new Vector3(120.0f,0.0f,80.0f));
            BlueBalloon.charModel = Content.Load<Model>(".\\Models\\balloonBlue");
            GoldBalloon = new Character(new Vector3( 0.0f, 110.0f, 0.0f));
            GoldBalloon.charModel = Content.Load<Model>(".\\Models\\balloonGold");

            //-------------------------------------------------------------
            // added to load Model
            //-------------------------------------------------------------

            aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;

            // TODO: use this.Content to load your game content here
        }