示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (!Game.Instance.IsGameGoing())
        {
            return;
        }

        if (!Player.IsDocked() && !Generator.GettingToSellingStationSoon())
        {
            _timeToNextRock -= Time.deltaTime;
        }
        if (_timeToNextRock <= 0f)
        {
            Vector3 rockPosition = new Vector3(0, Player.transform.position.y + 9f + Random.value * 3f, 0);
            rockPosition.x = Random.Range(LeftWall.GetObstacleX() + 1f, RightWall.GetObstacleX() - 1f);
            Game.Instance.CreateRock(rockPosition, transform);
            SetNextRockTime();
        }
    }