private void OnUpgradeClicked(object source, float cost, float multiplier, UpgradeBase.UpgradeType upgradeType) { if (amountOfCookies >= cost) { switch (upgradeType) { case UpgradeBase.UpgradeType.ClickUpgrade: cookiesPerClick *= multiplier; break; case UpgradeBase.UpgradeType.AutoCookieUpgrade: cookiesPerSec *= multiplier; cookiesPerSecText.text = cookiesPerSec.ToString() + "/sec"; break; } amountOfCookies -= cost; UpgradeCompleted.Invoke(this, upgradeType); } else if (amountOfCookies < cost) // If the upgrade cannot be afforded { if (!textOnCooldown) { StartCoroutine(ShowInfoText("Insufficient Funds")); } Debug.Log("Insufficient Funds"); } }
private async void DownLoadFromGithub() { string temppath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Temp"); //新建临时文件夹 if (!Directory.Exists(temppath)) { Directory.CreateDirectory(temppath); } await GetDownLoadList(); DownLoadProgress = new ProgressBUpdateEventArgs(); DownLoadProgress.maximum = DownLoadList.Count; foreach (var item in DownLoadList) { if (StopUpgrade) { return; } Console.WriteLine(item); string filepath = Path.Combine(temppath, item); if (!File.Exists(filepath)) { HttpResult streamResult = await DownLoadFile(file_url + item); //写入本地 if (streamResult != null) { WriteFile(streamResult.FileByte, filepath); } } DownLoadProgress.value += 1; if (!StopUpgrade) { onProgressChanged?.Invoke(this, DownLoadProgress); } } //复制文件并覆盖 执行 cmd 命令 UpgradeCompleted?.Invoke(this, null); }