예제 #1
0
    //=====================================================

    void Start()
    {
        if (Application.isPlaying == false)
        {
            return;
        }

        // Boss Doors - enable boss torches - all torches enabled unlocks boss door
        if (_type != eDoorType.BOSS || _targetScene != eLocation.BOSS_ROOM || _bossTorches == null)
        {
            return;
        }

        // Max level for fairies and boss
        var maxLevel = GameDataManager.Instance.PlayerMaxFairyLevel;

        // Get current boss level
        var bossLevel = GameDataManager.Instance.PlayerBossLevel;

        // Get current min fairy level for boss fight
        var minFairyLevel = GameDataManager.Instance.PlayerFairyMinLevel();

        // Are we at the max-level boss? If so, check time interval else check current fairy levels
        // Note: time-interval-start set after killing level 3 boss: GameManager->OnBossDeadEvent()
        if (bossLevel >= maxLevel && minFairyLevel >= maxLevel)
        {
            // Get time in seconds since last boss appearance
            var    timeNow    = PreHelpers.UnixUtcNow();
            double timePassed = 0;
            if (PlayerPrefsWrapper.HasKey("BossRoomTimedIntervalStarted"))
            {
                timePassed = timeNow - PlayerPrefsWrapper.GetDouble("BossRoomTimedIntervalStarted");
            }
            var intervalInDays    = Convert.ToSingle(SettingsManager.GetSettingsItem("BOSS_RESPAWN_TIME", -1));
            var intervalInSeconds = intervalInDays * 24 * 60 * 60;

            // ToDo: check time since boss last appeared
            if (timePassed > intervalInSeconds)
            {
                // Enable torches
                foreach (var torch in _bossTorches)
                {
                    torch.EnableTorch();
                }

                return;
            }
        }

        // Check current fairy levels
        var fairyLevels = GameDataManager.Instance.PlayerFairyLevels();

        if (fairyLevels.Length > _bossTorches.Length)
        {
            return;
        }

        // Enable torches for fairies at high enough level
        for (var i = 0; i < fairyLevels.Length; i++)
        {
            if (fairyLevels[i] >= bossLevel)
            {
                _bossTorches[i].EnableTorch();
            }
        }
    }