public virtual IEnumerator preloadCo() { yield return(new WaitForEndOfFrame()); GamePreset preset = GamePresets.Instance.GetCurrentPresetDataCharacter(); if (preset == null) { yield break; } List <GamePresetItem> presetItems = preset.data.items; foreach (GamePresetItem item in presetItems) { for (int i = 0; i < item.limit / 3; i++) { yield return(new WaitForEndOfFrame()); GameAIController.Load(item.code); } } yield return(new WaitForSeconds(1f)); // remove all characters GameController.ResetLevelActors(); yield return(new WaitForEndOfFrame()); }
public virtual void load(string code, string type = "enemy") { // Load by character code float speed = .3f; float attack = .3f; float scale = 1f; speed = UnityEngine.Random.Range(.8f, 1.6f); attack = UnityEngine.Random.Range(.3f, .4f); scale = UnityEngine.Random.Range(.8f, 1.6f); GameAIController.Load(code, type, speed, attack, scale); }
public virtual void directAI() { currentFPS = FPSDisplay.GetCurrentFPS(); if ((currentActorCount < currentCharacterLimit && currentFPS > 20f) || currentActorCount < currentCharacterMin) { // do some spawning if (currentActorCount < currentCharacterMin * 2) { currentSpawnAmount = 1; } GamePreset preset = GamePresets.Instance.GetCurrentPresetDataCharacter(); 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); } //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; * } * } * } * } */ GamePresetItem selectByProbabilityItem = MathUtil.ChooseProbability <GamePresetItem>(presetItems, probs); if (selectByProbabilityItem == null) { return; } string code = selectByProbabilityItem.code; GameAIController.Load(code); } }
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); } }