コード例 #1
0
    private void GiveResourceReward()
    {
        int chunk = (PlayerData.Instance.LifetimeChunk.Value <= PersistentSingleton <GameSettings> .Instance.DrillResourceMinimumConfig) ? PersistentSingleton <GameSettings> .Instance.DrillResourceMinimumConfig : PlayerData.Instance.LifetimeChunk.Value;
        ChunkGeneratingConfig chunkGeneratingConfig = Singleton <EconomyHelpers> .Instance.GetChunkGeneratingConfig(chunk, bossFight : false);

        float num = (from w in chunkGeneratingConfig.Materials
                     select w.Weight).Aggregate(0f, (float a, float b) => a + b);

        int[] array = new int[6];
        foreach (WeightedObject <BlockType> material in chunkGeneratingConfig.Materials)
        {
            array[(int)material.Value] = (int)(material.Weight / num * (float)chunkGeneratingConfig.MaxBlocks * PersistentSingleton <GameSettings> .Instance.DrillResourceMultiplier);
        }
        for (int i = 0; i < array.Length; i++)
        {
            if (array[i] > 0)
            {
                Singleton <FundRunner> .Instance.AddResource((BlockType)i, array[i]);

                List <string[]> rewards = Rewards;
                string[]        obj     = new string[2]
                {
                    array[i].ToString(),
                    null
                };
                BlockType blockType = (BlockType)i;
                obj[1] = "UI/BundleItems/BundleItem_Resource_" + blockType.ToString();
                rewards.Add(obj);
            }
        }
    }
コード例 #2
0
    private void CalculateBlocksAndGoldBlocks()
    {
        ChunkGeneratingConfig chunkGeneratingConfig = Singleton <EconomyHelpers> .Instance.GetChunkGeneratingConfig(Singleton <WorldRunner> .Instance.CurrentChunk.Value.Index, bossFight : false);

        int maxBlocks = chunkGeneratingConfig.MaxBlocks;
        int num       = 0;

        foreach (BlockController listBlock in m_listBlocks)
        {
            if (listBlock.Type == BlockType.Gold)
            {
                int num2 = listBlock.ApproximateSize();
                int num3 = 0;
                switch (num2)
                {
                case 1:
                    num3 = 1;
                    break;

                case 2:
                    num3 = 9;
                    break;

                case 4:
                    num3 = 73;
                    break;
                }
                num += num3;
            }
        }
        BlocksInChunk.SetValueAndForceNotify(maxBlocks);
        GoldBlocks.SetValueAndForceNotify(num);
    }
コード例 #3
0
    private void DebugGiveChunkReward()
    {
        int value = PlayerData.Instance.MainChunk.Value;
        ChunkGeneratingConfig chunkGeneratingConfig = Singleton <EconomyHelpers> .Instance.GetChunkGeneratingConfig(value, bossFight : false);

        GiveChunkReward(chunkGeneratingConfig, boss: false);
        if (value % 5 == 4)
        {
            ChunkGeneratingConfig chunkGeneratingConfig2 = Singleton <EconomyHelpers> .Instance.GetChunkGeneratingConfig(value, bossFight : true);

            GiveChunkReward(chunkGeneratingConfig2, boss: true);
        }
    }
