Пример #1
0
        public static void EquipItemFromSublist(ShipParts kind, int equipPos, int invPos)
        {
            List <ShipPart> availablePrimaryWeapons;

            switch (kind)
            {
            case ShipParts.Primary1:
            {
                availablePrimaryWeapons = ShipInventoryManager.GetAvailablePrimaryWeapons(1);
                ShipInventoryManager.equippedPrimaryWeapons.RemoveAt(0);
                ShipInventoryManager.equippedPrimaryWeapons.Insert(0, (PlayerWeapon)availablePrimaryWeapons[invPos]);
                break;
            }

            case ShipParts.Primary2:
            {
                availablePrimaryWeapons = ShipInventoryManager.GetAvailablePrimaryWeapons(2);
                ShipInventoryManager.equippedPrimaryWeapons.RemoveAt(1);
                ShipInventoryManager.equippedPrimaryWeapons.Insert(1, (PlayerWeapon)availablePrimaryWeapons[invPos]);
                break;
            }

            case ShipParts.Secondary:
            {
                ShipInventoryManager.equippedSecondary = (PlayerWeapon)ShipInventoryManager.ownedSecondary[invPos];
                break;
            }

            case ShipParts.Plating:
            {
                equippedPlating = (PlayerPlating)ShipInventoryManager.ownedPlatings[invPos];
                ChangePrimarySlots(equippedPlating.PrimarySlots);
                break;
            }

            case ShipParts.EnergyCell:
            {
                ShipInventoryManager.equippedEnergyCell = (PlayerEnergyCell)ShipInventoryManager.ownedEnergyCells[invPos];
                break;
            }

            case ShipParts.Shield:
            {
                ShipInventoryManager.equippedShield = (PlayerShield)ShipInventoryManager.ownedShields[invPos];
                break;
            }

            default:
            {
                throw new ArgumentException("You entered an unimplemented shippart!");
            }
            }

            UpdateLists(emptyItem);
        }
