Пример #1
0
 private void HandleOptionBar(OptionBar optionBar, int addition)
 {
     if (addition > 0)
     {
         if (optionBar.TenPercentage != 10)
         {
             optionBar.TenPercentage += addition;
         }
     }
     else if (addition < 0)
     {
         if (optionBar.TenPercentage != 0)
         {
             optionBar.TenPercentage += addition;
         }
     }
 }
Пример #2
0
        public OptionMenu(GameEngine engine)
        {
            this.engine = engine;
            float btnXPos = engine.GetScreenSize().Width / 2;
            float btnYPos = engine.GetScreenSize().Height / 2;

            backBtn = new Button("backBtn", btnXPos - 200, btnYPos + 200, 150, 50, 0,
                                 new BoundingBox(new Vector3(0, 0, 0), new Vector3(0, 0, 0)), 1, null, false, true, 2);

            menu = new RenderedEntity("menu", engine.GetScreenSize().Width / 2, engine.GetScreenSize().Height / 2, 600, 480, 0,
                                      new BoundingBox(), 0, null);

            volume = new OptionBar("masterVolume", engine.GetScreenSize().Width / 2, engine.GetScreenSize().Height / 2 - 100, 165, 24, 0,
                                   new BoundingBox(), 1, null, false, false, 10, 0, new Rectangle(0, 0, 0, 0));

            fullscreen = new CheckBox("fullscreen", engine.GetScreenSize().Width / 2, engine.GetScreenSize().Height / 2 + 0, 20, 20, 0,
                                      new BoundingBox(), 1, null, false, false, 1);
        }
Пример #3
0
        public void HandleOptionBar(OptionBar optionBar)
        {
            if (!optionBar.IsHighlighted)
            {
                engine.AddTextureOnEntity("Bars", optionBar.ID);
            }
            else
            {
                engine.AddTextureOnEntity("Bars_Y", optionBar.ID);
            }
            int x      = optionBar.TenPercentage * (engine.GetTextureWidth("Bars") / 11);
            int width  = engine.GetTextureWidth("Bars") / 11;
            int height = engine.GetTextureHeight("Bars");

            switch (optionBar.TenPercentage)
            {
            case 0:
                if (optionBar.Texture == null || !optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                else if (optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                break;

            case 1:
                if (optionBar.Texture == null || !optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                else if (optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                break;

            case 2:
                if (optionBar.Texture == null || !optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                else if (optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                break;

            case 3:
                if (optionBar.Texture == null || !optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                else if (optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                break;

            case 4:
                if (optionBar.Texture == null || !optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                else if (optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                break;

            case 5:
                if (optionBar.Texture == null || !optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                else if (optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                break;

            case 6:
                if (optionBar.Texture == null || !optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                else if (optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                break;

            case 7:
                if (optionBar.Texture == null || !optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                else if (optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                break;

            case 8:
                if (optionBar.Texture == null || !optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                else if (optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                break;

            case 9:
                if (optionBar.Texture == null || !optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                else if (optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                break;

            case 10:
                if (optionBar.Texture == null || !optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                else if (optionBar.IsHighlighted)
                {
                    engine.HandleSpriteSheet(optionBar.ID, new Rectangle(x, 0, width, height));
                }
                break;
            }
        }
Пример #4
0
        //Defines which content should be ed for the specified entity

        /*TODO iteration3: First of all add more content to the game engine, but  it should also
         * be able to  content not only for a player but also other kinds of objects
         */
        public void OnNext(List <Texture2D> value)
        {
            for (int i = 0; i < engine.Entities.Count; i++)
            {
                if (engine.Entities [i].GetType() == typeof(Player))
                {
                    HandlePlayerContent(value, i);
                }

                else if (engine.Entities [i].GetType() == typeof(Tile))
                {
                    Tile tile = (Tile)engine.Entities [i];

                    if (tile.Texture == null)
                    {
                        Random r = new Random(int.Parse(Guid.NewGuid().ToString().Substring(0, 8),
                                                        System.Globalization.NumberStyles.HexNumber));
                        int randInt = r.Next(1, nTileTypes + 1);
                        tile.Texture = value.Find(x => x.Name.Equals("tile_" + randInt));
                    }
                    engine.Entities [i] = tile;
                }
                if (engine.Entities [i].GetType() == typeof(HealthBar))
                {
                    HealthBar healthBar = (HealthBar)engine.Entities [i];
                    if (healthBar.Texture == null)
                    {
                        engine.AddTextureOnEntity("health_Bar", healthBar.ID);
                    }
                }
                if (engine.Entities [i].GetType() == typeof(HungerBar))
                {
                    HungerBar hungerBar = (HungerBar)engine.Entities [i];
                    if (hungerBar.Texture == null)
                    {
                        engine.AddTextureOnEntity("hunger_Bar", hungerBar.ID);
                    }
                }
                if (engine.Entities[i].GetType() == typeof(Bush))
                {
                    Bush bush = (Bush)engine.Entities [i];

                    if (bush.Texture == null)
                    {
                        bush.Texture = value.Find(x => x.Name.Equals("bush_2"));
                    }
                    //engine.Entities[i] = bush;
                    if (bush.IsUsed)
                    {
                        engine.AddTextureOnEntity("bush_1", bush.ID);
                    }
                }

                if (engine.Entities[i].GetType() == typeof(Wolf))
                {
                    HandleWolfContent(value, i);
                }

                else if (engine.Entities [i].GetType() == typeof(Button))
                {
                    Button button = (Button)engine.Entities [i];
                    HandleButtonTexture(button);
                }
                else if (engine.Entities [i].GetType() == typeof(CheckBox))
                {
                    CheckBox checkBox = (CheckBox)engine.Entities [i];
                    if (checkBox.Texture == null || !checkBox.IsHighlighted)
                    {
                        if (!checkBox.IsChecked)
                        {
                            engine.AddTextureOnEntity("CheckBox", checkBox.ID);
                        }
                        else
                        {
                            engine.AddTextureOnEntity("CheckBox_C", checkBox.ID);
                        }
                    }
                    else if (checkBox.IsHighlighted)
                    {
                        if (!checkBox.IsChecked)
                        {
                            engine.AddTextureOnEntity("CheckBox_Y", checkBox.ID);
                        }
                        else
                        {
                            engine.AddTextureOnEntity("CheckBox_C_Y", checkBox.ID);
                        }
                    }
                }
                else if (engine.Entities [i].GetType() == typeof(RenderedEntity))
                {
                    RenderedEntity rendEnt = (RenderedEntity)engine.Entities [i];
                    if (rendEnt.Texture == null)
                    {
                        engine.AddTextureOnEntity("Menu", rendEnt.ID);
                    }
                }
                else if (engine.Entities [i].GetType() == typeof(OptionBar))
                {
                    OptionBar optionBar = (OptionBar)engine.Entities [i];
                    HandleOptionBar(optionBar);
                }
            }
        }