コード例 #1
0
    void Update()
    {
        if (paused)
        {
            return;
        }

        FixedPoint dt = (FixedPoint)Time.deltaTime;

        //process ufo spawn near mouse region
        var v3 = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        mouseTarget.position = new FixedPointVector3(v3.x, v3.y, 0);

        if (Input.GetMouseButtonUp(0) && mouseTarget.behavior.IsColliding() == false && timeSinceUfoSpawned > ufoSpawnInterval)
        {
            SpawnUfo(mouseTarget.position);
            timeSinceUfoSpawned = 0;
        }
        timeSinceUfoSpawned += dt;


        //spawn random asteroids
        if (timeSinceAsteroidSpawned >= asteroidSpawnInterval && entities.Count(e => e.type == EntityType.Asteroid) < 10)
        {
            SpawnAsteroid();
            timeSinceAsteroidSpawned = 0;
        }
        timeSinceAsteroidSpawned += dt;

        //process spawn queue
        while (entitiesToSpawn.Count > 0)
        {
            MaterializeEntity(entitiesToSpawn.Dequeue());
        }

        behaviorController.UpdateBehavior(dt);
        collisionController.UpdateCollisions();
        viewController.UpdateViews();

        //despawn dead stuff
        BringOutTheDead();
    }