public void VerifyHasTableWorks() { DropTable.For <Player>().TryExecute(Connection); Assert.That(HasTable.For <Player>().ExecuteCheck(Connection), Is.False); CreateTable.For <Player>().Execute(Connection); Assert.That(HasTable.For <Player>().ExecuteCheck(Connection), Is.True); }
void Start() { initialPosition = transform.position; dropTable = new DropTable(); dropTable.loot = new List <LootDrop>() { new LootDrop("Sword_01", 45), new LootDrop("Staff_01", 30), new LootDrop("Potion", 20) }; Experience = 20 * ExpModifier; ID = 0; navMeshAgent = GetComponent <NavMeshAgent>(); characterStats = new CharacterStats(5, 10, 2); healthbarUI = GetComponent <HealthbarUI>(); currentHealth = maxHealth; healthbarUI.UpdateHealthBar(gameObject, currentHealth, maxHealth); woundedSound = GetComponent <AudioSource>(); woundSpotSystem = gameObject.transform.Find("WoundSpot").GetComponent <ParticleSystem>(); }
public void Migrate(DougContext db) { var lines = File.ReadLines("droptables.csv").ToList(); lines.RemoveAt(0); foreach (var line in lines) { var values = Split(line); var existingTable = db.Droptables.Include(t => t.Items).SingleOrDefault(table => table.Id == values[0]); if (existingTable != null) { if (existingTable.Items.Any(itm => itm.Id == values[1])) { continue; } existingTable.Items.Add(new LootItem(values[1], int.Parse(values[2]), double.Parse(values[3]))); } else { var droptable = new DropTable() { Id = values[0] }; droptable.Items.Add(new LootItem(values[1], int.Parse(values[2]), double.Parse(values[3]))); db.Droptables.Add(droptable); } db.SaveChanges(); } }
public async Task VerifyHasTableWorks() { DropTable.For <Player>().TryExecute(Connection); await Table.Ensure <Player>(Connection); await InsertInto.Row(Create("Willem")).ExecuteAsync(Connection); await InsertInto.Row(Create("Willemse")).ExecuteAsync(Connection); await InsertInto.Row(Create("Bastiaan")).ExecuteAsync(Connection); await InsertInto.Row(Create("Harry")).ExecuteAsync(Connection); Console.WriteLine(Select <Player> .All().WhereContains(x => x.Name, "illem").Format(SqlFormat.MySql)); var result = Select <Player> .All().WhereContains(x => x.Name, "illem").ExecuteRead(Connection).ToList(); Assert.That(result, Has.Count.EqualTo(2)); result = Select <Player> .All().WhereStartsWith(x => x.Name, "bas").ExecuteRead(Connection).ToList(); Assert.That(result, Has.Count.EqualTo(1)); Assert.That(result[0].Name, Is.EqualTo("Bastiaan")); result = Select <Player> .All().WhereEndsWith(x => x.Name, "ry").ExecuteRead(Connection).ToList(); Assert.That(result, Has.Count.EqualTo(1)); Assert.That(result[0].Name, Is.EqualTo("Harry")); }
private static List <ItemDrop.ItemData> GetDropListItems(DropTable dropTable) { try { var context = DropLinkCache.GetLink(dropTable); var dropTemplates = DropConfigManager.GetPossibleDrops(context, dropTable); #if DEBUG Log.LogDebug("Potential drops: " + dropTemplates.Count); foreach (var drop in dropTemplates) { Log.LogDebug("\t" + drop.Drop.m_item.name); } #endif if (dropTemplates.Count == 0) { return(new(0)); } return(DropTableManager.GetItemDrops(dropTable, context)); } catch (Exception e) { Log.LogError("Error during calculation of item drops", e); return(new(0)); } }
private static string GetData(MonoBehaviour source, DropTable dropTable, string[] additionalHeaders) { StringBuilder sBuilder = new(); string sourceName = source.gameObject.GetCleanedName(); if (string.IsNullOrWhiteSpace(sourceName)) { return(""); } sBuilder.AppendLine(); sBuilder.AppendLine($"## DropTable Source: {source.GetType().Name}; " + additionalHeaders.Join(delimiter: "; ")); sBuilder.AppendLine($"[{sourceName}]"); sBuilder.AppendLine($"{nameof(DropTableEntityConfiguration.SetDropChance)}={(dropTable.m_dropChance * 100).ToString(CultureInfo.InvariantCulture)}"); sBuilder.AppendLine($"{nameof(DropTableEntityConfiguration.SetDropOnlyOnce)}={dropTable.m_oneOfEach}"); sBuilder.AppendLine($"{nameof(DropTableEntityConfiguration.SetDropMin)}={dropTable.m_dropMin}"); sBuilder.AppendLine($"{nameof(DropTableEntityConfiguration.SetDropMax)}={dropTable.m_dropMax}"); for (int i = 0; i < dropTable.m_drops.Count; ++i) { var drop = dropTable.m_drops[i]; sBuilder.AppendLine(); sBuilder.AppendLine($"[{sourceName}.{i}]"); sBuilder.AppendLine($"{nameof(DropTableItemConfiguration.PrefabName)}={(drop.m_item.IsNotNull() ? drop.m_item.name : "")}"); sBuilder.AppendLine($"{nameof(DropTableItemConfiguration.SetTemplateWeight)}={drop.m_weight.ToString(CultureInfo.InvariantCulture)}"); sBuilder.AppendLine($"{nameof(DropTableItemConfiguration.SetAmountMin)}={drop.m_stackMin}"); sBuilder.AppendLine($"{nameof(DropTableItemConfiguration.SetAmountMax)}={drop.m_stackMax}"); } return(sBuilder.ToString()); }
public GeneralDropTable(DropTable dropTable) : base("General") { tableType = DropTableType.General; numRolls = dropTable.numRolls; lootItems = dropTable.lootItems; }
// Start is called before the first frame update void Start() { //Debug.Log("Creating Drops...."); // Drops: //------------------------------------------- Drop shotgunAmmoDrop_5 = CreateDrop("shotgunAmmoDrop_5", shotgunAmmoDropPrefab, 5f); Drop shotgunAmmoDrop_10 = CreateDrop("shotgunAmmoDrop_10", shotgunAmmoDropPrefab, 10f); Drop pistolAmmoDrop_10 = CreateDrop("pistolAmmoDrop_10", pistolAmmoDropPrefab, 10f); Drop pistolAmmoDrop_20 = CreateDrop("pistolAmmoDrop_20", pistolAmmoDropPrefab, 20f); Drop rifleAmmoDrop_10 = CreateDrop("rifleAmmoDrop_10", rifleAmmoDropPrefab, 10f); Drop rifleAmmoDrop_20 = CreateDrop("rifleAmmoDrop_20", rifleAmmoDropPrefab, 20f); Drop explosiveDrop = CreateDrop("explosiveDrop", explosiveBulletEffectDropPrefab, 1f); // Drop Tables: //------------------------------------------- //Test Drop Table DropTable test = CreateDropTable("TestDropTable"); test.dropTable.Add(shotgunAmmoDrop_5, 10f); test.dropTable.Add(shotgunAmmoDrop_10, 10f); test.dropTable.Add(pistolAmmoDrop_10, 10f); test.dropTable.Add(pistolAmmoDrop_20, 10f); test.dropTable.Add(rifleAmmoDrop_10, 10f); test.dropTable.Add(rifleAmmoDrop_20, 10f); dropTables.Add(test); // Porcupine with explosives (Cutscene) DropTable PorcupineExplosives = CreateDropTable("PorcupineExplosives"); PorcupineExplosives.dropTable.Add(explosiveDrop, 100f); dropTables.Add(PorcupineExplosives); //Debug.Log("Amount of dropTables: " + dropTables.Count); }
/// <summary> /// 指定のテーブル定義を破棄する /// </summary> /// <param name="table">テーブル定義</param> /// <returns>DROP TABLE句ノード</returns> public DropTable DropTable(ITableDef table) { var node = new DropTable(this, table); this.Children.Add(node); return(node); }
public PetDropTable(DropTable dropTable) : base("Pet") { tableType = DropTableType.Pet; numRolls = dropTable.numRolls; lootItems = dropTable.lootItems; }
private static void MM_AdjustDropList(ref List <GameObject> __result, DropTable __instance) { //Clone the old list List <GameObject> list = new List <GameObject>(__result); // now loop through the old list foreach (GameObject obj in __result) { Plugin.Log($"MM_AdjustDropList: GameObject: {obj.name}"); //add 1-3 additional feathers) to the NEW list if (obj.name.ToLower() == "feathers") { // Return a random int within [minInclusive..maxExclusive) (Read Only). // Notes on UnityEngine.Random.Range(min int, max int) // Float numbers work differently where min/max are both inclusive // these are ints below int amount = UnityEngine.Random.Range(1, 3); for (int i = 0; i < amount; i++) { list.Add(obj); } // added the feathers, now don't add any more... // break here so that if there are additional feather entries in the result list we don't find and continue to add more break; } } // replace the initial List<GameObject> result with the new list __result = list; }
public void DropTable() { MiniSQLQuery query = MiniSQLParser.Parse("DROP TABLE Person;"); DropTable dropQuery = query as DropTable; Assert.AreEqual("Person", dropQuery.table); }
public void DropTable() { Query query = Parser.Parse("DROP TABLE Employees;"); DropTable selectQuery = query as DropTable; Assert.AreEqual("Employees", selectQuery.Table); }
public void WhenRecordInsertedWithAutoIncrementIdentityGetsUpdated() { DropTable.For <TableWithIncrement>().TryExecute(Connection); CreateTable.For <TableWithIncrement>().Execute(Connection); var first = new TableWithIncrement { Value = "Foo" }; var second = new TableWithIncrement { Value = "Bar" }; var numberFirst = InsertInto.Row(first).GetLastInsertIdentity <ulong>().ExecuteRead(Connection).Single(); var numberSecond = InsertInto.Row(second).GetLastInsertIdentity <ulong>().ExecuteRead(Connection).Single(); Assert.That(numberFirst, Is.EqualTo(1)); Assert.That(numberSecond, Is.EqualTo(2)); var firstSelected = Select.From <TableWithIncrement>().WhereEqual(x => x.Identifier, 1UL) .ExecuteRead(Connection) .SingleOrDefault(); Assert.IsNotNull(firstSelected); Assert.That(firstSelected.Identifier, Is.EqualTo(1UL)); Assert.That(firstSelected.Value, Is.EqualTo("Foo")); }
public void WhenRecordsInsertedTheyCanGetUpdated() { DropTable.For <Player>().TryExecute(Connection); CreateTable.For <Player>().Execute(Connection); var player = new Player { Age = 10, Birthday = DateTime.Now, Identifier = Guid.NewGuid(), Name = "Jim" }; Assert.That(InsertInto.Row(player).TryExecute(Connection)); var records = Select.From <Player>().ExecuteRead(Connection).ToImmutableList(); Assert.That(records, Has.Count.EqualTo(1)); Assert.That(records[0].Name, Is.EqualTo("Jim")); player.Name = "John"; Assert.That(InsertInto.Row(player).TryExecute(Connection), Is.False); records = Select.From <Player>().ExecuteRead(Connection).ToImmutableList(); Assert.That(records, Has.Count.EqualTo(1)); Assert.That(records[0].Name, Is.EqualTo("Jim")); Assert.That(InsertInto.Row(player).UpdateOnDuplicateKey.TryExecute(Connection)); records = Select.From <Player>().ExecuteRead(Connection).ToImmutableList(); Assert.That(records, Has.Count.EqualTo(1)); Assert.That(records[0].Name, Is.EqualTo("John")); }
public void Collect() { for (int i = 0; i < Trap.TrapInfo.Size; i++) { Drop drop = DropTable.GetDrop(); double chance = 1; GameItem dropItem = ItemManager.Instance.GetItemByName(drop.ItemName); Console.WriteLine("Got a " + drop.ItemName); foreach (Requirement req in dropItem.Requirements) { if (req.Skill == "Hunting") { if (Player.Instance.GetLevel("Hunting") >= req.SkillLevel) { chance = 1; } else { chance = 1 / (req.SkillLevel - Player.Instance.GetLevel("Hunting")); } continue; } } if (chance >= rand.NextDouble()) { MessageManager.AddMessage("You find a " + drop.ItemName + " in the trap."); Player.Instance.GainExperience(dropItem.ExperienceGained); Player.Instance.Inventory.AddDrop(drop); } else { MessageManager.AddMessage("You find evidence a " + drop.ItemName + " escaped the trap."); } } }
private DropTable CreateDropTable(string name) { DropTable temp = new DropTable(); temp.dropTableName = name; temp.dropTable = new Dictionary <Drop, float>(); return(temp); }
public void GetRandomDrop_test() { DropTable dropTable = GetDropTableFixture(); Drop drop = dropTable.GetRandomDrop(); Assert.That(drop.ItemData, Is.EqualTo(GetItemDataFixture(0)).Or.EqualTo(GetItemDataFixture(1))); Assert.That(drop.Amount, Is.GreaterThanOrEqualTo(1)); }
public static string DropTableToString(DropTable x) { if (x == null) { return(""); } return($"m_dropChance={x.m_dropChance}, m_dropMin={x.m_dropMin}, m_dropMax={x.m_dropMax}, m_oneOfEach={x.m_oneOfEach}, m_drops={DropListToString(x.m_drops)}"); }
public void DropTable() { SQLParser par = new SQLParser(); DropTable sbres = (DropTable)par.Parser("DROP TABLE table1;"); DropTable sel = new DropTable("table1"); Assert.AreEqual(sbres.GetType(), sel.GetType()); Assert.AreEqual(sbres.getTabla(), sel.getTabla()); }
public string Sample(DropTable table) { var totalWeight = table.Sum(item => item.Weight); var roll = Random.Next(totalWeight); foreach(var item in table) if (roll < item.Weight) return item.Name; else roll -= item.Weight; throw new Exception("No item was rolled. Is your table empty?"); }
//Initialize components void Start() { con = GetComponent <EnemyArcherController> (); col = GetComponent <CapsuleCollider> (); agent = GetComponent <NavMeshAgent> (); table = GetComponent <DropTable>(); myStats = GetComponent <EnemyStats>(); myStats.OnHealthReachedZero += Die; }
void DropLoot() { Item item = DropTable.GetDrop(); if (item != null) { PickupItem instance = Instantiate(pickupItem, transform.position, Quaternion.identity); instance.ItemDrop = item; } }
/// <summary> /// 生成删除数据表的语句 /// </summary> /// <param name="op">删除表对象</param> protected override void Generate(DropTable op) { using (var sql = this.Writer()) { sql.Write("DROP TABLE "); sql.Write(this.Quote(op.TableName)); sql.Write(";"); this.AddRun(sql); } }
void Start() { hpBar = transform.Find("HealthBar"); bar = hpBar.transform.Find("Bar"); hpBar.gameObject.SetActive(false); player = GameObject.Find("Player"); rb2d = GetComponent <Rigidbody2D>(); timeStamp = Time.time + cooldown; rb2d.freezeRotation = true; dropTable = GetComponent <DropTable>(); }
public static void Initialize() { nextPlayerGuid = CharacterTable.getNextGuid(); nextPlayerGuid++; nextItemGuid = InventoryItemTable.getNextGuid(); nextItemGuid++; nextGuildId = GuildTable.getNextGuid(); nextGuildId++; nextMountId = MountTable.getNextGuid(); nextMountId++; nextSpeakingId = SpeakingTable.getNextGuid(); nextSpeakingId++; SpellTable.Load(); ExpFloorTable.Load(); MonsterTable.Load(); ItemTemplateTable.Load(); ItemTemplateTable.LoadItemActions(); ItemSetTable.Load(); DropTable.Load(); TitleTable.Load(); IObjectTemplateTable.Load(); AreaTable.Load(); AreaSubTable.Load(); MapTable.Load(); MapTable.LoadActions(); CellActionTable.Load(); MobGroupFixTable.Load(); BreedTable.Load(); NpcTemplateTable.Load(); NpcTemplateTable.LoadPlaces(); NpcQuestionTable.Load(); NpcReplyTable.Load(); ShopNpcTable.Initialize(); GuildTable.Load(); CharactersGuildTable.Load(); TaxCollectorTable.Load(); PrismeTable.Load(); BidHouseTable.Load(); BidHouseTable.LoadItems(); MountParkTable.Load(); StaticMountTable.Load(); MountTable.Load();//TODO Dynamic load of Character mount ZaapTable.Load(); ZaapiTable.Load(); var Timer = new System.Timers.Timer(1000 * 60 * 25); Timer.Elapsed += delegate(object sender, ElapsedEventArgs e) { Save(); }; Timer.Start(); }
//Sets up basic information. void Start() { hpBar = transform.Find("HealthBar"); bar = hpBar.transform.Find("Bar"); hpBar.gameObject.SetActive(false); player = GameObject.Find("Player"); rb2d = GetComponent <Rigidbody2D>(); charging = false; rb2d.freezeRotation = true; animator = GetComponent <Animator>(); dropTable = GetComponent <DropTable>(); }
protected override void Generate(DropTable op) { base.Generate(op); if (op.PKIdentity) { this.AddRun(new SqlMigrationRun { Sql = "DROP SEQUENCE " + SequenceName(op.TableName, op.PKName) }); } }
void DropLoot() { List <Item> items = DropTable.GetEquipDrop(1); if (items != null) { foreach (Item item in items) { PickupItem instance = Instantiate(pickupItem, transform.position, Quaternion.identity); instance.ItemDrop = item; } } }
public static List <GameObject> GetDrops(DropTable dropTable, DropSourceTemplateLink context) { var drops = GetDrops(dropTable, context, ConvertTemplateToDrop); #if DEBUG Log.LogDebug($"Dropping {drops.Count} items:"); foreach (var drop in drops) { Log.LogDebug($"\t{drop}"); } #endif return(drops); }
public void RollDropTable(string nameOfDropTable, Transform positionToSpawnDrop) { DropTable tableToRoll = FindDropTable(nameOfDropTable); Drop dropToInstantiate = RollTable(tableToRoll); if (dropToInstantiate.dropGameObject != null) { GameObject drop = Instantiate(dropToInstantiate.dropGameObject, positionToSpawnDrop.position, Quaternion.Euler(Vector3.zero)); if (drop.GetComponent <Pickup>()) { drop.GetComponent <Pickup>().SetPickupValue(dropToInstantiate.amountToDrop); } } }
public string visit(DropTable ddl) { return ""; }
void Awake() { if (table == null) { table = GameObject.FindObjectOfType<DropTable>(); } }