/// <summary>
 /// Initializes a new instance of the <see cref="ServerResult" /> class.
 /// </summary>
 /// <param name="level">The level this server is running.</param>
 /// <param name="gameMode">The game mode this server is running.</param>
 /// <param name="gamePreset">The game preset this server is running.</param>
 /// <param name="url">The URL to the server on BattleLog.</param>
 public ServerResult(GameLevel level, GameMode gameMode, GamePreset gamePreset, string url)
 {
     Level = level;
     GameMode = gameMode;
     GamePreset = gamePreset;
     Url = url;
 }
    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());
    }
示例#3
0
    private void GetChosenPreset()
    {
        string theme = GlobalGameSettings.GetSetting("Theme");

        GamePreset chosenPreset = themeStrings.First(x => x.name.Equals(theme)).preset;

        if (chosenPreset != null)
        {
            gamePreset = chosenPreset;
        }
    }
        private void UpdateFormatList(GamePreset preset)
        {
            if (comboBoxFormatFaces.Items.Count == 0)
            {
                return;
            }

            switch (preset)
            {
            case GamePreset.BreathOfTheWild:
                comboBoxFormatPositions.SelectedItem    = AttribFormat.Format_16_16_16_16_Single;
                comboBoxFormatNormals.SelectedItem      = AttribFormat.Format_10_10_10_2_SNorm;
                comboBoxFormatTangents.SelectedItem     = AttribFormat.Format_8_8_8_8_SNorm;
                comboBoxFormatBitans.SelectedItem       = AttribFormat.Format_8_8_8_8_SNorm;
                comboBoxFormatVertexColors.SelectedItem = AttribFormat.Format_8_8_8_8_UNorm;
                comboBoxFormatUvs.SelectedItem          = AttribFormat.Format_16_16_UNorm;
                comboBoxFormatIndices.SelectedItem      = AttribFormat.Format_8_8_8_8_UInt;
                comboBoxFormatWeights.SelectedItem      = AttribFormat.Format_8_8_8_8_UNorm;
                break;

            case GamePreset.WindWakerHD:
                comboBoxFormatPositions.SelectedItem    = AttribFormat.Format_32_32_32_Single;
                comboBoxFormatNormals.SelectedItem      = AttribFormat.Format_32_32_32_Single;
                comboBoxFormatTangents.SelectedItem     = AttribFormat.Format_32_32_32_32_Single;
                comboBoxFormatBitans.SelectedItem       = AttribFormat.Format_32_32_32_32_Single;
                comboBoxFormatVertexColors.SelectedItem = AttribFormat.Format_32_32_32_32_Single;
                comboBoxFormatUvs.SelectedItem          = AttribFormat.Format_32_32_Single;
                comboBoxFormatIndices.SelectedItem      = AttribFormat.Format_32_32_32_32_UInt;
                comboBoxFormatWeights.SelectedItem      = AttribFormat.Format_32_32_32_32_Single;
                break;

            default:
                comboBoxFormatPositions.SelectedItem    = AttribFormat.Format_32_32_32_32_Single;
                comboBoxFormatNormals.SelectedItem      = AttribFormat.Format_10_10_10_2_SNorm;
                comboBoxFormatTangents.SelectedItem     = AttribFormat.Format_8_8_8_8_SNorm;
                comboBoxFormatBitans.SelectedItem       = AttribFormat.Format_8_8_8_8_SNorm;
                comboBoxFormatVertexColors.SelectedItem = AttribFormat.Format_8_8_8_8_UNorm;
                comboBoxFormatUvs.SelectedItem          = AttribFormat.Format_16_16_UNorm;
                comboBoxFormatIndices.SelectedItem      = AttribFormat.Format_8_8_8_8_UInt;
                comboBoxFormatWeights.SelectedItem      = AttribFormat.Format_8_8_8_8_UNorm;
                break;
            }
        }
    //

    public virtual void direct()
    {
        currentFPS = FPSDisplay.GetCurrentFPS();

        if ((currentItemCount < currentItemLimit &&
             currentFPS > 20f) || currentItemCount < currentItemMin)
        {
            // do some spawning

            if (currentItemCount < currentItemMin * 2)
            {
                currentSpawnAmount = 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);
        }
    }
示例#6
0
 public static void Load(GamePreset argument, LoadSceneMode loadSceneMode = LoadSceneMode.Single)
 {
     LoadScene(GUID, loadSceneMode, argument);
 }
    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);
        }
    }
    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 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);
        }
    }