示例#1
0
    void OnUpdate(List <TieredUnit> selected)
    {
        for (int i = 0; i < getHighestSlotCount(); i++)
        {
            ScriptableUnitConfig unit = null;

            if (i < selected.Count)
            {
                unit = TieredUnit.Unlocks(selected[i].Tiers, PlayerLevel.Instance).GetHighestUnlocked().Config;
            }
            Slots[i].SetUnit(unit);
        }
        UpdateTF();
    }
示例#2
0
    public static UnitSpawnGroupConfig MakeSquadGroup()
    {
        List <ScriptableUnitConfig> unit_configs = new List <ScriptableUnitConfig>();
        UnitSpawnGroupConfig        conf         = new UnitSpawnGroupConfig();

        conf.ForceGroup     = true;
        conf.SpawnerGroup   = 1;
        conf.SpawnableUnits = new List <WeightedUnit>();

        if (Instance.selected_units.IsNullOrEmpty())
        {
            Debug.LogWarning("NO UNITS SELECTED");

            Instance.unitunlocks.Select(unlock => unlock.Item).ToList().ForEach(unlock => unit_configs.Add(unlock.Tiers.GetRandom().Config));
        }
        else
        {
            foreach (var _selected in Instance.selected_units)
            {
                unit_configs.Add(TieredUnit.Unlocks(_selected.Tiers, PlayerLevel.Instance).GetHighestUnlocked().Config);
            }
        }


        List <ScriptableUnitConfig> selected = unit_configs.GetRandomRemove(Instance.GetMaxSquadsize());

        foreach (ScriptableUnitConfig unit_config in selected)
        {
            WeightedUnit unit = new WeightedUnit();
            unit.ForceUnit       = true;
            unit.TurnTimeOnSpawn = Constants.PLAYER_SQUAD_START_INITIATIVE;
            unit.UnitConfig      = unit_config;

            conf.SpawnableUnits.Add(unit);
        }

        return(conf);
    }
示例#3
0
 public static void RemoveFromSquad(TieredUnit conf)
 {
     MDebug.Log("REMOVING " + conf.Tiers[0].Config.ID);
     Instance.selected_units.Remove(conf);
     Instance.OnSelectedUpdate.AttemptCall(Instance.selected_units);
 }
示例#4
0
 public static string GetID(TieredUnit tier)
 {
     return(tier.Tiers[0].Config.ID);
 }
示例#5
0
 public static int GetRequirement(TieredUnit tier)
 {
     return(tier.Tiers.Min(_tier => _tier.LevelRequirement));
 }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        ScriptableUnitTiers _target         = target as ScriptableUnitTiers;
        List <IUnlockable>  all_unlockables = new List <IUnlockable>();


        List <Unlockable <SquadSizeConfig> > squadsizes = UnlockableFactory.MakeUnlockables(_target.SquadSizes, null, SquadSizeConfig.GetRequirement, SquadSizeConfig.GetID);
        List <Unlockable <UnitTier> >        units      = UnlockableFactory.MakeUnlockables(TieredUnit.AllTiers(_target.TieredUnitsSelectible), null, UnitTier.GetRequirement, UnitTier.GetID);

        all_unlockables.AddRange(units.Select(tier => tier as IUnlockable).ToList());
        all_unlockables.AddRange(squadsizes.Select(size => size as IUnlockable).ToList());

        all_unlockables = all_unlockables.OrderBy(unlockable => unlockable.GetLevelRequirement()).ToList();

        all_unlockables.ForEach(unlockable => EditorGUILayout.LabelField(unlockable.GetLevelRequirement() + " - " + unlockable.GetID()));
    }