private void setObject(ObjGame obj) { this.txtX.Text = (obj != null)? obj.X.ToString() : "0"; this.txtY.Text = (obj != null) ? obj.Y.ToString() : "0"; this.txtVx.Text = (obj != null) ? obj.Width.ToString() : "0"; this.txtVy.Text = (obj != null) ? obj.Height.ToString() : "0"; this.txtType.Text = (obj != null) ? obj.Type.ToString() : "nothing"; this.txtName.Text = (obj != null) ? obj.Name.ToString() : "nothing"; }
public void addObjGame(ObjGame obj) { this.Region.AddObj(obj); if (this.Region.IsSplit()) { split(); } }
public void RemoveObj(ObjGame obj) { if (obj != null) { this.objs.Remove(obj); } else { MyLogger.getInstance().logDebug("Removed object is null"); } }
public void AddObj(ObjGame obj) { if (obj != null) { this.objs.Add(obj); } else { MyLogger.getInstance().logDebug("Add object in null"); } }
private void click_pb_obj(object sender, EventArgs e) { PictureBox pb = (PictureBox)sender; Rectangle rec = pb.Bounds; if (ModifierKeys == Keys.Alt) { foreach (ObjGame obj in this.enemies) { int x = obj.X + (obj.Width / 2); int y = obj.Y + (obj.Height / 2); if (rec.Contains(x, y)) { this.enemies.Remove(obj); break; } } this.picMap.Controls.Remove(pb); } else { foreach (ObjGame obj in this.enemies) { int x = obj.X + (obj.Width / 2); int y = obj.Y + (obj.Height / 2); if (rec.Contains(x, y)) { setObject(obj); this.objGameSelected = obj; } } foreach (PictureBox _pb in this.picMap.Controls) { Rectangle _rec = new Rectangle(_pb.Location.X - _pb.Size.Width / 2, _pb.Location.Y + _pb.Size.Height / 2, _pb.Size.Width + 15, _pb.Size.Height + 15); if (_rec.Contains(this.x, this.y)) { if (this.pbObjSelected != null) { this.pbObjSelected.BackColor = Color.Transparent; } this.pbObjSelected = _pb; this.pbObjSelected.BackColor = Color.Red; updateGraphic(); return; } } } }
public static bool IsContain(ObjGame obj, int x, int y, int width, int height) { bool result = false; bool check_x = obj.X >= x && obj.X < (x + width); bool check_y = obj.Y >= y && obj.Y < (y + height); if (check_x && check_y) { result = true; } return(result); }
private void picMap_Click(object sender, EventArgs e) { if (ModifierKeys == Keys.Shift) { if (this.selectedObj != null) { picMap.Controls.Add(pushObjGame(this.x, this.y, this.selectedObj)); ObjGame obj = null; if (this.selectedObj.Obj.Type.Equals("enemy")) { obj = new Enemy(this.selectedObj.Obj); this.enemies.Add(obj); } else if (this.selectedObj.Obj.Type.Equals("boss")) { obj = new Boss(this.selectedObj.Obj); this.bosses.Add(obj); } else if (this.selectedObj.Obj.Type.Equals("item")) { Item item = new Item(this.selectedObj.Obj, txtContainer.Text); this.itemList.Add(item); } } } else if (ModifierKeys == Keys.Control) { if (tlPoint.X == -1 && tlPoint.Y == -1) { tlPoint = new Point((this.x / 16) * 16, (this.y / 16) * 16); } else if (rbPoint.X == -1 && rbPoint.Y == -1) { rbPoint = new Point((this.x / 16 + 1) * 16, (this.y / 16 + 1) * 16); Rectangle rec = new Rectangle(tlPoint.X, tlPoint.Y, rbPoint.X - tlPoint.X, rbPoint.Y - tlPoint.Y); this.recs.Add(rec); tlPoint = new Point(-1, -1); rbPoint = new Point(-1, -1); this.Invalidate(); this.Update(); this.Refresh(); } } }
public QUADTREE_NODE getNumberNodeWhenSplit(ObjGame obj) { if (IsContain(obj, x, y, width / 2, height / 2)) { return(QUADTREE_NODE.NODE1); } else if (IsContain(obj, x + width / 2, y, width / 2, height / 2)) { return(QUADTREE_NODE.NODE2); } else if (IsContain(obj, x, y + height / 2, width / 2, height / 2)) { return(QUADTREE_NODE.NODE3); } else { return(QUADTREE_NODE.NODE4); } }
public ObjDTO(ObjGame objGame, String imagePath) { this.Obj = objGame; this.ImagePath = imagePath; }