Пример #1
0
    private void CreateObstacle(int index = -1)
    {
        if (index < 0)
        {
            index = Random.Range(0, plateformPrefabs.Length);
        }
        Vector3 position = new Vector3();

        position = currentObjects.Count == 0 ?
                   startPoint.transform.position : currentObjects[currentObjects.Count - 1].GetBottomPoint();
        position.x  = fixedX;
        position.y -= plateformPrefabs[index].Top;

        PlateformScript plateform = Instantiate(plateformPrefabs[index], position, plateformPrefabs[index].transform.rotation);

        currentObjects.Add(plateform);

        if (Random.Range(0, 1) == 0)
        {
            plateform.transform.eulerAngles = new Vector3(0, 180);
        }
    }
Пример #2
0
    private bool IsGone(PlateformScript plateform)
    {
        Vector3 screenTop = mainCamera.ViewportToWorldPoint(new Vector3(0.5F, 1.0F, -mainCamera.transform.position.z));

        return(screenTop.y < plateform.GetBottomPoint().y);
    }