Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 public bool RemoveItemThroughHoverPopup(string itemName, SpawnedItemBase itemOnGround)
 {
     foreach (InventoryItem item in inventoryItems)
     {
         if (item.itemName == itemName)
         {
             item.UpdateCount(1);
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 4
0
    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);
    }
Ejemplo n.º 5
0
    // 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();
        }
    }
Ejemplo n.º 6
0
 public void ClickSpawnedItem(SpawnedItemBase spawnedItem)
 {
     itemPopup.Activate(spawnedItem.itemName, spawnedItem);
 }
Ejemplo n.º 7
0
 // when player hovers over spawned item
 public void HoverOverSpawnedItem(SpawnedItemBase spawnedItem)
 {
     anItemIsHovered = true;
 }
Ejemplo n.º 8
0
 // when player hovers over spawned item
 public void HoverOverSpawnedItem(SpawnedItemBase spawnedItem)
 {
     anItemIsHovered = true;
 }
Ejemplo n.º 9
0
 public void ClickSpawnedItem(SpawnedItemBase spawnedItem)
 {
     itemPopup.Activate(spawnedItem.itemName, spawnedItem);
 }
Ejemplo n.º 10
0
 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;
 }
Ejemplo n.º 11
0
 public bool RemoveItemThroughHoverPopup(string itemName, SpawnedItemBase itemOnGround)
 {
     foreach (InventoryItem item in inventoryItems)
     {
         if (item.itemName == itemName)
         {
             item.UpdateCount(1);
             return true;
         }
     }
     return false;
 }