public bool CheckFlip()
    {
        // If there's at least 2, the next in line will be the front table
        if (scrollingTableList.Count > 1)
        {
            if (frontTable.CheckFlipped())
            {
                flippingTableList.Enqueue(scrollingTableList.Dequeue());
                frontTable = scrollingTableList.Peek().GetComponent <TableBehaviour>();
                return(true);
            }
        }
        // If only 1, it'll be removed on impact, and the next created will be in front
        // Needs to evaluate for 1 so 0 doesn't come in here.
        else if (scrollingTableList.Count == 1)
        {
            if (frontTable.CheckFlipped())
            {
                flippingTableList.Enqueue(scrollingTableList.Dequeue());
                nextTableInFront = true;
                return(true);
            }
        }

        return(false);
    }
    void GetNextTable()
    {
        randTableIdx = Random.Range(0, tables.Length);

        // If this one created is in the front of the line, get it's script
        if (nextTableInFront)
        {
            frontTable       = scrollingTableList.Peek().GetComponent <TableBehaviour>();
            nextTableInFront = false;
        }
    }
Example #3
0
    private void RayCastObjects()
    {
        RaycastHit tableRay;

        Debug.DrawRay(transform.position, transform.forward, Color.red);
        if (Physics.Raycast(transform.position, transform.forward, out tableRay, tableRayDistance))
        {
            TableBehaviour table = tableRay.collider.GetComponent <TableBehaviour>() != null?tableRay.collider.GetComponent <TableBehaviour>() : null;

            if (table == null)
            {
                tableManager.ClearActiveTable();
                return;
            }

            tableManager.SetActiveTable(table);
        }
        else
        {
            tableManager.ClearActiveTable();
        }
    }
    public void Reset()
    {
        foreach (GameObject table in scrollingTableList)
        {
            Destroy(table);
        }
        foreach (GameObject table in flippingTableList)
        {
            Destroy(table);
        }

        scrollingTableList.Clear();
        flippingTableList.Clear();

        // First table, right in front of player
        randTableIdx = Random.Range(0, tables.Length);
        GameObject FrontTableObj = Instantiate(tables[randTableIdx], tables[randTableIdx].transform.position, Quaternion.identity) as GameObject;

        frontTable       = FrontTableObj.GetComponent <TableBehaviour>();
        nextTableInFront = false;
        scrollingTableList.Enqueue(FrontTableObj);

        // Second table, further back into the screen
        randTableIdx = Random.Range(0, tables.Length);
        scrollingTableList.Enqueue(Instantiate(tables[randTableIdx], new Vector3((Constants.TABLE_LAUNCH_X + tables[randTableIdx].transform.position.x) / 2.0f, tables[randTableIdx].transform.position.y, tables[randTableIdx].transform.position.z), Quaternion.identity) as GameObject);

        counter = 99.0f;

        dropTime01 = 2.0f; // regular drop
        dropTime02 = 3.0f; // max of regular two-table drop
        dropTime03 = 2.5f; // max of random ranged drop

        pattern2Toggle     = true;
        pattern3RandomTime = Random.Range(Constants.DROP_TIME_MIN, dropTime03);

        dropPattern = 0;
    }