Пример #2
0
        public static void DisplayPrimaryWeaponInfo(SpriteBatch spriteBatch)
        {
            if (layer == 2)
            {
                if (ShipInventoryManager.OwnedPrimaryWeapons.Count > 0)
                {
                    int slot = layer1YPos + 1;

                    ShipInventoryManager.GetAvailablePrimaryWeapons(slot)[layer2pos].DisplayInventoryInfo(
                        spriteBatch, infoFont, FontManager.FontColorStatic);
                }
            }
        }
        private void OnPressLevel1()
        {
            if (cursorCoordLv1.Position != backPos &&
                cursorCoordLv1.Position < 5 &&
                ShipInventoryManager.ownCounts[cursorCoordLv1.Position - 1] > 0)
            {
                cursorLevel          = 2;
                cursorLevel2Position = 0;
                elapsedSinceKey      = 0;
            }

            else if (cursorCoordLv1.Position == 5)
            {
                switch (cursorCoordLv1.Y)
                {
                case 0:
                    if (ShipInventoryManager.GetAvailablePrimaryWeapons(1).Count > 0)
                    {
                        cursorLevel          = 2;
                        cursorLevel2Position = 0;
                        elapsedSinceKey      = 0;
                    }
                    break;

                case 1:
                    if (ShipInventoryManager.GetAvailablePrimaryWeapons(2).Count > 0)
                    {
                        cursorLevel          = 2;
                        cursorLevel2Position = 0;
                        elapsedSinceKey      = 0;
                    }
                    break;
                }
            }
            else if (cursorCoordLv1.Position == backPos)
            {
                BackToOverworldLogic();
            }
        }
        private void CheckMouseLevel2()
        {
            int    listLength;
            string text = "";

            if (cursorCoordLv1.Position != 5)
            {
                listLength = ShipInventoryManager.ownCounts[cursorCoordLv1.Position - 1];
            }

            else
            {
                if (cursorCoordLv1.Y == 0)
                {
                    listLength = ShipInventoryManager.GetAvailablePrimaryWeapons(1).Count;
                }
                else
                {
                    listLength = ShipInventoryManager.GetAvailablePrimaryWeapons(2).Count;
                }
            }

            for (int i = 0; i < listLength + 1; i++)
            {
                if (i < listLength)
                {
                    if (cursorCoordLv1.Position != 5)
                    {
                        if (cursorCoordLv1.Position == 1)
                        {
                            text = ShipInventoryManager.ownedEnergyCells[i].Name;
                        }
                        else if (cursorCoordLv1.Position == 2)
                        {
                            text = ShipInventoryManager.ownedPlatings[i].Name;
                        }
                        else if (cursorCoordLv1.Position == 3)
                        {
                            text = ShipInventoryManager.ownedShields[i].Name;
                        }
                        else if (cursorCoordLv1.Position == 4)
                        {
                            text = ShipInventoryManager.OwnedSecondary[i].Name;
                        }
                    }

                    else
                    {
                        if (cursorCoordLv1.Y == 0)
                        {
                            text = ShipInventoryManager.GetAvailablePrimaryWeapons(1)[i].Name;
                        }
                        else
                        {
                            text = ShipInventoryManager.GetAvailablePrimaryWeapons(2)[i].Name;
                        }
                    }
                }
                else
                {
                    text = "Back";
                }

                if (ControlManager.IsMouseOverText(FontManager.GetFontStatic(16), text,
                                                   new Vector2(Game1.ScreenSize.X / 2 + 50, 93 + i * 23), Vector2.Zero, false))
                {
                    cursorLevel2Position = i;

                    if (ControlManager.IsLeftMouseButtonClicked())
                    {
                        if (cursorLevel2Position < listLength)
                        {
                            OnPressLevel2();
                        }
                        else
                        {
                            cursorLevel     = 1;
                            elapsedSinceKey = 0;
                        }
                    }
                }
            }
        }
        private void CheckKeysLevel2(GameTime gameTime)
        {
            if (cursorLevel == 2 && cursorCoordLv1.Position != inventoryPos)
            {
                int listLength;

                if (cursorCoordLv1.Position != 5)
                {
                    listLength = ShipInventoryManager.ownCounts[cursorCoordLv1.Position - 1];
                }

                else
                {
                    if (cursorCoordLv1.Y == 0)
                    {
                        listLength = ShipInventoryManager.GetAvailablePrimaryWeapons(1).Count;
                    }
                    else
                    {
                        listLength = ShipInventoryManager.GetAvailablePrimaryWeapons(2).Count;
                    }
                }

                if (ControlManager.CheckPress(RebindableKeys.Down) && cursorLevel == 2 &&
                    elapsedSinceKey > elapseDelay)
                {
                    cursorLevel2Position += 1;
                    if (cursorLevel2Position > listLength)
                    {
                        cursorLevel2Position = 0;
                    }

                    elapsedSinceKey = 0;

                    holdTimer = Game.HoldKeyTreshold;
                }

                else if (ControlManager.CheckHold(RebindableKeys.Down))
                {
                    holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                    if (holdTimer <= 0)
                    {
                        cursorLevel2Position += 1;
                        if (cursorLevel2Position > listLength)
                        {
                            cursorLevel2Position = listLength;
                        }

                        elapsedSinceKey = 0;

                        holdTimer = Game.ScrollSpeedFast;
                    }
                }

                if (ControlManager.CheckPress(RebindableKeys.Up) && cursorLevel == 2 &&
                    elapsedSinceKey > elapseDelay)
                {
                    cursorLevel2Position -= 1;
                    if (cursorLevel2Position < 0)
                    {
                        cursorLevel2Position = listLength;
                    }

                    elapsedSinceKey = 0;

                    holdTimer = Game.HoldKeyTreshold;
                }

                else if (ControlManager.CheckHold(RebindableKeys.Up))
                {
                    holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                    if (holdTimer <= 0)
                    {
                        cursorLevel2Position -= 1;
                        if (cursorLevel2Position < 0)
                        {
                            cursorLevel2Position = 0;
                        }

                        elapsedSinceKey = 0;

                        holdTimer = Game.ScrollSpeedFast;
                    }
                }

                //This is where the magic happens.
                if (((ControlManager.CheckPress(RebindableKeys.Action1) || ControlManager.CheckKeyPress(Keys.Enter)) && cursorLevel == 2 &&
                     elapsedSinceKey > elapseDelay))
                {
                    if (cursorLevel2Position < listLength)
                    {
                        OnPressLevel2();
                    }
                    else
                    {
                        cursorLevel     = 1;
                        elapsedSinceKey = 0;
                    }
                }

                if (ControlManager.CheckPress(RebindableKeys.Action2) && cursorLevel == 2 &&
                    elapsedSinceKey > elapseDelay)
                {
                    cursorLevel     = 1;
                    elapsedSinceKey = 0;
                }
            }
        }
        private void ItemComparision()
        {
            switch (cursorLevel)
            {
            case 1:
            {
                itemComp.OkayToClearStats   = true;
                itemComp.OkayToClearSymbols = true;
                break;
            }

            case 2:
            {
                switch (cursorCoordLv1.ToInt())
                {
                case 1:
                    if (cursorLevel2Position < ShipInventoryManager.ownedEnergyCells.Count)
                    {
                        itemComp.SetItem2(ShipInventoryManager.ownedEnergyCells[cursorLevel2Position]);
                        itemComp.SetItem1(ShipInventoryManager.equippedEnergyCell);
                        itemComp.ShowSymbols = true;
                    }
                    else
                    {
                        itemComp.OkayToClearStats   = true;
                        itemComp.OkayToClearSymbols = true;
                    }
                    break;

                case 2:
                    if (cursorLevel2Position < ShipInventoryManager.ownedPlatings.Count)
                    {
                        itemComp.SetItem2(ShipInventoryManager.OwnedPlatings[cursorLevel2Position]);
                        itemComp.SetItem1(ShipInventoryManager.equippedPlating);
                        itemComp.ShowSymbols = true;
                    }
                    else
                    {
                        itemComp.OkayToClearStats   = true;
                        itemComp.OkayToClearSymbols = true;
                    }
                    break;

                case 3:
                    if (cursorLevel2Position < ShipInventoryManager.ownedShields.Count)
                    {
                        itemComp.SetItem2(ShipInventoryManager.ownedShields[cursorLevel2Position]);
                        itemComp.SetItem1(ShipInventoryManager.equippedShield);
                        itemComp.ShowSymbols = true;
                    }
                    else
                    {
                        itemComp.OkayToClearStats   = true;
                        itemComp.OkayToClearSymbols = true;
                    }
                    break;

                case 4:
                    if (cursorLevel2Position < ShipInventoryManager.OwnedSecondary.Count)
                    {
                        itemComp.SetItem2(ShipInventoryManager.OwnedSecondary[cursorLevel2Position]);
                        itemComp.SetItem1(ShipInventoryManager.equippedSecondary);
                        itemComp.ShowSymbols = true;
                    }
                    else
                    {
                        itemComp.OkayToClearStats   = true;
                        itemComp.OkayToClearSymbols = true;
                    }
                    break;

                case 5:
                    if (cursorCoordLv1.Y == 0)
                    {
                        if (cursorLevel2Position < ShipInventoryManager.GetAvailablePrimaryWeapons(1).Count)
                        {
                            itemComp.SetItem2(ShipInventoryManager.GetAvailablePrimaryWeapons(1)[cursorLevel2Position]);
                            itemComp.SetItem1(ShipInventoryManager.equippedPrimaryWeapons[0]);
                            itemComp.ShowSymbols = true;
                        }
                        else
                        {
                            itemComp.OkayToClearStats   = true;
                            itemComp.OkayToClearSymbols = true;
                        }
                    }

                    else if (cursorCoordLv1.Y == 1)
                    {
                        if (cursorLevel2Position < ShipInventoryManager.GetAvailablePrimaryWeapons(2).Count)
                        {
                            itemComp.SetItem2(ShipInventoryManager.GetAvailablePrimaryWeapons(2)[cursorLevel2Position]);
                            itemComp.SetItem1(ShipInventoryManager.equippedPrimaryWeapons[1]);
                            itemComp.ShowSymbols = true;
                        }
                        else
                        {
                            itemComp.OkayToClearStats   = true;
                            itemComp.OkayToClearSymbols = true;
                        }
                    }
                    break;
                }
                break;
            }
            }
        }
