public void UpdateToLatestVersion(Dispatcher myDispatcher, LauncherData.LauncherVersion theVersion) { myDispatcher.BeginInvoke(new System.Windows.Forms.MethodInvoker(delegate() { //open a webrequest WebRequest req = WebRequest.Create("http://swganh.hooni.us" + theVersion.Location); req.Method = "GET"; //wrap our object togethers DownloadRequest theRequest = new DownloadRequest { Request = req, Version = theVersion }; //and initialise an array to hold our bytes[] arFileBytes = new byte[theVersion.FileSize]; //and a counter to record the download progress nBytesRead = 0; //start the download req.BeginGetResponse(new AsyncCallback(DownloadStarted), theRequest); }), System.Windows.Threading.DispatcherPriority.Normal); }
public ApplicationUpdates(LauncherData.LauncherDataClient myClient) { _WCFClient = myClient; }
private void DownloadComplete(LauncherData.LauncherVersion theVersion, byte[] arFileBytes) { App.Current.Dispatcher.BeginInvoke(new System.Windows.Forms.MethodInvoker(delegate() { string strUpdateDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + "Updates"; string strFilename = Path.GetFileName(theVersion.Location); if (!Directory.Exists(strUpdateDirectory)) { Directory.CreateDirectory(strUpdateDirectory); } if (File.Exists(strUpdateDirectory + Path.DirectorySeparatorChar + strFilename)) { File.Delete(strUpdateDirectory + Path.DirectorySeparatorChar + strFilename); } FileStream outFile = new FileStream(strUpdateDirectory + Path.DirectorySeparatorChar + strFilename, FileMode.CreateNew, FileAccess.Write); BinaryWriter writeME = new BinaryWriter(outFile); writeME.Write(arFileBytes); writeME.Close(); outFile.Close(); if (OnDownloadComplete != null) { OnDownloadComplete(this, new DownloadCompleteEventArgs(strUpdateDirectory + Path.DirectorySeparatorChar + strFilename)); } }), System.Windows.Threading.DispatcherPriority.Normal); }
private static System.Collections.IEnumerator OnNewInit(object objd) { Object obj = ResManager.Instance.LoadObject("ServerSetting", "GlobalRes/ServerSetting/", ResType.GlobalRes, typeof(TextAsset)); if (obj == null) { InitLogic.SetInitFailed(); yield break; } TextAsset ta = obj as TextAsset; XmlDocument doc = new XmlDocument(); doc.LoadXml(ta.text); XmlNode pConfig = doc.SelectSingleNode("Config"); XmlNode verNode = pConfig.SelectSingleNode("ServerVersion"); XmlNode comboNode = pConfig.SelectSingleNode("Combo"); XmlNode energyNode = pConfig.SelectSingleNode("Energy"); XmlNode cannonNode = pConfig.SelectSingleNode("Cannon"); XmlNode skillNode = pConfig.SelectSingleNode("Skill"); XmlNode rateNode = pConfig.SelectSingleNode("Rate"); XmlNode fishNode = pConfig.SelectSingleNode("Fish"); XmlNode rankNode = pConfig.SelectSingleNode("Rank"); XmlNode dstNode = pConfig.SelectSingleNode("FishDeadTime"); if (verNode == null || comboNode == null || energyNode == null || skillNode == null || rateNode == null || cannonNode == null || fishNode == null || rankNode == null || dstNode == null) { LogMgr.Log("ServerSetting load failed."); InitLogic.SetInitFailed(); yield break; } if (energyNode.ChildNodes.Count != cannonNode.ChildNodes.Count) { LogMgr.Log("energyNode<>cannonNode"); InitLogic.SetInitFailed(); yield break; } int nFishs = 0; int nFishValues = 0; LauncherInfo [] plauncherinfo; yield return(new WaitForEndOfFrame()); Attribute(verNode, "wonderful_base", ref ExtraSetting.WonderFulBase); /////Ver //Attribute(verNode, "maxfish", ref FishSetting.FISH_MAX_NUM); //Attribute(verNode, "maxbullet", ref BulletSetting.BULLET_MAX_NUM); /////Combo Attribute(comboNode, "sustain_time", ref DoubleHit.IntervalTime); Attribute(comboNode, "buff_cycle", ref DoubleHit.MaxTimes); ////Cannon int launcherCount = energyNode.ChildNodes.Count; plauncherinfo = new LauncherInfo[launcherCount]; LauncherSetting.LauncherDataList = new LauncherData[launcherCount]; for (int i = 0; i < launcherCount; ++i)//from energy { LauncherData ld = new LauncherData(); XmlNode node = energyNode.ChildNodes[i]; Attribute(node, "id", ref ld.ID); Attribute(node, "cditme", ref ld.LaserCDTime); Attribute(node, "speed", ref ld.LaserReduction.Speed); Attribute(node, "time1", ref ld.LaserReduction.Duration1); Attribute(node, "time2", ref ld.LaserReduction.Duration2); Attribute(node, "time3", ref ld.LaserReduction.Duration3); LauncherInfo Item = new LauncherInfo(); Attribute(node, "mincatch", ref Item.nmincatch); Attribute(node, "maxcatch", ref Item.nmaxcatch); Attribute(node, "revise", ref Item.nrevise); Attribute(node, "energyratio", ref Item.denergyratio); if (LauncherSetting.LauncherDataList[ld.ID] != null) { LogMgr.Log("Exist the same launcher id."); InitLogic.SetInitFailed(); yield break; } LauncherSetting.LauncherDataList[ld.ID] = ld; plauncherinfo[ld.ID] = Item; } yield return(new WaitForEndOfFrame()); for (int i = 0; i < launcherCount; ++i)//from cannon { XmlNode node = cannonNode.ChildNodes[i]; byte byid = 0; Attribute(node, "id", ref byid); LauncherData ld = LauncherSetting.LauncherDataList[byid]; ld.name = node.Attributes["name"].Value; Attribute(node, "launcherinterval", ref ld.Interval); Attribute(node, "consume", ref ld.Consume); Attribute(node, "bulletspeed", ref ld.Speed); Attribute(node, "itemid", ref ld.nItemid); Attribute(node, "itemcount", ref ld.nItemcount); Attribute(node, "skill", ref ld.nSkillBind); if (byid == (byte)LauncherType.LAUNCHER_4)//4号炮特有 { Attribute(node, "speed", ref BulletSetting.FreezeBulletReduction.Speed); Attribute(node, "time1", ref BulletSetting.FreezeBulletReduction.Duration1); Attribute(node, "time2", ref BulletSetting.FreezeBulletReduction.Duration2); Attribute(node, "time3", ref BulletSetting.FreezeBulletReduction.Duration3); } } yield return(new WaitForEndOfFrame()); /////SkillInfo int skillCount = skillNode.ChildNodes.Count; SkillSetting.SkillDataList = new SkillData[skillCount]; for (int i = 0; i < skillCount; ++i) { SkillData sd = new SkillData(); XmlNode node = skillNode.ChildNodes[i]; Attribute(node, "id", ref sd.ID); sd.name = node.Attributes["name"].Value; Attribute(node, "cditme", ref sd.CDTime); Attribute(node, "goodsid", ref sd.ItemId); Attribute(node, "multiple", ref sd.multiple); Attribute(node, "speed", ref sd.Reduction.Speed); Attribute(node, "time1", ref sd.Reduction.Duration1); Attribute(node, "time2", ref sd.Reduction.Duration2); Attribute(node, "time3", ref sd.Reduction.Duration3); string szInfo = ""; Attribute(node, "goodsconsume", ref szInfo); if (szInfo.Length > 0) { string[] pConsume = szInfo.Split(' '); for (int index = 0; index < pConsume.Length; index += 2) { SkillConsume pskill = new SkillConsume(); pskill.byorder = System.Convert.ToByte(pConsume[index]); pskill.byCount = System.Convert.ToByte(pConsume[index + 1]); sd.NumRequire.Add(pskill); } } if (SkillSetting.SkillDataList[sd.ID] != null) { LogMgr.Log("Exist the same skill id."); InitLogic.SetInitFailed(); yield break; } SkillSetting.SkillDataList[sd.ID] = sd; } yield return(new WaitForEndOfFrame()); //Rate int rateCount = rateNode.ChildNodes.Count; BulletSetting.BulletRate = new ushort[rateCount]; BulletSetting.RateUnlock = new ushort[rateCount]; BulletSetting.RateReward = new ushort[rateCount]; for (int i = 0; i < rateCount; ++i) { XmlNode node = rateNode.ChildNodes[i]; byte byid = 0; Attribute(node, "id", ref byid); Attribute(node, "value", ref BulletSetting.BulletRate[byid]); Attribute(node, "unlock", ref BulletSetting.RateUnlock[byid]); Attribute(node, "unlockreward", ref BulletSetting.RateReward[byid]); } //Fish int fishCount = fishNode.ChildNodes.Count; FishSetting.FishDataList = new FishData[fishCount]; for (int i = 0; i < fishCount; ++i) { XmlNode node = fishNode.ChildNodes[i]; FishData fd = new FishData(); Attribute(node, "id", ref fd.ID); Attribute(node, "value", ref fd.Gold); fd.Name = node.Attributes["name"].Value; fd.Decl = node.Attributes["declare"].Value; if (FishSetting.FishDataList[fd.ID] != null) { LogMgr.Log("Exist the same fish id:" + fd.ID); InitLogic.SetInitFailed(); yield break; } FishSetting.FishDataList[fd.ID] = fd; byte maxcount = 0; Attribute(node, "maxcount", ref maxcount); nFishs += maxcount; nFishValues += maxcount * fd.Gold; } FishSetting.SortByGold(); yield return(new WaitForEndOfFrame()); //Rank int nRank = rankNode.ChildNodes.Count; Experience.Exp = new uint[nRank]; for (int i = 0; i < nRank; i++) { XmlNode node = rankNode.ChildNodes[i]; byte byid = 0; Attribute(node, "id", ref byid); Attribute(node, "experience", ref Experience.Exp[byid]); } /// //FishDeadTime FishDeadTimeData ftd = new FishDeadTimeData(); Attribute(dstNode, "TianZai_DouDong", ref ftd.TianZai_DouDong_Time);//float.Parse(fishDeadNode.ChildNodes[0].FirstChild.Value); Attribute(dstNode, "TianZai_Stay_Min", ref ftd.TianZai_Stay_Time1); Attribute(dstNode, "TianZai_Stay_Max", ref ftd.TianZai_Stay_Time2); Attribute(dstNode, "TianZai_Dead_Min", ref ftd.TianZai_Dead_Time1); Attribute(dstNode, "TianZai_Dead_Max", ref ftd.TianZai_Dead_Time2); Attribute(dstNode, "Bullet_BingDong_Dead_Min", ref ftd.Bullet_BingDong_Dead_Time1); Attribute(dstNode, "Bullet_BingDong_Dead_Max", ref ftd.Bullet_BingDong_Dead_Time2); Attribute(dstNode, "BingDong_Dead_Min", ref ftd.BingDong_Dead_Time1); Attribute(dstNode, "BingDong_Dead_Max", ref ftd.BingDong_Dead_Time2); Attribute(dstNode, "ShanDian_Dead_Min", ref ftd.ShanDian_Dead_Time1); Attribute(dstNode, "ShanDian_Dead_Max", ref ftd.ShanDian_Dead_Time2); Attribute(dstNode, "LongJuanFeng_Dead_Min", ref ftd.LongJuanFeng_Dead_Time1); Attribute(dstNode, "LongJuanFeng_Dead_Max", ref ftd.LongJuanFeng_Dead_Time2); Attribute(dstNode, "JiGuang_Stay_Time", ref ftd.JiGuang_Stay_Time); Attribute(dstNode, "JiGuang_Dead_Min", ref ftd.JiGuang_Dead_Time1); Attribute(dstNode, "JiGuang_Dead_Max", ref ftd.JiGuang_Dead_Time2); Attribute(dstNode, "ShandDian_Speed", ref ftd.ShandDian_Speed); Attribute(dstNode, "JiGuang_Speed", ref ftd.JiGuang_Speed); Attribute(dstNode, "JiGuang_BingDong_Speed", ref ftd.JiGuang_BingDong_Speed); Attribute(dstNode, "TianZai_Speed", ref ftd.TianZai_Speed); Attribute(dstNode, "BingDong_Speed", ref ftd.BingDong_Speed); FishSetting.FishDeadTime = ftd; //cal for (int i = 0; i < launcherCount; i++) { LauncherInfo item = plauncherinfo[i]; item.nincome = (ushort)((item.nmincatch + item.nmaxcatch) / 2.0f / nFishs * nFishValues + item.nrevise); LauncherSetting.LauncherDataList[i].Energy = (ushort)(item.nincome * item.denergyratio);//大招 } yield return(new WaitForEndOfFrame()); int roomCount = 4; ExtraSetting.RoomDataList = new RoomData[roomCount]; for (int i = 0; i < roomCount; ++i) { RoomData rd = new RoomData(); rd.RoomID = (byte)i; rd.RoomRateIdx = (byte)i; ExtraSetting.RoomDataList[i] = rd; } //XmlNode childNode = pConfig.SelectSingleNode("RoomInfo"); //if (childNode == null) //{ // LogMgr.Log("RoomInfo not found."); // InitLogic.SetInitFailed(); // yield break; //} //int roomCount = childNode.ChildNodes.Count; //ExtraSetting.RoomDataList = new RoomData[roomCount]; //for (int i = 0; i < roomCount; ++i) //{ // RoomData rd = new RoomData(); // rd.RoomID = byte.Parse(childNode.ChildNodes[i].Attributes["id"].Value); // rd.RoomRateIdx = byte.Parse(childNode.ChildNodes[i].FirstChild.Value); // if (ExtraSetting.RoomDataList[rd.RoomID] != null) // { // LogMgr.Log("Exist the same room id."); // InitLogic.SetInitFailed(); // yield break; // } // ExtraSetting.RoomDataList[rd.RoomID] = rd; //} ResManager.Instance.UnloadObject(obj); InitLogic.EndInit(); }
public ChangeCustomerServerEventArgs(bool blnDelete, LauncherData.ServerInfo theServerInfo) { this.Delete = blnDelete; this.ServerInfo = theServerInfo; }
async Task CheckAndDownloadLatestPackage(IWurmAssistantService wurmAssistantService, Launcher launcher, LauncherData launcherData) { Version remoteVersion = null; try { remoteVersion = await wurmAssistantService.GetLatestVersionAsync(gui); } catch (Exception exception) { launcher.WriteErrorFile( string.Format("Launcher failed to check latest WA version. Error: {0}", exception.ToString())); } if (remoteVersion != null && launcherData.WurmAssistantInstalledVersion < remoteVersion) { try { await wurmAssistantService.GetPackageAsync(gui, remoteVersion); // done - next run will install this staged version } catch (Exception exception) { launcher.WriteErrorFile( string.Format("Launcher failed to download latest WA version. Error: {0}", exception.ToString())); } } }