Ejemplo n.º 1
0
    public void SwapTile(TileContainerScripts otherTile)
    {
        gm.tileCurrentlySelected.transform.parent = currentStorageTile.transform;
        gm.tileCurrentlySelected.GetComponent <TileBaseScript>().currentStorageTile = currentStorageTile.GetComponent <TileContainerScripts>();
        currentStorageTile.GetComponent <TileContainerScripts>().tileContained      = gm.tileCurrentlySelected;

        transform.parent   = otherTile.transform;
        currentStorageTile = otherTile;
        currentStorageTile.tileContained = transform;
        gm.cleanupTime = true;
    }
Ejemplo n.º 2
0
    public bool IsTileAdjacent(TileContainerScripts otherTile)
    {
        //CheckLeft
        if (otherTile.coordinates.x > -1 && otherTile.coordinates.x < 9 && otherTile.coordinates.y < 9 && otherTile.coordinates.y > -1)
        {
            if (Mathf.Abs(otherTile.coordinates.x - currentStorageTile.coordinates.x) == 1)
            {
                return(true);
            }
            else if (Mathf.Abs(otherTile.coordinates.y - currentStorageTile.coordinates.y) == 1)
            {
                return(true);
            }

            Debug.Log(Mathf.Abs(otherTile.coordinates.x - currentStorageTile.coordinates.x));
            Debug.Log(otherTile.name + " " + currentStorageTile.name);
        }

        return(false);
    }
    public void CheckIfMatch()
    {
        GameManagerV2.TileColors colorToMatch = tileContained.GetComponent <TileBaseScript>().currentColor;
        if (shouldOutputDebug)
        {
            Debug.Log(colorToMatch);
        }
        //Checks Left
        if (coordinates.x > 0)
        {
            for (int x = Mathf.RoundToInt(coordinates.x); x > 0; x--)
            {
                TileContainerScripts temp = gm.gridStorageObjects[x - 1][Mathf.RoundToInt(coordinates.y)].GetComponent <TileContainerScripts>();
                if (temp.tileContained.GetComponent <TileBaseScript>().currentColor == colorToMatch)
                {
                    horizontalMatch++;
                }
                else
                {
                    break;
                }
            }
        }
        if (coordinates.x < 8)
        {
            for (int x = Mathf.RoundToInt(coordinates.x); x < 8; x++)
            {
                TileContainerScripts temp = gm.gridStorageObjects[x + 1][Mathf.RoundToInt(coordinates.y)].GetComponent <TileContainerScripts>();
                if (temp.tileContained.GetComponent <TileBaseScript>().currentColor == colorToMatch)
                {
                    horizontalMatch++;
                }
                else
                {
                    break;
                }
            }
        }

        if (coordinates.y > 0)
        {
            for (int y = Mathf.RoundToInt(coordinates.y); y > 0; y--)
            {
                TileContainerScripts temp = gm.gridStorageObjects[Mathf.RoundToInt(coordinates.x)][y - 1].GetComponent <TileContainerScripts>();
                if (temp.tileContained.GetComponent <TileBaseScript>().currentColor == colorToMatch)
                {
                    verticalMatch++;
                }
                else
                {
                    break;
                }
            }
        }
        if (coordinates.y < 8)
        {
            for (int y = Mathf.RoundToInt(coordinates.y); y < 8; y++)
            {
                TileContainerScripts temp = gm.gridStorageObjects[Mathf.RoundToInt(coordinates.x)][y + 1].GetComponent <TileContainerScripts>();
                if (temp.tileContained.GetComponent <TileBaseScript>().currentColor == colorToMatch)
                {
                    verticalMatch++;
                }
                else
                {
                    break;
                }
            }
        }

        if (verticalMatch >= 3 || horizontalMatch >= 3)
        {
            if (verticalMatch >= 3 && horizontalMatch >= 3)
            {
                isMatched = true;
            }
            else
            {
                isMatched = true;
            }
        }

        verticalMatch   = 1;
        horizontalMatch = 1;
    }
Ejemplo n.º 4
0
 void ResetPosition()
 {
     currentStorageTile = transform.parent.GetComponent <TileContainerScripts>();
     transform.position = Vector3.Lerp(transform.position, currentStorageTile.transform.position, Time.deltaTime * TileMoveSpeed);
 }