Пример #7
0
 public static void DisplayPrimaryWeaponInfo2(SpriteBatch spriteBatch)
 {
     spriteBatch.DrawString(FontManager.GetFontStatic(fontSize), "Primary weapon slot 2", topDisplayPos + FontManager.FontOffsetStatic, FontManager.FontColorStatic, 0, FontManager.GetFontStatic(16).MeasureString("Primary weapon slot 2") / 2, 1.0f, SpriteEffects.None, 0.5f);
     DisplayList(spriteBatch, "Owned weapons", ShipInventoryManager.GetAvailablePrimaryWeapons(2), equippedDisplayPos + FontManager.FontOffsetStatic, ySpacing, 2);
 }
        public void Draw(SpriteBatch spriteBatch)
        {
            foreach (ShipInventoryDisplayObject dispObj in displayList)
            {
                dispObj.Draw(spriteBatch);
            }

            if (back.isActive)
            {
                ShipManagerText.DisplayBackInfo(spriteBatch);
            }

            else if (primaryDisplay.isActive)
            {
                ShipManagerText.DisplayPrimaryWeaponInfo1(spriteBatch);

                if (layer >= 2 && cursorLv2Pos < ShipInventoryManager.GetAvailablePrimaryWeapons(1).Count)
                {
                    InventoryInformation.DisplayPrimaryWeaponInfo(spriteBatch);
                }
            }

            else if (primaryDisplay2.isActive)
            {
                ShipManagerText.DisplayPrimaryWeaponInfo2(spriteBatch);

                if (layer >= 2 && cursorLv2Pos < ShipInventoryManager.GetAvailablePrimaryWeapons(2).Count)
                {
                    InventoryInformation.DisplayPrimaryWeaponInfo(spriteBatch);
                }
            }

            else if (secondaryDisplay.isActive)
            {
                ShipManagerText.DisplaySecondaryInfo(spriteBatch);

                if (layer >= 2 && cursorLv2Pos < ShipInventoryManager.OwnedSecondary.Count)
                {
                    InventoryInformation.DisplaySecondaryWeaponInfo(spriteBatch);
                }
            }

            else if (platingDisplay.isActive)
            {
                ShipManagerText.DisplayPlatingInfo(spriteBatch);

                if (layer >= 2 && cursorLv2Pos < ShipInventoryManager.ownedPlatings.Count)
                {
                    InventoryInformation.DisplayPlatingInfo(spriteBatch);
                }
            }

            else if (cellDisplay.isActive)
            {
                ShipManagerText.DisplayEnergyCellInfo(spriteBatch);

                if (layer >= 2 && cursorLv2Pos < ShipInventoryManager.ownedEnergyCells.Count)
                {
                    InventoryInformation.DisplayEnergyCellInfo(spriteBatch);
                }
            }

            else if (shieldDisplay.isActive)
            {
                ShipManagerText.DisplayShieldInfo(spriteBatch);

                if (layer >= 2 && cursorLv2Pos < ShipInventoryManager.ownedShields.Count)
                {
                    InventoryInformation.DisplayShieldInfo(spriteBatch);
                }
            }

            //if (inventoryDisplay.isActive && cursorLv3Pos != -1) // Why was this here to begin with? /Jakob 140615
            //if (inventoryDisplay.isActive)
            //{
            //    ShipManagerText.DisplayInventory(spriteBatch, Game.Resolution);
            //
            //    if (layer >= 2)
            //        InventoryInformation.DisplayInventoryInfo(spriteBatch);
            //}
        }