Ejemplo n.º 1
0
    public void OnGetBack()
    {
        //Debug.Log("clicked" + droppedEssence);

        if (droppedEssence != null && locked == false)
        {
            GetBack();
            dragNDrop      = null;
            droppedEssence = null;
            _img.sprite    = _defaultImg;
            _img.color     = _defaultColor;
        }
        gridGen.OnHexGridExport();
    }
Ejemplo n.º 2
0
    public void OnDrop()
    {
        //Debug.Log("dropped");
        if (drag)
        {
            drag = false;
            for (int i = 0; i < dropSpot.Length; i++)
            {
                essenceDropCell = dropSpot[i].GetComponent <EssenceDropCell>();
                if (essenceDropCell.isDropCell && essenceDropCell.locked == false)
                {
                    if (essenceDropCell.name == "Hexagon(Clone)" /*&& essenceDropCell.droppedEssence == null*/)
                    {
                        //SOUND
                        audioPlayer.PlayWrite();

                        essenceDisplay._essence.amount -= 1;
                        essenceDisplay.UpdateAmount();
                        if (essenceDropCell.droppedEssence != null)
                        {
                            Debug.Log("gives back");
                            essenceDropCell.OnPrevGetBack();

                            /*
                             * essenceDropCell.droppedEssence.amount += 1;
                             * essenceDropCell.dragNDrop.gameObject.GetComponent<EssenceDisplay>().UpdateAmount();
                             */
                        }
                    }
                    else
                    {
                        audioPlayer.PlayZap(1);
                    }
                    essenceDropCell.dragNDrop = this.gameObject.GetComponent <DragNDrop>(); //Needs the gameobject, gets destroyed when next holders
                    essenceDropCell.SetEssence();
                    if (essenceDropCell.name == "Hexagon(Clone)")
                    {
                        essenceDropCell.GetComponent <EssenceCheckNeighbor>().CheckCell(); //check neighbors NEEDS new essence
                    }
                    Destroy(essenceClone);
                    //Debug.Log("gets called");
                    break;
                }
                if (!essenceDropCell.isDropCell && i >= dropSpot.Length - 1)
                {
                    //Debug.Log(essenceDropCell.isDropCell);
                    //Debug.Log("gives back");
                    //essenceDisplay._essence.amount += 1;
                    //essenceDisplay.UpdateAmount();
                    Destroy(essenceClone);

                    //SOUND
                    audioPlayer.PlayZap(1);

                    break;
                }
                //Debug.Log(dropSpot.Length + "  " + i);
            }
            gridGen.OnHexGridExport();
        }
    }