public List <CollectibleItem> ConvertAssetsToCollectibleItems(CollectionPointAssets assets) { var output = new List <CollectibleItem>(); if (assets != null) { foreach (var asset in assets.ImageAssets) { var image = new CollectibleItem(); image.Id = asset.Id == Guid.Empty ? null : asset.Id.ToString(); image.ImageUrl = GenerateImageUrl(asset.Data.ImageAsset?.Iv.FirstOrDefault()); image.ValuePairs = Mapper.Map <Dictionary <string, int> >(asset.Data.Values?.Iv); image.Caption = asset.Data.Caption?.Iv; image.Credit = asset.Data.Credit?.Iv; if (asset.Data?.ShopifyIcon != null) { image.IconUrl = GenerateImageUrl(asset.Data.ShopifyIcon?.Iv.FirstOrDefault()); } output.Add(image); } foreach (var asset in assets.QuoteAssets) { var quote = new CollectibleItem(); quote.Id = asset.Id == Guid.Empty ? null : asset.Id.ToString(); quote.ValuePairs = Mapper.Map <Dictionary <string, int> >(asset.Data.Values?.Iv); if (asset.Data?.ShopifyIcon != null) { quote.IconUrl = GenerateImageUrl(asset.Data.ShopifyIcon?.Iv.FirstOrDefault()); } output.Add(quote); } } return(output); }
public Location GetLocationByItem(CollectibleItem item) { using (SQLiteConnection conn = new SQLiteConnection(App.DatabaseLocation)) { return(conn.Table <Location>().Where(x => item.Location.Contains(x.LocationName)).FirstOrDefault()); } }
void OnGUI() { //draw stuff if (IsInsideMenuArea()) { exitArea = true; } if (exitArea) { if (fadingIn) { StartFadingIn(); } GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), blackTexture); } if (fadingOut) //fading in to black is finished { CollectibleItem.resetCollectedItems(); fadingOut = false; if (_once) { return; } _once = true; SceneManager.LoadScene("Launcher"); } }
public ItemSlot TakeItem(CollectibleItem item) { if (item == null) { return(null); } WeaponSlot weapon = WeaponsSlots.Find(lambdaExpression => lambdaExpression.BulletType == item.ItemType); if (weapon != null) { AddAmmo(weapon, item.Quantity); return(null); } if (item.ItemType == ItemType.Nothing) { return(null); } if (item.ItemInstance == null && !item.Unequipable) { return(null); } return(AddItem(item)); }
private void CheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) { var cis = new CollectibleItemsService(); var itemChecked = (CheckBox)sender; CollectibleItem item = itemChecked.BindingContext as CollectibleItem; cis.UpdateItemCheck(itemChecked.IsChecked, item); }
//Spawn new object in the slot public void ChangeItem(ItemObject item) { var obj = Instantiate(item.Prefab, gameObject.transform.position, Quaternion.identity, gameObject.transform); obj.GetComponent <Rigidbody>().isKinematic = true; obj.GetComponent <Collider>().enabled = false; _storedItem = obj.GetComponent <CollectibleItem>(); _storedItem.enabled = false; }
public void UpdateItemCheck(bool check, CollectibleItem item) { using (SQLiteConnection conn = new SQLiteConnection(App.DatabaseLocation)) { var result = conn.Table <CollectibleItem>().Where(x => x.ID == item.ID).FirstOrDefault(); result.Check = check; conn.Update(result); } }
public CollectibleItemPage(CollectibleItem item) { Item = item; InitializeComponent(); var cis = new CollectibleItemsService(); ItemLocation = cis.GetLocationByItem(Item); this.BindingContext = new CollectibleItemViewModel(Item); }
// Unsnap stored item's gameObject public void UnsnapItem() { _storedItem.enabled = true; _storedItem.gameObject.GetComponent <MouseMoveableObj>().Toggle(true); _storedItem.gameObject.transform.parent = null; _storedItem.gameObject.GetComponent <Rigidbody>().isKinematic = false; _storedItem = null; }
public void FillItem(CollectibleItem item) { name = item.Name; Description = item.Description; quantity = item.Quantity; id = item.Id; type = item.ItemType; Unequipable = item.Unequipable; itemInstance = item.ItemInstance; RenderItem(); }
public int CheckItem(CollectibleItem itemType) { if (Inventory.ContainsKey(itemType)) { return(Inventory[itemType].Count); } else { return(0); } }
// Check if there is free space for the item and set appropriate material as highlight public void CheckPlace(CollectibleItem collectibleItem) { _hasPlace = _backpack.CheckPlace(collectibleItem.Item, collectibleItem.ItemAmount); if (_hasPlace) { _meshRenderer.material = greenMaterial; } else { _meshRenderer.material = redMaterial; } }
public override void Damage(float amount) { base.Damage(amount); if (curHealth <= 0) { BlockingDoor.isBossDefeated = true; for (int i = 0; i < 3; i++) { CollectibleItem item = Instantiate(keyPrefab, transform.position, Quaternion.identity); } } }
public CollectibleItemViewModel(CollectibleItem item) { Item = item; var cis = new CollectibleItemsService(); var itemLocation = cis.GetLocationByItem(Item); if (itemLocation == null) { return; } HasLocationLink = true; }
void OnGUI() { int dist = 10; int left = marginLeft; int collectedItems = CollectibleItem.getCollectedItems(); if (collectedItems > 0) { GUI.DrawTexture(new Rect(left, marginTop, texW, texH), tex); left = left + texW + dist; GUI.Label(new Rect(left, marginTop + 5, 200, texH), " x " + collectedItems, counterStyle); } }
public void OnReceived(EBEvent e) { switch (e.type) { case EBEventType.RoomSpawningTrigger: RoomSpawningTriggerEvent rstee = (e as RoomSpawningTriggerEvent); if (rstee.action == TriggerAction.Enter) { if ((rstee.roomEntryId == id) && spawningEnabled) { roomsManager.DisableAllRoomScenes(); RoomScene room = roomsManager.GetRandomRoomScene(); AttachRoom(room); SetSpawningEnabled(false); room.ClearCollectibles(); Transform itemPlace = room.GetCollectiblePlaceholder(); if (itemPlace != null) { CollectibleItem item = itemsManager.GetItem(); if (item != null) { item.transform.parent = itemPlace; item.transform.position = itemPlace.position; item.transform.rotation = itemPlace.rotation; item.SetRoomScene(room); item.gameObject.SetActive(true); } } } if (rstee.roomEntryId != id) { SetSpawningEnabled(true); } } break; case EBEventType.DoorClosingTrigger: DoorClosingTriggerEvent dcte = (e as DoorClosingTriggerEvent); if ((dcte.roomEntryId == id) && (dcte.action == TriggerAction.Exit)) { CloseDoor(); } break; case EBEventType.HallMovingTriggerEntered: CloseDoor(); break; } }
public bool Pick(CollectibleItem item) { if (items.Count < sizeLimit) { items.Add(item); Debug.Log(items.Count); UpdateInventoryLabel(item.itemType, 1); return(true); } return(false); }
/// <summary> /// Spawned function that takes Player's GUID to spawn collectible. /// </summary> /// <param name="withGuid">GUID of player to whom collectible is being spawned.</param> /// <returns>Spawned collectible script object.</returns> public CollectibleItem spawnCollectible(System.Guid withGuid) { if (collectiblesPrefab.Count == 0) { return(null); } Vector2 randNormalizedPt = Random.insideUnitCircle; Vector3 spawnLoc = new Vector3(spawnZone.center.x + (spawnZone.extents.x * randNormalizedPt.x), spawnZone.center.y + (spawnZone.extents.y * randNormalizedPt.y), 0); GameObject go = Instantiate(collectiblesPrefab[Random.Range(0, collectiblesPrefab.Count)], spawnLoc, Quaternion.identity); CollectibleItem item = go.GetComponent <CollectibleItem>(); item.userId = withGuid; return(item); }
void Awake() { instance = this; GameObject keysObject = Instantiate(keyPrefab); keysObject.SetActive(false); keys = keysObject.GetComponent <CollectibleItem>(); booksPool = new CollectibleItem[bookPrefabs.Length]; for (int i = 0; i < bookPrefabs.Length; ++i) { GameObject book = Instantiate(bookPrefabs[i]); book.SetActive(false); booksPool[i] = book.GetComponent <CollectibleItem>(); } }
// Add collcetible to inventory public void AddItem(CollectibleItem collectibleItem) { // Add item to inventory _backpack.AddItem(collectibleItem.Item, collectibleItem.ItemAmount); _meshRenderer.material = defaultMaterial; // Get potential item-slnapping-slot var backpackSlot = GetBackpackSlot(collectibleItem.Item.Type); if (backpackSlot.isEmpty) { backpackSlot.SnapItem(collectibleItem); return; } // if we do not snap object, then put it in inventory and destroy gameObject Destroy(collectibleItem.gameObject); }
public async Task <IActionResult> PutCollectibleItem(int id, CollectibleItem collectibleItem) { if (id != collectibleItem.Id) { return(BadRequest()); } if (await _service.GetEntity(id) == null) { await _service.InsertEntity(collectibleItem); } else { await _service.UpdateEntity(collectibleItem); } return(NoContent()); }
public bool Drop(CollectibleItem item, DropHandler handler = null) { if (item != null) { if (handler != null) { handler.Invoke(item); } UpdateInventoryLabel(item.itemType, -1); items.Remove(item); return(true); } else { return(false); } }
private static List <CollectibleItem> GetExpectedCollectabileItems() { List <CollectibleItem> expected = new List <CollectibleItem>(); var item = new CollectibleItem() { Id = "c8ad4314-fd8b-4200-994c-366bfd87ae12", Credit = "Thank you tamar", Caption = "Tamar test", IconUrl = null, ValuePairs = new Dictionary <string, int>() { { "hope", 1 }, { "Fait", 2 }, { "Unity", 3 } }, ImageUrl = "https://cloud.squidex.io/api/assets/fldc-prod/c8ad4314-fd8b-4200-994c-366bfd87ae13" }; expected.Add(item); return(expected); }
// Snaps item's gameObject to the slot point public void SnapItem(CollectibleItem item) { item.gameObject.transform.parent = gameObject.transform; // Set isKinematic=false so the item won't fall item.gameObject.GetComponent <Rigidbody>().isKinematic = true; // Set target for magnite movement and enable movement var tmp = item.gameObject.GetComponent <MagnetMovement>(); tmp.Target = gameObject; tmp.enabled = true; // Turn Mouse Drag&drop off item.gameObject.GetComponent <MouseMoveableObj>().Toggle(false); // Turn collectible off item.enabled = false; // Save stored item ref _storedItem = item; }
private ItemSlot AddItem(CollectibleItem item) { var inventoryItem = ItensSlots.Find(lambdaExpression => lambdaExpression.Type == item.ItemType); if (inventoryItem != null) { inventoryItem.Quantity += item.Quantity; inventoryItem.RenderItem(); return(inventoryItem); } for (int i = 0; i < ItensSlots.Count; i++) { if (ItensSlots[i].Type == ItemType.Nothing) { ItensSlots[i].FillItem(item); return(ItensSlots[i]); } } return(null); }
bool Collisions(Vector3Int direction) { Vector3Int newPosition = new Vector3Int((int)transform.position.x, (int)transform.position.y, (int)transform.position.z) + direction; Tile tileToMoveTo = Level.GetTileAt(newPosition.x, newPosition.y); if (tileToMoveTo.Type == TileType.WALL) { return(true); } else if (tileToMoveTo.itemOnTop != null) { switch (tileToMoveTo.itemOnTop.tag) { case "MovableItem": MovableItem item = tileToMoveTo.itemOnTop.GetComponent <MovableItem>(); // You add direction again because this is what the item will be moving to. Basically checking your position + 2 if (item.CanMoveItem(newPosition + direction)) { // If you can move the item that direction then move it and move character item.MoveItem(newPosition + direction); } else { // If you can't move the item that direction then don't do anything return(true); } break; case "CollectibleItem": CollectibleItem collectible = tileToMoveTo.itemOnTop.GetComponent <CollectibleItem>(); collectible.CollectItem(); break; } } return(false); }
public void GainItem(CollectibleItem itemType, Collectible collectible) { if (Inventory.ContainsKey(itemType)) { Inventory[itemType].Add(collectible); UpdateUI(); } else { Inventory.Add(itemType, new List <Collectible>()); Inventory[itemType].Add(collectible); } if (Inventory.ContainsKey(CollectibleItem.Medkit)) { List <Collectible> medkits = Inventory[CollectibleItem.Medkit]; while (medkits.Count > 0) { Medkit medkit = medkits[0] as Medkit; Director.Instance.PlayerHealth.HealthSync += medkit.HealAmount; medkits.Remove(medkit); } } UpdateUI(); }
public async Task <ActionResult <CollectibleItem> > PostCollectibleItem(CollectibleItem collectibleItem) { await _service.InsertEntity(collectibleItem); return(CreatedAtAction("GetCollectibleItem", new { id = collectibleItem.Id }, collectibleItem)); }
public void BurnWood(CollectibleItem item) { heat = maxHeat; Debug.Log("Heat is now " + heat); }
public void Shroomerge(CollectibleItem item) { size += item.ShroomGrowth; Debug.Log("Mushroom is now size " + size); }