/*
         * void WeaponWheelUIV2_KeyClicked(object sender, KeysEventArgs e)
         * {
         *  if(e.Keys.Contains(Keys.Q) || e.Keys.Contains(Keys.Escape))
         *  {
         *      currentInventory = null;
         *  }
         * }
         */
        // <summary>
        /// Load the inventory you want to view.
        /// </summary>
        /// <param name="inventory"></param>
        public void Load(Inventory inventory)
        {
            // Load inventory
            currentInventory = inventory;

            // Get just weps. (need where?)
            List <Weapon> weapons = currentInventory.EntityInventory.Where(item => item is Weapon).Cast <Weapon>().ToList();

            // Find angle interval
            angleInterval = (float)(2 * Math.PI) / currentInventory.Holster.Length;

            // weapon button side length
            // TO-DO automatic!!
            weaponButtonSideLength = 75;

            // or weaponStatsContainer.Size.X / 2?
            radius = ((sideLength / 2) - (weaponButtonSideLength / 2));

            // Create button with weapon image and name.
            // if current weapon, highlight button and place stats in center.
            float currentAngle = 0;

            foreach (Weapon weapon in weapons)
            {
                ButtonContainer <Weapon> weaponButton = new ButtonContainer <Weapon>();
                weaponButton.Size     = new Vector2(weaponButtonSideLength, weaponButtonSideLength);
                weaponButton.Location = new Vector2(radius * (float)Math.Cos(currentAngle), radius * (float)Math.Sin(currentAngle));
                weaponButton.Data     = weapon;

                if (weapon == currentInventory.EntityInventory[currentInventory.ActiveWeapon])
                {
                    weaponButton.DefaultBorder = new BorderInfo(5, Color.Purple);
                    weaponStatsContainer.Load(weapon);
                    currentWeaponButton = weaponButton;
                }
                else
                {
                    weaponButton.DefaultBorder = new BorderInfo(1, Color.Transparent);
                }

                weaponButton.Fill = new FillInfo(weapon.previewSprite.Texture, Color.White);

                weaponButton.Text      = weapon.name;
                weaponButton.Click    += weaponButton_Click;
                weaponButton.Alignment = ControlAlignment.Center;
                Add(weaponButton);

                currentAngle += angleInterval;
            }
        }
Example #2
0
        void tmpContainer_Hover(object sender, EventArgs e)
        {
            // if this container does not have an item in it, return
            DragableContainer container = sender as DragableContainer;

            if (container == null || container.ControlContained == null || container.ControlContained.Item == null)
            {
                //Console.WriteLine("nothing");
                //contextMenu.IsDrawn = false;
                return;
            }

            // display hovering container showing stats of item.
            Item.Item item = container.ControlContained.Item;

            // menu location
            if (currentDragableContainer == null)
            {
                contextMenu.Location = new Vector2(this.CurrentFrameMouseState.Position.X, this.CurrentFrameMouseState.Position.Y);
            }
            else
            {
                contextMenu.Location = new Vector2(currentDragableControl.GlobalLocation().X + currentDragableControl.Size.X, currentDragableControl.GlobalLocation().Y);
            }



            // load item info
            if (contextMenu.Item != item)
            {
                contextMenu.Load(item);
            }

            // make sure it draws
            contextMenu.IsDrawn = true;
        }