コード例 #4
0
    private void GiveChunkReward(ChunkGeneratingConfig cnfg, bool boss)
    {
        BigDouble left = BigDouble.ZERO;

        if (boss)
        {
            int       value  = PlayerData.Instance.MainChunk.Value;
            BigDouble amount = Singleton <EconomyHelpers> .Instance.GetRelicsFromBoss(value) * PlayerData.Instance.BoostersEffect[2].Value;

            Singleton <FundRunner> .Instance.AddRelicsToBackpak(amount);

            bool        flag   = ChunkRunner.IsLastChunkForNode(value);
            BiomeConfig value2 = Singleton <WorldRunner> .Instance.CurrentBiomeConfig.Value;
            left  = ((!flag) ? value2.MiniBossReward : value2.BossReward);
            left *= Singleton <CumulativeBonusRunner> .Instance.BonusMult[2].Value;
        }
        int[] array = new int[7];
        int   num   = 0;

        if (Random.Range(0f, 1f) < cnfg.TNTChance)
        {
            num = Random.Range(cnfg.TNTMin, cnfg.TNTMax + 1) * 8;
        }
        int num2 = 0;

        if (Random.Range(0f, 1f) < cnfg.DiamondChance)
        {
            num2 = Random.Range(cnfg.DiamondMin, cnfg.DiamondMax);
        }
        Singleton <FundRunner> .Instance.AddGems(num2 *PersistentSingleton <GameSettings> .Instance.GemBlockReward, "debugMenu", "debug");

        for (int i = 0; i < cnfg.MaxBlocks - num2 - num - cnfg.GoldBlockAverage; i++)
        {
            array[(int)cnfg.Materials.AllotObject()]++;
        }
        for (int j = 0; j < array.Length; j++)
        {
            PlayerData.Instance.BlocksInBackpack[j].Value += array[j];
        }
        left += cnfg.MaxBlocks * Singleton <WorldRunner> .Instance.CurrentBiomeConfig.Value.BlockReward * Singleton <CumulativeBonusRunner> .Instance.BonusMult[1].Value * PlayerData.Instance.BoostersEffect[1].Value;
        Singleton <FundRunner> .Instance.AddCoins(left);
    }
コード例 #5
0
    public void LevelSkip(int skipAmount)
    {
        int value = PlayerData.Instance.MainChunk.Value;

        SkippingLevels.Value = true;
        for (int i = 0; i < skipAmount; i++)
        {
            Singleton <WorldRunner> .Instance.IncreaseChunk();
        }
        Singleton <WorldRunner> .Instance.LevelSkip();

        (from seq in Singleton <WorldRunner> .Instance.MapSequence
         where !seq
         select seq).Take(1).Subscribe(delegate
        {
            SkippingLevels.Value = false;
        }).AddTo(SceneLoader.Instance);
        int value2 = PlayerData.Instance.MainChunk.Value;
        ChunkGeneratingConfig chunkGeneratingConfig = Singleton <EconomyHelpers> .Instance.GetChunkGeneratingConfig(value2, bossFight : false);

        BigDouble bigDouble = chunkGeneratingConfig.MaxBlocks * Singleton <WorldRunner> .Instance.CurrentBiomeConfig.Value.BlockReward * Singleton <CumulativeBonusRunner> .Instance.BonusMult[1].Value * PlayerData.Instance.BoostersEffect[1].Value * PersistentSingleton <GameSettings> .Instance.ChunksMoneysAfterSkip;

        CoinReward.Value = bigDouble;
        Singleton <FundRunner> .Instance.AddCoins(bigDouble);

        int[] array = new int[5];
        for (int j = 0; j < chunkGeneratingConfig.MaxBlocks - chunkGeneratingConfig.GoldBlockAverage; j++)
        {
            array[(int)chunkGeneratingConfig.Materials.AllotObject()]++;
        }
        for (int k = 0; k < array.Length; k++)
        {
            long num = (long)((float)(array[k] * skipAmount) * PersistentSingleton <GameSettings> .Instance.ResourceMultAfterSkip);
            PlayerData.Instance.BlocksInBackpack[k].Value += num;
            SkippedResources[k] = num;
        }
        SkippedCompanions[0] = Singleton <EconomyHelpers> .Instance.GetNumUnlockedHeroes(value);

        SkippedCompanions[1] = Singleton <EconomyHelpers> .Instance.GetNumUnlockedHeroes(value2);
    }
