236 lines
4.6 KiB
C#
236 lines
4.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using BitStrap;
|
|
using Steamworks;
|
|
using UnityEngine;
|
|
|
|
public class DLCManager : MonoBehaviour
|
|
{
|
|
public enum DLC_ID
|
|
{
|
|
TEST_DLC = 0,
|
|
MORAINE_LAKE = 1,
|
|
KARIBA_DAM = 2,
|
|
GREENLAND = 3,
|
|
AMAZON_RIVER = 4,
|
|
JAPAN = 5,
|
|
VR_DLC = 6,
|
|
EQUIPMENT_01 = 7,
|
|
THAILAND = 8,
|
|
FISH_01 = 9,
|
|
TANGARIRO = 10,
|
|
AQUARIUM = 11,
|
|
COUNT = 12
|
|
}
|
|
|
|
[Serializable]
|
|
public class DLCSettings
|
|
{
|
|
public string dlcName = string.Empty;
|
|
|
|
[TextArea]
|
|
public string dlcDescription = string.Empty;
|
|
|
|
public DLC_ID dlcID;
|
|
|
|
[Header("ID")]
|
|
public uint appID;
|
|
|
|
public uint appID_VR;
|
|
|
|
public ulong railID;
|
|
|
|
public ulong gogID;
|
|
|
|
public string oculusID = string.Empty;
|
|
|
|
public string viveportID = string.Empty;
|
|
|
|
[Header("URL")]
|
|
public string steamUrl = string.Empty;
|
|
|
|
public string steamUrl_VR = string.Empty;
|
|
|
|
public string railUrl = string.Empty;
|
|
|
|
public string gogUrl = string.Empty;
|
|
|
|
public string oculusUrl = string.Empty;
|
|
|
|
public string viveportUrl = string.Empty;
|
|
|
|
[Header("Other")]
|
|
public string testLeaderboardName = string.Empty;
|
|
|
|
public Sprite banner;
|
|
|
|
public bool isInstalled;
|
|
|
|
public CallResult<LeaderboardFindResult_t> onTestLeaderboardFindResult_t;
|
|
|
|
public string GetDLCUrl()
|
|
{
|
|
return steamUrl;
|
|
}
|
|
|
|
public string GetDLCReviewUrl()
|
|
{
|
|
return "https://store.steampowered.com/recommended/recommendgame/" + appID;
|
|
}
|
|
}
|
|
|
|
private static DLCManager instance;
|
|
|
|
public List<DLCSettings> dlcSettingsList = new List<DLCSettings>();
|
|
|
|
public static DLCManager Instance
|
|
{
|
|
get
|
|
{
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
private DLCManager()
|
|
{
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = this;
|
|
UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
|
|
}
|
|
else
|
|
{
|
|
UnityEngine.Object.DestroyImmediate(base.gameObject);
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
if (VRManager.IsVROn() && !IsDLCInstalled(DLC_ID.VR_DLC))
|
|
{
|
|
Debug.LogError("VR without DLC");
|
|
Application.Quit();
|
|
}
|
|
}
|
|
|
|
public DLCSettings FindDLCSettings(DLC_ID dlcID)
|
|
{
|
|
for (int i = 0; i < dlcSettingsList.Count; i++)
|
|
{
|
|
if (dlcSettingsList[i].dlcID == dlcID)
|
|
{
|
|
return dlcSettingsList[i];
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public bool IsDLCInstalled(DLCSettings dlcSettings)
|
|
{
|
|
if (dlcSettings == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (GlobalSettings.Instance.currentPlatform == GlobalSettings.Platform.ARCADE)
|
|
{
|
|
return true;
|
|
}
|
|
if (!GlobalSettings.Instance.turnOnMyCheats || dlcSettings.dlcID == DLC_ID.THAILAND)
|
|
{
|
|
}
|
|
if (!SteamManager.Initialized)
|
|
{
|
|
return false;
|
|
}
|
|
dlcSettings.isInstalled = SteamApps.BIsDlcInstalled(new AppId_t(dlcSettings.appID));
|
|
return dlcSettings.isInstalled;
|
|
}
|
|
|
|
public bool IsDLCInstalled(DLC_ID dlcID)
|
|
{
|
|
return IsDLCInstalled(FindDLCSettings(dlcID));
|
|
}
|
|
|
|
public bool IsAnyDLCInstalled(List<DLC_ID> dlcIDs)
|
|
{
|
|
if (dlcIDs.Count == 0)
|
|
{
|
|
return true;
|
|
}
|
|
foreach (DLC_ID dlcID in dlcIDs)
|
|
{
|
|
if (Instance.IsDLCInstalled(dlcID))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool IsAnyFishDLCInstalled()
|
|
{
|
|
for (int i = 0; i < dlcSettingsList.Count; i++)
|
|
{
|
|
if (Instance.IsDLCInstalled(dlcSettingsList[i]) && dlcSettingsList[i].dlcID != DLC_ID.EQUIPMENT_01)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
[Button]
|
|
public void ListAllDLCSettings()
|
|
{
|
|
for (int i = 0; i < dlcSettingsList.Count; i++)
|
|
{
|
|
bool flag = IsDLCInstalled(dlcSettingsList[i]);
|
|
Debug.Log(string.Concat("DLC ID: ", dlcSettingsList[i].dlcID, " appId: ", dlcSettingsList[i].appID, " installed: ", flag));
|
|
}
|
|
}
|
|
|
|
public IEnumerator SendTestLeaderboards()
|
|
{
|
|
for (int k = 0; k < dlcSettingsList.Count; k++)
|
|
{
|
|
if (dlcSettingsList[k].dlcID == DLC_ID.THAILAND)
|
|
{
|
|
yield return new WaitForSeconds(1f);
|
|
if (IsDLCInstalled(dlcSettingsList[k]) && dlcSettingsList[k].testLeaderboardName != string.Empty)
|
|
{
|
|
LeaderboardsManager.Instance.FindTestLeaderboardSteam(dlcSettingsList[k].testLeaderboardName, dlcSettingsList[k].onTestLeaderboardFindResult_t);
|
|
}
|
|
yield return new WaitForSeconds(9f);
|
|
}
|
|
}
|
|
yield return null;
|
|
}
|
|
|
|
[Button]
|
|
public void ListAllPlatformDLCs()
|
|
{
|
|
if (SteamManager.Initialized)
|
|
{
|
|
for (int i = 0; i < SteamApps.GetDLCCount(); i++)
|
|
{
|
|
AppId_t pAppID;
|
|
bool pbAvailable;
|
|
string pchName;
|
|
SteamApps.BGetDLCDataByIndex(i, out pAppID, out pbAvailable, out pchName, 128);
|
|
bool flag = SteamApps.BIsDlcInstalled(pAppID);
|
|
Debug.Log("DLC nr: " + i + " appId: " + pAppID.m_AppId + " available: " + pbAvailable + " dlcName: " + pchName + " isInstalled: " + flag);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void BuyDLC(DLC_ID dlcId)
|
|
{
|
|
Utilities.OpenURL(FindDLCSettings(dlcId).GetDLCUrl());
|
|
}
|
|
}
|