Beispiel #1
0
    //ad hoc solution for adaptive random generator(needs rework)
    //void RunChoiseShifting(float[] array, int groupToBoost, float value)
    //{
    //    groupToBoost = groupToBoost * 2;
    //    float groupRatioOne = SpawnerTools.GetRatio(array[groupToBoost], array[groupToBoost + 1]);

    //    float groupRatioTwo = SpawnerTools.GetRatio(array[GetGroupsThatAreLeft(groupToBoost)[0]], array[GetGroupsThatAreLeft(groupToBoost)[0] + 1]);
    //    float groupRatioThree = SpawnerTools.GetRatio(array[GetGroupsThatAreLeft(groupToBoost)[1]], array[GetGroupsThatAreLeft(groupToBoost)[1] + 1]);

    //    array[groupToBoost] += value * groupRatioOne;
    //    array[groupToBoost + 1] += value * (1 - groupRatioOne);

    //    float intrGroupRatio;
    //    intrGroupRatio = SpawnerTools.GetGroupRatio(array[GetGroupsThatAreLeft(groupToBoost)[0]], array[GetGroupsThatAreLeft(groupToBoost)[0] + 1], array[GetGroupsThatAreLeft(groupToBoost)[1]], array[GetGroupsThatAreLeft(groupToBoost)[1] + 1]);

    //    float valuePartForGroup = value * intrGroupRatio;
    //    array[GetGroupsThatAreLeft(groupToBoost)[0]] -= valuePartForGroup * groupRatioTwo;
    //    array[GetGroupsThatAreLeft(groupToBoost)[0]+1] -= valuePartForGroup * (1 - groupRatioTwo);
    //    array[GetGroupsThatAreLeft(groupToBoost)[1]] -= (value - valuePartForGroup) * groupRatioThree;
    //    array[GetGroupsThatAreLeft(groupToBoost)[1]+1] -= (value - valuePartForGroup) * (1 - groupRatioTwo);
    //}

    //int[] GetGroupsThatAreLeft(int chosenGroup) {
    //    if (chosenGroup == 0) {
    //        return new int []{2, 4};
    //    } else if (chosenGroup == 2)
    //    {
    //        return new int[] { 0, 4 };
    //    }
    //    return new int[] { 0, 2};
    //}
    #endregion


    void RunBoosterChances(int x, int y)
    {
        switch (SpawnerTools.ComplexRando(BoostersTypesSpawnChance, 0))
        {
        case 1:
            levelDataItems.Add(new LevelDataItem("shot_booster", x, y, "booster"));
            break;

        case 2:
            levelDataItems.Add(new LevelDataItem("laser_V_booster", x, y, "booster"));
            break;

        case 3:
            levelDataItems.Add(new LevelDataItem("laser_H_booster", x, y, "booster"));
            break;

        case 4:
            levelDataItems.Add(new LevelDataItem("bomb_booster", x, y, "booster"));
            break;

        case 5:
            levelDataItems.Add(new LevelDataItem("bigbomb_booster", x, y, "booster"));
            break;

        case 6:
            levelDataItems.Add(new LevelDataItem("teleport_booster", x, y, "booster"));
            break;

        case 7:
            levelDataItems.Add(new LevelDataItem("time_stop_booster", x, y, "booster"));
            break;

        case 8:
            levelDataItems.Add(new LevelDataItem("coin", x, y, "booster"));
            break;

        default:
            break;
        }
    }