コード例 #6
0
    public static List <ChunkGeneratingConfig> ParseChunkGeneratings(string text)
    {
        IEnumerable <string[]> source = TSVParser.Parse(text).Skip(1);

        return(source.Select(delegate(string[] line)
        {
            ChunkGeneratingConfig chunkGeneratingConfig = new ChunkGeneratingConfig
            {
                Chunk = line.asInt(0, line.toError <int>()),
                MaxBlocks = line.asInt(1, line.toError <int>()),
                FourBlockMin = line.asInt(2, line.toError <int>()),
                FourBlockMax = line.asInt(3, line.toError <int>()),
                TwoBlockMin = line.asInt(4, line.toError <int>()),
                TwoBlockMax = line.asInt(5, line.toError <int>())
            };
            List <WeightedObject <BlockType> > list = new List <WeightedObject <BlockType> >();
            for (int i = 6; i < line.Length - 7; i++)
            {
                BlockType value = (BlockType)(i - 6);
                WeightedObject <BlockType> item = new WeightedObject <BlockType>
                {
                    Value = value,
                    Weight = line.asFloat(i, line.toError <float>())
                };
                list.Add(item);
            }
            chunkGeneratingConfig.Materials = list;
            chunkGeneratingConfig.GoldBlockAverage = line.asInt(11, line.toError <int>());
            chunkGeneratingConfig.DiamondMin = line.asInt(12, line.toError <int>());
            chunkGeneratingConfig.DiamondMax = line.asInt(13, line.toError <int>());
            chunkGeneratingConfig.DiamondChance = line.asFloat(14, line.toError <float>());
            chunkGeneratingConfig.TNTMin = line.asInt(15, line.toError <int>());
            chunkGeneratingConfig.TNTMax = line.asInt(16, line.toError <int>());
            chunkGeneratingConfig.TNTChance = line.asFloat(17, line.toError <float>());
            return chunkGeneratingConfig;
        }).ToList());
    }
