예제 #1
0
 // Use this for initialization
 void Start()
 {
     drawLine = GetComponent <DrawConnectedLine>();
     hexCells = GameObject.FindGameObjectsWithTag("DropSpot");
     for (int i = 0; i < hexCells.Length; i++)
     {
         if (hexCells[i].transform == this.transform)
         {
             currentCell = i;
             currentEss  = hexCells[i].GetComponent <EssenceDropCell>();
             break;
         }
     }
     if (hexCells[currentCell].GetComponent <EssenceDropCell>().locked == true)
     {
         connectedLocked = 1;
     }
     //Debug.Log(currentCell);
 }
예제 #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();
        }
    }
예제 #3
0
    public void CheckCell()
    {
        if (currentCell > 5 && rownum <= 3)
        {
            rownum += 1;
            if (currentCell > 10 && currentCell < 35)
            {
                rownum += 1;
                if (currentCell > 16 && currentCell < 30)
                {
                    rownum += 1;
                    fixer  += 1;
                }
                if (currentCell > 24)
                {
                    fixer += 1;
                    if (currentCell > 30)
                    {
                        fixer += 1;
                    }
                }
            }
        }
        Debug.Log(rownum);
        if (hexCells[currentCell].GetComponent <EssenceDropCell>().droppedEssence != null)
        {
            //DOWN
            if (currentCell > 0 && hexCells[currentCell - 1].GetComponent <EssenceDropCell>().droppedEssence != null) //UP
            {
                otherEss = hexCells[currentCell - 1].GetComponent <EssenceDropCell>();
                Debug.Log("Found Downer");
                if (otherEss.droppedEssence.name == currentEss.droppedEssence.ess1 || otherEss.droppedEssence.name == currentEss.droppedEssence.ess2 || otherEss.droppedEssence.ess1 == currentEss.droppedEssence.name || otherEss.droppedEssence.ess2 == currentEss.droppedEssence.name)
                {
                    Debug.Log("Connection made");
                    drawLine.DrawLine();
                    if (otherEss.GetComponent <EssenceCheckNeighbor>().connectedLocked > 0)
                    {
                        otherEss.GetComponent <EssenceCheckNeighbor>().connectedLocked -= 1;
                        connectedLocked += 1;
                    }
                }
            }

            //UP
            if (currentCell < hexCells.Length - 1 && hexCells[currentCell + 1].GetComponent <EssenceDropCell>().droppedEssence != null) //Down
            {
                otherEss = hexCells[currentCell + 1].GetComponent <EssenceDropCell>();
                Debug.Log("Found Upper");
                if (otherEss.droppedEssence.name == currentEss.droppedEssence.ess1 || otherEss.droppedEssence.name == currentEss.droppedEssence.ess2 || otherEss.droppedEssence.ess1 == currentEss.droppedEssence.name || otherEss.droppedEssence.ess2 == currentEss.droppedEssence.name)
                {
                    Debug.Log("Connection made");
                    drawLine.DrawLine();
                    if (otherEss.GetComponent <EssenceCheckNeighbor>().connectedLocked > 0)
                    {
                        otherEss.GetComponent <EssenceCheckNeighbor>().connectedLocked -= 1;
                        connectedLocked += 1;
                    }
                }
            }

            //BOTTOM LEFT
            if (currentCell - rownum - 4 > 0 && hexCells[currentCell - rownum - 4].GetComponent <EssenceDropCell>().droppedEssence != null)
            {
                otherEss = hexCells[currentCell - rownum - 4].GetComponent <EssenceDropCell>();
                Debug.Log("Bottom Left");
                if (otherEss.droppedEssence.name == currentEss.droppedEssence.ess1 || otherEss.droppedEssence.name == currentEss.droppedEssence.ess2 || otherEss.droppedEssence.ess1 == currentEss.droppedEssence.name || otherEss.droppedEssence.ess2 == currentEss.droppedEssence.name)
                {
                    Debug.Log("Connection made");
                    drawLine.DrawLine();
                    if (otherEss.GetComponent <EssenceCheckNeighbor>().connectedLocked > 0)
                    {
                        otherEss.GetComponent <EssenceCheckNeighbor>().connectedLocked -= 1;
                        connectedLocked += 1;
                    }
                }
            }

            //BOTTOM RIGHT
            if (currentCell + rownum + 4 - fixer < hexCells.Length && hexCells[currentCell + rownum + 4 - fixer].GetComponent <EssenceDropCell>().droppedEssence != null)
            {
                otherEss = hexCells[currentCell + rownum + 4 - fixer].GetComponent <EssenceDropCell>();
                Debug.Log("Bottom Right");
                if (otherEss.droppedEssence.name == currentEss.droppedEssence.ess1 || otherEss.droppedEssence.name == currentEss.droppedEssence.ess2 || otherEss.droppedEssence.ess1 == currentEss.droppedEssence.name || otherEss.droppedEssence.ess2 == currentEss.droppedEssence.name)
                {
                    Debug.Log("Connection made");
                    drawLine.DrawLine();
                    if (otherEss.GetComponent <EssenceCheckNeighbor>().connectedLocked > 0)
                    {
                        otherEss.GetComponent <EssenceCheckNeighbor>().connectedLocked -= 1;
                        connectedLocked += 1;
                    }
                }
            }

            //TOP LEFT
            if (currentCell - rownum - 3 > 0 && hexCells[currentCell - rownum - 3].GetComponent <EssenceDropCell>().droppedEssence != null)
            {
                otherEss = hexCells[currentCell - rownum - 3].GetComponent <EssenceDropCell>();
                Debug.Log("Top Left");
                if (otherEss.droppedEssence.name == currentEss.droppedEssence.ess1 || otherEss.droppedEssence.name == currentEss.droppedEssence.ess2 || otherEss.droppedEssence.ess1 == currentEss.droppedEssence.name || otherEss.droppedEssence.ess2 == currentEss.droppedEssence.name)
                {
                    Debug.Log("Connection made");
                    drawLine.DrawLine();
                    if (otherEss.GetComponent <EssenceCheckNeighbor>().connectedLocked > 0)
                    {
                        otherEss.GetComponent <EssenceCheckNeighbor>().connectedLocked -= 1;
                        connectedLocked += 1;
                    }
                }
            }

            //TOP RIGHT
            if (currentCell + rownum + 5 - fixer < hexCells.Length && hexCells[currentCell + rownum + 5 - fixer].GetComponent <EssenceDropCell>().droppedEssence != null)
            {
                otherEss = hexCells[currentCell + rownum + 5 - fixer].GetComponent <EssenceDropCell>();
                Debug.Log("Top Right");
                if (otherEss.droppedEssence.name == currentEss.droppedEssence.ess1 || otherEss.droppedEssence.name == currentEss.droppedEssence.ess2 || otherEss.droppedEssence.ess1 == currentEss.droppedEssence.name || otherEss.droppedEssence.ess2 == currentEss.droppedEssence.name)
                {
                    Debug.Log("Connection made");
                    drawLine.DrawLine();
                    if (otherEss.GetComponent <EssenceCheckNeighbor>().connectedLocked > 0)
                    {
                        otherEss.GetComponent <EssenceCheckNeighbor>().connectedLocked -= 1;
                        connectedLocked += 1;
                    }
                }
            }
            Debug.Log(connectedLocked);
        }
    }