예제 #1
0
 public void Start()
 {
     UpdateEvent = new EconEvent();
     foreach (var resource in Enum.GetValues(typeof(ResourceType)))
     {
         _resources[(ResourceType)resource] = 0;
     }
 }
 public override void performHoverAction(int x, int y)
 {
     base.performHoverAction(x, y);
     this.hoverBox = null;
     foreach (var content in this.events.Zip(this.dims.SectionBoxes(), Tuple.Create))
     {
         EconEvent e    = content.Item1;
         Rectangle rect = content.Item2;
         if (rect.Contains(x, y))
         {
             if (e.AffectedItem > -1)
             {
                 this.hoverBox = new EconEventHoverBox(e);
             }
             break;
         }
     }
 }
예제 #3
0
    void Start()
    {
        KeyPressed = new EconEvent();

        // TODO: move these to respective managers
        KeyPressed.AddListener((args) =>
        {
            if (args.IsPressed(KeyCode.B))
            {
                BuildingManager.StartPlacingHouse();
            }

            return(args.RemoveKeys(KeyCode.B));
        });

        KeyPressed.AddListener((args) =>
        {
            if (args.IsPressed(KeyCode.Q))
            {
                UserActionManager.Chop();
            }

            return(args.RemoveKeys(KeyCode.Q));
        });

        KeyPressed.AddListener((args) =>
        {
            if (args.IsPressed(KeyCode.E))
            {
                UserActionManager.Interact();
            }

            return(args.RemoveKeys(KeyCode.E));
        });

        KeyPressed.AddListener((args) =>
        {
            if (args.IsPressed(KeyCode.Escape))
            {
                //if (UIManager.Dialog.activeInHierarchy)
                //{
                //    // We have an active dialog - dismiss it
                //    UIManager.Dialog.SetActive(false);
                //}
                //else
                {
                    UIManager.ToggleSettingsDialog();
                }
            }

            return(args.RemoveKeys(KeyCode.Escape));
        });

        KeyPressed.AddListener((args) =>
        {
            if (ChatManager.IsActive)
            {
                return(args.ClearKeys());
            }

            return(args);
        });

        KeyPressed.AddListener((args) =>
        {
            if (args.IsPressed(KeyCode.I))
            {
                UIManager.TogglePlayerInventory();
            }

            return(args.RemoveKeys(KeyCode.I));
        });
    }
        /**
         * <summary>Draws the menu.</summary>
         */
        public override void draw(SpriteBatch b)
        {
            this.dims.SetZoom(Game1.pixelZoom);

            // Draw box and background fade
            var dialogueBox = this.dims.DialogueBox();
            var labelPt     = this.dims.MenuLabelPoint();

            b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.4f);
            Game1.drawDialogueBox(
                x: dialogueBox.X,
                y: dialogueBox.Y,
                width: dialogueBox.Width,
                height: dialogueBox.Height,
                speaker: false,
                drawOnlyBox: true,
                message: null,
                objectDialogueWithPortrait: false);
            base.drawBorderLabel(b, "News Bulletin", Game1.smallFont, labelPt.X, labelPt.Y);

            // Draw contents
            if (true)
            {
                for (int i = 0; i < this.events.Count; i++)
                {
                    EconEvent e = this.events[i];
                    if (i != this.events.Count - 1)
                    {
                        this.drawHorizontalPartition(b, this.dims.SeparatorYPosition(i), true);
                    }

                    var sectionBox = this.dims.SectionBox(i);
                    Utility.DrawWrappedString(b, Game1.dialogueFont, e.Headline, sectionBox, Color.Black);
                }
            }
            else
            {
                // Test code to make sure icons display correctly
                //this.drawIconGrid(b, EconEventFactory._Crops);
            }

            // Test code to test dimensions:
            //var flatColor = Game1.fadeToBlackRect;
            //b.Draw(flatColor, this.dims.OuterBox(),    Color.Blue * 0.5f);
            //b.Draw(flatColor, this.dims.DialogueBox(), Color.Red * 0.5f);
            //b.Draw(flatColor, this.dims.InnerBox(),    Color.Green * 0.5f);
            //
            //for (int i = 0; i < this.events.Count; i++)
            //{
            //    var box = this.dims.SectionBox(i);
            //    b.Draw(flatColor, box, Color.Green * 0.5f);

            //    var lineY = this.dims.SeparatorYPosition(i);
            //    var line = new Rectangle
            //    {
            //        X = box.X,
            //        Y = lineY,
            //        Width = box.Width,
            //        Height = 1 * Game1.pixelZoom,
            //    };
            //    b.Draw(flatColor, line, Color.Red * 0.5f);
            //}

            // Draw close box and mouse
            base.draw(b);
            this.drawMouse(b);

            // Draw hover text
            this.hoverBox?.Draw(b);
        }
예제 #5
0
 public EconEventHoverBox(EconEvent e)
 {
     this.ItemAffected  = e.AffectedItem;
     this.PercentChange = e.PercentChange;
 }
예제 #6
0
 public EconSelectable()
 {
     SelectEvent   = new EconEvent();
     DeselectEvent = new EconEvent();
 }