public void MongoConnectionCanDeleteData() { Member member = InsertMember(); member.Delete(_mongoConnection); Member readMember = AbstractData.Read <Member>(_mongoConnection, member.Id); Assert.IsNull(readMember); }
/// <summary> /// returns a string given an AbstractData type that is /// inherited by a StringKeyValue /// </summary> public static string GetString(AbstractData ad) { var stringKeyValue = ad as StringKeyValue; if (stringKeyValue == null) { throw new GeneralException($"Unable to convert the AbstractData type to a StringKeyValue type: [{ad.Key}]"); } return(string.IsNullOrEmpty(stringKeyValue.Value) ? null : stringKeyValue.Value); }
public void MongoConnectionCanUpdateData() { Member member = InsertMember(); member.CardId = $"new card id {Guid.NewGuid()}"; member.Update <Member>(_mongoConnection); Member readMember = AbstractData.Read <Member>(_mongoConnection, member.Id); Assert.IsTrue(member.Equals(readMember)); }
/// <summary> /// returns true if the annotation is on the reverse strand, false otherwise /// </summary> public static bool GetStrand(AbstractData ad) { int strandNum = DumperUtilities.GetInt32(ad); // sanity check: make sure the value is either 1 or -1 if (strandNum != -1 && strandNum != 1) { throw new GeneralException($"Expected the strand number to be either -1 or 1. Found: {strandNum}."); } return(strandNum == -1); }
public void Update() { if (Owner == null || Owner.Data == null || Owner.Data.GetBody() == null) { Active = false; return; } bool isPlayer = Owner is Player; Collider2D[] hits = Physics2D.OverlapCircleAll(Owner.Data.GetBody().transform.position, VisibleRadius); if (isPlayer) { foreach (GameObject o in KnownObjects) { if (o == null) { continue; } AbstractData d = o.GetData(); if (d != null) { d.IsVisibleToPlayer = false; } } } KnownObjects.Clear(); foreach (Collider2D h in hits) { if ("Cave Generator".Equals(h.gameObject.name) || h.gameObject.Equals(Owner.GetData().gameObject)) { continue; } if (isPlayer) { AbstractData d = h.gameObject.GetData(); if (d != null) { d.IsVisibleToPlayer = true; } } KnownObjects.Add(h.gameObject); } }
public static Character GetCharacter(GameObject o) { AbstractData d = o.GetComponent <AbstractData>(); if (d == null) { return(null); } Character ch = d.GetOwner(); return(ch); }
/// <summary> /// returns true if the data type is a pointer to another type /// </summary> public static bool IsReference(AbstractData ad) { var referenceStringValue = ad as ReferenceStringValue; if (referenceStringValue != null && referenceStringValue.Value.StartsWith("$VAR1->")) { return(true); } var referenceKeyValue = ad as ReferenceKeyValue; return(referenceKeyValue != null && referenceKeyValue.Value.StartsWith("$VAR1->")); }
public void MongoConnectionCanUpdateMultipleData() { Member member1 = InsertMember(); Member member2 = InsertMember(); string newId = $"new card id {Guid.NewGuid()}"; AbstractData.Update <Member, string>(_mongoConnection, member => true, member => member.CardId, newId); IOrderedEnumerable <Member> readMembers = AbstractData.Read <Member>(_mongoConnection, member => true).OrderBy(member => member.Id); Assert.IsTrue(readMembers.All(member => member.CardId == newId)); }
public void MongoConnectionCanReadMultipleData() { Member member1 = InsertMember(); Member member2 = InsertMember(); IOrderedEnumerable <Member> members = new List <Member>() { member1, member2 }.OrderBy(member => member.Id); IOrderedEnumerable <Member> readMembers = AbstractData.Read <Member>(_mongoConnection, member => true).OrderBy(member => member.Id); CollectionAssert.AreEqual(readMembers, members); }
public static Character GetCharacterFromObject(GameObject obj) { AbstractData data = obj.GetComponentInParent <AbstractData>(); if (data == null) { return(null); } Character targetCh = data.GetOwner(); return(targetCh); }
private static void LogDiagnostics(string dataType, AbstractData data, List <KeyValuePair <DiagnosticSeverity, string> > logs) { if (data.IgnoredReason != null) { logs.Add(new KeyValuePair <DiagnosticSeverity, string>(data.IgnoredReason.DiagnosticSeverity, $"{dataType} {data.GetSymbol().Name} {data.GetLineSpan().Span.Format()} ignored reason: {data.IgnoredReason.Reason}")); } foreach (var diagnostic in data.GetDiagnostics()) { logs.Add(new KeyValuePair <DiagnosticSeverity, string>(diagnostic.DiagnosticSeverity, $"{dataType} {data.GetSymbol().Name} {data.GetLineSpan().Span.Format()}: {diagnostic.Description}")); } }
public static int AddItem(AbstractData itemData) { //ない場合は新しく1追加 if (!_itemOwnedDictionary.ContainsKey(itemData.ID)) { _itemOwnedDictionary [itemData.ID] = 1; } else { _itemOwnedDictionary [itemData.ID] += 1; } return(_itemOwnedDictionary [itemData.ID]); }
/// <summary> /// returns the mapper unit type given the specialized string key/value type /// </summary> public static MapperUnitType GetMapperUnitType(AbstractData ad) { string mapperUnitTypeString = DumperUtilities.GetString(ad); MapperUnitType ret; if (!MapperUnitTypes.TryGetValue(mapperUnitTypeString, out ret)) { throw new GeneralException( $"Unable to find the specified mapper unit type ({mapperUnitTypeString}) in the MapperUnitType dictionary."); } return(ret); }
void Districts(AbstractData data) { for (int i = 0; i < buildings.Count; i++) { AbstractData.Area area = new AbstractData.Area(); area.areaFunction = buildings[i].functionType; area.position = buildings[i].Location; area.size = buildings[i].areaSize; area.area = buildings[i].gameObject; data.districts.Add(area); } }
private static void LogDocumentDiagnostics(AbstractData data, List <KeyValuePair <DiagnosticSeverity, string> > logs) { if (data.IgnoredReason != null) { logs.Add(new KeyValuePair <DiagnosticSeverity, string>(data.IgnoredReason.DiagnosticSeverity, $"Document ignored reason: {data.IgnoredReason.Reason}")); } foreach (var diagnostic in data.GetDiagnostics()) { logs.Add(new KeyValuePair <DiagnosticSeverity, string>(diagnostic.DiagnosticSeverity, $"Document: {diagnostic.Description}")); } }
public static Vector3 GenerateFixedPositionAroundObject(GameObject o, float circleRadius, int fixedAngle) { AbstractData data = o.GetData(); Vector3 dir = data.GetForwardVector(); Vector3 newRot = RotateDirectionVector(dir, fixedAngle) * circleRadius; Vector3 target = o.transform.position + newRot; if (IsNotAccessible(target)) { return(GenerateRandomPositionAround(o.transform.position, 5, 2)); } return(o.transform.position + newRot); }
public double getPrixPortefeuille(double[] spot, int now, AbstractData donnees) { // Recupere la valeur du portefeuille à l'instant actuel var result = 0.0; int i = 0; foreach (var par in this.nbActions) { result += par * spot[i]; i++; } int span = (donnees.listeDate[now] - donnees.listeDate[date]).Days;; result += tauxSansRisque * RiskFreeRateProvider.GetRiskFreeRateAccruedValue(DayCount.ConvertToDouble(span, 365)); return(result); }
public static Character GetChar(this GameObject o) { AbstractData d = o.GetComponent <AbstractData>(); if (d == null) { /*Destroyable dest = o.GetComponent<Destroyable>(); * if(dest != null) * return dest.owner.GetChar();*/ return(null); } Character ch = d.GetOwner(); return(ch); }
public string ToString(double[] spot, int date, AbstractData donnees) { var res = ""; res += "##########PORTEFEUILLE##########\n"; res += "Part des actions \n"; int i = 0; foreach (var nb in this.nbActions) { res += nb + " actions " + i + " (Cours " + spot[i] + "€ )\n"; i++; } res += "Montant dans le sans risque : " + tauxSansRisque + "€\n"; res += "Valeur totale du portefeuille = " + this.getPrixPortefeuille(spot, date, donnees) + "€\n"; res += "##########FIN PORTEFEUILLE##########"; return(res); }
protected Member[] InsertMembers(int numberOfMembersToCreate) { Member[] members = new Member[numberOfMembersToCreate]; for (int currentMemberIndex = 0; currentMemberIndex < numberOfMembersToCreate; currentMemberIndex++) { Member member = new Member() { CardId = Guid.NewGuid().ToString(), NickName = $"nickname {Guid.NewGuid()}", }; members[currentMemberIndex] = member; } AbstractData.Insert(_mongoConnection, members); return(members); }
public AbstractData CreateData() { AbstractData data = new AbstractData(); //adds all the areas to the data Districts(data); // for (int i = 0; i < NPCs.Count; i++) { AbstractData.Entity entity = new AbstractData.Entity(); entity.NPC = NPCs[i]; if (entity.NPC.name.Contains("Noble")) { Debug.Log(entity.NPC.name); entity.entityType = AbstractData.EntityType.NPCNoble; } else if (entity.NPC.name.Contains("Gaurd")) { Debug.Log(entity.NPC.name); entity.entityType = AbstractData.EntityType.NPCGuard; } else { entity.entityType = AbstractData.EntityType.NPC; } data.entitys.Add(entity); } foreach (GameObject g in Swords) { AbstractData.AllItems e = new AbstractData.AllItems(); e.Item = g; e.ItemType = SubQuestType.Q_Items.Usable; e.location = g.transform.position; data.items.Add(e); } return(data); }
private void OnUseItem <T>(AbstractData itemData) where T : AbstractData { Debug.LogError("itemData.ID: " + itemData.ID); //============= Foodの消費 =============// if (typeof(T) == typeof(FoodData)) { //最初数チェック int crntNum = PlayerData.GetItemNum(itemData.ID); if (crntNum <= 0) { UiController.Instance.OpenDialogPanel("Don't have " + itemData.Name + ".", () => {} ); return; } //満腹だった場合は消費しない if (_charData.hunger >= 100.0f) { UiController.Instance.OpenDialogPanel("Don't need to eat now.", () => {} ); return; } //消費して回復 float recoverVal = CharaData.HUNGER_MAX * ((FoodData)itemData).RecoverRatio; float tmpHungerLv = recoverVal + _charData.hunger; UiController.Instance.OpenDialogPanel("Do you want to use " + itemData.Name + "?", //YES () => { PlayerData.UseItem(itemData.ID, 1); _charData.hunger = Mathf.Min(CharaData.HUNGER_MAX, tmpHungerLv); //数値が変わっていた場合コンテンツリセット ResetStatusPanelItems <T> (); }, () => {} ); } //Use Food }
/// <summary> /// returns an int given an AbstractData type that is /// inherited by a StringKeyValue /// </summary> public static int GetInt32(AbstractData ad) { var s = GetString(ad); // sanity check: handle null values if (s == null) { return(-1); } int ret; if (!int.TryParse(s, out ret)) { throw new GeneralException($"Unable to convert the string ({s}) to an integer."); } return(ret); }
protected Visit[] InsertVisits(Member[] members, int numberOfVisitsToCreate, int visitAgeHours) { Visit[] visits = new Visit[numberOfVisitsToCreate]; DateTime visitTime = DateTime.Now - TimeSpan.FromHours(_random.NextDouble() * visitAgeHours); for (int currentVisitIndex = 0; currentVisitIndex < numberOfVisitsToCreate; currentVisitIndex++) { Visit visit = new Visit(members[_random.Next(0, members.Length)].Id) { VisitTime = visitTime, }; visits[currentVisitIndex] = visit; } AbstractData.Insert(_mongoConnection, visits); return(visits); }
protected VisitTimeAlert[] InsertVisitTimeAlerts(Member[] members, int numberOfVisitTimeAlertsToCreate, int timeFromLatestVisitBeforeAlertHours) { VisitTimeAlert[] visitTimeAlerts = new VisitTimeAlert[numberOfVisitTimeAlertsToCreate]; TimeSpan timeFromLatestVisitBeforeAlert = TimeSpan.FromHours(_random.NextDouble() * timeFromLatestVisitBeforeAlertHours); for (int currentVisitTimeAlertIndex = 0; currentVisitTimeAlertIndex < numberOfVisitTimeAlertsToCreate; currentVisitTimeAlertIndex++) { VisitTimeAlert visitTimeAlert = new VisitTimeAlert(members[_random.Next(0, members.Length)]) { TimeFromLatestVisitBeforeAlert = timeFromLatestVisitBeforeAlert, }; visitTimeAlerts[currentVisitTimeAlertIndex] = visitTimeAlert; } AbstractData.Insert(_mongoConnection, visitTimeAlerts); return(visitTimeAlerts); }
public Sprite GetSpriteFromID(string id) { //Search Sword Items AbstractData searchingData = SwordDataTableObject.Instance.GetParams(id); if (searchingData != null) { return(GetSpriteFromPath("WeaponAtlas", searchingData.Image)); } //Search Gun Items searchingData = GunDataTableObject.Instance.GetParams(id); if (searchingData != null) { return(GetSpriteFromPath("WeaponAtlas", searchingData.Image)); } //Search Tool Items searchingData = ToolItemDataTableObject.Instance.GetParams(id); if (searchingData != null) { return(GetSpriteFromPath("ItemAtlas", searchingData.Image)); } //Search Material Items searchingData = CraftItemDataTableObject.Instance.GetParams(id); if (searchingData != null) { return(GetSpriteFromPath("ItemAtlas", searchingData.Image)); } //Search Food Items searchingData = FoodDataTableObject.Instance.GetParams(id); if (searchingData != null) { return(GetSpriteFromPath("ItemAtlas", searchingData.Image)); } return(null); }
private void NotifyNearbyAggroAdded(Character target) { if (!GetTemplate().AlertsAllies) { return; } if (lastNotify + notifyInterval < Time.time) { lastNotify = Time.time; Collider2D[] colliders = Physics2D.OverlapCircleAll(Owner.GetData().GetBody().transform.position, AggressionRange); foreach (Collider2D c in colliders) { if (c.gameObject == null) { continue; } AbstractData d = c.gameObject.GetData(); if (d == null) { continue; } if (d.GetOwner() is Monster) { Monster monster = (Monster)d.GetOwner(); if (monster.AI.State != AIState.ATTACKING) { monster.AI.AddAggro(target, 1); continue; } } } } }
void Start() { ownerData = transform.parent.gameObject.GetData(); labelStyle = null; //if (ownerData != null) // showObjectName = ownerData.showObjectName; foreach (Transform child in transform.parent.transform) { if (child.gameObject.name.Equals("Healthbar Center")) { center = child.gameObject; break; } } foreach (Transform child in transform) { if (child.gameObject.name.Equals("AutoattackCooldown")) { cooldownBar = child.gameObject; foreach (Transform t in cooldownBar.transform) { if (t.gameObject.name.Equals("cooldown")) { cooldownMarker = t.gameObject; mat = cooldownMarker.GetComponent <SpriteRenderer>().material; break; } } break; } } }
public AbstractData readAbstractDataCSV(String path, String delimiter, String name) { AbstractData AData; String currentPath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName; using (TextFieldParser parser = new TextFieldParser(currentPath + "\\Files\\" + path)) { parser.TextFieldType = FieldType.Delimited; parser.SetDelimiters(delimiter); Dictionary <String, String> setOfData = new Dictionary <String, String>(); while (!parser.EndOfData) { //Processing row string[] fields = parser.ReadFields(); //ConcreteData concreteData = new ConcreteData(fields[0], fields[1]); setOfData[fields[0]] = fields[1]; } AData = new AbstractData(name, setOfData); } return(AData); }
public void InitItemCraftingData(AbstractData itemData) { gameObject.SetActive(true); _itemData = itemData; string atlasName = ""; if (_itemData.GetType() == typeof(SwordData)) { atlasName = "WeaponAtlas"; } //アイテムの画像設置 itemImage.sprite = GameManager.Instance.GetSpriteFromPath(atlasName, _itemData.Image); //アスペクトをONのまま横サイズをFixさせながらリサイズ。 itemImage.preserveAspect = true; itemImage.SetNativeSize(); Vector2 imgSize = itemImage.GetComponent <RectTransform>().sizeDelta; imgSize.x = 100; itemImage.GetComponent <RectTransform> ().sizeDelta = imgSize; //素材設置<ID, 数> Dictionary <string, int> requirementDict = _itemData.ParseRequirementStr(); foreach (string id in requirementDict.Keys) { int value = requirementDict [id]; MaterialItem materialItem = (MaterialItem)Instantiate(materialItemPrefab); materialItem.SetUpMaterialItem(id); materialItem.materialNum.text = id + " x" + value; materialItem.transform.SetParent(MaterialListPos); materialItem.transform.localPosition = Vector3.zero; materialItem.transform.localScale = Vector3.one; } }