private JSONObject S_DEPLOY() { UserInfoRow user = SyncData.MainUser; BaseInfoRow baseInfo = SyncData.CurrentMainBase; Dictionary <string, string> data = new Dictionary <string, string>() { { "Server_ID", user.Server_ID }, { "ID_User", user.ID_User.ToString() }, { "ID_Unit", ((int)refTag.Type).ToString() }, { "Quality", ((int)refTag.Slider.Value).ToString() }, { "BaseNumber", baseInfo.BaseNumber.ToString() } }; JSONObject packet = new JSONObject(data); Debugger.Log(packet); return(packet); }
private JSONObject S_TRAINING() { UserInfoRow user = SyncData.MainUser; BaseInfoRow baseInfo = SyncData.CurrentMainBase; Dictionary <string, string> data = new Dictionary <string, string>() { { "ID_User", user.ID_User.ToString() }, { "Server_ID", user.Server_ID.ToString() }, { "BaseNumber", baseInfo.BaseNumber.ToString() }, { "ID_Unit", ((int)refType.ID).ToString() }, { "Level", refType.Level.ToString() }, { "Quality", quality.ToString() }, }; JSONObject result = new JSONObject(data); Debug.Log(result.ToString()); return(result); }
private void UpdateBaseInfo(int i) { BaseInfoRow baseInfo = BaseInfos.ReadOnlyRows[i]; baseInfo.Update(this); }
protected override void Init() { baseInfo = SyncData.CurrentMainBase; }
/// <summary> /// 0: type - ListUpgrade /// 1: need material - int[4] /// 2: might bonus - int /// 3: time min - string /// 4: time int - int /// </summary> /// <param name="data">Params object</param> public override void Load(params object[] data) { currentMainBase = SyncData.CurrentMainBase; ListUpgrade loadType = data.TryGet <ListUpgrade>(0); ITable table = dbReference[loadType]; string title = loadType.ToString().InsertSpace(); int level = SyncData.CurrentBaseUpgrade[loadType].Level; ITableData needInfo = table[level - 1]; int foodCost = GetPublicValue <int>(needInfo, "FoodCost"); int woodCost = GetPublicValue <int>(needInfo, "WoodCost"); int metalCost = GetPublicValue <int>(needInfo, "MetalCost"); int stoneCost = GetPublicValue <int>(needInfo, "StoneCost"); int mightBonus = GetPublicValue <int>(needInfo, "MightBonus"); int[] needMaterials = new int[] { foodCost, woodCost, stoneCost, metalCost }; curMaterials[0] = currentMainBase.Farm; curMaterials[1] = currentMainBase.Wood; curMaterials[2] = currentMainBase.Stone; curMaterials[3] = currentMainBase.Metal; isUpgradeType = loadType.IsUpgrade(); bool activeProgressBar = isUpgradeType ? currentMainBase.UpgradeWait_ID.IsDefined() : currentMainBase.ResearchWait_ID.IsDefined(); bool activeBtnGroup = !activeProgressBar; activeBtnGroup = activeBtnGroup && IsEnoughtMeterial(needMaterials); ActiveBtnGroup(activeBtnGroup); bool isSimilarCurUpgResType = true; if (isUpgradeType) { if (currentMainBase.UpgradeWait_ID.IsDefined() && loadType != currentMainBase.UpgradeWait_ID) { loadType = currentMainBase.UpgradeWait_ID; isSimilarCurUpgResType = false; } } else { if (currentMainBase.ResearchWait_ID.IsDefined() && loadType != currentMainBase.ResearchWait_ID) { loadType = currentMainBase.ResearchWait_ID; isSimilarCurUpgResType = false; } } refUpgType = SyncData.CurrentBaseUpgrade[loadType]; if (!isSimilarCurUpgResType) { table = dbReference[loadType]; level = refUpgType.Level; needInfo = table[level - 1]; } string timeMin = GetPublicValue <string>(needInfo, "TimeMin"); // needInfo.TimeMin; int timeInt = GetPublicValue <int>(needInfo, "TimeInt"); //needInfo.TimeInt; ActiveProgressBar(activeProgressBar && timeInt > 0); ProgressSlider.Slider.MaxValue = timeInt; bool isBuildingRequire = false; bool isResearchRequire = false; BuildingLevel.transform.parent.gameObject.SetActive(isBuildingRequire); ResearchLevel.transform.parent.gameObject.SetActive(isResearchRequire); #region display info Title.text = title; if (curMaterials != null && needMaterials != null) { for (int i = 0; i < 4; i++) { int captureInt = i; OrderMaterialElements[i].SelectableComp.OnClickEvents += delegate { SetMaterialRequirement(captureInt, ++curMaterials[captureInt], needMaterials[captureInt]); if (IsEnoughtMeterial(needMaterials)) { ActiveBtnGroup(true); } }; SetMaterialRequirement(i, curMaterials[i], needMaterials[i]); } } // ============================ // NumberName.text = "Might Bonus"; Amount.text = string.Format("{0}", mightBonus); //DurationText.text = "Duration: " + timeMin; DurationText.text = timeMin; #endregion }