Пример #1
0
        public static bool InventoryContainsDragonball(int whichDragonball, Item[] inventory)
        {
            for (var i = 0; i < inventory.Length; i++)
            {
                var item = inventory[i];
                if (item == null)
                {
                    continue;
                }

                if (item.modItem == null)
                {
                    continue;
                }

                if (!(item.modItem is DragonBallItem))
                {
                    continue;
                }

                var dbItem = item.modItem as DragonBallItem;
                // assume this runs before the inventory loop that turns stone balls into real ones - we don't care which it is, if it's legit, we don't want to spawn dragonballs replacing it.
                if (dbItem.item.type == ItemHelper.GetItemTypeFromName(DragonBallItem.GetStoneBallFromNumber(whichDragonball)) && dbItem.WorldDragonBallKey == GetWorld().WorldDragonBallKey)
                {
                    return(true);
                }
                if (dbItem.item.type == ItemHelper.GetItemTypeFromName(DragonBallItem.GetDragonBallItemTypeFromNumber(whichDragonball)) && dbItem.WorldDragonBallKey == GetWorld().WorldDragonBallKey)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #2
0
        public override void MouseOver(int i, int j)
        {
            Player player = Main.LocalPlayer;

            player.noThrow       = 2;
            player.showItemIcon  = true;
            player.showItemIcon2 = mod.ItemType(DragonBallItem.GetDragonBallItemTypeFromNumber(WhichDragonBallAmI));
        }
Пример #3
0
 /// <summary>
 ///     Whether a single dragon ball of a specific type is present in an inventory.
 /// </summary>
 /// <param name="inventory">The inventory being checked.</param>
 /// <param name="whichDragonBall">Which (int) dragon ball we're looking for.</param>
 /// <returns></returns>
 public static bool IsDragonBallPresent(this Item[] inventory, int whichDragonBall)
 {
     return
         ((
              from item in inventory
              where item != null && item.modItem != null
              where item.modItem is DragonBallItem
              select(DragonBallItem) item.modItem
              ).Any(
              dbItem => dbItem.item.type == ItemHelper.GetItemTypeFromName(DragonBallItem.GetDragonBallItemTypeFromNumber(whichDragonBall))
              ));
 }
Пример #4
0
        public static void SwapStoneBallWithDragonBall(Item[] inventory, int WorldDragonBallKey, int WhichDragonBall)
        {
            // this stone ball was pulled back into its world. Turn it into a dragon ball.
            int dbKey  = WorldDragonBallKey;
            int dbSlot = ItemHelper.RemoveStoneBall(inventory, WorldDragonBallKey, WhichDragonBall);

            // something went wrong, abort.
            if (dbSlot == -1)
            {
                return;
            }
            var dbType        = DragonBallItem.GetDragonBallItemTypeFromNumber(WhichDragonBall);
            var newDragonBall = DBZMOD.instance.GetItem(DragonBallItem.GetDragonBallItemTypeFromNumber(WhichDragonBall)).item.DeepClone();
            var dbData        = newDragonBall.modItem as DragonBallItem;

            dbData.WorldDragonBallKey = dbKey;
            inventory[dbSlot]         = newDragonBall;
        }
Пример #5
0
        /// <summary>
        ///     Return the slot of the inventory a dragon ball was in after deleting it.
        ///     This is used to replace a dragon ball with an inert dragon ball brought from other worlds.
        /// </summary>
        /// <returns></returns>
        public static int RemoveDragonBall(Item[] inventory, int dbKey, int whichDragonBall)
        {
            string ballType    = DragonBallItem.GetDragonBallItemTypeFromNumber(whichDragonBall);
            int    ballTypeInt = GetItemTypeFromName(ballType);

            for (var i = 0; i < inventory.Length; i++)
            {
                var item = inventory[i];
                if (item == null)
                {
                    continue;
                }

                if (item.modItem == null)
                {
                    continue;
                }

                if (item.type != ballTypeInt)
                {
                    continue;
                }

                if (item.modItem is DragonBallItem)
                {
                    var dBall = item.modItem as DragonBallItem;
                    if (dBall.WorldDragonBallKey == dbKey)
                    {
                        inventory[i].TurnToAir();
                        return(i);
                    }
                }
            }

            // dragonball wasn't found, return an oob index.
            return(-1);
        }