예제 #1
0
 public bool IsChestStillAvailable(BazaarItem bazaarItem)
 {
     if (bazaarItem.maxPurchases == -1 || bazaarItem.purchaseCount < bazaarItem.maxPurchases)
     {
         return(true);
     }
     return(false);
 }
예제 #2
0
        // bazaar building
        private void SpawnBazaarItemAt(Vector3 position, Vector3 rotation, PickupTier pickupTier, int cost)
        {
            // chest players interact with
            SpawnCard chestCard;

            if (ModConfig.chestCostType.Value == 0)
            {
                chestCard = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscChest1");
            }
            else
            {
                chestCard = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscLunarChest");
            }
            DirectorPlacementRule placementRule = new DirectorPlacementRule();

            placementRule.placementMode = DirectorPlacementRule.PlacementMode.Direct;
            GameObject chest = chestCard.DoSpawn(position, Quaternion.Euler(new Vector3(0f, 0f, 0f)), new DirectorSpawnRequest(chestCard, placementRule, Run.instance.runRNG)).spawnedInstance;

            chest.transform.eulerAngles = rotation;


            ItemIndex          rItem;
            PickupIndex        rPickupIndex;
            List <PickupIndex> availableItems = GetAvailableItems(pickupTier);
            //if(availableItems.Count > 0)
            //{
            int rItemIndex = r.Next(availableItems.Count);

            rPickupIndex = availableItems[rItemIndex];
            //rItem = PickupCatalog.GetPickupDef(rPickupIndex).itemIndex;
            //}
            //else
            //{
            //    List<ItemIndex> drops = ItemDropAPI.GetDefaultDropList(pickupTier);
            //    int rItemIndex = r.Next(drops.Count);
            //    rItem = drops[rItemIndex];
            //}


            GameObject itemGameObject = UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/NetworkedObjects/GenericPickup"), position, Quaternion.identity);

            itemGameObject.GetComponent <GenericPickupController>().transform.Translate(-2f, 4f, -3f, Space.World);
            itemGameObject.GetComponent <GenericPickupController>().NetworkpickupIndex = rPickupIndex;

            displayItems.Add(itemGameObject);
            NetworkServer.Spawn(itemGameObject);

            var chestPI = chest.GetComponent <PurchaseInteraction>();

            if (ModConfig.chestCostType.Value == 1)
            {
                chestPI.costType    = CostTypeIndex.LunarCoin;
                chestPI.Networkcost = cost;
                //chestPI.SetDirtyBit(12u);
            }
            else if (cost == -1)
            {
                if (ModConfig.nextLevelChestPriceScaling.Value)
                {
                    //next level price scaling
                    chestPI.Networkcost = Run.instance.GetDifficultyScaledCost(chestPI.cost);
                    chestPI.Networkcost = (int)(chestPI.Networkcost * ModConfig.GetTierUnitConfig(pickupTier).cost);
                }
                else
                {
                    //previous level price scaling
                    chestPI.Networkcost = GetDifficultyScaledCostFromItemTier(chestPI.cost);
                    chestPI.Networkcost = (int)(chestPI.Networkcost * ModConfig.GetTierUnitConfig(pickupTier).cost);
                }
            }
            else
            {
                chestPI.Networkcost = GetDifficultyScaledCost(cost);
            }



            BazaarItem bazaarItem = new BazaarItem();

            bazaarItem.chestBehavior           = chest.GetComponent <ChestBehavior>();
            bazaarItem.genericPickupController = itemGameObject.GetComponent <GenericPickupController>();
            bazaarItem.pickupIndex             = rPickupIndex;
            bazaarItem.purchaseCount           = 0;
            bazaarItem.maxPurchases            = ModConfig.GetTierUnitConfig(pickupTier).maxChestPurchases;

            bazaarItems.Add(bazaarItem);
            itemGameObject.GetComponent <GenericPickupController>().pickupIndex = PickupIndex.none;
        }