コード例 #7
0
    public static void GenerateFromConfig(Vector3 pos, int chunk, int prestige, int retryNumber, Transform container, bool bossFight)
    {
        int[] array = new int[13]
        {
            50,
            70,
            50,
            30,
            20,
            10,
            5,
            3,
            0,
            0,
            0,
            0,
            0
        };
        ChunkGeneratingConfig chunkGeneratingConfig = Singleton <EconomyHelpers> .Instance.GetChunkGeneratingConfig(chunk, bossFight);

        int num = chunkGeneratingConfig.MaxBlocks;

        if (!bossFight)
        {
            Singleton <ChunkRunner> .Instance.BlocksInChunk.SetValueAndForceNotify(num);
        }
        else
        {
            Singleton <ChunkRunner> .Instance.BlocksInChunk.SetValueAndForceNotify(num - 64);
        }
        int num2 = (int)((float)chunkGeneratingConfig.GoldBlockAverage * (PredictableRandom.GetNextRangeFloat(0f, 0.5f) + 0.75f));

        Singleton <ChunkRunner> .Instance.GoldBlocks.SetValueAndForceNotify(num2);

        PredictableRandom.SetSeed((uint)chunk, (uint)(prestige + retryNumber));
        List <BlockSpawnPoint> list = new List <BlockSpawnPoint>();

        int[] array2 = new int[5];
        List <WeightedObject <int[]> > list2 = new List <WeightedObject <int[]> >();

        if (bossFight)
        {
            list2.AddRange(PersistentSingleton <Economies> .Instance.ChunkMaps[0].ChunkMapClone());
            list2 = RemoveSpawnLocationsForBossFight(list2);
        }
        else
        {
            list2.AddRange(PersistentSingleton <Economies> .Instance.ChunkMaps[chunk % 5].ChunkMapClone());
        }
        int nextRangeInt = PredictableRandom.GetNextRangeInt(chunkGeneratingConfig.FourBlockMin, chunkGeneratingConfig.FourBlockMax + 1);

        for (int num3 = nextRangeInt; num3 > 0; num3--)
        {
            List <WeightedObject <int[]> > list3 = list2.FindAll((WeightedObject <int[]> x) => x.Value[3] >= 4);
            if (list3.Count <= 0)
            {
                break;
            }
            int       nextRangeInt2 = PredictableRandom.GetNextRangeInt(0, list3.Count);
            int[]     spawnSpot     = list3[nextRangeInt2].Value;
            BlockType blockType     = chunkGeneratingConfig.Materials.PredictableAllotObject();
            string    prefabPath    = GetPrefabPath(blockType, 4);
            if (list.Count <= 0 && bossFight)
            {
                spawnSpot = new int[5]
                {
                    0,
                    0,
                    1,
                    4,
                    1
                };
                blockType  = BlockType.Invalid;
                prefabPath = ((!Singleton <DrJellyRunner> .Instance.DrJellyBattle.Value) ? "Blocks/BigBossCube_4x4" : "Blocks/DrJelly");
            }
            Vector3 coordinates = new Vector3(spawnSpot[0], spawnSpot[1] + 2, spawnSpot[2]) + pos;
            list.Add(new BlockSpawnPoint(blockType, prefabPath, coordinates));
            int i;
            for (i = -4; i <= 3; i++)
            {
                int j;
                for (j = -4; j <= 3; j++)
                {
                    int num4 = list2.FindIndex((WeightedObject <int[]> x) => x.Value[0] == spawnSpot[0] + i && x.Value[2] == spawnSpot[2] + j);
                    if (num4 == -1)
                    {
                        continue;
                    }
                    WeightedObject <int[]> weightedObject = list2[num4];
                    if (-2 <= i && i <= 1 && -2 <= j && j <= 1)
                    {
                        weightedObject.Value[1] += 4;
                        weightedObject.Weight    = array[weightedObject.Value[1]];
                    }
                    if (i == 0 && j == 0)
                    {
                        if (weightedObject.Value[1] > 4)
                        {
                            weightedObject.Value[3] = 2;
                        }
                    }
                    else if (-1 <= i && i <= 1 && -1 <= j && j <= 1)
                    {
                        weightedObject.Value[3] = 2;
                    }
                    else if (-2 <= i && i <= 2 && -2 <= j && j <= 2)
                    {
                        weightedObject.Value[3] = 1;
                    }
                    else
                    {
                        if (weightedObject.Value[3] == 4)
                        {
                            weightedObject.Value[3] = 2;
                        }
                        if (-3 <= i && i <= 2 && -3 <= j && j <= 2)
                        {
                            weightedObject.Weight = array[1];
                        }
                        else
                        {
                            weightedObject.Weight = array[0];
                        }
                    }
                    list2[num4] = weightedObject;
                }
            }
            num -= 64;
        }
        int   nextRangeInt3 = PredictableRandom.GetNextRangeInt(chunkGeneratingConfig.TwoBlockMin, chunkGeneratingConfig.TwoBlockMax + 1);
        float num5          = (float)(nextRangeInt3 * 8) / (float)num;
        int   num6          = Mathf.RoundToInt((float)num2 * num5 / 9f);

        for (int num7 = 0; num7 < nextRangeInt3; num7++)
        {
            array2[(int)chunkGeneratingConfig.Materials.PredictableAllotObject()]++;
        }
        int num8 = 0;

        if (PredictableRandom.GetNextRangeFloat(0f, 1f) < chunkGeneratingConfig.TNTChance)
        {
            num8 = PredictableRandom.GetNextRangeInt(chunkGeneratingConfig.TNTMin, chunkGeneratingConfig.TNTMax + 1);
        }
        nextRangeInt3 += num8;
        for (int num9 = nextRangeInt3; num9 > 0; num9--)
        {
            List <WeightedObject <int[]> > list4 = list2.FindAll((WeightedObject <int[]> x) => x.Value[3] >= 2);
            if (list4.Count <= 0)
            {
                break;
            }
            int[]     spawnSpot2 = list4.PredictableAllotObject();
            BlockType blockType2 = BlockType.Gold;
            for (int num10 = array2.Length - 1; num10 >= 0; num10--)
            {
                if (num8 > 0)
                {
                    blockType2 = BlockType.TNT;
                    num8--;
                    break;
                }
                if (num6 > 0)
                {
                    blockType2 = BlockType.Gold;
                    num6--;
                    num2 -= 9;
                    break;
                }
                if (array2[num10] > 0)
                {
                    blockType2 = (BlockType)num10;
                    array2[num10]--;
                    break;
                }
            }
            string  prefabPath2  = GetPrefabPath(blockType2, 2);
            Vector3 coordinates2 = new Vector3(spawnSpot2[0], spawnSpot2[1] + 1, spawnSpot2[2]) + pos;
            list.Add(new BlockSpawnPoint(blockType2, prefabPath2, coordinates2));
            int k;
            for (k = -2; k <= 1; k++)
            {
                int l;
                for (l = -2; l <= 1; l++)
                {
                    int num11 = list2.FindIndex((WeightedObject <int[]> x) => x.Value[0] == spawnSpot2[0] + k && x.Value[2] == spawnSpot2[2] + l);
                    if (num11 == -1)
                    {
                        continue;
                    }
                    WeightedObject <int[]> weightedObject2 = list2[num11];
                    if (-1 <= k && k <= 0 && -1 <= l && l <= 0)
                    {
                        weightedObject2.Value[1] += 2;
                    }
                    if (-1 <= k && k <= 1 && -1 <= l && l <= 1)
                    {
                        if (weightedObject2.Value[1] >= 10)
                        {
                            weightedObject2.Value[3] = 0;
                        }
                        else
                        {
                            weightedObject2.Value[3] = 1;
                            if (k == 0 && l == 0)
                            {
                                weightedObject2.Value[3] = 2;
                            }
                        }
                    }
                    weightedObject2.Weight = array[weightedObject2.Value[1]];
                    list2[num11]           = weightedObject2;
                }
            }
            num -= 8;
        }
        int num12 = 0;

        if (PredictableRandom.GetNextRangeFloat(0f, 1f) < chunkGeneratingConfig.DiamondChance)
        {
            num12 = PredictableRandom.GetNextRangeInt(chunkGeneratingConfig.DiamondMin, chunkGeneratingConfig.DiamondMax + 1);
        }
        for (int num13 = 0; num13 < num - num12 - num2; num13++)
        {
            array2[(int)chunkGeneratingConfig.Materials.PredictableAllotObject()]++;
        }
        List <WeightedObject <int[]> > list5 = list2.FindAll((WeightedObject <int[]> x) => x.Value[3] >= 1);

        for (int num14 = num; num14 > 0; num14--)
        {
            if (list5.Count > 0)
            {
                int[]     spawnSpot3 = list5.PredictableAllotObject();
                BlockType type       = BlockType.Diamond;
                for (int num15 = array2.Length - 1; num15 >= 0; num15--)
                {
                    if (num12 > 0)
                    {
                        type = BlockType.Diamond;
                        num12--;
                        break;
                    }
                    if (num2 > 0)
                    {
                        type = BlockType.Gold;
                        num2--;
                        break;
                    }
                    if (array2[num15] > 0)
                    {
                        type = (BlockType)num15;
                        array2[num15]--;
                        break;
                    }
                }
                Vector3 coordinates3 = new Vector3((float)spawnSpot3[0] + 0.5f, (float)spawnSpot3[1] + 0.5f, (float)spawnSpot3[2] + 0.5f) + pos;
                list.Add(new BlockSpawnPoint(type, string.Empty, coordinates3));
                int m;
                for (m = -1; m <= 1; m++)
                {
                    int n;
                    for (n = -1; n <= 1; n++)
                    {
                        WeightedObject <int[]> weightedObject3 = list5.Find((WeightedObject <int[]> x) => x.Value[0] == spawnSpot3[0] + m && x.Value[2] == spawnSpot3[2] + n);
                        if (weightedObject3 != null)
                        {
                            if (m == 0 && n == 0)
                            {
                                weightedObject3.Value[1]++;
                            }
                            if (weightedObject3.Value[1] >= 10)
                            {
                                list5.Remove(weightedObject3);
                            }
                            else
                            {
                                weightedObject3.Weight = array[weightedObject3.Value[1]];
                            }
                        }
                    }
                }
            }
        }
        List <BlockSpawnPoint> blocks = list.FindAll((BlockSpawnPoint x) => x.PrefabPath == string.Empty);

        for (int num16 = -5; num16 <= 4; num16++)
        {
            for (int num17 = -7; num17 <= 8; num17++)
            {
                List <BlockSpawnPoint> blocksNearCoordinates = GetBlocksNearCoordinates(blocks, (float)num16 + 0.5f + pos.x, (float)num17 + 0.5f + pos.z);
                BlockType blockType3 = BlockType.Invalid;
                if (blocksNearCoordinates.Count <= 0)
                {
                    continue;
                }
                for (int num18 = blocksNearCoordinates.Count - 1; num18 >= 0; num18--)
                {
                    string          empty           = string.Empty;
                    BlockType       num19           = blockType3;
                    BlockSpawnPoint blockSpawnPoint = blocksNearCoordinates[num18];
                    if (num19 != blockSpawnPoint.Type)
                    {
                        BlockSpawnPoint blockSpawnPoint2 = blocksNearCoordinates[num18];
                        empty = GetPrefabPath(blockSpawnPoint2.Type, 1, BlockAlignment.Top);
                    }
                    else if (num18 - 1 >= 0)
                    {
                        BlockSpawnPoint blockSpawnPoint3 = blocksNearCoordinates[num18];
                        BlockType       type2            = blockSpawnPoint3.Type;
                        BlockSpawnPoint blockSpawnPoint4 = blocksNearCoordinates[num18 - 1];
                        if (type2 == blockSpawnPoint4.Type)
                        {
                            BlockSpawnPoint blockSpawnPoint5 = blocksNearCoordinates[num18];
                            empty = GetPrefabPath(blockSpawnPoint5.Type, 1, BlockAlignment.Middle);
                        }
                        else
                        {
                            BlockSpawnPoint blockSpawnPoint6 = blocksNearCoordinates[num18];
                            empty = GetPrefabPath(blockSpawnPoint6.Type, 1, BlockAlignment.Bottom);
                        }
                    }
                    else
                    {
                        BlockSpawnPoint blockSpawnPoint7 = blocksNearCoordinates[num18];
                        empty = GetPrefabPath(blockSpawnPoint7.Type, 1, BlockAlignment.Bottom);
                    }
                    BlockSpawnPoint blockSpawnPoint8 = blocksNearCoordinates[num18];
                    blockType3 = blockSpawnPoint8.Type;
                    List <BlockSpawnPoint> list6      = list;
                    int             index             = list.IndexOf(blocksNearCoordinates[num18]);
                    BlockSpawnPoint blockSpawnPoint9  = blocksNearCoordinates[num18];
                    BlockType       type3             = blockSpawnPoint9.Type;
                    string          prefabPath3       = empty;
                    BlockSpawnPoint blockSpawnPoint10 = blocksNearCoordinates[num18];
                    list6[index] = new BlockSpawnPoint(type3, prefabPath3, blockSpawnPoint10.Coordinates);
                }
            }
        }
        for (int num20 = 0; num20 < list.Count; num20++)
        {
            EntityPoolManager instance           = Singleton <EntityPoolManager> .Instance;
            BlockSpawnPoint   blockSpawnPoint11  = list[num20];
            GameObject        orCreateGameObject = instance.GetOrCreateGameObject(blockSpawnPoint11.PrefabPath);
            BlockController   component          = orCreateGameObject.GetComponent <BlockController>();
            if (component != null)
            {
                BlockController blockController   = component;
                BlockSpawnPoint blockSpawnPoint12 = list[num20];
                blockController.Init(blockSpawnPoint12.Type);
            }
            else
            {
                BossBlockController component2 = orCreateGameObject.GetComponent <BossBlockController>();
                if (component2 != null)
                {
                    component2.Init();
                }
            }
            Transform       transform         = orCreateGameObject.transform;
            BlockSpawnPoint blockSpawnPoint13 = list[num20];
            transform.position = blockSpawnPoint13.Coordinates;
            orCreateGameObject.transform.rotation = Quaternion.identity;
            if (orCreateGameObject.transform.parent == null)
            {
                orCreateGameObject.transform.SetParent(container, worldPositionStays: true);
            }
        }
    }