Exemplo n.º 1
0
    public void CheckAllNeighbors()
    {
        List<GameObject> eggs = EggUtility.GetEggs();

        for (int i = 0; i < eggs.Capacity; i++)
        {
            //Returns an egg directly below in the same x position on the grid
            if ((eggs[i].GetComponent<SimpleEgg>().gridCoord.y == gridCoord.y - 1) && (eggs[i].GetComponent<SimpleEgg>().gridCoord.x == gridCoord.x))
            {
                ndown = eggs[i].GetComponent<SimpleEgg>();
            }
            else
                //Returns an egg above below in the same x position on the grid
                if ((eggs[i].GetComponent<SimpleEgg>().gridCoord.y == gridCoord.y + 1) && (eggs[i].GetComponent<SimpleEgg>().gridCoord.x == gridCoord.x))
                {
                    nUp = eggs[i].GetComponent<SimpleEgg>();
                }
                else
                    //Returns an egg directly below in the same x position on the grid
                    if ((eggs[i].GetComponent<SimpleEgg>().gridCoord.x == gridCoord.x - 1) && (eggs[i].GetComponent<SimpleEgg>().gridCoord.y == gridCoord.y))
                    {
                        nLeft = eggs[i].GetComponent<SimpleEgg>();
                    }
                    else
                        //Returns an egg directly below in the same x position on the grid
                        if ((eggs[i].GetComponent<SimpleEgg>().gridCoord.x == gridCoord.x + 1) && (eggs[i].GetComponent<SimpleEgg>().gridCoord.y == gridCoord.y))
                        {
                            nRight = eggs[i].GetComponent<SimpleEgg>();
                        }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Check to see if there is an egg underneath me
    /// </summary>
    /// <param name="grid"></param>
    public bool IsSomethingLeftOfMe(Vector2 grid)
    {
        List<GameObject> eggs = EggUtility.GetEggs();

        for (int i = 0; i < eggs.Capacity; i++)
        {
            //Returns an egg directly below in the same x position on the grid
            if ((eggs[i].GetComponent<SimpleEgg>().gridCoord.x == gridCoord.x - 1) && (eggs[i].GetComponent<SimpleEgg>().gridCoord.y == gridCoord.y))
            {
                nLeft = eggs[i].GetComponent<SimpleEgg>();
                return true;
            }
        }
        return false;
    }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        //Create the Coordinate Vector and size it by rows * columns
        coords = new Vector2[rowCount * colCount];

        currentEggHolder = GameObject.Find("Current");
        nextEggHolder = GameObject.Find("Next");

        //Create the actual grid
        CreateGrid();

        //Create the first Egg
        currentEgg = Instantiate(EggUtility.CreateNewEgg()) as SimpleEgg;
        nextEgg = Instantiate(EggUtility.CreateNewEgg()) as SimpleEgg;

        currentEgg.transform.position = new Vector3(currentEggHolder.transform.position.x, currentEggHolder.transform.position.y, -3);
        nextEgg.transform.position = new Vector3(nextEggHolder.transform.position.x, nextEggHolder.transform.position.y, -3);
    }