Beispiel #2
0
    /// ////////////////////////////////////////

    //main logic body
    public void RandomLevelCreator()
    {
        int IndexFromSaveNode = GetBlockIndex(SaveNode.PlayerBlockChoise);

        if (IndexFromSaveNode < 8)
        {
            actualChancesToSpawnDifferentType[IndexFromSaveNode] = defChancesToSpawnDifferentType[IndexFromSaveNode];
        }
        else
        {
            Debug.Log(IndexFromSaveNode);
        }


        int x, y;

        //int strategyCounter = 1;
        //int internalCounter = 1;
        //float currentChangePartition = 0f;
        //float valueOne = 0f;
        for (y = 0; y < CreatorGrid.height; y++)
        {
            //adaptive chances

            /*
             *
             * lineCounter++;
             *
             * if (((float)lineCounter / (strategyStep * (float)strategyCounter)) >= (float)strategyCounter) {
             *  strategyCounter = Mathf.Min(++strategyCounter, spawnChanceStrategy.Length - 1);
             *  currentGoalSpawnChance = spawnChanceStrategy[strategyCounter];
             *  currentGoalSpawnChanceBoosters = spawnChanceStrategyBoosters[strategyCounter];
             *  if (internalCounter == strategyCounter)
             *  {
             *      valueOne = (actualChancesToSpawnDifferentType[groupToBoost[strategyCounter] * 2] + actualChancesToSpawnDifferentType[groupToBoost[strategyCounter] * 2 + 1]);
             *      internalCounter++;
             *  }
             * }
             *
             * currentChangePartition = ((float)lineCounter - (((float)strategyCounter - 1) * (float)strategyStep)) / (float)strategyStep;
             * ChanceToSpawnAnything = Mathf.Lerp(spawnChanceStrategy[strategyCounter - 1], currentGoalSpawnChance, currentChangePartition);
             * BoostersSpawnChance = Mathf.Lerp(spawnChanceStrategyBoosters[strategyCounter - 1], currentGoalSpawnChanceBoosters, currentChangePartition);
             */

            //non-finished part of adaptive below

            //float deltaPartOne = Mathf.Lerp(valueOne, 80.0f, currentChangePartition);
            //float deltaPartTwo = (actualChancesToSpawnDifferentType[groupToBoost[strategyCounter] * 2] + actualChancesToSpawnDifferentType[groupToBoost[strategyCounter] * 2 + 1]);
            //float delta = deltaPartOne - deltaPartTwo ;
            //delta = Mathf.Floor(delta * 100) / 100;
            //RunChoiseShifting(actualChancesToSpawnDifferentType, groupToBoost[strategyCounter], delta);

            for (x = 0; x < CreatorGrid.width; x++)
            {
                int[] Offset = new int[2];

                if (CreatorGrid.cells[x, y].IsEmpty)
                {
                    if (SpawnerTools.BinaryRandom(ChanceToSpawnAnything))
                    {
                        if (x <= 3 && CreatorGrid.cells[x + 1, y].IsEmpty)
                        {
                            if (x <= 2 && CreatorGrid.cells[x + 2, y].IsEmpty)
                            {
                                CasingFigure(x, y, CeilingSwitch(CreatorGrid.height - y - 1, SpawnerTools.ComplexRando(ChancesToSpawnDifferentType, 0)), SpawnerTools.BinaryRandom(ChanceToMakeCubeImmovable), out Offset);
                            }
                            else
                            {
                                CasingFigure(x, y, CeilingSwitch(CreatorGrid.height - y - 1, SpawnerTools.ComplexRando(ChancesToSpawnDifferentType, 1)), SpawnerTools.BinaryRandom(ChanceToMakeCubeImmovable), out Offset);
                            }
                        }
                        else
                        {
                            CasingFigure(x, y, CeilingSwitch(CreatorGrid.height - y - 1, SpawnerTools.ComplexRando(ChancesToSpawnDifferentType, 3)), SpawnerTools.BinaryRandom(ChanceToMakeCubeImmovable), out Offset);
                        }

                        OffsetMaker(x, y, Offset);
                    }
                }

                if ((Game.Instance.count == 1 && x == 2 && y == 3) == true)
                {
                    continue;
                }

                if (SpawnerTools.BinaryRandom(BoostersSpawnChance))
                {
                    RunBoosterChances(x, y);
                }
            }
        }
    }