public async Task <IActionResult> Edit(int id, [Bind("ID,Material,Shape,Color,Size_MM,Quantity,Price_Point")] Bead bead) { if (id != bead.ID) { return(NotFound()); } if (ModelState.IsValid) { try{ _context.Update(bead); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BeadExists(bead.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(bead)); }
public void OnMouseDown() { MouseDownVec = Camera.main.ScreenToWorldPoint(Input.mousePosition); MouseDownVec.z = 0f; MouseDownVec /= thisKnot.GlobalRate; //Debug.Log(MouseDownVec); if (Display.IsDrawKnotMode()) { thisKnot = ThisKnot.GetComponent <Knot>(); thisKnot.GetAllThings(); //ノード上をクリックしているかどうかをチェック DraggedNode = null; for (int n = 0; n < thisKnot.AllNodes.Length; n++) { Node thisNode = thisKnot.AllNodes[n]; float dist = (MouseDownVec - thisNode.Position).magnitude; if (dist < 0.25f) { DraggedNode = thisNode; DraggedNodeStartPosition = thisNode.Position; return; } } //ビーズ(ノード以外)をクリックしているかどうかをチェック StartFreeCurveBead = null; for (int n = 0; n < thisKnot.AllBeads.Length; n++) { //ノードを見つけたらreturn if ((MouseDownVec - thisKnot.AllBeads[n].Position).magnitude < 0.15f) { StartFreeCurve = thisKnot.AllBeads[n].Position; StartFreeCurveBead = thisKnot.AllBeads[n]; thisFreeLoop.AddPoint2FreeCurve(MouseDownVec); PreviousPosition = MouseDownVec; // ノードにスポットをつける //for(int i=0; i<thisKnot.AllNodes.Length; i++) //{ // Vector3 Pos = thisKnot.AllNodes[i].Position; // if (thisKnot.AllNodes[i].Active) // { // GameObject prefab = Resources.Load<GameObject>("Prefabs/Spot"); // GameObject obj = Instantiate<GameObject>(prefab, new Vector3(Pos.x, Pos.y, 0.1f), Quaternion.identity); // obj.transform.localScale = new Vector3(0.25f, 0.25f, 1f); // } //} return; } } // ノードやビーズ以外にマウスダウンしたとき // 新しくフリーループを認める。 FreeLoopMouseDown(); } else if (Display.IsFreeLoopMode()) { FreeLoopMouseDown(); } else if (Display.IsEditKnotMode()) { } }
public void SetNU12(Bead n1, Bead u1, Bead n2, Bead u2) { N1 = n1; U1 = u1; N2 = n2; U2 = u2; }
public async Task <IActionResult> PutBead(long id, Bead bead) { var num = _context.Beads.Where(e => e.Num == bead.Num).FirstOrDefault(); if (num == null) { if (id != bead.Id) { return(BadRequest()); } _context.Entry(bead).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BeadExists(id)) { return(NotFound()); } else { throw; } } } return(NoContent()); }
public NewBeadPage() { InitializeComponent(); Bead = new Bead { Material = "Jasper", Shape = "round", Color = "Black", Size_MM = 10, Quantity = 7, Description = "10mm round Black Jasper bead, natural stone", Price_Point = 0.1, Brand = "Bead Gallery" }; BindingContext = this; }
private void CreateBoard() { Game game = Game.Instance; int heaps = 0; int[] beadsPerHeap = null; switch (game.Difficulty) { case Difficulty.EASY: heaps = 2; beadsPerHeap = new int[] { 3, 3 }; break; case Difficulty.MEDIUM: heaps = 3; beadsPerHeap = new int[] { 2, 5, 7 }; break; case Difficulty.HARD: heaps = 4; beadsPerHeap = new int[] { 2, 3, 8, 9 }; break; } //heaps = 4; //beadsPerHeap = new int[] { 2, 3, 8, 9 }; float x = -6.5f + (1.6f * (4 - heaps)); float y = 0.0f; for (int i = 0; i < heaps; ++i) { GameObject heap = Instantiate(m_heapTemplate, new Vector3(x, y), Quaternion.identity, transform); float bX = 0.0f; float bY = 3.6f - (0.25f * (9 - beadsPerHeap[i])); float scale = 0.5f - (0.03f * (beadsPerHeap[i] - 2)); m_heaps.Add(new List <Bead>()); for (int j = 0; j < beadsPerHeap[i]; ++j) { GameObject bubble = Instantiate(m_beadTemplate, Vector3.zero, Quaternion.identity, heap.transform); bubble.GetComponentInChildren <SpriteRenderer>().transform.localScale = new Vector3(scale, scale); bubble.transform.localPosition = new Vector3(bX, bY); Bead bead = bubble.GetComponent <Bead>(); SpriteRenderer renderer = bead.GetComponentInChildren <SpriteRenderer>(); renderer.color = new Color(0.0f, 243.0f / 255.0f, 255.0f / 255.0f); bead.DeSelect(); bead.Heap = i; m_heaps[i].Add(bead); bY -= 0.8f + (0.15f * (9 - beadsPerHeap[i])); bX = Random.Range(-1.0f, 1.0f); } x += 4.3f + (1.0f * (4 - heaps)); } }
public BeadDetailPage() { InitializeComponent(); var bead = new Bead { Material = "Jasper", Shape = "round", Color = "Black", Size_MM = 10, Quantity = 7, Description = "10mm round Black Jasper bead, natural stone", Price_Point = 0.1, Brand = "Bead Gallery" }; viewModel = new BeadDetailViewModel(bead); BindingContext = viewModel; }
public byte[] GetFile(Bead file) { if (file == null) { return(new byte[0]); } else { return(file.File); } }
public async Task <IActionResult> Create([Bind("ID,Material,Shape,Color,Size_MM,Quantity,Price_Point")] Bead bead) { if (ModelState.IsValid) { _context.Add(bead); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(bead)); }
bool GetMeetPairOfNewFreeCurve(int b1, Bead b1n, Bead b1p, int b2, Bead b2n, Bead b2p, List <PairInt> meets) { float x1 = b1p.Position.x; float y1 = b1p.Position.y; float x2 = b1n.Position.x; float y2 = b1n.Position.y; float x3 = b2p.Position.x; float y3 = b2p.Position.y; float x4 = b2n.Position.x; float y4 = b2n.Position.y; // (x2-x1)s+x1 = (x4-x3)t+x3 // (y2-y1)s+y1 = (y4-y3)t+y3 // (x2-x1)s - (x4-x3)t = +x3-x1 // (y2-y1)s - (y4-y3)t = +y3-y1 float a = x2 - x1; float b = -x4 + x3; float c = y2 - y1; float d = -y4 + y3; float p = x3 - x1; float q = y3 - y1; float s1 = p * d - b * q; // s = s1/st float t1 = a * q - p * c; // t = t1/st float st = a * d - b * c; if (st < 0) { st *= -1; s1 *= -1; t1 *= -1; } if (0 < s1 && s1 < st && 0 < t1 && t1 < st) { // 線分が交わっている条件 //重複を排してListに貯める for (int mt = 0; mt < meets.Count; mt++) { int m1 = meets[mt].first; int m2 = meets[mt].second; if (b1 == m1 || b2 == m2) { //Debug.Log("(" + b1 + "," + b2 + ")=(" + m1 + "," + m2 + ")"); return(false); } if (b1n.ID == m1 || b1p.ID == m1 || b2n.ID == m2 || b2p.ID == m2) { //Debug.Log("(" + b1 + "," + b2 + ")=(" + m1 + "," + m2 + ")"); return(false); } } //Debug.Log("(" + b1 + "," + b2 + ")"); return(true); } return(false); }
public bool CanChangeMind(Bead bead) { if (bead.CurrentGuess !.IsCompleted) { return(false); } if (bead.CurrentGuess.YourBeads.Count == 0) { throw new BasicBlankException("Not Sure"); } return(true); }
public IActionResult Edit([FromBody] Bead bead) { try{ if (bead == null || !ModelState.IsValid) { return(BadRequest("Invalid State")); } ItemRepository.Update(bead); }catch (Exception) { return(BadRequest("Error while creating")); } return(NoContent()); }
public IEnumerator BD_DeSelect() { GameObject obj = Object.Instantiate(Resources.Load <GameObject>("Bubble")); Bead bead = obj.AddComponent <Bead>(); Assert.AreEqual(bead.Selected, false); bead.Select(); Assert.AreEqual(bead.Selected, true); bead.DeSelect(); Assert.AreEqual(bead.Selected, false); yield return(null); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Bead = await _context.Bead.FirstOrDefaultAsync(m => m.ID == id); if (Bead == null) { return(NotFound()); } return(Page()); }
public async Task <ActionResult <Bead> > PostBead(Bead bead) { var num = _context.Beads.Where(e => e.Num == bead.Num).FirstOrDefault(); var image = _context.Beads.Where(e => e.Image == bead.Image).FirstOrDefault(); if (num == null && image == null) { _context.Beads.Add(bead); await _context.SaveChangesAsync(); } return(CreatedAtAction("GetBead", new { id = bead.Id }, bead)); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Bead = await _context.Bead.FindAsync(id); if (Bead != null) { _context.Bead.Remove(Bead); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async System.Threading.Tasks.Task DontShoulAddAllBeadsAsync() { BeadsController controller = new BeadsController(_context); Bead bead = new Bead { ColorId = 1, BeadsTypeId = 1, Num = "1111", Image = "dsfsd" }; await controller.PostBead(bead); await controller.PostBead(bead); var query = new GetBeadsQuery(_context); var result = query.Execute(); Assert.Equal(1, result.Count); }
public void SetNU12(int RID, Bead bd) { if (RID == 0) { N1 = bd; } else if (RID == 1) { U1 = bd; } else if (RID == 2) { N2 = bd; } else if (RID == 3) { U2 = bd; } }
public int GetRID(Bead bd) { if (N1 == bd) { return(0); } if (U1 == bd) { return(1); } if (N2 == bd) { return(2); } if (U2 == bd) { return(3); } return(-1); }
public async System.Threading.Tasks.Task DontShoulPutAllBeadsAsync() { BeadsController controller = new BeadsController(_context); Bead bead = new Bead { ColorId = 1, BeadsTypeId = 1, Num = "1111", Image = "dsfsd" }; Bead bead1 = new Bead { ColorId = 1, BeadsTypeId = 1, Num = "111", Image = "dsfs" }; await controller.PostBead(bead); await controller.PostBead(bead1); Bead cbead = new Bead { Id = 2, ColorId = 1, BeadsTypeId = 1, Num = "1111", Image = "dsfs" }; await controller.PutBead(2, cbead); var query = new GetBeadsQuery(_context); var result = query.Execute(); Assert.Equal("111", result[1].Num); }
public bool CreateBead(BeadCreate model) { var entity = new Bead() { Brand = model.Brand, Type = model.Type, SubType = model.SubType, Shape = model.Shape, Size = model.Size, Color = model.Color, Quantity = model.Quantity, Cost = model.Cost, Description = model.Description, LocationId = model.LocationId, SourceId = model.SourceId, File = _FileService.ConvertToBytes(model.File), }; using (var ctx = new ApplicationDbContext()) { ctx.Beads.Add(entity); return(ctx.SaveChanges() == 1); } }
private void button4_Click_1(object sender, EventArgs e) { #region 判断输入是否合法 if (luntaiguige.Text.Trim() == "") { MessageBox.Show("输入不能为空!"); luntaiguige.Focus(); return; } if (singleheight.Text.Trim() == "") { MessageBox.Show("输入不能为空!"); singleheight.Focus(); return; } if (reduction.Text.Trim() == "") { MessageBox.Show("输入不能为空!"); reduction.Focus(); return; } if (Bead.Text.Trim() == "") { MessageBox.Show("输入不能为空!"); Bead.Focus(); return; } if (minnumber.Text.Trim() == "") { MessageBox.Show("输入不能为空!"); minnumber.Focus(); return; } if (maxheight.Text.Trim() == "") { MessageBox.Show("输入不能为空!"); maxheight.Focus(); return; } double aa; int i; if (!double.TryParse(singleheight.Text.Trim(), out aa)) { MessageBox.Show("单个高度输入的不是数字!"); singleheight.Focus(); return; } if (!double.TryParse(reduction.Text.Trim(), out aa)) { MessageBox.Show("形变量输入的不是数字!"); reduction.Focus(); return; } if (!int.TryParse(Bead.Text.Trim(), out i)) { MessageBox.Show("子口输入的不是整数!"); Bead.Focus(); return; } if (!double.TryParse(maxheight.Text.Trim(), out aa)) { MessageBox.Show("最大库位高度输入的不是数字!"); maxheight.Focus(); return; } if (!int.TryParse(minnumber.Text.Trim(), out i)) { MessageBox.Show("最小出库数量输入的不是整数!"); minnumber.Focus(); return; } #endregion if (button4.Text == "添加") { string dStr = "insert into tyremaintenance(luntaiguige,singleheight,reduction,Bead,minnumber,maxheight,jitaiid) " + "values('" + luntaiguige.Text.Trim() + "'," + singleheight.Text.Trim() + "," + reduction.Text.Trim() + "," + Bead.Text.Trim() + "," + minnumber.Text.Trim() + "," + maxheight.Text.Trim() + "," + jitaihaozhi.Text.Trim() + ");"; Utils.DatabaseUtils.ExecuteSqlCommand(dStr); } if (button4.Text == "修改") { string dStr = "update tyremaintenance set luntaiguige = '" + luntaiguige.Text.Trim() + "',singleheight = " + singleheight.Text.Trim() + ",reduction = " + reduction.Text.Trim() + ",Bead = " + Bead.Text.Trim() + ",minnumber = " + minnumber.Text.Trim() + ",maxheight =" + maxheight.Text.Trim() + ",jitaiid =" + jitaihaozhi.Text.Trim() + " where id = " + myid.ToString() + ";"; Utils.DatabaseUtils.ExecuteSqlCommand(dStr); } if (button4.Text == "删除") { DialogResult dr = MessageBox.Show("删除后数据将无法修复,是否删除?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { string dStr = "delete from tyremaintenance where id=" + myid.ToString(); Utils.DatabaseUtils.ExecuteSqlCommand(dStr); } } luntaiguige.Text = ""; singleheight.Text = ""; reduction.Text = ""; Bead.Text = ""; minnumber.Text = ""; maxheight.Text = ""; jitaihaozhi.Text = ""; string dStr1 = "select * from tyremaintenance"; DataSet myds = Utils.DatabaseUtils.GetDataSet(dStr1, "tyremaintenance"); this.dataGridView1.DataSource = myds.Tables[0]; button4.Enabled = false; }
public Bead GetBead(string id) { Bead bead = ItemRepository.Get(id); return(bead); }
public List <BaseItem> GetAllItemsInNpcBag(byte bag, int npcId) { DbParameter bagIdParameter = _db.CreateParameter(DbNames.GETALLNPCITEMSBYBAGID_BAGID_PARAMETER, bag); bagIdParameter.DbType = DbType.Byte; DbParameter characterIdParameter = _db.CreateParameter(DbNames.GETALLNPCITEMSBYBAGID_NPCID_PARAMETER, npcId); characterIdParameter.DbType = DbType.Int32; List <BaseItem> items = new List <BaseItem>(); _db.Open(); DbDataReader reader = _db.ExcecuteReader(DbNames.GETALLNPCITEMSBYBAGID_STOREDPROC, CommandType.StoredProcedure, bagIdParameter, characterIdParameter); int ordinalITEM_REFERENCEID = reader.GetOrdinal(DbNames.ITEM_REFID); int ordinalITEM_BTYPE = reader.GetOrdinal(DbNames.ITEM_BTYPE); int ordinalITEM_BKIND = reader.GetOrdinal(DbNames.ITEM_BKIND); int ordinalITEM_VISUALID = reader.GetOrdinal(DbNames.ITEM_VISUALID); int ordinalITEM_CLASS = reader.GetOrdinal(DbNames.ITEM_CLASS); int ordinalITEM_AMOUNT = reader.GetOrdinal(DbNames.ITEM_AMOUNT); int ordinalITEM_PRICE = reader.GetOrdinal(DbNames.ITEM_PRICE); int ordinalITEM_LEVEL = reader.GetOrdinal(DbNames.ITEM_LEVEL); int ordinalITEM_DEX = reader.GetOrdinal(DbNames.ITEM_DEX); int ordinalITEM_STR = reader.GetOrdinal(DbNames.ITEM_STR); int ordinalITEM_STA = reader.GetOrdinal(DbNames.ITEM_STA); int ordinalITEM_ENE = reader.GetOrdinal(DbNames.ITEM_ENE); int ordinalITEM_DURABILITY = reader.GetOrdinal(DbNames.ITEM_DURABILITY); int ordinalITEM_DAMAGE = reader.GetOrdinal(DbNames.ITEM_DAMAGE); int ordinalITEM_DEFENCE = reader.GetOrdinal(DbNames.ITEM_DEFENCE); int ordinalITEM_ATTACKRATING = reader.GetOrdinal(DbNames.ITEM_ATTACKRATING); int ordinalITEM_ATTACKSPEED = reader.GetOrdinal(DbNames.ITEM_ATTACKSPEED); int ordinalITEM_ATTACKRANGE = reader.GetOrdinal(DbNames.ITEM_ATTACKRANGE); int ordinalITEM_INCMAXLIFE = reader.GetOrdinal(DbNames.ITEM_INCMAXLIFE); int ordinalITEM_INCMAXMANA = reader.GetOrdinal(DbNames.ITEM_INCMAXMANA); int ordinalITEM_LIFEREGEN = reader.GetOrdinal(DbNames.ITEM_LIFEREGEN); int ordinalITEM_MANAREGEN = reader.GetOrdinal(DbNames.ITEM_MANAREGEN); int ordinalITEM_CRITICAL = reader.GetOrdinal(DbNames.ITEM_CRITICAL); int ordinalITEM_TOMAPID = reader.GetOrdinal(DbNames.ITEM_TOMAPID); int ordinalITEM_IMBUERATE = reader.GetOrdinal(DbNames.ITEM_IMBUERATE); int ordinalITEM_IMBUEINCREASE = reader.GetOrdinal(DbNames.ITEM_IMBUEINCREASE); int ordinalITEM_BOOKSKILLID = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLID); int ordinalITEM_BOOKSKILLLEVEL = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLLEVEL); int ordinalITEM_BOOKSKILLDATA = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLDATA); int ordinalITEM_MAXPOLISHTRIES = reader.GetOrdinal(DbNames.ITEM_MAXPOLISHTRIES); int ordinalITEM_MAXIMBUETRIES = reader.GetOrdinal(DbNames.ITEM_MAXIMBUES); int ordinalITEM_BAG = reader.GetOrdinal(DbNames.ITEM_BAG); int ordinalITEM_SLOT = reader.GetOrdinal(DbNames.ITEM_SLOT); int ordinalITEM_SIZEX = reader.GetOrdinal(DbNames.ITEM_SIZEX); int ordinalITEM_SIZEY = reader.GetOrdinal(DbNames.ITEM_SIZEY); while (reader.Read()) { BaseItem b = null; int BType = reader.GetByte(ordinalITEM_BTYPE); int BKind = reader.GetByte(ordinalITEM_BKIND); if (BType == (byte)bType.Weapon || BType == (byte)bType.Clothes || BType == (byte)bType.Hat || BType == (byte)bType.Necklace || BType == (byte)bType.Ring || BType == (byte)bType.Shoes || BType == (byte)bType.Cape) { if (BKind == (byte)bKindWeapons.Sword && BType == (byte)bType.Weapon) { b = new Sword(); } if (BKind == (byte)bKindWeapons.Blade && BType == (byte)bType.Weapon) { b = new Blade(); } if (BKind == (byte)bKindWeapons.Fan && BType == (byte)bType.Weapon) { b = new Fan(); } if (BKind == (byte)bKindWeapons.Brush && BType == (byte)bType.Weapon) { b = new Brush(); } if (BKind == (byte)bKindWeapons.Claw && BType == (byte)bType.Weapon) { b = new Claw(); } if (BKind == (byte)bKindWeapons.Axe && BType == (byte)bType.Weapon) { b = new Axe(); } if (BKind == (byte)bKindWeapons.Talon && BType == (byte)bType.Weapon) { b = new Talon(); } if (BKind == (byte)bKindWeapons.Tonfa && BType == (byte)bType.Weapon) { b = new Tonfa(); } if (BKind == (byte)bKindWeapons.Hammer && BType == (byte)bType.Weapon) { b = new Hammer(); } if (BKind == (byte)bKindArmors.SwordMan && BType == (byte)bType.Clothes) { b = new Clothes(); } if (BKind == (byte)bKindArmors.Mage && BType == (byte)bType.Clothes) { b = new Dress(); } if (BKind == (byte)bKindArmors.Warrior && BType == (byte)bType.Clothes) { b = new Armor(); } if (BKind == (byte)bKindArmors.GhostFighter && BType == (byte)bType.Clothes) { b = new LeatherClothes(); } if (BKind == (byte)bKindHats.SwordMan && BType == (byte)bType.Hat) { b = new Hood(); } if (BKind == (byte)bKindHats.Mage && BType == (byte)bType.Hat) { b = new Tiara(); } if (BKind == (byte)bKindHats.Warrior && BType == (byte)bType.Hat) { b = new Helmet(); } if (BKind == (byte)bKindHats.GhostFighter && BType == (byte)bType.Hat) { b = new Hat(); } if (BKind == (byte)bKindHats.SwordMan && BType == (byte)bType.Shoes) { b = new SmBoots(); } if (BKind == (byte)bKindHats.Mage && BType == (byte)bType.Shoes) { b = new MageBoots(); } if (BKind == (byte)bKindHats.Warrior && BType == (byte)bType.Shoes) { b = new WarriorShoes(); } if (BKind == (byte)bKindHats.GhostFighter && BType == (byte)bType.Shoes) { b = new GhostFighterShoes(); } if (BKind == 0 && BType == (byte)bType.Ring) { b = new Ring(); } if (BKind == 0 && BType == (byte)bType.Necklace) { b = new Necklace(); } if (BType == (byte)bType.Cape) { b = new Cape(); Cape c = b as Cape; c.MaxPolishImbueTries = reader.GetInt16(ordinalITEM_MAXPOLISHTRIES); } Equipment e = b as Equipment; e.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL); e.RequiredDexterity = reader.GetInt16(ordinalITEM_DEX); e.RequiredStrength = reader.GetInt16(ordinalITEM_STR); e.RequiredStamina = reader.GetInt16(ordinalITEM_STA); e.RequiredEnergy = reader.GetInt16(ordinalITEM_ENE); e.Durability = reader.GetInt32(ordinalITEM_DURABILITY); e.MaxDurability = e.Durability; e.Damage = reader.GetInt16(ordinalITEM_DAMAGE); e.Defence = reader.GetInt16(ordinalITEM_DEFENCE); e.AttackRating = reader.GetInt16(ordinalITEM_ATTACKRATING); e.AttackSpeed = reader.GetInt16(ordinalITEM_ATTACKSPEED); e.AttackRange = reader.GetInt16(ordinalITEM_ATTACKRANGE); e.IncMaxLife = reader.GetInt16(ordinalITEM_INCMAXLIFE); e.IncMaxMana = reader.GetInt16(ordinalITEM_INCMAXMANA); e.IncLifeRegen = reader.GetInt16(ordinalITEM_LIFEREGEN); e.IncManaRegen = reader.GetInt16(ordinalITEM_MANAREGEN); e.Critical = reader.GetInt16(ordinalITEM_CRITICAL); e.MaxImbueTries = reader.GetByte(ordinalITEM_MAXIMBUETRIES); } if (BType == (byte)bType.ImbueItem) { if (BKind == (byte)bKindStones.Black) { b = new Black(); } if (BKind == (byte)bKindStones.White) { b = new White(); } if (BKind == (byte)bKindStones.Red) { b = new Red(); } if (BKind == (byte)bKindStones.Dragon) { b = new Dragon(); } ImbueItem im = b as ImbueItem; im.ImbueChance = reader.GetInt16(ordinalITEM_IMBUERATE); im.IncreaseValue = reader.GetInt16(ordinalITEM_IMBUEINCREASE); } if (BType == (byte)bType.Potion) { if (BKind == (byte)bKindPotions.Normal) { b = new Potion(); } if (BKind == (byte)bKindPotions.Elixir) { b = new Elixir(); } PotionItem pot = b as PotionItem; pot.HealHp = reader.GetInt16(ordinalITEM_INCMAXLIFE); pot.HealMana = reader.GetInt16(ordinalITEM_INCMAXMANA); } if (BType == (byte)bType.Book) { if (BKind == (byte)bKindBooks.SoftBook) { b = new SoftBook(); } if (BKind == (byte)bKindBooks.HardBook) { b = new HardBook(); } BookItem book = b as BookItem; book.RequiredClass = reader.GetByte(ordinalITEM_CLASS); book.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL); book.SkillID = reader.GetInt32(ordinalITEM_BOOKSKILLID); book.SkillLevel = reader.GetByte(ordinalITEM_BOOKSKILLLEVEL); book.SkillData = reader.GetInt32(ordinalITEM_BOOKSKILLDATA); } if (BType == (byte)bType.Bead) { if (BKind == (byte)bKindBeads.Normal) { b = new Bead(); } BeadItem bead = b as BeadItem; bead.ToMapID = reader.GetInt32(ordinalITEM_TOMAPID); } b.ReferenceID = reader.GetInt16(ordinalITEM_REFERENCEID); b.VisualID = reader.GetInt16(ordinalITEM_VISUALID); b.Bag = reader.GetByte(ordinalITEM_BAG); b.Slot = reader.GetByte(ordinalITEM_SLOT); b.bType = reader.GetByte(ordinalITEM_BTYPE); b.bKind = reader.GetByte(ordinalITEM_BKIND); b.RequiredClass = reader.GetByte(ordinalITEM_CLASS); b.Amount = reader.GetInt16(ordinalITEM_AMOUNT); b.SizeX = reader.GetByte(ordinalITEM_SIZEX); b.SizeY = reader.GetByte(ordinalITEM_SIZEY); b.Price = reader.GetInt32(ordinalITEM_PRICE); items.Add(b); } reader.Close(); _db.Close(); return(items); }
public BaseItem GetItemByItemID(int itemID) { DbParameter itemIdParameter = _db.CreateParameter(DbNames.GETITEMBYITEMID_ITEMID_PARAMETER, itemID); itemIdParameter.DbType = DbType.Int32; BaseItem b = null; _db.Open(); DbDataReader reader = _db.ExcecuteReader(DbNames.GETITEMBYITEMID_STOREDPROC, CommandType.StoredProcedure, itemIdParameter); int ordinalITEM_ITEMID = reader.GetOrdinal(DbNames.ITEM_ITEMID); int ordinalITEM_OWNERID = reader.GetOrdinal(DbNames.ITEM_OWNERID); int ordinalITEM_REFERENCEID = reader.GetOrdinal(DbNames.ITEM_REFERENCEID); int ordinalITEM_BTYPE = reader.GetOrdinal(DbNames.ITEM_BTYPE); int ordinalITEM_BKIND = reader.GetOrdinal(DbNames.ITEM_BKIND); int ordinalITEM_VISUALID = reader.GetOrdinal(DbNames.ITEM_VISUALID); int ordinalITEM_COST = reader.GetOrdinal(DbNames.ITEM_COST); int ordinalITEM_CLASS = reader.GetOrdinal(DbNames.ITEM_CLASS); int ordinalITEM_AMOUNT = reader.GetOrdinal(DbNames.ITEM_AMOUNT); int ordinalITEM_LEVEL = reader.GetOrdinal(DbNames.ITEM_LEVEL); int ordinalITEM_DEX = reader.GetOrdinal(DbNames.ITEM_DEX); int ordinalITEM_STR = reader.GetOrdinal(DbNames.ITEM_STR); int ordinalITEM_STA = reader.GetOrdinal(DbNames.ITEM_STA); int ordinalITEM_ENE = reader.GetOrdinal(DbNames.ITEM_ENE); int ordinalITEM_MAXIMBUES = reader.GetOrdinal(DbNames.ITEM_MAXIMBUES); int ordinalITEM_MAXDURA = reader.GetOrdinal(DbNames.ITEM_MAXDURA); int ordinalITEM_CURDURA = reader.GetOrdinal(DbNames.ITEM_CURDURA); int ordinalITEM_DAMAGE = reader.GetOrdinal(DbNames.ITEM_DAMAGE); int ordinalITEM_DEFENCE = reader.GetOrdinal(DbNames.ITEM_DEFENCE); int ordinalITEM_ATTACKRATING = reader.GetOrdinal(DbNames.ITEM_ATTACKRATING); int ordinalITEM_ATTACKSPEED = reader.GetOrdinal(DbNames.ITEM_ATTACKSPEED); int ordinalITEM_ATTACKRANGE = reader.GetOrdinal(DbNames.ITEM_ATTACKRANGE); int ordinalITEM_INCMAXLIFE = reader.GetOrdinal(DbNames.ITEM_INCMAXLIFE); int ordinalITEM_INCMAXMANA = reader.GetOrdinal(DbNames.ITEM_INCMAXMANA); int ordinalITEM_LIFEREGEN = reader.GetOrdinal(DbNames.ITEM_LIFEREGEN); int ordinalITEM_MANAREGEN = reader.GetOrdinal(DbNames.ITEM_MANAREGEN); int ordinalITEM_CRITICAL = reader.GetOrdinal(DbNames.ITEM_CRITICAL); int ordinalITEM_PLUS = reader.GetOrdinal(DbNames.ITEM_PLUS); int ordinalITEM_SLVL = reader.GetOrdinal(DbNames.ITEM_SLVL); int ordinalITEM_IMBUETRIES = reader.GetOrdinal(DbNames.ITEM_IMBUETRIES); int ordinalITEM_DRAGONSUCCESSIMBUETRIES = reader.GetOrdinal(DbNames.ITEM_DRAGONSUCCESSIMBUETRIES); int ordinalITEM_DISCOUNTREPAIRFEE = reader.GetOrdinal(DbNames.ITEM_DISCOUNTREPAIRFEE); int ordinalITEM_TOTALDRAGONIMBUES = reader.GetOrdinal(DbNames.ITEM_TOTALDRAGONIMBUES); int ordinalITEM_DRAGONDAMAGE = reader.GetOrdinal(DbNames.ITEM_DRAGONDAMAGE); int ordinalITEM_DRAGONDEFENCE = reader.GetOrdinal(DbNames.ITEM_DRAGONDEFENCE); int ordinalITEM_DRAGONATTACKRATING = reader.GetOrdinal(DbNames.ITEM_DRAGONATTACKRATING); int ordinalITEM_DRAGONLIFE = reader.GetOrdinal(DbNames.ITEM_DRAGONLIFE); int ordinalITEM_MAPPEDSTUFF = reader.GetOrdinal(DbNames.ITEM_MAPPEDSTUFF); int ordinalITEM_FORCENUMBER = reader.GetOrdinal(DbNames.ITEM_FORCENUMBER); int ordinalITEM_REBIRTHHOLE = reader.GetOrdinal(DbNames.ITEM_REBIRTHHOLE); int ordinalITEM_REBIRTHHOLEITEM = reader.GetOrdinal(DbNames.ITEM_REBIRTHHOLEITEM); int ordinalITEM_REBIRTHHOLESTAT = reader.GetOrdinal(DbNames.ITEM_REBIRTHHOLESTAT); int ordinalITEM_TOMAPID = reader.GetOrdinal(DbNames.ITEM_TOMAPID); int ordinalITEM_IMBUERATE = reader.GetOrdinal(DbNames.ITEM_IMBUERATE); int ordinalITEM_IMBUEINCREASE = reader.GetOrdinal(DbNames.ITEM_IMBUEINCREASE); int ordinalITEM_BOOKSKILLID = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLID); int ordinalITEM_BOOKSKILLLEVEL = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLLEVEL); int ordinalITEM_BOOKSKILLDATA = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLDATA); int ordinalITEM_MAXPOLISHTRIES = reader.GetOrdinal(DbNames.ITEM_MAXPOLISHTRIES); int ordinalITEM_POLISHTRIES = reader.GetOrdinal(DbNames.ITEM_POLISHTRIES); int ordinalITEM_VIGISTAT1 = reader.GetOrdinal(DbNames.ITEM_VIGISTAT1); int ordinalITEM_VIGISTAT2 = reader.GetOrdinal(DbNames.ITEM_VIGISTAT2); int ordinalITEM_VIGISTAT3 = reader.GetOrdinal(DbNames.ITEM_VIGISTAT3); int ordinalITEM_VIGISTAT4 = reader.GetOrdinal(DbNames.ITEM_VIGISTAT4); int ordinalITEM_VIGISTATADD1 = reader.GetOrdinal(DbNames.ITEM_VIGISTATADD1); int ordinalITEM_VIGISTATADD2 = reader.GetOrdinal(DbNames.ITEM_VIGISTATADD2); int ordinalITEM_VIGISTATADD3 = reader.GetOrdinal(DbNames.ITEM_VIGISTATADD3); int ordinalITEM_VIGISTATADD4 = reader.GetOrdinal(DbNames.ITEM_VIGISTATADD4); int ordinalITEM_BAG = reader.GetOrdinal(DbNames.ITEM_BAG); int ordinalITEM_SLOT = reader.GetOrdinal(DbNames.ITEM_SLOT); int ordinalITEM_SIZEX = reader.GetOrdinal(DbNames.ITEM_SIZEX); int ordinalITEM_SIZEY = reader.GetOrdinal(DbNames.ITEM_SIZEY); while (reader.Read()) { int BType = reader.GetByte(ordinalITEM_BTYPE); int BKind = reader.GetByte(ordinalITEM_BKIND); if (BType == (byte)bType.Weapon || BType == (byte)bType.Clothes || BType == (byte)bType.Hat || BType == (byte)bType.Necklace || BType == (byte)bType.Ring || BType == (byte)bType.Shoes || BType == (byte)bType.Cape) { if (BKind == (byte)bKindWeapons.Sword && BType == (byte)bType.Weapon) { b = new Sword(); } if (BKind == (byte)bKindWeapons.Blade && BType == (byte)bType.Weapon) { b = new Blade(); } if (BKind == (byte)bKindWeapons.Fan && BType == (byte)bType.Weapon) { b = new Fan(); } if (BKind == (byte)bKindWeapons.Brush && BType == (byte)bType.Weapon) { b = new Brush(); } if (BKind == (byte)bKindWeapons.Claw && BType == (byte)bType.Weapon) { b = new Claw(); } if (BKind == (byte)bKindWeapons.Axe && BType == (byte)bType.Weapon) { b = new Axe(); } if (BKind == (byte)bKindWeapons.Talon && BType == (byte)bType.Weapon) { b = new Talon(); } if (BKind == (byte)bKindWeapons.Tonfa && BType == (byte)bType.Weapon) { b = new Tonfa(); } if (BKind == (byte)bKindArmors.SwordMan && BType == (byte)bType.Clothes) { b = new Clothes(); } if (BKind == (byte)bKindArmors.Mage && BType == (byte)bType.Clothes) { b = new Dress(); } if (BKind == (byte)bKindArmors.Warrior && BType == (byte)bType.Clothes) { b = new Armor(); } if (BKind == (byte)bKindArmors.GhostFighter && BType == (byte)bType.Clothes) { b = new LeatherClothes(); } if (BKind == (byte)bKindHats.SwordMan && BType == (byte)bType.Hat) { b = new Hood(); } if (BKind == (byte)bKindHats.Mage && BType == (byte)bType.Hat) { b = new Tiara(); } if (BKind == (byte)bKindHats.Warrior && BType == (byte)bType.Hat) { b = new Helmet(); } if (BKind == (byte)bKindHats.GhostFighter && BType == (byte)bType.Hat) { b = new Hat(); } if (BKind == (byte)bKindHats.SwordMan && BType == (byte)bType.Shoes) { b = new SmBoots(); } if (BKind == (byte)bKindHats.Mage && BType == (byte)bType.Shoes) { b = new MageBoots(); } if (BKind == (byte)bKindHats.Warrior && BType == (byte)bType.Shoes) { b = new WarriorShoes(); } if (BKind == (byte)bKindHats.GhostFighter && BType == (byte)bType.Shoes) { b = new GhostFighterShoes(); } if (BKind == 0 && BType == (byte)bType.Ring) { b = new Ring(); } if (BKind == 0 && BType == (byte)bType.Necklace) { b = new Necklace(); } if (BType == (byte)bType.Cape) { b = new Cape(); Cape c = b as Cape; c.MaxPolishImbueTries = reader.GetInt16(ordinalITEM_MAXPOLISHTRIES); c.PolishImbueTries = reader.GetByte(ordinalITEM_POLISHTRIES); c.VigiStat1 = reader.GetInt16(ordinalITEM_VIGISTAT1); c.VigiStatAdd1 = reader.GetInt16(ordinalITEM_VIGISTATADD1); c.VigiStat2 = reader.GetInt16(ordinalITEM_VIGISTAT2); c.VigiStatAdd2 = reader.GetInt16(ordinalITEM_VIGISTATADD2); c.VigiStat3 = reader.GetInt16(ordinalITEM_VIGISTAT3); c.VigiStatAdd3 = reader.GetInt16(ordinalITEM_VIGISTATADD3); c.VigiStat4 = reader.GetInt16(ordinalITEM_VIGISTAT4); c.VigiStatAdd4 = reader.GetInt16(ordinalITEM_VIGISTATADD4); } Equipment e = b as Equipment; e.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL); e.RequiredDexterity = reader.GetInt16(ordinalITEM_DEX); e.RequiredStrength = reader.GetInt16(ordinalITEM_STR); e.RequiredStamina = reader.GetInt16(ordinalITEM_STA); e.RequiredEnergy = reader.GetInt16(ordinalITEM_ENE); e.MaxImbueTries = reader.GetByte(ordinalITEM_MAXIMBUES); e.Durability = reader.GetInt16(ordinalITEM_CURDURA); e.MaxDurability = reader.GetInt16(ordinalITEM_MAXDURA); e.Damage = reader.GetInt16(ordinalITEM_DAMAGE); e.Defence = reader.GetInt16(ordinalITEM_DEFENCE); e.AttackRating = reader.GetInt16(ordinalITEM_ATTACKRATING); e.AttackSpeed = reader.GetInt16(ordinalITEM_ATTACKSPEED); e.AttackRange = reader.GetInt16(ordinalITEM_ATTACKRANGE); e.IncMaxLife = reader.GetInt16(ordinalITEM_INCMAXLIFE); e.IncMaxMana = reader.GetInt16(ordinalITEM_INCMAXMANA); e.IncLifeRegen = reader.GetInt16(ordinalITEM_LIFEREGEN); e.IncManaRegen = reader.GetInt16(ordinalITEM_MANAREGEN); e.Critical = reader.GetInt16(ordinalITEM_CRITICAL); e.Plus = reader.GetByte(ordinalITEM_PLUS); e.Slvl = reader.GetByte(ordinalITEM_SLVL); e.ImbueTries = reader.GetByte(ordinalITEM_IMBUETRIES); e.DragonSuccessImbueTries = reader.GetInt16(ordinalITEM_DRAGONSUCCESSIMBUETRIES); e.DiscountRepairFee = reader.GetByte(ordinalITEM_DISCOUNTREPAIRFEE); e.TotalDragonImbueTries = reader.GetInt16(ordinalITEM_TOTALDRAGONIMBUES); e.DragonDamage = reader.GetInt16(ordinalITEM_DRAGONDAMAGE); e.DragonDefence = reader.GetInt16(ordinalITEM_DRAGONDEFENCE); e.DragonAttackRating = reader.GetInt16(ordinalITEM_DRAGONATTACKRATING); e.DragonLife = reader.GetInt16(ordinalITEM_DRAGONLIFE); e.MappedData = reader.GetByte(ordinalITEM_MAPPEDSTUFF); e.ForceSlot = reader.GetByte(ordinalITEM_FORCENUMBER); e.RebirthHole = reader.GetByte(ordinalITEM_REBIRTHHOLE); e.RebirthHoleItem = reader.GetByte(ordinalITEM_REBIRTHHOLEITEM); e.RebirthHoleStat = reader.GetInt16(ordinalITEM_REBIRTHHOLESTAT); } if (BType == (byte)bType.ImbueItem) { if (BKind == (byte)bKindStones.Black) { b = new Black(); } if (BKind == (byte)bKindStones.White) { b = new White(); } if (BKind == (byte)bKindStones.Red) { b = new Red(); } if (BKind == (byte)bKindStones.Dragon) { b = new Dragon(); } ImbueItem im = b as ImbueItem; im.ImbueChance = reader.GetInt16(ordinalITEM_IMBUERATE); im.IncreaseValue = reader.GetInt16(ordinalITEM_IMBUEINCREASE); } if (BType == (byte)bType.Potion) { if (BKind == (byte)bKindPotions.Normal) { b = new Potion(); } if (BKind == (byte)bKindPotions.Elixir) { b = new Elixir(); } PotionItem pot = b as PotionItem; pot.HealHp = reader.GetInt16(ordinalITEM_INCMAXLIFE); pot.HealMana = reader.GetInt16(ordinalITEM_INCMAXMANA); } if (BType == (byte)bType.Book) { if (BKind == (byte)bKindBooks.SoftBook) { b = new SoftBook(); } if (BKind == (byte)bKindBooks.HardBook) { b = new HardBook(); } BookItem book = b as BookItem; book.RequiredClass = reader.GetByte(ordinalITEM_CLASS); book.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL); book.SkillID = reader.GetInt32(ordinalITEM_BOOKSKILLID); book.SkillLevel = reader.GetByte(ordinalITEM_BOOKSKILLLEVEL); book.SkillData = reader.GetInt32(ordinalITEM_BOOKSKILLDATA); } if (BType == (byte)bType.Bead) { if (BKind == (byte)bKindBeads.Normal) { b = new Bead(); } BeadItem bead = b as BeadItem; bead.ToMapID = reader.GetInt32(ordinalITEM_TOMAPID); } b.ItemID = reader.GetInt32(ordinalITEM_ITEMID); b.OwnerID = reader.GetInt32(ordinalITEM_OWNERID); b.ReferenceID = reader.GetInt16(ordinalITEM_REFERENCEID); b.VisualID = reader.GetInt16(ordinalITEM_VISUALID); b.Bag = reader.GetByte(ordinalITEM_BAG); b.Slot = reader.GetByte(ordinalITEM_SLOT); b.bType = reader.GetByte(ordinalITEM_BTYPE); b.bKind = reader.GetByte(ordinalITEM_BKIND); b.RequiredClass = reader.GetByte(ordinalITEM_CLASS); b.Amount = reader.GetInt16(ordinalITEM_AMOUNT); b.SizeX = reader.GetByte(ordinalITEM_SIZEX); b.SizeY = reader.GetByte(ordinalITEM_SIZEY); b.Price = reader.GetInt32(ordinalITEM_COST); } reader.Close(); _db.Close(); return b; }
public List<BaseItem> GetAllItemsInNpcBag(byte bag, int npcId) { DbParameter bagIdParameter = _db.CreateParameter(DbNames.GETALLNPCITEMSBYBAGID_BAGID_PARAMETER, bag); bagIdParameter.DbType = DbType.Byte; DbParameter characterIdParameter = _db.CreateParameter(DbNames.GETALLNPCITEMSBYBAGID_NPCID_PARAMETER, npcId); characterIdParameter.DbType = DbType.Int32; List<BaseItem> items = new List<BaseItem>(); _db.Open(); DbDataReader reader = _db.ExcecuteReader(DbNames.GETALLNPCITEMSBYBAGID_STOREDPROC, CommandType.StoredProcedure, bagIdParameter, characterIdParameter); int ordinalITEM_REFERENCEID = reader.GetOrdinal(DbNames.ITEM_REFID); int ordinalITEM_BTYPE = reader.GetOrdinal(DbNames.ITEM_BTYPE); int ordinalITEM_BKIND = reader.GetOrdinal(DbNames.ITEM_BKIND); int ordinalITEM_VISUALID = reader.GetOrdinal(DbNames.ITEM_VISUALID); int ordinalITEM_CLASS = reader.GetOrdinal(DbNames.ITEM_CLASS); int ordinalITEM_AMOUNT = reader.GetOrdinal(DbNames.ITEM_AMOUNT); int ordinalITEM_PRICE = reader.GetOrdinal(DbNames.ITEM_PRICE); int ordinalITEM_LEVEL = reader.GetOrdinal(DbNames.ITEM_LEVEL); int ordinalITEM_DEX = reader.GetOrdinal(DbNames.ITEM_DEX); int ordinalITEM_STR = reader.GetOrdinal(DbNames.ITEM_STR); int ordinalITEM_STA = reader.GetOrdinal(DbNames.ITEM_STA); int ordinalITEM_ENE = reader.GetOrdinal(DbNames.ITEM_ENE); int ordinalITEM_DURABILITY = reader.GetOrdinal(DbNames.ITEM_DURABILITY); int ordinalITEM_DAMAGE = reader.GetOrdinal(DbNames.ITEM_DAMAGE); int ordinalITEM_DEFENCE = reader.GetOrdinal(DbNames.ITEM_DEFENCE); int ordinalITEM_ATTACKRATING = reader.GetOrdinal(DbNames.ITEM_ATTACKRATING); int ordinalITEM_ATTACKSPEED = reader.GetOrdinal(DbNames.ITEM_ATTACKSPEED); int ordinalITEM_ATTACKRANGE = reader.GetOrdinal(DbNames.ITEM_ATTACKRANGE); int ordinalITEM_INCMAXLIFE = reader.GetOrdinal(DbNames.ITEM_INCMAXLIFE); int ordinalITEM_INCMAXMANA = reader.GetOrdinal(DbNames.ITEM_INCMAXMANA); int ordinalITEM_LIFEREGEN = reader.GetOrdinal(DbNames.ITEM_LIFEREGEN); int ordinalITEM_MANAREGEN = reader.GetOrdinal(DbNames.ITEM_MANAREGEN); int ordinalITEM_CRITICAL = reader.GetOrdinal(DbNames.ITEM_CRITICAL); int ordinalITEM_TOMAPID = reader.GetOrdinal(DbNames.ITEM_TOMAPID); int ordinalITEM_IMBUERATE = reader.GetOrdinal(DbNames.ITEM_IMBUERATE); int ordinalITEM_IMBUEINCREASE = reader.GetOrdinal(DbNames.ITEM_IMBUEINCREASE); int ordinalITEM_BOOKSKILLID = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLID); int ordinalITEM_BOOKSKILLLEVEL = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLLEVEL); int ordinalITEM_BOOKSKILLDATA = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLDATA); int ordinalITEM_MAXPOLISHTRIES = reader.GetOrdinal(DbNames.ITEM_MAXPOLISHTRIES); int ordinalITEM_MAXIMBUETRIES = reader.GetOrdinal(DbNames.ITEM_MAXIMBUES); int ordinalITEM_BAG = reader.GetOrdinal(DbNames.ITEM_BAG); int ordinalITEM_SLOT = reader.GetOrdinal(DbNames.ITEM_SLOT); int ordinalITEM_SIZEX = reader.GetOrdinal(DbNames.ITEM_SIZEX); int ordinalITEM_SIZEY = reader.GetOrdinal(DbNames.ITEM_SIZEY); while (reader.Read()) { BaseItem b = null; int BType = reader.GetByte(ordinalITEM_BTYPE); int BKind = reader.GetByte(ordinalITEM_BKIND); if (BType == (byte)bType.Weapon || BType == (byte)bType.Clothes || BType == (byte)bType.Hat || BType == (byte)bType.Necklace || BType == (byte)bType.Ring || BType == (byte)bType.Shoes || BType == (byte)bType.Cape) { if (BKind == (byte)bKindWeapons.Sword && BType == (byte)bType.Weapon) { b = new Sword(); } if (BKind == (byte)bKindWeapons.Blade && BType == (byte)bType.Weapon) { b = new Blade(); } if (BKind == (byte)bKindWeapons.Fan && BType == (byte)bType.Weapon) { b = new Fan(); } if (BKind == (byte)bKindWeapons.Brush && BType == (byte)bType.Weapon) { b = new Brush(); } if (BKind == (byte)bKindWeapons.Claw && BType == (byte)bType.Weapon) { b = new Claw(); } if (BKind == (byte)bKindWeapons.Axe && BType == (byte)bType.Weapon) { b = new Axe(); } if (BKind == (byte)bKindWeapons.Talon && BType == (byte)bType.Weapon) { b = new Talon(); } if (BKind == (byte)bKindWeapons.Tonfa && BType == (byte)bType.Weapon) { b = new Tonfa(); } if(BKind == (byte)bKindWeapons.Hammer && BType == (byte)bType.Weapon) { b = new Hammer(); } if (BKind == (byte)bKindArmors.SwordMan && BType == (byte)bType.Clothes) { b = new Clothes(); } if (BKind == (byte)bKindArmors.Mage && BType == (byte)bType.Clothes) { b = new Dress(); } if (BKind == (byte)bKindArmors.Warrior && BType == (byte)bType.Clothes) { b = new Armor(); } if (BKind == (byte)bKindArmors.GhostFighter && BType == (byte)bType.Clothes) { b = new LeatherClothes(); } if (BKind == (byte)bKindHats.SwordMan && BType == (byte)bType.Hat) { b = new Hood(); } if (BKind == (byte)bKindHats.Mage && BType == (byte)bType.Hat) { b = new Tiara(); } if (BKind == (byte)bKindHats.Warrior && BType == (byte)bType.Hat) { b = new Helmet(); } if (BKind == (byte)bKindHats.GhostFighter && BType == (byte)bType.Hat) { b = new Hat(); } if (BKind == (byte)bKindHats.SwordMan && BType == (byte)bType.Shoes) { b = new SmBoots(); } if (BKind == (byte)bKindHats.Mage && BType == (byte)bType.Shoes) { b = new MageBoots(); } if (BKind == (byte)bKindHats.Warrior && BType == (byte)bType.Shoes) { b = new WarriorShoes(); } if (BKind == (byte)bKindHats.GhostFighter && BType == (byte)bType.Shoes) { b = new GhostFighterShoes(); } if (BKind == 0 && BType == (byte)bType.Ring) { b = new Ring(); } if (BKind == 0 && BType == (byte)bType.Necklace) { b = new Necklace(); } if (BType == (byte)bType.Cape) { b = new Cape(); Cape c = b as Cape; c.MaxPolishImbueTries = reader.GetInt16(ordinalITEM_MAXPOLISHTRIES); } Equipment e = b as Equipment; e.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL); e.RequiredDexterity = reader.GetInt16(ordinalITEM_DEX); e.RequiredStrength = reader.GetInt16(ordinalITEM_STR); e.RequiredStamina = reader.GetInt16(ordinalITEM_STA); e.RequiredEnergy = reader.GetInt16(ordinalITEM_ENE); e.Durability = reader.GetInt32(ordinalITEM_DURABILITY); e.MaxDurability = e.Durability; e.Damage = reader.GetInt16(ordinalITEM_DAMAGE); e.Defence = reader.GetInt16(ordinalITEM_DEFENCE); e.AttackRating = reader.GetInt16(ordinalITEM_ATTACKRATING); e.AttackSpeed = reader.GetInt16(ordinalITEM_ATTACKSPEED); e.AttackRange = reader.GetInt16(ordinalITEM_ATTACKRANGE); e.IncMaxLife = reader.GetInt16(ordinalITEM_INCMAXLIFE); e.IncMaxMana = reader.GetInt16(ordinalITEM_INCMAXMANA); e.IncLifeRegen = reader.GetInt16(ordinalITEM_LIFEREGEN); e.IncManaRegen = reader.GetInt16(ordinalITEM_MANAREGEN); e.Critical = reader.GetInt16(ordinalITEM_CRITICAL); e.MaxImbueTries = reader.GetByte(ordinalITEM_MAXIMBUETRIES); } if (BType == (byte)bType.ImbueItem) { if (BKind == (byte)bKindStones.Black) { b = new Black(); } if (BKind == (byte)bKindStones.White) { b = new White(); } if (BKind == (byte)bKindStones.Red) { b = new Red(); } if (BKind == (byte)bKindStones.Dragon) { b = new Dragon(); } ImbueItem im = b as ImbueItem; im.ImbueChance = reader.GetInt16(ordinalITEM_IMBUERATE); im.IncreaseValue = reader.GetInt16(ordinalITEM_IMBUEINCREASE); } if (BType == (byte)bType.Potion) { if (BKind == (byte)bKindPotions.Normal) { b = new Potion(); } if (BKind == (byte)bKindPotions.Elixir) { b = new Elixir(); } PotionItem pot = b as PotionItem; pot.HealHp = reader.GetInt16(ordinalITEM_INCMAXLIFE); pot.HealMana = reader.GetInt16(ordinalITEM_INCMAXMANA); } if (BType == (byte)bType.Book) { if (BKind == (byte)bKindBooks.SoftBook) { b = new SoftBook(); } if (BKind == (byte)bKindBooks.HardBook) { b = new HardBook(); } BookItem book = b as BookItem; book.RequiredClass = reader.GetByte(ordinalITEM_CLASS); book.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL); book.SkillID = reader.GetInt32(ordinalITEM_BOOKSKILLID); book.SkillLevel = reader.GetByte(ordinalITEM_BOOKSKILLLEVEL); book.SkillData = reader.GetInt32(ordinalITEM_BOOKSKILLDATA); } if (BType == (byte)bType.Bead) { if (BKind == (byte)bKindBeads.Normal) { b = new Bead(); } BeadItem bead = b as BeadItem; bead.ToMapID = reader.GetInt32(ordinalITEM_TOMAPID); } b.ReferenceID = reader.GetInt16(ordinalITEM_REFERENCEID); b.VisualID = reader.GetInt16(ordinalITEM_VISUALID); b.Bag = reader.GetByte(ordinalITEM_BAG); b.Slot = reader.GetByte(ordinalITEM_SLOT); b.bType = reader.GetByte(ordinalITEM_BTYPE); b.bKind = reader.GetByte(ordinalITEM_BKIND); b.RequiredClass = reader.GetByte(ordinalITEM_CLASS); b.Amount = reader.GetInt16(ordinalITEM_AMOUNT); b.SizeX = reader.GetByte(ordinalITEM_SIZEX); b.SizeY = reader.GetByte(ordinalITEM_SIZEY); b.Price = reader.GetInt32(ordinalITEM_PRICE); items.Add(b); } reader.Close(); _db.Close(); return items; }
public static void ScoreBead(Bead b, float accuracy) { if(accuracy > singleton.accuracyCutoff) { singleton.Combo++; singleton.maxCombo = (int) Mathf.Max(singleton.maxCombo, singleton.Combo); singleton.Score += singleton.Combo; } else { singleton.Combo = 0f; } }
public BaseItem GetRebirthPillDrop(Monster m) { DbParameter levelParameter = _db.CreateParameter(DbNames.GETPILLDROPITEM_LEVEL_PARAMETER, m.Level); levelParameter.DbType = DbType.Int32; List<BaseItem> items = new List<BaseItem>(); _db.Open(); DbDataReader reader = _db.ExcecuteReader(DbNames.GETPILLDROPITEM_STOREDPROC, CommandType.StoredProcedure, levelParameter); int ordinalITEM_REFERENCEID = reader.GetOrdinal(DbNames.ITEM_REFERENCEID); int ordinalITEM_BTYPE = reader.GetOrdinal(DbNames.ITEM_BTYPE); int ordinalITEM_BKIND = reader.GetOrdinal(DbNames.ITEM_BKIND); int ordinalITEM_VISUALID = reader.GetOrdinal(DbNames.ITEM_VISUALID); int ordinalITEM_COST = reader.GetOrdinal(DbNames.ITEM_COST); int ordinalITEM_CLASS = reader.GetOrdinal(DbNames.ITEM_CLASS); int ordinalITEM_LEVEL = reader.GetOrdinal(DbNames.ITEM_LEVEL); int ordinalITEM_DEX = reader.GetOrdinal(DbNames.ITEM_DEX); int ordinalITEM_STR = reader.GetOrdinal(DbNames.ITEM_STR); int ordinalITEM_STA = reader.GetOrdinal(DbNames.ITEM_STA); int ordinalITEM_ENE = reader.GetOrdinal(DbNames.ITEM_ENE); int ordinalITEM_MAXIMBUES = reader.GetOrdinal(DbNames.ITEM_MAXIMBUES); int ordinalITEM_MAXDURA = reader.GetOrdinal(DbNames.DROPITEM_DURABILITY); int ordinalITEM_DAMAGE = reader.GetOrdinal(DbNames.ITEM_DAMAGE); int ordinalITEM_DEFENCE = reader.GetOrdinal(DbNames.ITEM_DEFENCE); int ordinalITEM_ATTACKRATING = reader.GetOrdinal(DbNames.ITEM_ATTACKRATING); int ordinalITEM_ATTACKSPEED = reader.GetOrdinal(DbNames.ITEM_ATTACKSPEED); int ordinalITEM_ATTACKRANGE = reader.GetOrdinal(DbNames.ITEM_ATTACKRANGE); int ordinalITEM_INCMAXLIFE = reader.GetOrdinal(DbNames.ITEM_INCMAXLIFE); int ordinalITEM_INCMAXMANA = reader.GetOrdinal(DbNames.ITEM_INCMAXMANA); int ordinalITEM_LIFEREGEN = reader.GetOrdinal(DbNames.ITEM_LIFEREGEN); int ordinalITEM_MANAREGEN = reader.GetOrdinal(DbNames.ITEM_MANAREGEN); int ordinalITEM_CRITICAL = reader.GetOrdinal(DbNames.ITEM_CRITICAL); int ordinalITEM_TOMAPID = reader.GetOrdinal(DbNames.ITEM_TOMAPID); int ordinalITEM_IMBUERATE = reader.GetOrdinal(DbNames.ITEM_IMBUERATE); int ordinalITEM_IMBUEINCREASE = reader.GetOrdinal(DbNames.ITEM_IMBUEINCREASE); int ordinalITEM_BOOKSKILLID = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLID); int ordinalITEM_BOOKSKILLLEVEL = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLLEVEL); int ordinalITEM_BOOKSKILLDATA = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLDATA); int ordinalITEM_MAXPOLISHTRIES = reader.GetOrdinal(DbNames.ITEM_MAXPOLISHTRIES); int ordinalITEM_POLISHTRIES = reader.GetOrdinal(DbNames.ITEM_POLISHTRIES); int ordinalITEM_SIZEX = reader.GetOrdinal(DbNames.ITEM_SIZEX); int ordinalITEM_SIZEY = reader.GetOrdinal(DbNames.ITEM_SIZEY); while (reader.Read()) { BaseItem b = null; int BType = reader.GetByte(ordinalITEM_BTYPE); int BKind = reader.GetByte(ordinalITEM_BKIND); if (BType == (byte)bType.Weapon || BType == (byte)bType.Clothes || BType == (byte)bType.Hat || BType == (byte)bType.Necklace || BType == (byte)bType.Ring || BType == (byte)bType.Shoes || BType == (byte)bType.Cape) { if (BKind == (byte)bKindWeapons.Sword && BType == (byte)bType.Weapon) { b = new Sword(); } if (BKind == (byte)bKindWeapons.Blade && BType == (byte)bType.Weapon) { b = new Blade(); } if (BKind == (byte)bKindWeapons.Fan && BType == (byte)bType.Weapon) { b = new Fan(); } if (BKind == (byte)bKindWeapons.Brush && BType == (byte)bType.Weapon) { b = new Brush(); } if (BKind == (byte)bKindWeapons.Claw && BType == (byte)bType.Weapon) { b = new Claw(); } if (BKind == (byte)bKindWeapons.Axe && BType == (byte)bType.Weapon) { b = new Axe(); } if (BKind == (byte)bKindWeapons.Talon && BType == (byte)bType.Weapon) { b = new Talon(); } if (BKind == (byte)bKindWeapons.Tonfa && BType == (byte)bType.Weapon) { b = new Tonfa(); } if (BKind == (byte)bKindArmors.SwordMan && BType == (byte)bType.Clothes) { b = new Clothes(); } if (BKind == (byte)bKindArmors.Mage && BType == (byte)bType.Clothes) { b = new Dress(); } if (BKind == (byte)bKindArmors.Warrior && BType == (byte)bType.Clothes) { b = new Armor(); } if (BKind == (byte)bKindArmors.GhostFighter && BType == (byte)bType.Clothes) { b = new LeatherClothes(); } if (BKind == (byte)bKindHats.SwordMan && BType == (byte)bType.Hat) { b = new Hood(); } if (BKind == (byte)bKindHats.Mage && BType == (byte)bType.Hat) { b = new Tiara(); } if (BKind == (byte)bKindHats.Warrior && BType == (byte)bType.Hat) { b = new Helmet(); } if (BKind == (byte)bKindHats.GhostFighter && BType == (byte)bType.Hat) { b = new Hat(); } if (BKind == (byte)bKindHats.SwordMan && BType == (byte)bType.Shoes) { b = new SmBoots(); } if (BKind == (byte)bKindHats.Mage && BType == (byte)bType.Shoes) { b = new MageBoots(); } if (BKind == (byte)bKindHats.Warrior && BType == (byte)bType.Shoes) { b = new WarriorShoes(); } if (BKind == (byte)bKindHats.GhostFighter && BType == (byte)bType.Shoes) { b = new GhostFighterShoes(); } if (BKind == 0 && BType == (byte)bType.Ring) { b = new Ring(); } if (BKind == 0 && BType == (byte)bType.Necklace) { b = new Necklace(); } if (BType == (byte)bType.Cape) { b = new Cape(); Cape c = b as Cape; c.MaxPolishImbueTries = reader.GetInt16(ordinalITEM_MAXPOLISHTRIES); c.PolishImbueTries = reader.GetByte(ordinalITEM_POLISHTRIES); } Equipment e = b as Equipment; e.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL); e.RequiredDexterity = reader.GetInt16(ordinalITEM_DEX); e.RequiredStrength = reader.GetInt16(ordinalITEM_STR); e.RequiredStamina = reader.GetInt16(ordinalITEM_STA); e.RequiredEnergy = reader.GetInt16(ordinalITEM_ENE); e.MaxImbueTries = reader.GetByte(ordinalITEM_MAXIMBUES); e.Durability = reader.GetInt32(ordinalITEM_MAXDURA); e.MaxDurability = reader.GetInt32(ordinalITEM_MAXDURA); e.Damage = reader.GetInt32(ordinalITEM_DAMAGE); e.Defence = reader.GetInt32(ordinalITEM_DEFENCE); e.AttackRating = reader.GetInt32(ordinalITEM_ATTACKRATING); e.AttackSpeed = reader.GetInt16(ordinalITEM_ATTACKSPEED); e.AttackRange = reader.GetInt16(ordinalITEM_ATTACKRANGE); e.IncMaxLife = reader.GetInt16(ordinalITEM_INCMAXLIFE); e.IncMaxMana = reader.GetInt16(ordinalITEM_INCMAXMANA); e.IncLifeRegen = reader.GetInt16(ordinalITEM_LIFEREGEN); e.IncManaRegen = reader.GetInt16(ordinalITEM_MANAREGEN); e.Critical = reader.GetInt16(ordinalITEM_CRITICAL); } if (BType == (byte)bType.ImbueItem) { if (BKind == (byte)bKindStones.Black) { b = new Black(); } if (BKind == (byte)bKindStones.White) { b = new White(); } if (BKind == (byte)bKindStones.Red) { b = new Red(); } if (BKind == (byte)bKindStones.Dragon) { b = new Dragon(); } if (BKind == (byte)bKindStones.RbItem) { b = new RbHoleItem(); } ImbueItem im = b as ImbueItem; im.ImbueChance = reader.GetInt16(ordinalITEM_IMBUERATE); im.IncreaseValue = reader.GetInt16(ordinalITEM_IMBUEINCREASE); } if (BType == (byte)bType.Potion) { if (BKind == (byte)bKindPotions.Normal) { b = new Potion(); } if (BKind == (byte)bKindPotions.Elixir) { b = new Elixir(); } PotionItem pot = b as PotionItem; pot.HealHp = reader.GetInt16(ordinalITEM_INCMAXLIFE); pot.HealMana = reader.GetInt16(ordinalITEM_INCMAXMANA); } if (BType == (byte)bType.Book) { if (BKind == (byte)bKindBooks.SoftBook) { b = new SoftBook(); } if (BKind == (byte)bKindBooks.HardBook) { b = new HardBook(); } if (BKind == (byte)bKindBooks.RebirdBook) { b = new RebirthBook(); } if (BKind == (byte)bKindBooks.FourthBook) { b = new FourthBook(); } if (BKind == (byte)bKindBooks.FeSkillBook) { b = new FeSkillBook(); } if (BKind == (byte)bKindBooks.FeBook) { b = new FiveElementBook(); } if (BKind == (byte)bKindBooks.FocusBook) { b = new FocusBook(); } BookItem book = b as BookItem; book.RequiredClass = reader.GetByte(ordinalITEM_CLASS); book.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL); book.SkillID = reader.GetInt32(ordinalITEM_BOOKSKILLID); book.SkillLevel = reader.GetByte(ordinalITEM_BOOKSKILLLEVEL); book.SkillData = reader.GetInt32(ordinalITEM_BOOKSKILLDATA); } if (BType == (byte)bType.Bead) { if (BKind == (byte)bKindBeads.Normal) { b = new Bead(); } BeadItem bead = b as BeadItem; bead.ToMapID = reader.GetInt32(ordinalITEM_TOMAPID); } if (BType == (byte)bType.StoreTag) { b = new StoreTag(); StoreTag tag = b as StoreTag; tag.TimeLeft = reader.GetInt16(ordinalITEM_MAXDURA); tag.TimeMax = reader.GetInt16(ordinalITEM_MAXDURA); } if (BType == (byte)bType.PetItem) { if (BKind == (byte)bKindPetItems.Taming) b = new TameItem(); if (BKind == (byte)bKindPetItems.Food) b = new PetFood(); if (BKind == (byte)bKindPetItems.Potion) b = new PetPotion(); if (BKind == (byte)bKindPetItems.Resurect) b = new PetResurrectItem(); PetItem p = b as PetItem; p.TameChance = reader.GetInt16(ordinalITEM_IMBUERATE); p.DecreaseWildness = reader.GetInt16(ordinalITEM_IMBUEINCREASE); p.HealLife = reader.GetInt16(ordinalITEM_INCMAXLIFE); } if (BType == (byte)bType.Pill) { if (BKind == (byte)bKindPills.Rebirth) b = new RebirthPill(); RebirthPill p = b as RebirthPill; p.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL); p.RequiredRebirth = reader.GetByte(ordinalITEM_CLASS); p.ToRebirth = (byte)(p.RequiredRebirth + 1); p.IncreaseSp = reader.GetInt16(ordinalITEM_DEX); } b.ItemID = 0; b.OwnerID = 0; b.ReferenceID = reader.GetInt16(ordinalITEM_REFERENCEID); b.VisualID = reader.GetInt16(ordinalITEM_VISUALID); b.Bag = 0; b.Slot = 0; b.bType = reader.GetByte(ordinalITEM_BTYPE); b.bKind = reader.GetByte(ordinalITEM_BKIND); b.RequiredClass = reader.GetByte(ordinalITEM_CLASS); b.Amount = 1; b.SizeX = reader.GetByte(ordinalITEM_SIZEX); b.SizeY = reader.GetByte(ordinalITEM_SIZEY); b.Price = reader.GetInt32(ordinalITEM_COST); items.Add(b); } reader.Close(); _db.Close(); if (items.Count > 0) { Random rand = new Random(); int itemPos = rand.Next(0, items.Count); return items[itemPos]; } else return null; }
void OutputData() { int nodeNumber = nodes.Count; thisKnot.ClearAll(); for (int n = 0; n < nodeNumber; n++) { DNode nn = nodes[n]; if (n % 5 == 0) { // ジョイント Node nd = thisKnot.AddNode(new Vector3((nn.x - 400f) * 0.01f, (nn.y - 400f) * 0.01f), n); // ID = n Bead bd = thisKnot.AddBead(new Vector3((nn.x - 400f) * 0.01f, (nn.y - 400f) * 0.01f), n); // ID = n if (nn.ou) { nd.Theta = Mathf.Atan2(nodes[n + 1].y - nodes[n].y, nodes[n + 1].x - nodes[n].x); } else { nd.Theta = Mathf.Atan2(nodes[n + 2].y - nodes[n].y, nodes[n + 1].x - nodes[n].x); } nd.R[0] = nd.R[1] = nd.R[2] = nd.R[3] = 0.1f; nd.ID = n; nd.Joint = true; nd.MidJoint = false; bd.NumOfNbhd = 4; //あとで設定 bd.N1 = bd.N2 = null; //あとで設定 bd.U1 = bd.U2 = null; //あとで設定 bd.ID = n; bd.Joint = true; bd.MidJoint = false; nd.ThisBead = bd; } else { //非ジョイント Bead bd = thisKnot.AddBead(new Vector3((nn.x - 400f) * 0.01f, (nn.y - 400f) * 0.01f), n); // ID = n bd.NumOfNbhd = 2; //あとで設定 bd.N1 = bd.N2 = null; //あとで設定 bd.U1 = bd.U2 = null; //あとで設定 bd.ID = n; bd.Joint = false; bd.MidJoint = false; } } int BeadLastID = thisKnot.GetMaxIDOfBead(); // edges int A = -1, AR = -1, B = -1, BR = -1; for (int e = 0; e < edges.Count; e++) { DEdge ee = edges[e]; if (ee.visible) { A = AR = B = BR = -1; if (ee.s % 5 != 0 && ee.t % 5 != 0) { for (int es = 0; es < edges.Count; es++) { DEdge ees = edges[es]; // ee.sからたどれるジョイントを見つける if (ees.visible && ees.s % 5 == 0 && ees.t == ee.s) { int s0 = ees.s; float aX = nodes[s0 + 2].x - nodes[s0 + 1].x; float aY = nodes[s0 + 2].y - nodes[s0 + 1].y; float bX = nodes[s0 + 4].x - nodes[s0 + 1].x; float bY = nodes[s0 + 4].y - nodes[s0 + 1].y; float orientation = aX * bY - aY * bX; int t = ees.t - ees.s; if (orientation > 0) { if (nodes[ees.s].ou) { t = (t + 7) % 4; } else { t = (t + 6) % 4; } } else { if (nodes[ees.s].ou) { t = (5 - t) % 4; } else { t = (6 - t) % 4; } } A = ees.s;// ee.sからたどれるジョイント AR = t; } // ee.tからたどれるジョイント if (ees.visible && ees.s % 5 == 0 && ees.t == ee.t) { int s0 = ees.s; float aX = nodes[s0 + 2].x - nodes[s0 + 1].x; float aY = nodes[s0 + 2].y - nodes[s0 + 1].y; float bX = nodes[s0 + 4].x - nodes[s0 + 1].x; float bY = nodes[s0 + 4].y - nodes[s0 + 1].y; float orientation = aX * bY - aY * bX; int t = ees.t - ees.s; if (orientation > 0) { if (nodes[ees.s].ou) { t = (t + 7) % 4; } else { t = (t + 6) % 4; } } else { if (nodes[ees.s].ou) { t = (5 - t) % 4; } else { t = (6 - t) % 4; } } B = ees.s;// ee.tからたどれるジョイント BR = t; } } //// Edge ed = thisKnot.AddEdge(A, B, AR, BR, e); // iD = e (連番に限らない。) Bead bdJointA = thisKnot.GetBeadByID(A); Bead bdAR = thisKnot.GetBeadByID(ee.s); Bead bdBR = thisKnot.GetBeadByID(ee.t); Bead bdJointB = thisKnot.GetBeadByID(B); if (bdJointA == null || bdAR == null || bdBR == null || bdJointB == null) { continue; } bdJointA.SetNU12(AR, bdAR); bdAR.N1 = bdJointA; bdAR.N2 = bdBR; bdBR.N1 = bdJointB; bdBR.N2 = bdAR; bdJointB.SetNU12(BR, bdBR); } } } thisKnot.GetAllThings(); thisKnot.Modify(); // NodeEdgeからBeadsを整える thisKnot.UpdateBeads(); //グラフの形を整える。現状ではR[]を整えるだけ。 thisKnot.Modify(); Display.SetDrawKnotMode();// drawモードの変更 }
public void Constructor_UsingInvalidSymbol_ThrowsException( [ValueSource(typeof(SymbolGenerator), "GetNullEmptyAndWhitespaceStrings")] string nullEmptyOrWhitespaceString) { Bead bead = new Bead(nullEmptyOrWhitespaceString); }
/// <summary> /// Once per frame: /// Rotate to the correct angle. /// </summary> void Update() { if (musicManager.IsBeat) { if ((NeedsReversing)) { speed = -speed; NeedsReversing = false; } } //Increment the local time by the current speed time += speed * musicManager.DeltaTime; transform.rotation = Quaternion.Euler(0, 0, (360 / beadList.Count) * (time)); //Calculate how close to the beat this frame is. frameAccuracy = musicManager.Accuracy;// Mathf.Abs(time % 1); //Set Next Bead//////////////////////////////////////////////////////////////////////////////////////// Bead nextBead; int nextBeadIndex = 0; if (!musicManager.IsBeat) { if (speed > 0) nextBeadIndex = (int)(time + 1) % beadList.Count; else nextBeadIndex = (int)(time) % beadList.Count; } foreach (Bead b in beadList) { if (b) b.IsNext = false; } nextBead = beadList[nextBeadIndex]; if (nextBead) nextBead.IsNext = true; nextBead = beadList[nextBeadIndex]; if (nextBead) { Vector3 targetPosNoZ = new Vector3(targetPos.x, targetPos.y, nextBead.transform.position.z); if (Mathf.Abs(Vector3.Distance(nextBead.transform.position, targetPosNoZ)) < 0.3f) { nextBead.OnBeat(); rend.material.color = Random.ColorHSV(0, 1, .5f, 1f, .5f, 1f); } } //End Set Next Bead//////////////////////////////////////////////////////////////////////////////////////////// //Set Current Bead///////////////////////////////////////////////////////////////////////////////////////////// float closestDistance = 99999.9f; Bead lastCurrentBead = currentBead; for (int i = 0; i < beadList.Count; i++) { Vector3 pos = transform.TransformPoint(calculateBeadPosition(i)); if (Mathf.Abs(Vector3.Distance(pos, targetPos)) < closestDistance) { transform.TransformPoint(calculateBeadPosition(i)); closestDistance = Mathf.Abs(Vector3.Distance(pos, targetPos)); currentBead = beadList[i]; currentBeadIndex = i; } } if(lastCurrentBead != currentBead) { if (!beadHit && nextBead == currentBead) { if (lastCurrentBead != null) lastCurrentBead.OnMiss(); } beadHit = false; } //End Set Current Bead/////////////////////////////////////////////////////////////////////////////////////////// frameAccuracy = 2 * Mathf.Abs(.5f - frameAccuracy); //Debug code to adjust color based on the beat rend.material.color = Color.Lerp(rend.material.color, Color.white, Time.deltaTime * 1f); lastBead = currentBeadIndex; if (needNewBead >= 0) { tryAddBead(); } //Reposition the beads. RecalculateBeadPositions(); }
/// <summary> /// left button dragged /// </summary> public void OnMouseDrag() { MouseDragVec = Camera.main.ScreenToWorldPoint(Input.mousePosition); MouseDragVec.z = 0f; MouseDragVec /= thisKnot.GlobalRate; if (Display.IsDrawKnotMode())//通常モードドラッグ中 { //ノードをドラッグしているとき if (DraggedNode != null) { NodeDragging(); } //通常モードでフリーカーブを描いているとき else if (StartFreeCurveBead != null) { float dist = (PreviousPosition - MouseDragVec).magnitude; if (dist > 0.1f) {//少し進んだら点を追加。 int divisionNumber = Mathf.CeilToInt(dist / 0.1f); for (int repeat = 1; repeat <= divisionNumber; repeat++) { float ratio = 1f * repeat / divisionNumber; thisFreeLoop.AddPoint2FreeCurve(PreviousPosition * (1f - ratio) + MouseDragVec * ratio); } PreviousPosition = MouseDragVec; //ジョイントノードの近くを通り過ぎたら、フリーカーブをやめる。 for (int i = 0; i < thisKnot.AllNodes.Length; i++) { Vector3 Pos = thisKnot.AllNodes[i].Position; if (thisKnot.AllNodes[i].Active) { if ((MouseDragVec - Pos).magnitude < 0.25f) {//フリーカーブをやめる。 thisFreeLoop.FreeCurve.Clear(); // スポットを消去する //Spot[] NodeSpots = FindObjectsOfType<Spot>(); //for (int j = 0; j < NodeSpots.Length; j++) //{ // Destroy(NodeSpots[j].gameObject); //} StartFreeCurveBead = null; } } } } } else if (StartFreeLoop) {// 通常モードでフリーループを追加しているとき FreeLoopDragging(); //ジョイントノードの近くを通り過ぎたら、フリーカーブをやめる。 for (int i = 0; i < thisKnot.AllNodes.Length; i++) { Vector3 Pos = thisKnot.AllNodes[i].Position; if (thisKnot.AllNodes[i].Active) { if ((MouseDragVec - Pos).magnitude < 0.25f) {//フリーカーブをやめる。 thisFreeLoop.FreeCurve.Clear(); // スポットを消去する //Spot[] NodeSpots = FindObjectsOfType<Spot>(); //for (int j = 0; j < NodeSpots.Length; j++) //{ // Destroy(NodeSpots[j].gameObject); //} StartFreeLoop = false; } } } } } else if (Display.IsFreeLoopMode())//フリーループモード、ドラッグ中 { FreeLoopDragging(); } else if (Display.IsEditKnotMode()) { } }
public List<BaseItem> GetAllItemsInBag(byte bag, int characterId) { DbParameter bagIdParameter = _db.CreateParameter(DbNames.GETALLITEMSBYBAGID_BAGID_PARAMETER, bag); bagIdParameter.DbType = DbType.Byte; DbParameter characterIdParameter = _db.CreateParameter(DbNames.GETALLITEMSBYBAGID_CHARACTERID_PARAMETER, characterId); characterIdParameter.DbType = DbType.Int32; List<BaseItem> items = new List<BaseItem>(); _db.Open(); DbDataReader reader = _db.ExcecuteReader(DbNames.GETALLITEMSBYBAGID_STOREDPROC, CommandType.StoredProcedure, bagIdParameter, characterIdParameter); int ordinalITEM_ITEMID = reader.GetOrdinal(DbNames.ITEM_ITEMID); int ordinalITEM_OWNERID = reader.GetOrdinal(DbNames.ITEM_OWNERID); int ordinalITEM_REFERENCEID = reader.GetOrdinal(DbNames.ITEM_REFERENCEID); int ordinalITEM_BTYPE = reader.GetOrdinal(DbNames.ITEM_BTYPE); int ordinalITEM_BKIND = reader.GetOrdinal(DbNames.ITEM_BKIND); int ordinalITEM_VISUALID = reader.GetOrdinal(DbNames.ITEM_VISUALID); int ordinalITEM_COST = reader.GetOrdinal(DbNames.ITEM_COST); int ordinalITEM_CLASS = reader.GetOrdinal(DbNames.ITEM_CLASS); int ordinalITEM_AMOUNT = reader.GetOrdinal(DbNames.ITEM_AMOUNT); int ordinalITEM_LEVEL = reader.GetOrdinal(DbNames.ITEM_LEVEL); int ordinalITEM_DEX = reader.GetOrdinal(DbNames.ITEM_DEX); int ordinalITEM_STR = reader.GetOrdinal(DbNames.ITEM_STR); int ordinalITEM_STA = reader.GetOrdinal(DbNames.ITEM_STA); int ordinalITEM_ENE = reader.GetOrdinal(DbNames.ITEM_ENE); int ordinalITEM_MAXIMBUES = reader.GetOrdinal(DbNames.ITEM_MAXIMBUES); int ordinalITEM_MAXDURA = reader.GetOrdinal(DbNames.ITEM_MAXDURA); int ordinalITEM_CURDURA = reader.GetOrdinal(DbNames.ITEM_CURDURA); int ordinalITEM_DAMAGE = reader.GetOrdinal(DbNames.ITEM_DAMAGE); int ordinalITEM_DEFENCE = reader.GetOrdinal(DbNames.ITEM_DEFENCE); int ordinalITEM_ATTACKRATING = reader.GetOrdinal(DbNames.ITEM_ATTACKRATING); int ordinalITEM_ATTACKSPEED = reader.GetOrdinal(DbNames.ITEM_ATTACKSPEED); int ordinalITEM_ATTACKRANGE = reader.GetOrdinal(DbNames.ITEM_ATTACKRANGE); int ordinalITEM_INCMAXLIFE = reader.GetOrdinal(DbNames.ITEM_INCMAXLIFE); int ordinalITEM_INCMAXMANA = reader.GetOrdinal(DbNames.ITEM_INCMAXMANA); int ordinalITEM_LIFEREGEN = reader.GetOrdinal(DbNames.ITEM_LIFEREGEN); int ordinalITEM_MANAREGEN = reader.GetOrdinal(DbNames.ITEM_MANAREGEN); int ordinalITEM_CRITICAL = reader.GetOrdinal(DbNames.ITEM_CRITICAL); int ordinalITEM_PLUS = reader.GetOrdinal(DbNames.ITEM_PLUS); int ordinalITEM_SLVL = reader.GetOrdinal(DbNames.ITEM_SLVL); int ordinalITEM_IMBUETRIES = reader.GetOrdinal(DbNames.ITEM_IMBUETRIES); int ordinalITEM_DRAGONSUCCESSIMBUETRIES = reader.GetOrdinal(DbNames.ITEM_DRAGONSUCCESSIMBUETRIES); int ordinalITEM_DISCOUNTREPAIRFEE = reader.GetOrdinal(DbNames.ITEM_DISCOUNTREPAIRFEE); int ordinalITEM_TOTALDRAGONIMBUES = reader.GetOrdinal(DbNames.ITEM_TOTALDRAGONIMBUES); int ordinalITEM_DRAGONDAMAGE = reader.GetOrdinal(DbNames.ITEM_DRAGONDAMAGE); int ordinalITEM_DRAGONDEFENCE = reader.GetOrdinal(DbNames.ITEM_DRAGONDEFENCE); int ordinalITEM_DRAGONATTACKRATING = reader.GetOrdinal(DbNames.ITEM_DRAGONATTACKRATING); int ordinalITEM_DRAGONLIFE = reader.GetOrdinal(DbNames.ITEM_DRAGONLIFE); int ordinalITEM_MAPPEDSTUFF = reader.GetOrdinal(DbNames.ITEM_MAPPEDSTUFF); int ordinalITEM_FORCENUMBER = reader.GetOrdinal(DbNames.ITEM_FORCENUMBER); int ordinalITEM_REBIRTHHOLE = reader.GetOrdinal(DbNames.ITEM_REBIRTHHOLE); int ordinalITEM_REBIRTHHOLESTAT = reader.GetOrdinal(DbNames.ITEM_REBIRTHHOLESTAT); int ordinalITEM_TOMAPID = reader.GetOrdinal(DbNames.ITEM_TOMAPID); int ordinalITEM_IMBUERATE = reader.GetOrdinal(DbNames.ITEM_IMBUERATE); int ordinalITEM_IMBUEINCREASE = reader.GetOrdinal(DbNames.ITEM_IMBUEINCREASE); int ordinalITEM_IMBUEDATA = reader.GetOrdinal(DbNames.ITEM_IMBUEDATA); int ordinalITEM_BOOKSKILLID = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLID); int ordinalITEM_BOOKSKILLLEVEL = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLLEVEL); int ordinalITEM_BOOKSKILLDATA = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLDATA); int ordinalITEM_MAXPOLISHTRIES = reader.GetOrdinal(DbNames.ITEM_MAXPOLISHTRIES); int ordinalITEM_POLISHTRIES = reader.GetOrdinal(DbNames.ITEM_POLISHTRIES); int ordinalITEM_VIGISTAT1 = reader.GetOrdinal(DbNames.ITEM_VIGISTAT1); int ordinalITEM_VIGISTAT2 = reader.GetOrdinal(DbNames.ITEM_VIGISTAT2); int ordinalITEM_VIGISTAT3 = reader.GetOrdinal(DbNames.ITEM_VIGISTAT3); int ordinalITEM_VIGISTAT4 = reader.GetOrdinal(DbNames.ITEM_VIGISTAT4); int ordinalITEM_VIGISTATADD1 = reader.GetOrdinal(DbNames.ITEM_VIGISTATADD1); int ordinalITEM_VIGISTATADD2 = reader.GetOrdinal(DbNames.ITEM_VIGISTATADD2); int ordinalITEM_VIGISTATADD3 = reader.GetOrdinal(DbNames.ITEM_VIGISTATADD3); int ordinalITEM_VIGISTATADD4 = reader.GetOrdinal(DbNames.ITEM_VIGISTATADD4); int ordinalITEM_PETID = reader.GetOrdinal(DbNames.ITEM_PETID); int ordinalITEM_DAMAGEABSORB = reader.GetOrdinal(DbNames.ITEM_DAMAGEABSORB); int ordinalITEM_DEFENSEABSORB = reader.GetOrdinal(DbNames.ITEM_DEFENSEABSORB); int ordinalITEM_ATTACKRATINGABSORB = reader.GetOrdinal(DbNames.ITEM_ATTACKRATINGABSORB); int ordinalITEM_LIFEABSORB = reader.GetOrdinal(DbNames.ITEM_LIFEABSORB); int ordinalITEM_BAG = reader.GetOrdinal(DbNames.ITEM_BAG); int ordinalITEM_SLOT = reader.GetOrdinal(DbNames.ITEM_SLOT); int ordinalITEM_SIZEX = reader.GetOrdinal(DbNames.ITEM_SIZEX); int ordinalITEM_SIZEY = reader.GetOrdinal(DbNames.ITEM_SIZEY); while (reader.Read()) { BaseItem b = null; int BType = reader.GetByte(ordinalITEM_BTYPE); int BKind = reader.GetByte(ordinalITEM_BKIND); if (BType == (byte)bType.Weapon || BType == (byte)bType.Clothes || BType == (byte)bType.Hat || BType == (byte)bType.Necklace || BType == (byte)bType.Ring || BType == (byte)bType.Shoes || BType == (byte)bType.Cape || BType == (byte)bType.Mirror) { if (BKind == (byte)bKindWeapons.Sword && BType == (byte)bType.Weapon) { b = new Sword(); } if (BKind == (byte)bKindWeapons.Blade && BType == (byte)bType.Weapon) { b = new Blade(); } if (BKind == (byte)bKindWeapons.Fan && BType == (byte)bType.Weapon) { b = new Fan(); } if (BKind == (byte)bKindWeapons.Brush && BType == (byte)bType.Weapon) { b = new Brush(); } if (BKind == (byte)bKindWeapons.Claw && BType == (byte)bType.Weapon) { b = new Claw(); } if (BKind == (byte)bKindWeapons.Axe && BType == (byte)bType.Weapon) { b = new Axe(); } if (BKind == (byte)bKindWeapons.Talon && BType == (byte)bType.Weapon) { b = new Talon(); } if (BKind == (byte)bKindWeapons.Tonfa && BType == (byte)bType.Weapon) { b = new Tonfa(); } if (BKind == (byte)bKindArmors.SwordMan && BType == (byte)bType.Clothes) { b = new Clothes(); } if (BKind == (byte)bKindArmors.Mage && BType == (byte)bType.Clothes) { b = new Dress(); } if (BKind == (byte)bKindArmors.Warrior && BType == (byte)bType.Clothes) { b = new Armor(); } if (BKind == (byte)bKindArmors.GhostFighter && BType == (byte)bType.Clothes) { b = new LeatherClothes(); } if (BKind == (byte)bKindHats.SwordMan && BType == (byte)bType.Hat) { b = new Hood(); } if (BKind == (byte)bKindHats.Mage && BType == (byte)bType.Hat) { b = new Tiara(); } if (BKind == (byte)bKindHats.Warrior && BType == (byte)bType.Hat) { b = new Helmet(); } if (BKind == (byte)bKindHats.GhostFighter && BType == (byte)bType.Hat) { b = new Hat(); } if (BKind == (byte)bKindHats.SwordMan && BType == (byte)bType.Shoes) { b = new SmBoots(); } if (BKind == (byte)bKindHats.Mage && BType == (byte)bType.Shoes) { b = new MageBoots(); } if (BKind == (byte)bKindHats.Warrior && BType == (byte)bType.Shoes) { b = new WarriorShoes(); } if (BKind == (byte)bKindHats.GhostFighter && BType == (byte)bType.Shoes) { b = new GhostFighterShoes(); } if (BKind == 0 && BType == (byte)bType.Ring) { b = new Ring(); } if (BKind == 0 && BType == (byte)bType.Necklace) { b = new Necklace(); } if (BType == (byte)bType.Cape) { b = new Cape(); Cape c = b as Cape; c.MaxPolishImbueTries = reader.GetInt16(ordinalITEM_MAXPOLISHTRIES); c.PolishImbueTries = reader.GetByte(ordinalITEM_POLISHTRIES); c.VigiStat1 = reader.GetInt16(ordinalITEM_VIGISTAT1); c.VigiStatAdd1 = reader.GetInt16(ordinalITEM_VIGISTATADD1); c.VigiStat2 = reader.GetInt16(ordinalITEM_VIGISTAT2); c.VigiStatAdd2 = reader.GetInt16(ordinalITEM_VIGISTATADD2); c.VigiStat3 = reader.GetInt16(ordinalITEM_VIGISTAT3); c.VigiStatAdd3 = reader.GetInt16(ordinalITEM_VIGISTATADD3); c.VigiStat4 = reader.GetInt16(ordinalITEM_VIGISTAT4); c.VigiStatAdd4 = reader.GetInt16(ordinalITEM_VIGISTATADD4); } if (BType == (byte)bType.Mirror) { // bkind 4 = mirror, 0 = jar b = new Mirror(); Mirror m = b as Mirror; m.PetID = reader.GetInt32(ordinalITEM_PETID); m.LifeAbsorb = reader.GetInt16(ordinalITEM_LIFEABSORB); m.DamageAbsorb = reader.GetInt16(ordinalITEM_DAMAGEABSORB); m.DefenseAbsorb = reader.GetInt16(ordinalITEM_DEFENSEABSORB); m.AttackRatingAbsorb = reader.GetInt16(ordinalITEM_ATTACKRATINGABSORB); } Equipment e = b as Equipment; e.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL); e.RequiredDexterity = reader.GetInt16(ordinalITEM_DEX); e.RequiredStrength = reader.GetInt16(ordinalITEM_STR); e.RequiredStamina = reader.GetInt16(ordinalITEM_STA); e.RequiredEnergy = reader.GetInt16(ordinalITEM_ENE); e.MaxImbueTries = reader.GetByte(ordinalITEM_MAXIMBUES); e.Durability = reader.GetInt16(ordinalITEM_CURDURA); e.MaxDurability = reader.GetInt16(ordinalITEM_MAXDURA); e.Damage = reader.GetInt32(ordinalITEM_DAMAGE); e.Defence = reader.GetInt32(ordinalITEM_DEFENCE); e.AttackRating = reader.GetInt32(ordinalITEM_ATTACKRATING); e.AttackSpeed = reader.GetInt16(ordinalITEM_ATTACKSPEED); e.AttackRange = reader.GetInt16(ordinalITEM_ATTACKRANGE); e.IncMaxLife = reader.GetInt16(ordinalITEM_INCMAXLIFE); e.IncMaxMana = reader.GetInt16(ordinalITEM_INCMAXMANA); e.IncLifeRegen = reader.GetInt16(ordinalITEM_LIFEREGEN); e.IncManaRegen = reader.GetInt16(ordinalITEM_MANAREGEN); e.Critical = reader.GetInt16(ordinalITEM_CRITICAL); e.Plus = reader.GetByte(ordinalITEM_PLUS); e.Slvl = reader.GetByte(ordinalITEM_SLVL); e.ImbueTries = reader.GetByte(ordinalITEM_IMBUETRIES); e.DragonSuccessImbueTries = reader.GetInt16(ordinalITEM_DRAGONSUCCESSIMBUETRIES); e.DiscountRepairFee = reader.GetByte(ordinalITEM_DISCOUNTREPAIRFEE); e.TotalDragonImbueTries = reader.GetInt16(ordinalITEM_TOTALDRAGONIMBUES); e.DragonDamage = reader.GetInt32(ordinalITEM_DRAGONDAMAGE); e.DragonDefence = reader.GetInt32(ordinalITEM_DRAGONDEFENCE); e.DragonAttackRating = reader.GetInt32(ordinalITEM_DRAGONATTACKRATING); e.DragonLife = reader.GetInt16(ordinalITEM_DRAGONLIFE); e.MappedData = reader.GetByte(ordinalITEM_MAPPEDSTUFF); e.ForceSlot = reader.GetByte(ordinalITEM_FORCENUMBER); e.RebirthHole = reader.GetInt16(ordinalITEM_REBIRTHHOLE); e.RebirthHoleStat = reader.GetInt16(ordinalITEM_REBIRTHHOLESTAT); } if (BType == (byte)bType.ImbueItem) { if (BKind == (byte)bKindStones.Black) { b = new Black(); } if (BKind == (byte)bKindStones.White) { b = new White(); } if (BKind == (byte)bKindStones.Red) { b = new Red(); } if (BKind == (byte)bKindStones.Dragon) { b = new Dragon(); } if (BKind == (byte)bKindStones.RbItem) { b = new RbHoleItem(); } ImbueItem im = b as ImbueItem; im.ImbueChance = reader.GetInt16(ordinalITEM_IMBUERATE); im.IncreaseValue = reader.GetInt16(ordinalITEM_IMBUEINCREASE); im.ImbueData = reader.GetByte(ordinalITEM_IMBUEDATA); } if (BType == (byte)bType.Potion) { if (BKind == (byte)bKindPotions.Normal) { b = new Potion(); } if (BKind == (byte)bKindPotions.Elixir) { b = new Elixir(); } PotionItem pot = b as PotionItem; pot.HealHp = reader.GetInt16(ordinalITEM_INCMAXLIFE); pot.HealMana = reader.GetInt16(ordinalITEM_INCMAXMANA); } if (BType == (byte)bType.Book) { if (BKind == (byte)bKindBooks.SoftBook) { b = new SoftBook(); } if (BKind == (byte)bKindBooks.HardBook) { b = new HardBook(); } if (BKind == (byte)bKindBooks.RebirdBook) { b = new RebirthBook(); } if (BKind == (byte)bKindBooks.FourthBook) { b = new FourthBook(); } if (BKind == (byte)bKindBooks.FeSkillBook) { b = new FeSkillBook(); } if (BKind == (byte)bKindBooks.FeBook) { b = new FiveElementBook(); } if (BKind == (byte)bKindBooks.FocusBook) { b = new FocusBook(); } BookItem book = b as BookItem; book.RequiredClass = reader.GetByte(ordinalITEM_CLASS); book.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL); book.SkillID = reader.GetInt32(ordinalITEM_BOOKSKILLID); book.SkillLevel = reader.GetByte(ordinalITEM_BOOKSKILLLEVEL); book.SkillData = reader.GetInt32(ordinalITEM_BOOKSKILLDATA); } if (BType == (byte)bType.Bead) { if (BKind == (byte)bKindBeads.Normal) { b = new Bead(); } BeadItem bead = b as BeadItem; bead.ToMapID = reader.GetInt32(ordinalITEM_TOMAPID); } if (BType == (byte)bType.StoreTag) { b = new StoreTag(); StoreTag tag = b as StoreTag; tag.TimeLeft = reader.GetInt16(ordinalITEM_CURDURA); tag.TimeMax = reader.GetInt16(ordinalITEM_MAXDURA); } if (BType == (byte)bType.PetItem) { if (BKind == (byte)bKindPetItems.Taming) b = new TameItem(); if (BKind == (byte)bKindPetItems.Food) b = new PetFood(); if (BKind == (byte)bKindPetItems.Potion) b = new PetPotion(); if (BKind == (byte)bKindPetItems.Resurect) b = new PetResurrectItem(); PetItem p = b as PetItem; p.TameChance = reader.GetInt16(ordinalITEM_IMBUERATE); p.DecreaseWildness = reader.GetInt16(ordinalITEM_IMBUEINCREASE); p.HealLife = reader.GetInt16(ordinalITEM_INCMAXLIFE); } if (BType == (byte)bType.Pill) { if (BKind == (byte)bKindPills.Rebirth) b = new RebirthPill(); RebirthPill p = b as RebirthPill; p.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL); p.RequiredRebirth = reader.GetByte(ordinalITEM_CLASS); p.ToRebirth = (byte)(p.RequiredRebirth + 1); p.IncreaseSp = reader.GetInt16(ordinalITEM_DEX); } b.ItemID = reader.GetInt32(ordinalITEM_ITEMID); b.OwnerID = reader.GetInt32(ordinalITEM_OWNERID); b.ReferenceID = reader.GetInt16(ordinalITEM_REFERENCEID); b.VisualID = reader.GetInt16(ordinalITEM_VISUALID); b.Bag = reader.GetByte(ordinalITEM_BAG); b.Slot = reader.GetByte(ordinalITEM_SLOT); b.bType = reader.GetByte(ordinalITEM_BTYPE); b.bKind = reader.GetByte(ordinalITEM_BKIND); b.RequiredClass = reader.GetByte(ordinalITEM_CLASS); b.Amount = reader.GetInt16(ordinalITEM_AMOUNT); b.SizeX = reader.GetByte(ordinalITEM_SIZEX); b.SizeY = reader.GetByte(ordinalITEM_SIZEY); b.Price = reader.GetInt32(ordinalITEM_COST); items.Add(b); } reader.Close(); _db.Close(); return items; }
public void OnMouseUp() { Vector3 MouseUpVec = Camera.main.ScreenToWorldPoint(Input.mousePosition); MouseUpVec.z = 0f; MouseUpVec /= thisKnot.GlobalRate; if (Display.IsDrawKnotMode()) { if (DraggedNode != null) { //ノードマウスダウンから始めたとき if ((MouseUpVec - MouseDownVec).magnitude < 0.05f && DraggedNode.ThisBead.Joint) { // ノードをクリック -> クロシングチェンジ //ビーズのデータの変更 Bead bd = DraggedNode.ThisBead; Bead tmp = bd.N1; bd.N1 = bd.U2; bd.U2 = bd.N2; bd.N2 = bd.U1; bd.U1 = tmp; //ノードのデータの変更 DraggedNode.Theta -= Mathf.PI / 2f; float rtmp = DraggedNode.R[0]; DraggedNode.R[0] = DraggedNode.R[3]; DraggedNode.R[3] = DraggedNode.R[2]; DraggedNode.R[2] = DraggedNode.R[1]; DraggedNode.R[1] = rtmp; //エッジのデータの変更 Edge[] AllEdges = FindObjectsOfType <Edge>(); for (int e = 0; e < AllEdges.Length; e++) { Edge ed = AllEdges[e]; if (ed.ANodeID == DraggedNode.ID) { ed.ANodeRID = (ed.ANodeRID + 1) % 4; } else if (ed.BNodeID == DraggedNode.ID) { ed.BNodeRID = (ed.BNodeRID + 1) % 4; } } } //ノードをドラッグしたときは後処理なし DraggedNode = null; } // フリーカーブを描いているとき else if (StartFreeCurveBead != null) { // スポットを消去する //Spot[] NodeSpots = FindObjectsOfType<Spot>(); //for(int i= NodeSpots.Length; i>=0; i--) //{ // Destroy(NodeSpots[i].gameObject); //} ////終了地点がノードでないことが要件 bool NoProc = false; //終了地点がノードだったら、非処理フラグを立てる thisKnot.GetAllThings(); for (int n = 0; n < thisKnot.AllNodes.Length; n++) { if ((thisKnot.AllNodes[n].Position - MouseUpVec).magnitude < 0.2f) { NoProc = true; } } //終了地点がビーズだったら、処理に入る。 //終了地点がビーズでなかったら、非処理フラグを立てる Bead EndFreeCurveBead = null; if (!NoProc) { NoProc = true; for (int b = 0; b < thisKnot.AllBeads.Length; b++) { if ((thisKnot.AllBeads[b].Position - MouseUpVec).magnitude < 0.15f) { NoProc = false; // 終了ビーズを記録 EndFreeCurveBead = thisKnot.AllBeads[b]; break; } } } //非処理フラグが立っていたらフリーカーブを消去して終わり if (NoProc) { thisFreeLoop.FreeCurve.Clear(); } else// 処理に入る { // 開始ビーズから終了ビーズをたどる方法を探索 // 開始ビーズから終了ビーズの間にクロシングがどのように表れるかを調査。 // first : 0:何もなし、1:オーバーのみ、2:アンダーのみ // second : ビーズ距離 PairInt GotoN1 = thisKnot.FindBeadAlongCurve(StartFreeCurveBead, StartFreeCurveBead.N1, EndFreeCurveBead); PairInt GotoN2 = thisKnot.FindBeadAlongCurve(StartFreeCurveBead, StartFreeCurveBead.N2, EndFreeCurveBead); //Debug.Log(GotoN1.first + "," + GotoN2.first); bool BothOK = (GotoN1.first != -1) && (GotoN2.first != -1); // オーバーのみ、またはアンダーのみの時には処理を開始(どちらともとれる場合には、短いほう) if (GotoN1.first != -1 || (BothOK && GotoN1.second < GotoN2.second)) { // 開始ビーズから終了ビーズまでの既存のビーズラインを消去 thisKnot.DeleteBeadsFromTo(StartFreeCurveBead, StartFreeCurveBead.N1, EndFreeCurveBead); // フリーループにあたる部分をビーズへと変換 thisKnot.FreeCurve2Bead(StartFreeCurveBead, EndFreeCurveBead, GotoN1.first); // 旧フリーループと旧ビーズとの交点を探してジョイントにする。 } else if (GotoN2.first != -1 || (BothOK && GotoN1.second > GotoN2.second)) { // 開始ビーズから終了ビーズまでの既存のビーズラインを消去 thisKnot.DeleteBeadsFromTo(StartFreeCurveBead, StartFreeCurveBead.N2, EndFreeCurveBead); // フリーループにあたる部分をビーズへと変換 thisKnot.FreeCurve2Bead(StartFreeCurveBead, EndFreeCurveBead, GotoN2.first); // 旧フリーループと旧ビーズとの交点を探してジョイントにする。 } else //書き換える条件を満たしていないとき {//すべてを消去して終了 thisFreeLoop.FreeCurve.Clear(); Display.SetDrawKnotMode(); } // グラフ構造を書き換える // 形を整える //thisKnot.Modify(); //thisKnot.UpdateBeads(); } } else if (StartFreeLoop) { StartFreeLoop = false;//必ずフリーループモードは終了 if (!thisFreeLoop.CircleEffectEnable) { thisFreeLoop.FreeCurve.Clear(); Display.SetDrawKnotMode(); // フリーループモードから抜けたことが直感的にわかりにくい。 } else { // まず1列のbeadの列を作る。 int BeadCount = thisKnot.GetMaxIDOfBead(); int freeCurveSize = thisFreeLoop.FreeCurve.Count; for (int b = 0; b < freeCurveSize; b++) { //ビーズを追加(ID番号=BeadCount + 1 + b) thisKnot.AddBead(thisFreeLoop.FreeCurve[b], BeadCount + 1 + b); } //FreeCurveをクリアしておく thisFreeLoop.CircleEffect.GetComponent <LineRenderer>().enabled = thisFreeLoop.CircleEffectEnable = false; thisFreeLoop.FreeCurve.Clear(); thisKnot.AllBeads = FindObjectsOfType <Bead>(); // N1,N2, NumOfNbhdを設定 for (int b = 0; b < freeCurveSize; b++) { Bead bd = thisKnot.GetBeadByID(BeadCount + 1 + b); bd.N1 = thisKnot.GetBeadByID(BeadCount + 1 + (b + 1) % freeCurveSize); bd.N2 = thisKnot.GetBeadByID(BeadCount + 1 + (b + freeCurveSize - 1) % freeCurveSize); bd.NumOfNbhd = 2; } //重複も許して交点を検出 List <PairInt> meets = new List <PairInt>(); for (int b1 = 0; b1 < thisKnot.GetMaxIDOfBead() + 1; b1++) { Bead b1c = thisKnot.GetBeadByID(b1); if (b1c == null) { continue; } Bead b1n = b1c.N1; Bead b1p = b1c.N2; if (b1n == null || b1p == null) { continue; } for (int b2 = BeadCount + 1; b2 < BeadCount + freeCurveSize; b2++) { if (b1 >= b2) { continue; } Bead b2c = thisKnot.GetBeadByID(b2); if (b2c == null) { continue; } Bead b2n = b2c.N1; Bead b2p = b2c.N2; if (b2n == null || b2p == null) { continue; } if (b1c == b2n || b1c == b2p || b1n == b2c || b1n == b2p) { continue; // そもそも異なる場所である保証。 } if (GetMeetPairOfNewFreeCurve(b1, b1n, b1p, b2, b2n, b2p, meets)) { meets.Add(new PairInt(b1, b2)); } } } if (meets.Count == 0) { // ある程度の長さがありかつ交点の個数が0ならば、トリビアルな成分を追加する。 if (freeCurveSize > 20) { Bead Bd = thisKnot.GetBeadByID(BeadCount + 1 + 1); Bd.MidJoint = true; Bd = thisKnot.GetBeadByID(BeadCount + 1 + Mathf.FloorToInt(freeCurveSize / 3)); Bd.MidJoint = true; Bd = thisKnot.GetBeadByID(BeadCount + 1 + Mathf.FloorToInt(2 * freeCurveSize / 3)); Bd.MidJoint = true; // BeadsからNodeEdgeを更新する thisKnot.CreateNodesEdgesFromBeads(); // 形を整える thisKnot.GetAllThings(); thisKnot.Modify(); thisKnot.UpdateBeads(); } else {// 交点の個数が0ならば、新規Beadを全部捨てる。 thisKnot.AllBeads = FindObjectsOfType <Bead>(); for (int i = 0; i < thisKnot.AllBeads.Length; i++) { Bead bd = thisKnot.AllBeads[i]; if (bd.ID > BeadCount) { bd.N1 = bd.N2 = null; bd.NumOfNbhd = 0; bd.Active = false; } } } //モードを戻しておく Display.SetDrawKnotMode(); } else {// さもなくば、交点に当たるところをJointにする for (int i = 0; i < meets.Count; i++) { int b1 = meets[i].first; int b2 = meets[i].second; Bead bd1 = thisKnot.GetBeadByID(b1); Bead bd2 = thisKnot.GetBeadByID(b2); if (bd1 == null || bd2 == null) { continue; } if (bd1.N1 == null || bd2.N1 == null || bd2.N2 == null) { continue; } bd1.Joint = true; //Nbhdの繋ぎ替え // これをどちらにどちらをつなぐかは、選ぶ必要がある。 float bd1x = bd1.Position.x; float bd1y = bd1.Position.y; float n1x = bd1.N1.Position.x - bd1x; float n1y = bd1.N1.Position.y - bd1y; float bd2n1x = bd2.N1.Position.x - bd1x; float bd2n1y = bd2.N1.Position.y - bd1y; float bd2n2x = bd2.N2.Position.x - bd1x; float bd2n2y = bd2.N2.Position.y - bd1y; if (n1x * bd2n1y - n1y * bd2n1x > 0 && n1x * bd2n2y - n1y * bd2n2x < 0) { bd1.U1 = bd2.N1; bd1.U2 = bd2.N2; } else { bd1.U1 = bd2.N2; bd1.U2 = bd2.N1; } if (bd2.N1.N1 == bd2) { bd2.N1.N1 = bd1; } else if (bd2.N1.N2 == bd2) { bd2.N1.N2 = bd1; } if (bd2.N2.N1 == bd2) { bd2.N2.N1 = bd1; } else if (bd2.N2.N2 == bd2) { bd2.N2.N2 = bd1; } //消去 bd2.Active = false;// // Joint-Jointとなるエッジには間にMidJointを必ず追加する。 for (int r1 = 0; r1 < 4; r1++) { PairInt br2 = thisKnot.FindEndOfEdgeOnBead(bd1, r1, true); Bead endBead = thisKnot.FindBeadByID(br2.first); if (endBead != null && endBead.Joint) { // ジョイント間のビーズ数を数える。 int count = thisKnot.CountBeadsOnEdge(bd1, r1); // midJointを作る Bead midJointBead = thisKnot.GetBeadOnEdge(bd1, r1, Mathf.FloorToInt(count / 2)); if (midJointBead != null) { midJointBead.MidJoint = true; } //Debug.Log(bd.ID + "," + r1 + "->" + br2.first + "," + br2.second + "(" + count + ")"); } } } thisKnot.AllBeads = FindObjectsOfType <Bead>(); // BeadsからNodeEdgeを更新する thisKnot.CreateNodesEdgesFromBeads(); // 形を整える thisKnot.GetAllThings(); thisKnot.Modify(); thisKnot.UpdateBeads(); } } } } else if (Display.IsFreeLoopMode()) { StartFreeLoop = false;//必ずフリーループモードは終了 //スタート地点に近くない場所で終了した場合には、すべてを消去して終了 if (!thisFreeLoop.CircleEffectEnable) { thisFreeLoop.FreeCurve.Clear(); Display.SetDrawKnotMode(); // フリーループモードから抜けたことが直感的にわかりにくい。 } else // { //以下は長い処理なので、メソッド化が望ましい。 //スタート地点に近い場所で終わった場合は、まずはBeadへと変換する。 // すべてのビーズを消す(不要) thisKnot.ClearAll(); // まず1列のbeadの列を作る。 int freeCurveSize = thisFreeLoop.FreeCurve.Count; for (int b = 0; b < freeCurveSize; b++) { //ビーズを追加(b=ID番号) thisKnot.AddBead(thisFreeLoop.FreeCurve[b], b); } //FreeCurveをクリアしておく thisFreeLoop.CircleEffect.GetComponent <LineRenderer>().enabled = thisFreeLoop.CircleEffectEnable = false; thisFreeLoop.FreeCurve.Clear(); // 新規ビーズのデータを整える thisKnot.AllBeads = FindObjectsOfType <Bead>(); freeCurveSize = thisKnot.AllBeads.Length;// おそらく無意味 for (int b = 0; b < freeCurveSize; b++) { // N1,N2, NumOfNbhdを設定 Bead bd = thisKnot.AllBeads[b]; bd.N1 = thisKnot.AllBeads[(b + 1) % freeCurveSize]; bd.N2 = thisKnot.AllBeads[(b + freeCurveSize - 1) % freeCurveSize]; bd.NumOfNbhd = 2; } //モードを戻しておく Display.SetDrawKnotMode(); //重複も許して交点を検出 List <PairInt> meets = new List <PairInt>(); for (int b1 = 0; b1 < freeCurveSize; b1++) { int b1n = (b1 + 1) % freeCurveSize; int b1p = (b1 + freeCurveSize - 1) % freeCurveSize; for (int b2 = b1 + 1; b2 < freeCurveSize; b2++) { int b2n = (b2 + 1) % freeCurveSize; int b2p = (b2 + freeCurveSize - 1) % freeCurveSize; //int difference = (b2 - b1 + freeCurveSize) % freeCurveSize;//なぜ? int difference = b2 - b1; if (2 < difference && difference < freeCurveSize - 2) {// そもそも異なる場所である保証。 float x1 = thisKnot.AllBeads[b1p].Position.x; float y1 = thisKnot.AllBeads[b1p].Position.y; float x2 = thisKnot.AllBeads[b1n].Position.x; float y2 = thisKnot.AllBeads[b1n].Position.y; float x3 = thisKnot.AllBeads[b2p].Position.x; float y3 = thisKnot.AllBeads[b2p].Position.y; float x4 = thisKnot.AllBeads[b2n].Position.x; float y4 = thisKnot.AllBeads[b2n].Position.y; // (x2-x1)s+x1 = (x4-x3)t+x3 // (y2-y1)s+y1 = (y4-y3)t+y3 // (x2-x1)s - (x4-x3)t = +x3-x1 // (y2-y1)s - (y4-y3)t = +y3-y1 float a = x2 - x1; float b = -x4 + x3; float c = y2 - y1; float d = -y4 + y3; float p = x3 - x1; float q = y3 - y1; float s1 = p * d - b * q; // s = s1/st float t1 = a * q - p * c; // t = t1/st float st = a * d - b * c; if (st < 0) { st *= -1; s1 *= -1; t1 *= -1; } if (0 < s1 && s1 < st && 0 < t1 && t1 < st) { // 線分が交わっている条件 //重複を排してListに貯める bool OK = true; for (int mt = 0; mt < meets.Count; mt++) { int m1 = meets[mt].first; int m2 = meets[mt].second; if (Math.Abs(b1 - m1) <= 2 && Math.Abs(b2 - m2) <= 2) { //Debug.Log("(" + b1 + "," + b2 + ")=(" + m1 + "," + m2 + ")"); OK = false; break; } } if (OK) { meets.Add(new PairInt(b1, b2)); } } } } } if (meets.Count == 0) {// ある程度の長さがありかつ交点の個数が0ならば、トリビアルな成分を追加する。 if (freeCurveSize > 20) { Bead Bd = thisKnot.AllBeads[1]; Bd.MidJoint = true; Bd = thisKnot.AllBeads[Mathf.FloorToInt(freeCurveSize / 3)]; Bd.MidJoint = true; Bd = thisKnot.AllBeads[Mathf.FloorToInt(2 * freeCurveSize / 3)]; Bd.MidJoint = true; // BeadsからNodeEdgeを更新する thisKnot.CreateNodesEdgesFromBeads(); // 形を整える thisKnot.GetAllThings(); thisKnot.Modify(); thisKnot.UpdateBeads(); } else { // 全体が短くてかつ交点の個数が0ならば、Beadを全部捨てる。 thisKnot.ClearAllBeads(); } //モードを戻しておく Display.SetDrawKnotMode(); } else {// さもなくば、交点に当たるところをJointにする for (int i = 0; i < meets.Count; i++) { int b1 = meets[i].first; int b2 = meets[i].second; Bead bd1 = thisKnot.AllBeads[b1]; Bead bd2 = thisKnot.AllBeads[b2]; bd1.Joint = true; //Nbhdの繋ぎ替え // これをどちらにどちらをつなぐかは、選ぶ必要がある。 float bd1x = bd1.Position.x; float bd1y = bd1.Position.y; float n1x = bd1.N1.Position.x - bd1x; float n1y = bd1.N1.Position.y - bd1y; float bd2n1x = bd2.N1.Position.x - bd1x; float bd2n1y = bd2.N1.Position.y - bd1y; float bd2n2x = bd2.N2.Position.x - bd1x; float bd2n2y = bd2.N2.Position.y - bd1y; if (n1x * bd2n1y - n1y * bd2n1x > 0 && n1x * bd2n2y - n1y * bd2n2x < 0) { bd1.U1 = bd2.N1; bd1.U2 = bd2.N2; } else { bd1.U1 = bd2.N2; bd1.U2 = bd2.N1; } thisKnot.AllBeads[b2 - 1].N1 = bd1; thisKnot.AllBeads[b2 + 1].N2 = bd1; //消去 bd2.Active = false;// } thisKnot.AllBeads = FindObjectsOfType <Bead>(); freeCurveSize = thisKnot.AllBeads.Length; // Joint-Jointとなるエッジには間にMidJointを必ず追加する。 for (int b1 = 0; b1 < freeCurveSize; b1++) { Bead bd = thisKnot.AllBeads[b1]; if (bd.Joint) { for (int r1 = 0; r1 < 4; r1++) { PairInt br2 = thisKnot.FindEndOfEdgeOnBead(bd, r1, true); Bead endBead = thisKnot.FindBeadByID(br2.first); if (endBead != null && endBead.Joint) { // ジョイント間のビーズ数を数える。 int count = thisKnot.CountBeadsOnEdge(bd, r1); // midJointを作る Bead midJointBead = thisKnot.GetBeadOnEdge(bd, r1, Mathf.FloorToInt(count / 2)); if (midJointBead != null) { midJointBead.MidJoint = true; } //Debug.Log(bd.ID + "," + r1 + "->" + br2.first + "," + br2.second + "(" + count + ")"); } } } } // BeadsからNodeEdgeを更新する thisKnot.CreateNodesEdgesFromBeads(); // 形を整える thisKnot.GetAllThings(); thisKnot.Modify(); thisKnot.UpdateBeads(); // thisKnot.AdjustEdgeLine(); //モードを戻す Display.SetDrawKnotMode(); } } } else if (Display.IsEditKnotMode()) { } else if (Display.IsMenuMode()) { } }
public void Constructor_UsingValidSymbol_DoesNotThrowException() { Bead bead = new Bead("symbol"); }
public BeadDetailViewModel(Bead bead = null) { Title = bead?.Description; Bead = bead; }