예제 #1
0
    public InitEnemyCount getSubWavelet()
    {
        InitEnemyCount enemies = new InitEnemyCount();

        enemies.name = currentEnemyType.ToString();
        enemies.c    = count;
        enemies.p    = path;

        return(enemies);
    }
예제 #2
0
    public void TestToJson()
    {
        InitLevel test = new InitLevel();

        test.init_stats = new InitStats(90, 10, TimeName.Day, 24, 20, 16, new LevelMod[1], EnvType.Default);


        test.toys    = new InitToy[2];
        test.toys[0] = new InitToy("sensible_tower", 1);
        test.toys[1] = new InitToy("airy_tower", 1);


        test.waves = new InitWave[2];
        InitWavelet[] wavelets = new InitWavelet[2];

        InitEnemyCount[] enemies0 = new InitEnemyCount[2];
        enemies0[0] = new InitEnemyCount("soldier", 3, 0);
        enemies0[1] = new InitEnemyCount("furfly", 3, 1);

        wavelets[0] = new InitWavelet(0.5f, 3, enemies0);

        //

        InitEnemyCount[] enemies1 = new InitEnemyCount[2];
        enemies1[0] = new InitEnemyCount("tank", 3, 0);
        enemies1[1] = new InitEnemyCount("furfly", 6, 1);

        wavelets[1] = new InitWavelet(0.8f, 5, enemies1);


        test.waves[0] = new InitWave(TimeName.Night, TimeName.Day, 0.8f, 90, 3, wavelets);
        test.waves[1] = new InitWave(TimeName.Day, TimeName.Day, 0.8f, 95, 4, wavelets);

        test.wishes    = new InitWish[2];
        test.wishes[0] = new InitWish(WishType.MoreDamage, 2);
        test.wishes[1] = new InitWish(WishType.MoreXP, 8);
        Debug.Log(JsonUtility.ToJson(test, true));
    }
예제 #3
0
    public WaveletStatDetails calculateStats(InitWavelet wavelet, bool include_end_time)
    {
        WaveletStatDetails details = new WaveletStatDetails();

        details.details = new List <WaveStat>();
        WaveStat summary = new WaveStat();
        int      max     = (repeatTimes > 0)? wavelet.enemies.Length / repeatTimes : wavelet.enemies.Length;

        for (int x = 0; x < max; x++)
        {
            InitEnemyCount i       = wavelet.enemies[x];
            WaveStat       subStat = new WaveStat();

            float mass  = EnemyStore.getEffectiveMass(EnumUtil.EnumFromString(i.name, EnemyType.Null));
            float speed = EnemyStore.getSpeed(EnumUtil.EnumFromString(i.name, EnemyType.Null));

            //      Debug.Log($"BEFORE {i.name} Mass {mass} Speed {speed}\n");

            //if (speed == 0) Debug.LogError($"Trying to get speed for an unsupported enemy {i.name}\n");
            float time = i.c * wavelet.interval;

            if (i.name.Equals("Tank"))
            {
                mass += EnemyStore.getEffectiveMass(EnemyType.TinyTank);

                float speed_adjusted =
                    EnemyStore.getSpeed(EnemyType.Tank) * EnemyStore.getEffectiveMass(EnemyType.Tank)
                    + EnemyStore.getSpeed(EnemyType.TinyTank) * EnemyStore.getEffectiveMass(EnemyType.TinyTank);
                speed_adjusted /= mass;
                speed           = speed_adjusted;
            }

            if (i.name.Equals("SturdyTank"))
            {
                mass += EnemyStore.getEffectiveMass(EnemyType.Tank) + EnemyStore.getEffectiveMass(EnemyType.TinyTank);

                float speed_adjusted =
                    EnemyStore.getSpeed(EnemyType.SturdyTank) * EnemyStore.getEffectiveMass(EnemyType.SturdyTank)
                    + EnemyStore.getSpeed(EnemyType.Tank) * EnemyStore.getEffectiveMass(EnemyType.Tank)
                    + EnemyStore.getSpeed(EnemyType.TinyTank) * EnemyStore.getEffectiveMass(EnemyType.TinyTank);
                speed_adjusted /= mass;
                speed           = speed_adjusted;
            }

            if (i.name.Equals("ImpossibleTank"))
            {
                mass += EnemyStore.getEffectiveMass(EnemyType.SturdyTank) + EnemyStore.getEffectiveMass(EnemyType.Tank) + EnemyStore.getEffectiveMass(EnemyType.TinyTank);

                float speed_adjusted =
                    EnemyStore.getSpeed(EnemyType.SturdyTank) * EnemyStore.getEffectiveMass(EnemyType.SturdyTank)
                    + EnemyStore.getSpeed(EnemyType.Tank) * EnemyStore.getEffectiveMass(EnemyType.Tank)
                    + EnemyStore.getSpeed(EnemyType.TinyTank) * EnemyStore.getEffectiveMass(EnemyType.TinyTank)
                    + EnemyStore.getSpeed(EnemyType.ImpossibleTank) * EnemyStore.getEffectiveMass(EnemyType.ImpossibleTank);
                speed_adjusted /= mass;
                speed           = speed_adjusted;
            }

            if (i.name.Equals("Turtle"))
            {
                mass += 8 * EnemyStore.getEffectiveMass(EnemyType.TinyPlane);
            }

            //      Debug.Log($"AFTER {i.name} Mass {mass} Speed {speed}\n");


            summary.count += i.c * repeatTimes;
            summary.total_modified_mass += i.c * mass * repeatTimes;
            //   Debug.Log($"{i.c - 1} * {wavelet.interval} * {repeatTimes}\n");
            summary.time  += ((i.c - 1) * wavelet.interval) * repeatTimes;
            summary.speed += speed * i.c * repeatTimes;

            subStat.speed = speed;
            subStat.time  = time;
            subStat.count = i.c;
            subStat.total_modified_mass = mass * i.c;
            subStat.name = i.name;

            subStat.mass_per_second = speed * i.c * mass / time;

            details.details.Add(subStat);
        }
        float extra = (include_end_time) ? wavelet.end_wait : 0;

        summary.speed /= summary.count;
        summary.time  += (wavelet.enemies.Length - 1) * wavelet.lull + extra;
//        Debug.Log($" + {wavelet.enemies.Length - 1} * {wavelet.lull} + {extra}\n");
        //    Debug.Log($"Speed: {summary.speed} Mass: {summary.total_modified_mass} Time: {summary.time}\n");
        summary.mass_per_second = summary.speed * summary.total_modified_mass / summary.time;

        details.summary = summary;
        return(details);
    }