コード例 #1
0
        /// <summary>
        /// Creates a new Living Entity
        /// </summary>
        /// <param name="rect">The rectangle that represents the location and width and height of the entity</param>
        /// <param name="fileName">the location of the sprite for this entity</param>
        public LivingEntity(FloatRectangle rect, Sprite sprite, int health, AI.AI ai = null, int cash = 0)
            : base(rect, sprite)
        {
            inventory = new Inventory();
            time = new GameTime();
            lastShot = 60000D;

            interactRange = 32;
            // the below depend on texture, this should not be needed ever but because of the player texture it is...
            //this.interactBoundsOffsetY = interactBoundsOffsetY;
            //this.interactBoundsOffsetX = interactBoundsOffsetX;

            this.cash = cash;
            this.health = health;
            this.ai = ai;

            maxHealth = health;

            color = Color.Red;

            healthBar = new ProgressBar(new Vector2(60, 20));
            healthBar.MaxValue = maxHealth;
            healthBar.CurrentValue = health;
            healthBar.IncludeText = Name;
            healthBar.LoadVisuals(Game1.Instance.Content, Game1.Instance.GraphicsDevice);
            controls.Add(healthBar);
        }
コード例 #2
0
        public void Close()
        {
            /*
            // set active weapon if changed...
            Item.Item item = matrix.GetItemFromLocation(new Vector2(-80, 0));
            if (item != null && item != currentInventory.EntityInventory[currentInventory.ActiveWeapon])
                currentInventory.ActiveWeapon = currentInventory.EntityInventory.IndexOf(item);

            currentInventory = null;
            matrix.Clear();
            isInventoryLoaded = false;
             * */

            currentInventory = null;
            weaponButtonsContainer.Clear();
            isInventoryLoaded = false;
        }
コード例 #3
0
        /*
        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;
            }
        }
コード例 #4
0
        /// <summary>
        /// Load the inventory you want to view.
        /// </summary>
        /// <param name="inventory"></param>
        public void Load(Inventory inventory)
        {
            currentInventory = inventory;

            foreach (Item.Item i in inventory.EntityInventory.Where(i => !(i.Equals(inventory.EntityInventory[inventory.ActiveWeapon]))))
                inventoryMatrix.AddToMatrix(i);

            if (inventory.ActiveWeapon != -1)
                currentWeaponMatrix.AddToMatrix(inventory.EntityInventory[inventory.ActiveWeapon]);

            isInventoryLoaded = true;
        }
コード例 #5
0
        public void Close()
        {
            // set active weapon if changed...

            Item.Item item = currentWeaponMatrix[0];
            if (item != null && item != currentInventory.EntityInventory[currentInventory.ActiveWeapon])
                currentInventory.ActiveWeapon = currentInventory.EntityInventory.IndexOf(item);

            currentWeaponMatrix.Clear();
            inventoryMatrix.Clear();

            currentInventory = null;
            isInventoryLoaded = false;
        }
コード例 #6
0
        /// <summary>
        /// Load the inventory you want to view.
        /// </summary>
        /// <param name="inventory"></param>
        public void Load(Inventory inventory)
        {
            /*
            currentInventory = inventory;

            foreach (Item.Item i in inventory.EntityInventory.Where(i => !(i.Equals(inventory.EntityInventory[inventory.ActiveWeapon]))))
                matrix.AddToMatrix(new DragableControl(i));

            if (inventory.ActiveWeapon != -1)
                matrix.AddOutsideMatrix(new DragableControl(inventory.EntityInventory[inventory.ActiveWeapon]), new Vector2(-90, -10));

            isInventoryLoaded = true;
             * */
            currentInventory = inventory;
            int count = 0;
            foreach(int i in inventory.Holster)
            {
                Weapon weapon = inventory.EntityInventory[i] as Weapon;

                Button weaponInfoRoot = new Button();
                weaponInfoRoot.Location = new Vector2((weaponButtonsContainer.Size.X / inventory.Holster.Length) * count, 0);
                weaponInfoRoot.Size = new Vector2(weaponButtonsContainer.Size.X / inventory.Holster.Length, weaponButtonsContainer.Size.Y);
                weaponInfoRoot.Text = weapon.name;
                weaponInfoRoot.Click += weaponInfoRoot_Click;

                if(i == inventory.ActiveWeapon)
                {
                    weaponInfoRoot.DefaultBorder = new BorderInfo(weaponInfoRoot.DefaultBorder.width, Color.Purple);
                    weaponInfoRoot.DefaultFill = new FillInfo(Color.LightGray);
                    weaponInfoRoot.HoverFill = new FillInfo(Color.LightGray);
                    currentActive = weaponInfoRoot;
                }

                //weaponInfoRoot.parent = weaponButtonsContainer;
                weaponButtonsContainer.Add(weaponInfoRoot);

                // image
                // name
                // stats

                count++;
            }

            isInventoryLoaded = true;
        }