コード例 #1
0
        private void SpawnEnemies(GameTime gameTime)
        {
            timeUntilNextSpawnWave -= gameTime.ElapsedGameTime;
            if (timeUntilNextSpawnWave < TimeSpan.Zero)
            {
                timeUntilNextSpawnWave += TimeSpan.FromSeconds(6);

                for (int i = 0; i < waveNumber * 2; ++i)
                {
                    var dist  = 20;
                    var enemy = new Enemy(game,
                                          Color.White,
                                          RandomFuncs.FromRange(16f, 64f),
                                          this.Phy.Pos + new Vector2(RandomFuncs.FromRange(-dist, dist), RandomFuncs.FromRange(-dist, dist)),
                                          (float)RandomFuncs.FromRange(0, MathHelper.TwoPi),
                                          new ChasingBehavior(game.MainScene, 500, 1500, RandomFuncs.FromRange(Player.DefaultMaxSpd * 0.2f, Player.DefaultMaxSpd * 0.7f)));
                    enemy.LoadContent(game.Content);
                    enemy.Phy.Spd = new Vector2(
                        RandomFuncs.FromRange(-Player.DefaultMaxSpd * 0.5f, Player.DefaultMaxSpd * 0.5f),
                        RandomFuncs.FromRange(-Player.DefaultMaxSpd * 0.5f, Player.DefaultMaxSpd * 0.5f));
                    game.MainScene.Enemies.Add(enemy);
                }
                ++waveNumber;
            }
        }
コード例 #2
0
    // Fills a queue with 10 recipes by Randomly shuffling the above food lists and picking items out of the shuffled list.
    //
    private void FillRecipeQueue()
    {
        for (int i = 0; i < 10; i++)
        {
            string currentRecipe = "";

            currentRecipe += (RandomFuncs.FYShuffle(BreadChoice)[0]) + ", ";
            currentRecipe += (RandomFuncs.FYShuffle(MeatChoice)[0]) + ", ";
            currentRecipe += (RandomFuncs.FYShuffle(CheeseChoice)[0]) + ", ";

            ToppingsChoice = RandomFuncs.FYShuffle(ToppingsChoice);
            for (int j = 0; j < Random.Range(1, 3); j++)
            {
                currentRecipe += ToppingsChoice[j] + ", ";
            }

            DressingsChoice = RandomFuncs.FYShuffle(DressingsChoice);
            int dressingsAmount = Random.Range(1, 2);
            for (int j = 0; j < dressingsAmount; j++)
            {
                currentRecipe += DressingsChoice[j];
                if (j != dressingsAmount - 1)
                {
                    currentRecipe += ", ";
                }
            }

            RecipeQueue.Enqueue(currentRecipe);
        }
    }
コード例 #3
0
    // Spawns a new customer, set its parent to empty Customers Object, give it the "Customer" tag and switch a bool to keep track of whether a customer is currently spawned
    //
    private void SpawnCustomer()
    {
        RandomFuncs.FYShuffle(_customerParent);
        GameObject spawnParent = _customerParent[0];
        GameObject newCustomer = GameObject.Instantiate(customerPrefab, spawnParent.transform.position, Quaternion.identity);

        newCustomer.transform.SetParent(spawnParent.transform);
        newCustomer.transform.localPosition = spawnParent.transform.position;
        _timeUntilNextCustomer = Random.Range(5f, 30f);
    }
コード例 #4
0
 public void Spawn()
 {
     if (Emitting && active < maxParticles)
     {
         pos[active]      = SpawnPos;
         spd[active]      = new Vector2(RandomFuncs.FromRange(-400, 400), RandomFuncs.FromRange(-400, 400));
         scl[active]      = Vector2.One * 0.8f;
         maxScl[active]   = Vector2.One * 0.1f;
         col[active]      = SpawnColor;
         maxCol[active]   = col[active];
         maxCol[active].A = 0;
         age[active]      = 0;
         active++;
     }
 }