示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (GameController.instance.gameover)
        {
            return;
        }

        if (GameConstants.scrollingSpeed <= -14)
        {
            spawnRateMax = 2f;
        }
        else if (GameConstants.scrollingSpeed <= -10)
        {
            spawnRateMax = 4f;
        }
        else
        {
            spawnRateMax = 5f;
        }

        System.DateTime now = System.DateTime.UtcNow;
        double          secondsSinceLastSpawn = (now - GameConstants.timeOfLastSpawn).TotalSeconds;

        if (secondsSinceLastSpawn < GameConstants.timeBetweenSpawns)
        {
            return;
        }

        timeSinceLastSpawn += Time.deltaTime;

        if (TimeForNextSpawn())
        {
            float      randomX = Random.Range(GameConstants.obstacleMinX, GameConstants.obstacleMaxX);
            GameObject obj;

            if (GameConstants.scrollingSpeed <= -14 && Random.value > .8f)
            {
                obj = fatMissilePool.BorrowFromPool();
            }
            else
            {
                obj = missilePool.BorrowFromPool();
            }

            obj.transform.position = new Vector2(randomX, GameConstants.spawnY);

            // rotate the missile 180 on the z axis
            obj.transform.rotation = Quaternion.Euler(0, 0, 180);
            arrowPool.SetArrow(GameConstants.ArrowColor.Red, obj.transform);

            GameController.instance.SetTimeOfLastSpawn(now);
            timeSinceLastSpawn = 0;
            ResetTimeForNextSpawn();
        }
    }
示例#2
0
 private void SetDistanceMeter(Transform other)
 {
     arrowPool.SetArrow(GameConstants.ArrowColor.Blue, other);
 }