private void SetupBaseLayout(BaseDescription baseDescription) { foreach (var obj in baseDescription.layout) { database.Instantiate(obj); } }
public static void WriteDefensesLayout(BaseDescription baseDesription) { var layoutObjects = UnityEngine.Object.FindObjectsOfType <LayoutObject>(); var objectId = 1; foreach (var obj in layoutObjects) { var objectIdentity = obj.GetComponent <ObjectIdentity>(); objectIdentity.RuntimeId = objectId++; baseDesription.AddToLayout(objectIdentity); var additionalData = obj.GetComponent <AdditionalDataProvider>(); if (additionalData != null) { baseDesription.AddAdditionalData(additionalData); } } //In case some objects have dependencies on each other, destroy them afterwards foreach (var layoutObject in layoutObjects) { UnityEngine.Object.DestroyImmediate(layoutObject.gameObject); } }
protected virtual bool ShouldBuildDescription(BaseDescription description) { if (description == null) { return(false); } if (!string.IsNullOrEmpty(description.NotFor)) { var notFor = description.NotFor.Split(';'); if (notFor.Any(_platformTags.ContainsKey)) { return(false); } } if (!string.IsNullOrEmpty(description.OnlyFor)) { var onlyFor = description.OnlyFor.Split(';'); if (onlyFor.Any(_platformTags.ContainsKey)) { return(true); } return(false); } return(true); }
protected void Fill(BaseDescription baseDescription) { foreach (var kvp in Properties) { baseDescription.Properties[kvp.Key] = kvp.Value; } baseDescription.OnlyFor = OnlyFor; baseDescription.NotFor = NotFor; }
private void SetupAdditionalData(BaseDescription baseDescription) { foreach (var data in baseDescription.additionalData) { var obj = database.GetByRuntimeId(data.objectRuntimeId); var additionalData = obj.GetComponent <AdditionalDataProvider>(); additionalData.InitFromString(data.data); } }
private static BaseProperties FromProperties(BaseDescription baseDescription) { var baseProperties = Selection.activeObject as BaseProperties; baseDescription.goldMiningLimit = baseProperties.goldMiningLimit; baseDescription.goldMiningStarted = DateTime.MinValue.ToBinary(); baseDescription.omoniumVeinsMax = baseProperties.omoniumVeinsMax; baseDescription.omoniumVeinsLeft = baseProperties.omoniumVeinsMax; baseDescription.omoniumMiningStarted = DateTime.MinValue.ToBinary(); baseDescription.availableDefenses = baseProperties.availableDefenses.ToArray(); return(baseProperties); }
private BaseDescription findClosest(IEnumerable <BaseDescription> list) { BaseDescription closest = null; foreach (var eon in list) { if (closest == null || distance(Description, eon) < distance(Description, closest)) { closest = eon; } } return(closest); }
public void Notify(BaseDescription desc) { if (!knownObjects.ContainsKey(desc.GenericName)) { knownObjects.Add(desc.GenericName, new Dictionary <int, BaseDescription>()); } if (!knownObjects[desc.GenericName].ContainsKey(desc.EntityID)) { knownObjects[desc.GenericName].Add(desc.EntityID, desc); } else { knownObjects[desc.GenericName][desc.EntityID] = desc; } }
public static void BuildBase() { var baseDescription = new BaseDescription(); BaseProperties baseProperties = FromProperties(baseDescription); //TODO populate layout and upgrades WriteDefensesLayout(baseDescription); //TODO automatically assing asset bundle names to corresponding assets var manifest = BuildPipeline.BuildAssetBundles(Constants.AssetBundlesPath, BuildAssetBundleOptions.None, BuildTarget.Android); var bundleName = manifest.GetAllAssetBundles()[0]; baseDescription.bundleName = bundleName; baseProperties.provider.UpdatePlayerBase(baseProperties.playerId.ToString(), baseDescription); }
//返回客戶中英文描述 public static BaseDescription GetCustomerByID(string strCustomerID) { string strSql = string.Format("Select name,english_name FROM dbo.bs_customer with(nolock) Where id='{0}' and state <>'2'", strCustomerID); DataTable dt = SQLHelper.ExecuteSqlReturnDataTable(strSql); BaseDescription objModel = new BaseDescription(); if (dt.Rows.Count > 0) { objModel.Cdesc = dt.Rows[0]["name"].ToString(); objModel.Edesc = dt.Rows[0]["english_name"].ToString(); } else { objModel.Cdesc = ""; objModel.Edesc = ""; } return(objModel); }
//返回附加費中英文描述 public static BaseDescription GetOtherFareByID(string strFareID) { string strSql = string.Format(@"Select name,english_name FROM bs_tack_fare with(nolock) WHERE id='{0}' and use_buy = '1' AND state='0'", strFareID); DataTable dt = SQLHelper.ExecuteSqlReturnDataTable(strSql); BaseDescription objModel = new BaseDescription(); if (dt.Rows.Count > 0) { objModel.Cdesc = dt.Rows[0]["name"].ToString(); objModel.Edesc = dt.Rows[0]["english_name"].ToString(); } else { objModel.Cdesc = ""; objModel.Edesc = ""; } return(objModel); }
//返回貨品中英文描述 public static BaseDescription GetProductByID(string strProductID) { string strSql = string.Format(@"Select name,english_name FROM {0}it_goods with(nolock) Where id='{1}' and state <>'2'", strRemoteDB, strProductID); DataTable dt = SQLHelper.ExecuteSqlReturnDataTable(strSql); BaseDescription objModel = new BaseDescription(); if (dt.Rows.Count > 0) { objModel.Cdesc = dt.Rows[0]["name"].ToString(); objModel.Edesc = dt.Rows[0]["english_name"].ToString(); } else { objModel.Cdesc = ""; objModel.Edesc = ""; } return(objModel); }
public async Task BuildBase(BaseDescription baseDescription) { var bundle = await AssetBundle.LoadFromFileAsync(Path.Combine(Constants.AssetBundlesPath, baseDescription.bundleName)); using (var disposable = new DisposableBundle(bundle)) { var sceneName = Path.GetFileNameWithoutExtension(disposable.GetAllScenePaths()[0]); await Scenes.LoadBaseScene(sceneName); SetupBaseLayout(baseDescription); SetupUpgrades(baseDescription); SetupAdditionalData(baseDescription); if (baseDescription.isAttacking) { SpawnPlayerSpaceship(); } onBaseBuilt.Raise(baseDescription); } }
static (string friendlyNameAttribute, string descriptionAttribute) CreateFriendlyNameAndDescriptionAttributes(BaseDescription description) { var friendlyNameAttribute = description.FriendlyName == null ? string.Empty : $@"[FriendlyName(""{description.FriendlyName}"")]{Environment.NewLine}"; var descriptionAttribute = description.Description == null ? string.Empty : $@"[Description(""{description.Description}"")]{Environment.NewLine}"; return(friendlyNameAttribute, descriptionAttribute); }
private double distance(BaseDescription a, BaseDescription b) { double dx = a.xCoord - b.xCoord, dy = a.yCoord - b.yCoord; return(Math.Sqrt(dx * dx + dy * dy)); }
private async Task InitNewPlayer(BaseDescription baseDescription) { Tutorials.TutorialUtility.SetTutorialRunning(true); await baseProvider.UpdatePlayerBase(playerData.Id, baseDescription); }
private bool canInteract(BaseDescription target) { return(distance(target, Description) - Description.Size - target.Size <= rules.MaxInteractionDistance); }
private double distance(BaseDescription a, int xCoord, int yCoord) { double dx = a.xCoord - xCoord, dy = a.yCoord - yCoord; return(Math.Sqrt(dx * dx + dy * dy)); }
public void OnBaseBuilt(BaseDescription baseDescription) { currentBaseDescription = baseDescription; }
private void SetupUpgrades(BaseDescription baseDescription) { }