public virtual void directWeapons( string itemType, double spawnCount, double spawnMin, double spawnLimit, bool limitFps = true) { currentFPS = FPSDisplay.GetCurrentFPS(); // DIRECT ENEMIES if ((spawnCount < spawnLimit && (currentFPS > 20f || !limitFps)) || spawnCount < spawnMin) { // do some spawning if (spawnCount < spawnMin * 2) { //spawnAmount = 1; } if (presetWeapons == null) { presetWeapons = new List <GameDataWeaponPreset>(); } else { presetWeapons.Clear(); } Debug.Log("directWeapons"); if (GameLevels.Current.data != null && GameLevels.Current.data.HasWeaponPresets()) { Debug.Log("directWeapons:HasWeaponPresets:level"); foreach (GameDataWeaponPreset weaponPreset in GameLevels.Current.data.weapon_presets) { if (weaponPreset.type == itemType) { presetWeapons.Add(weaponPreset); } } } else if (GameWorlds.Current.data != null && GameWorlds.Current.data.HasWeaponPresets()) { Debug.Log("directWeapons:HasWeaponPresets:world"); foreach (GameDataWeaponPreset weaponPreset in GameWorlds.Current.data.weapon_presets) { if (weaponPreset.type == itemType) { presetWeapons.Add(weaponPreset); } } } if (presetWeaponsAppend == null) { presetWeaponsAppend = new List <GamePresetItem>(); } else { presetWeaponsAppend.Clear(); } if (presetWeaponProbabilities == null) { presetWeaponProbabilities = new List <float>(); } else { presetWeaponProbabilities.Clear(); } foreach (GameDataWeaponPreset itemPreset in presetWeapons) { Debug.Log("directWeapons:GameDataWeaponPreset: " + itemPreset.code); GamePreset preset = GamePresets.Get(itemPreset.code); //GamePresets.Instance.GetCurrentPresetDataCharacter(); if (preset == null) { return; } Debug.Log("directWeapons:GamePreset:code: " + preset.code); Debug.Log("directWeapons:GamePreset:type: " + preset.type); Debug.Log("directWeapons:GamePreset:data: " + preset.ToJson()); List <GamePresetItem> presetItemsData = preset.data.items; foreach (GamePresetItem item in presetItemsData) { Debug.Log("directWeapons:GamePresetItem:code: " + item.code); Debug.Log("directWeapons:GamePresetItem:type: " + item.type); Debug.Log("directWeapons:GamePresetItem:data: " + item.ToJson()); if (itemPreset.type == itemType) { presetWeaponProbabilities.Add((float)item.probability); presetWeaponsAppend.Add(item); Debug.Log("directWeapons:GamePresetItem: " + item.code); } } } if (presetWeaponsAppend == null || presetWeaponProbabilities == null) { Debug.Log("directWeapons:presetWeaponProbabilities:null "); return; } if (presetWeaponsAppend.Count == 0 || presetWeaponProbabilities.Count == 0) { Debug.Log("directWeapons:presetWeaponProbabilities:empty "); return; } GamePresetItem selectByProbabilityItem = MathUtil.ChooseProbability <GamePresetItem>( presetWeaponsAppend, presetWeaponProbabilities); if (selectByProbabilityItem == null) { Debug.Log("directWeapons:selectByProbabilityItem:null "); return; } string code = selectByProbabilityItem.code; Debug.Log("directWeapons:selectByProbabilityItem:code: " + code); GameItemController.Load(code);//, itemType); } }
public virtual void directAICharacters( string actorType, double spawnCount, double spawnMin, double spawnLimit, bool limitFps = true) { currentFPS = FPSDisplay.GetCurrentFPS(); // DIRECT ENEMIES if ((spawnCount < spawnLimit && (currentFPS > 20f || !limitFps)) || spawnCount < spawnMin) { // do some spawning if (spawnCount < spawnMin * 2) { //spawnAmount = 1; } if (characters == null) { characters = new List <GameDataCharacterPreset>(); } else { characters.Clear(); } if (GameLevels.Current.data != null && GameLevels.Current.data.HasCharacterPresets()) { foreach (GameDataCharacterPreset characterPreset in GameLevels.Current.data.character_presets) { if (characterPreset.type == actorType) { characters.Add(characterPreset); } } } else if (GameWorlds.Current.data != null && GameWorlds.Current.data.HasCharacterPresets()) { foreach (GameDataCharacterPreset characterPreset in GameWorlds.Current.data.character_presets) { if (characterPreset.type == actorType) { characters.Add(characterPreset); } } } // IF SIDEKICKS, SELECT FROM SIDEKICKS NOT ENEMIES if (presetItemsAppend == null) { presetItemsAppend = new List <GamePresetItem>(); } else { presetItemsAppend.Clear(); } if (probs == null) { probs = new List <float>(); } else { probs.Clear(); } foreach (GameDataCharacterPreset characterPreset in characters) { GamePreset preset = GamePresets.Get(characterPreset.code); //GamePresets.Instance.GetCurrentPresetDataCharacter(); if (preset == null) { return; } List <GamePresetItem> presetItems = preset.data.items; foreach (GamePresetItem item in presetItems) { if (item.type == actorType) { probs.Add((float)item.probability); presetItemsAppend.Add(item); } } } //string characterCode = ""; /* * if (!IsPlayerControlled) { * // apply team * * GameTeam team = GameTeams.Current; * * // TODO randomize * * if (team != null) { * if (team.data != null) { * * GameDataModel item = team.data.GetModel(); * * if (item != null) { * characterCode = item.code; * controllerData.lastCharacterCode = item.code; * } * } * } * } */ if (presetItemsAppend == null || probs == null) { return; } if (presetItemsAppend.Count == 0 || probs.Count == 0) { return; } GamePresetItem selectByProbabilityItem = MathUtil.ChooseProbability <GamePresetItem>(presetItemsAppend, probs); if (selectByProbabilityItem == null) { return; } string code = selectByProbabilityItem.code; GameAIController.Load(code, actorType); } }
/* * public virtual void direct() { * * * currentFPS = FPSDisplay.GetCurrentFPS(); * * if ((currentItemCount < spawnLimit * && currentFPS > 20f) || currentItemCount < spawnMin) { * * // do some spawning * * if (currentItemCount < spawnMin * 2) { * spawnAmount = 1; * } * * GamePreset preset = GamePresets.Instance.GetCurrentPresetDataItem(); * * if (preset == null) { * return; * } * * List<GamePresetItem> presetItems = preset.data.items; * * List<float> probs = new List<float>(); * foreach (GamePresetItem item in presetItems) { * probs.Add((float)item.probability); * } * * GamePresetItem selectByProbabilityItem = * MathUtil.ChooseProbability<GamePresetItem>(presetItems, probs); * * if (selectByProbabilityItem == null) { * return; * } * * string code = selectByProbabilityItem.code; * * GameItemController.Load(code); * } * } * */ public virtual void directItems( string itemType, double spawnCount, double spawnMin, double spawnLimit, bool limitFps = true) { currentFPS = FPSDisplay.GetCurrentFPS(); // DIRECT ENEMIES if ((spawnCount < spawnLimit && (currentFPS > 20f || !limitFps)) || spawnCount < spawnMin) { // do some spawning if (spawnCount < spawnMin * 2) { //spawnAmount = 1; } if (presetItems == null) { presetItems = new List <GameDataItemPreset>(); } else { presetItems.Clear(); } if (GameLevels.Current.data != null && GameLevels.Current.data.HasItemPresets()) { foreach (GameDataItemPreset itemPreset in GameLevels.Current.data.item_presets) { if (itemPreset.type == itemType) { presetItems.Add(itemPreset); } } } else if (GameWorlds.Current.data != null && GameWorlds.Current.data.HasItemPresets()) { foreach (GameDataItemPreset itemPreset in GameWorlds.Current.data.item_presets) { if (itemPreset.type == itemType) { presetItems.Add(itemPreset); } } } if (presetItemsAppend == null) { presetItemsAppend = new List <GamePresetItem>(); } else { presetItemsAppend.Clear(); } if (presetItemProbabilities == null) { presetItemProbabilities = new List <float>(); } else { presetItemProbabilities.Clear(); } foreach (GameDataItemPreset itemPreset in presetItems) { GamePreset preset = GamePresets.Get(itemPreset.code); //GamePresets.Instance.GetCurrentPresetDataCharacter(); if (preset == null) { return; } List <GamePresetItem> presetItemsData = preset.data.items; foreach (GamePresetItem item in presetItemsData) { if (item.type == itemType) { presetItemProbabilities.Add((float)item.probability); presetItemsAppend.Add(item); } } } if (presetItemsAppend == null || presetItemProbabilities == null) { return; } if (presetItemsAppend.Count == 0 || presetItemProbabilities.Count == 0) { return; } GamePresetItem selectByProbabilityItem = MathUtil.ChooseProbability <GamePresetItem>( presetItemsAppend, presetItemProbabilities); if (selectByProbabilityItem == null) { return; } string code = selectByProbabilityItem.code; GameItemController.Load(code);//, itemType); } }