private void buttonReqItemAdd_Click(object sender, EventArgs e) { var itemId = short.Parse(textBoxReqItemId.Text); if (itemId <= 0) { logger.Error("ItemId must be greater than 0"); return; } var count = byte.Parse(textBoxReqItemCount.Text); if (count <= 0) { logger.Error("Count must be greater than 0"); return; } var itemRequirement = new ItemRequirement(itemId, count); if (listBoxReqItems.Items.Contains(itemRequirement)) { logger.Error("ItemId already added"); return; } this.listBoxReqItems.Items.Add(itemRequirement); }
void OnItemPickUp(Item anItem) { ItemRequirement requirement = itemRequirements.Find(x => x.item == anItem); if (requirement == null) { return; } if (!requirement.completed && requirement.count <= anItem.counter) { requirement.completed = true; bool completed = true; foreach (ItemRequirement ir in itemRequirements) { completed &= ir.completed; } if (completed) { GameHandler.musicHandler.TriggerLoopSequence(firstLoopTrigger); GameHandler.inventory.OnItemPickUp -= OnItemPickUp; GameHandler.sceneLoader.onNewSceneLoading += OnSceneChange; CheckSceneRequirement(SceneManager.GetActiveScene().name); } } }
private IngredientDto CreateIngredient(ItemRequirement arg) { return(new IngredientDto { Amount = arg.Amount, ItemName = arg.ItemName }); }
private static bool CanPlayerEnterRoom(Character.Models.Character player, Models.Room foundRoom, ItemRequirement itemReq = null, AttributeRequirement attrReq = null) { if (itemReq != null) { foreach (var item in player.CarriedItems) { if (item.ItemName == itemReq.RelevantItem.ItemName) { return(true); } } Console.WriteLine($"You need: <{itemReq.RequirementName}> to enter {foundRoom.RoomName}. \n", Color.DarkGoldenrod); } if (attrReq != null) { if (PlayerAttributeComparer.ComparePlayerTraitsToAttributeRequirement(player, attrReq)) { return(true); } Console.WriteLine($"You need: <{attrReq.RequirementName}> to enter {foundRoom.RoomName}. \n", Color.DarkGoldenrod); } return(false); }
public void CmdConstruct(int index, NetworkConnectionToClient client = null) { // Check if sending player is holding if (client != null && client.identity.GetComponent <Hands>().ItemInHand.gameObject != gameObject) { return; } Construction construction = constructions[index]; // TileDefinition tile = selectedTile.Tile; IInteraction interaction; if (construction.ObjectToConstruct) { interaction = new ItemConstructionInteraction { ObjectToConstruct = construction.ObjectToConstruct, LoadingBarPrefab = loadingBarPrefab, Delay = construction.buildTime, ObstacleMask = obstacleMask }; } /* * if (construction.turf) * { * interaction = new TurfConstructionInteraction * { * ObjectToConstruct = construction.turf, * ConstructIfTurf = construction.constructOverTurf, * LoadingBarPrefab = loadingBarPrefab, * Delay = construction.buildTime, * ObstacleMask = obstacleMask * }; * } * else if (construction.fixture) * { * interaction = new FixtureConstructionInteraction * { * Fixture = construction.fixture, * TileLayer = construction.tileLayer, * WallLayer = construction.wallLayer, * FloorLayer = construction.floorLayer, * FixtureType = construction.type, * LoadingBarPrefab = loadingBarPrefab, * Delay = construction.buildTime, * ObstacleMask = obstacleMask * }; * } */ else { Debug.LogError("Construction does not have a turf or fixture to construct"); return; } // Add material requirement interaction = new ItemRequirement(interaction, item.ItemId, construction.amount); var source = GetComponent <IInteractionSource>(); // Create interaction data var @event = new InteractionEvent(source, new InteractionTargetGameObject(selectedTile.gameObject), selectedTile.transform.position); // Check if interaction is possible if (!interaction.CanInteract(@event)) { return; } // Start interaction source.Interact(@event, interaction); }
public XamlItemRequirement(ItemRequirement req) { this.Type = req.Type; this.ItemStack = new XamlItemStack(req.ItemStack); this.Amount = req.Amount; this.PrecisionId = req.PrecisionId; }