Example #1
0
    public CollectibleItem GetItem()
    {
        float chance = 0.0f;

        if ((keysSpawningPredicate != null) && keysSpawningPredicate.Check(worldState))
        {
            chance = GetKeyChance();
            if (Random.value <= chance)
            {
                keySpawnTries = 0;
                return(keys);
            }
            else
            {
                ++keySpawnTries;
            }
        }

        chance = GetBookChance();
        if (Random.value <= chance)
        {
            bookSpawnTries = 0;
            int index = Random.Range(0, booksPool.Length);
            return(booksPool[index]);
        }
        else
        {
            ++bookSpawnTries;
        }
        return(null);
    }
 public bool CheckPredicate(WorldState world)
 {
     return((compositePredicate != null) && compositePredicate.Check(world));
 }
 public bool CheckPredicate(WorldState world)
 {
     return((predicate != null) && predicate.Check(world));
 }