public void Activate(string itemName, SpawnedItemBase item) { isActivated = true; title.text = itemName; itemOnGround = item; transform.position = Camera.main.WorldToScreenPoint(item.transform.position); animator.SetTrigger("Show"); gameManager.noSelection = false; }
public void Activate(string itemName, SpawnedItemBase item) { isActivated = true; title.text = itemName; itemOnGround = item; transform.position = Camera.main.WorldToScreenPoint(item.transform.position); animator.SetTrigger("Show"); gameManager.noSelection = false; }
public bool RemoveItemThroughHoverPopup(string itemName, SpawnedItemBase itemOnGround) { foreach (InventoryItem item in inventoryItems) { if (item.itemName == itemName) { item.UpdateCount(1); return(true); } } return(false); }
public bool SelectInventoryItemThroughHoverPopup(string itemName, SpawnedItemBase itemOnGround) { foreach (InventoryItem item in inventoryItems) { if (item.itemName == itemName) { // Debug.Log("START item move!"); itemMoveIsInProcess = true; meshTileMap.SelectComeBack(); SelectInventoryItem(item); return(true); } } return(false); }
// Update is called once per frame void Update() { if (selectedItem != null) { mouseToWorld = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, inputZ)); // Debug.Log(Input.mousePosition + " -> " + mouseToWorld); followSpriteTransform.position = new Vector3(mouseToWorld.x, followSpriteTransform.position.y, mouseToWorld.z); if (Input.GetMouseButtonUp(0) && !anItemIsHovered) { if (selectedItem.placementArea == PlacementArea.Villain) { // if mouse is on top of placement area (this time meshTileMap) if (meshTileMap.isHovering) { allowSpawn = true; } } if (allowSpawn) { float x = followSpriteTransform.position.x; float z = followSpriteTransform.position.z; // SNAP TO GRID float newx = Mathf.Round(x); if (x - newx > 0) { newx += 0.5f; } else { newx -= 0.5f; } float newz = Mathf.Round(z); if (z - newz > 0) { newz += 0.5f; } else { newz -= 0.5f; } GameObject spawnedObject = (GameObject)Instantiate(selectedItem.prefab, new Vector3(newx, followSpriteTransform.position.y, newz), followSpriteTransform.rotation); SpawnedItemBase spawnedItem = spawnedObject.GetComponent <SpawnedItemBase>(); MapNode testNode = tileMap.GetNodeNormalized(newx, newz); spawnedItem.Init(this, selectedItem.itemName, testNode); //Debug.Log((int)(newx) + ", " + (int)(newz) + " -> " + testNode.x + ", " + testNode.y); spawnedItem.transform.SetParent(followSpriteTransform.parent, true); UseItem(); allowSpawn = false; } } } if (Input.GetKeyUp(KeyCode.Escape)) { CancelItemSelection(); } if (Input.GetKeyUp(KeyCode.Space)) { StartLevel(); } }
public void ClickSpawnedItem(SpawnedItemBase spawnedItem) { itemPopup.Activate(spawnedItem.itemName, spawnedItem); }
// when player hovers over spawned item public void HoverOverSpawnedItem(SpawnedItemBase spawnedItem) { anItemIsHovered = true; }
// when player hovers over spawned item public void HoverOverSpawnedItem(SpawnedItemBase spawnedItem) { anItemIsHovered = true; }
public void ClickSpawnedItem(SpawnedItemBase spawnedItem) { itemPopup.Activate(spawnedItem.itemName, spawnedItem); }
public bool SelectInventoryItemThroughHoverPopup(string itemName, SpawnedItemBase itemOnGround) { foreach (InventoryItem item in inventoryItems) { if (item.itemName == itemName) { // Debug.Log("START item move!"); itemMoveIsInProcess = true; meshTileMap.SelectComeBack(); SelectInventoryItem(item); return true; } } return false; }
public bool RemoveItemThroughHoverPopup(string itemName, SpawnedItemBase itemOnGround) { foreach (InventoryItem item in inventoryItems) { if (item.itemName == itemName) { item.UpdateCount(1); return true; } } return false; }