Beispiel #1
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);

            var textures         = LoadTextures();
            var heroTexture      = Content.Load <Texture2D>("hero");
            var screenTexture    = Content.Load <Texture2D>("green-paper2");
            var heroPropTextures = LoadHeroTextures();
            var font             = Content.Load <SpriteFont>("Font");

            var menuTexture = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);

            Color[] c = new Color[1];
            c[0] = Color.White;
            menuTexture.SetData <Color>(c);

            _menu = new MonoMenu(font, Color.MintCream, MonoDrawer.SCREEN_WIDTH,
                                 MonoDrawer.SCREEN_HEIGHT + MonoDrawer.HEALTH_BAR_HEIGHT);
            _inventory = new MonoInventory(MonoDrawer.SCREEN_WIDTH, 0, MonoDrawer.INVENTORY_WIDTH,
                                           MonoDrawer.SCREEN_HEIGHT + MonoDrawer.HEALTH_BAR_HEIGHT, font, Color.Black, menuTexture);


            var pauseStrLength = font.MeasureString("Pause");
            var switchTexture  = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);

            Color[] c1 = new Color[1];
            c[0] = Color.WhiteSmoke;
            switchTexture.SetData <Color>(c);
            var pauseInfo = new MonoItemInfo(switchTexture, null, "Pause", () => _game.SetPaused());

            _pauseSwich = new MonoSwich(pauseInfo, false, switchTexture, font, Color.Black, MonoDrawer.SCREEN_WIDTH - (int)pauseStrLength.X - 2, MonoDrawer.SCREEN_HEIGHT);

            var knowledgesStrLength = font.MeasureString("Knowledges");
            var knowledgesInfo      = new MonoItemInfo(switchTexture, null, "Knowledges", () => _game.ShowKnowledges());

            _knowledgeSwich = new MonoSwich(knowledgesInfo, false, switchTexture, font, Color.Black, MonoDrawer.SCREEN_WIDTH - (int)pauseStrLength.X - (int)knowledgesStrLength.X - 10, MonoDrawer.SCREEN_HEIGHT);

            _monoKnowledges = new MonoKnowledges(GraphicsDevice, font);

            _drawer = new MonoDrawer(_spriteBatch, GraphicsDevice, textures, heroTexture, screenTexture,
                                     heroPropTextures, font, _menu, _inventory, _pauseSwich, _knowledgeSwich, _monoKnowledges);
            _game = new Engine.Game(_drawer, (uint)MonoDrawer.SCREEN_WIDTH, (uint)MonoDrawer.SCREEN_HEIGHT);

            _graphics.PreferredBackBufferWidth =
                MonoDrawer.SCREEN_WIDTH +
                MonoDrawer.INVENTORY_WIDTH; // set this value to the desired width of your window
            _graphics.PreferredBackBufferHeight =
                MonoDrawer.SCREEN_HEIGHT +
                MonoDrawer.HEALTH_BAR_HEIGHT; // set this value to the desired height of your window
            _graphics.ApplyChanges();

            _monoControls.Add(_menu);
            _monoControls.Add(_inventory);
            _monoControls.Add(_pauseSwich);
            _monoControls.Add(_knowledgeSwich);
        }
Beispiel #2
0
 public LogicalNode(GraphicsDevice device, string name, MonoMenu menu)
 {
     Children           = new List <LogicalNode>();
     this.menu          = menu;
     this.name          = name;
     Events             = new Dictionary <string, MenuEvent>();
     animations         = new Dictionary <string, BaseAnimation>();
     animationsToRemove = new List <BaseAnimation>();
     eventsToTrigger    = new List <MenuEvent>();
     this.VisualNode    = new VisualNode(device, this);
     Click += NodeClicked;
 }
Beispiel #3
0
 public ImageNode(GraphicsDevice device, MonoMenu menu, string name, Texture2D image) : base(device, name, menu)
 {
     this.visualNode.Primitive = image;
     this.Background           = Color.White;
 }
 public ColorAnimation(string name, string from, string to, TimeSpan duration, LogicalTree.LogicalNode node, Target targetProperty) : base(name, from, to, duration, node, targetProperty)
 {
     this.from = MonoMenu.ColorFromString(from);
     this.to   = MonoMenu.ColorFromString(to);
 }
Beispiel #5
0
        public override void Trigger(LogicalNode node)
        {
            string v = string.Copy(value);

            switch (eventTarget)
            {
            case Target.BorderColor:
                node.BorderColor = MonoMenu.ColorFromString(value);
                break;

            case Target.Background:
                node.Background = MonoMenu.ColorFromString(value);
                break;

            case Target.Foreground:
                node.Foreground = MonoMenu.ColorFromString(value);
                break;

            case Target.Height:
                if (value.Contains('%'))
                {
                    v = v.Replace(" ", "");
                    v = v.Replace("%", "");
                    node.PercentageHeight = true;
                }
                else
                {
                    node.PercentageHeight = false;
                }
                node.DesiredHeight = int.Parse(v);
                break;

            case Target.Width:
                if (value.Contains('%'))
                {
                    v = v.Replace(" ", "");
                    v = v.Replace("%", "");
                    node.PercentageWidth = true;
                }
                else
                {
                    node.PercentageWidth = false;
                }
                node.DesiredWidth = int.Parse(v);
                break;

            case Target.HorizontalAlignment:
                node.HorizontalAlignment = (HorizontalAlignment)Enum.Parse(typeof(HorizontalAlignment), value);
                break;

            case Target.VerticalAlignment:
                node.VerticalAlignment = (VerticalAlignment)Enum.Parse(typeof(VerticalAlignment), value);
                break;

            case Target.RelativeX:
                Point xnewPos = node.DesiredRelativePosition;
                if (value.Contains('%'))
                {
                    v = v.Replace(" ", "");
                    v = v.Replace("%", "");
                    node.PercentageX = true;
                }
                else
                {
                    node.PercentageX = false;
                }
                xnewPos.X = int.Parse(v);
                node.DesiredRelativePosition = xnewPos;
                break;

            case Target.RelativeY:
                Point ynewPos = node.DesiredRelativePosition;
                if (value.Contains('%'))
                {
                    v = v.Replace(" ", "");
                    v = v.Replace("%", "");
                    node.PercentageY = true;
                }
                else
                {
                    node.PercentageY = false;
                }
                ynewPos.Y = int.Parse(v);
                node.DesiredRelativePosition = ynewPos;
                break;

            case Target.BorderSize:
                node.BorderSize = int.Parse(value);
                break;

            case Target.FontSize:
                node.FontSize = int.Parse(value);
                break;

            case Target.Visibility:
                node.Visibility = (Visibility)Enum.Parse(typeof(Visibility), value);
                break;

            default:
                break;
            }
        }
Beispiel #6
0
 public TextboxNode(GraphicsDevice device, string name, MonoMenu menu) : base(device, name, menu)
 {
     OnFocusChange += NodeFocusChange;
 }
Beispiel #7
0
 public RectangleNode(GraphicsDevice device, string name, MonoMenu menu) : base(device, name, menu)
 {
     this.visualNode.Primitive = VisualPrimitives.PrimitiveHandler.GetRectangle(device);
 }
Beispiel #8
0
 public EllipseNode(GraphicsDevice device, string name, MonoMenu menu) : base(device, name, menu)
 {
     this.VisualNode.Primitive = VisualPrimitives.PrimitiveHandler.GetEllipse(device);
 }