Exemplo n.º 1
0
    public void SetLoot(LootConfig _loot)
    {
        if (_loot == null)
        {
            Destroy(this);
            return;
        }

        loot  = _loot;
        crate = Instantiate(_loot.WorldObject);

        Tile t = gameObject.GetComponent <Tile>();

        crate.transform.position = t.GetPosition();
        crate.transform.SetParent(t.transform, true);
        LootContentConfig content = M_Weightable.GetWeighted(loot.Drops);


        int amount = (int)content.BaseAmount.Value();

        if (content.Item.Type == ItemTypes.dust)
        {
            amount = Constants.GetDustForProgress(amount, WorldExtender.Instance.GetGetDifficulty());
        }

        item_lootable = new ItemInInventory(content.Item, amount);
    }
Exemplo n.º 2
0
    public static List <WeightedUnit> GetUnitsForGroupPower(UnitSpawnGroupConfig group)
    {
        int powerLeft = group.GroupPower;

        List <WeightedUnit> possibleUnits = group.SpawnableUnits.Where(u => !u.ForceUnit).ToList();
        List <WeightedUnit> choosenUnits  = group.SpawnableUnits.Where(u => u.ForceUnit).ToList();

        List <WeightedUnit> validUnits = GetUnitsInPowerRange(possibleUnits, powerLeft);

        while (validUnits.Count > 0)
        {
            WeightedUnit choosen = M_Weightable.GetWeighted(validUnits);
            choosenUnits.Add(choosen);
            int unitPower = choosen.UnitConfig.UnitPower;
            if (unitPower <= 0)
            {
                Debug.LogWarning("UNIT POWER 0, aborting to avoid infinite loop");
                return(null);
            }

            powerLeft -= unitPower;

            validUnits = GetUnitsInPowerRange(possibleUnits, powerLeft);
        }

        return(choosenUnits);
    }
Exemplo n.º 3
0
    public override Speech GetSpeech()
    {
        if (M_Math.Roll(Chance))
        {
            return(M_Weightable.GetWeighted(Speeches));
        }


        return(null);
    }
Exemplo n.º 4
0
    public virtual Speech GetSpeech(string trigger)
    {
        SpeechTriggerConfigIDGroupConfig _speech = Groups.FirstOrDefault(gr => gr.ID == trigger);

        if (_speech != null && M_Math.Roll(_speech.Chance))
        {
            return(M_Weightable.GetWeighted(_speech.Speeches));
        }

        return(null);
    }
Exemplo n.º 5
0
    // Use this for initialization
    public virtual void PlayIDWeighted(string ID)
    {
        List <WeightedAudio> clips = id_clips.GetItem(ID);

        if (clips.IsNullOrEmpty())
        {
            MDebug.Log("No Audio For " + ID);
            return;
        }

        AudioClip clip = M_Weightable.GetWeighted(clips).Value;

        Play(clip);
    }
Exemplo n.º 6
0
    public static List <RegionConfig> RegionsToSpawn(RegionConfigDataBase config)
    {
        List <RegionConfig> regions_to_spawn = new List <RegionConfig>();

        regions_to_spawn.Add(config.StartRegion);

        foreach (var pool in config.AllPools)
        {
            regions_to_spawn.Add(M_Weightable.GetWeighted(pool.Regions).Region);
        }

        regions_to_spawn.Add(M_Weightable.GetWeighted(config.Camps).Region);

        return(regions_to_spawn);
    }
Exemplo n.º 7
0
    public LootConfig GetLootConfig(EnemyDropCategory drop)
    {
        if (drop == EnemyDropCategory.none)
        {
            return(null);
        }
        EnemyDropConfig edc = EnemyDropConfigs.FirstOrDefault(config => config.Category == drop);

        if (edc != null && edc.DropChance >= UnityEngine.Random.value)
        {
            return(M_Weightable.GetWeighted(edc.Configs).config);
        }
        else
        {
            Debug.LogWarning("Could not find enemy drop config for " + drop + " configs=" + EnemyDropConfigs.Count);
            return(null);
        }
    }
Exemplo n.º 8
0
    public static List <UnitSpawnGroupConfig> GetGroupsForPower(RegionConfig region)
    {
        // MDebug.Log("Get groups for " + region);
        //Add all forced groups to choosen ones
        List <UnitSpawnGroupConfig> choosenGroups = region.Groups.Where(gr => gr.ForceGroup).ToList();

        //make a copy of groups but exclude the ones that we already have
        List <UnitSpawnGroupConfig> groupsCopy = new List <UnitSpawnGroupConfig>(region.Groups).Where(gr => !choosenGroups.Contains(gr)).ToList();

        int powerLeft = region.RegionTotalEnemyPower;
        //list of groupls that are valid for the powerlevel left
        List <UnitSpawnGroupConfig> validgroups = GetGroupsInPowerLevel(groupsCopy, powerLeft);

        while (validgroups.Count > 0)
        {
            UnitSpawnGroupConfig choosen = M_Weightable.GetWeighted(validgroups);
            choosenGroups.Add(choosen);
            groupsCopy.Remove(choosen);
            int groupPower = choosen.GroupPower;

            if (groupPower <= 0)
            {
                Debug.LogWarning("UNIT POWER 0, aborting to avoid infinite loop");
                return(choosenGroups);
            }

            powerLeft -= groupPower;

            if (groupsCopy.Count == 0)
            {
                Debug.LogWarning("No groups to spawn left");
                return(choosenGroups);
            }
            validgroups = GetGroupsInPowerLevel(groupsCopy, powerLeft);
        }

        return(choosenGroups);
    }
Exemplo n.º 9
0
    // Use this for initialization

    public int GetId(bool raged)
    {
        List <IdleConfig> list = raged ? IdleRush : IdleRegular;

        return(M_Weightable.GetWeighted(list).Index);
    }
Exemplo n.º 10
0
 public virtual Speech GetSpeech()
 {
     return(M_Weightable.GetWeighted(Speeches));
 }
Exemplo n.º 11
0
 public static List <Tile> GetCrumbleTiles(int count, TileManager region)
 {
     return((from wt
             in M_Weightable.GetWeighted(GetWeightedTiles(region).Cast <IWeightable>().ToList(), count)
             select region.Tiles[(wt as TileWeighted).tilePos.x, (wt as TileWeighted).tilePos.z]).ToList());
 }
Exemplo n.º 12
0
 public HeadData GetHead()
 {
     return(M_Weightable.GetWeighted(Heads));
 }