public void CreateBox() { Vector2 mp = UserInterface.WorldMousePos; //if (verts.Count < 3) return; //Vector2[] vertices = verts.ToArray(); //Node newNode = new Node(ShapeType.ePolygon); Node newNode = OrbIt.ui.sidebar.ActiveDefaultNode.CreateClone(); //Node.cloneNode(OrbIt.ui.sidebar.ActiveDefaultNode, newNode); Polygon poly = new Polygon(); poly.body = newNode.body; poly.SetBox(Utils.random.Next(100),Utils.random.Next(100)); newNode.body.shape = poly; newNode.body.pos = mp; room.spawnNode(newNode); //verts = new List<Vector2>(); }
public override void OnSpawn() { //Node.cloneNode(parent.Game1.ui.sidebar.ActiveDefaultNode, sword); //parent.body.texture = textures.orientedcircle; swordNode.dataStore["swordnodeparent"] = parent; Polygon poly = new Polygon(); poly.body = swordNode.body; poly.SetBox(swordWidth, swordLength); swordNode.body.shape = poly; swordNode.body.pos = parent.body.pos; swordNode.body.DrawPolygonCenter = false; swordNode.basicdraw.active = false; ///room.spawnNode(sword); room.groups.items.IncludeEntity(swordNode); swordNode.OnSpawn(); swordNode.body.AddExclusionCheck(parent.body); swordNode.body.ExclusionCheck += delegate(Collider p, Collider o) { return !movingStick; }; swordNode.body.OnCollisionEnter += (p, o) => { if (o.dataStore.ContainsKey("swordnodeparent")) { Node otherparent = o.dataStore["swordnodeparent"]; Vector2 f = otherparent.body.pos - parent.body.pos; VMath.NormalizeSafe(ref f); f *= parryKnockback; otherparent.body.ApplyForce(f); } else if (o.IsPlayer) { o.player.node.meta.CalculateDamage(parent, damageMultiplier); } }; //sword.body.exclusionList.Add(parent.body); // //parent.body.exclusionList.Add(sword.body); }
public Node ConstructWallPoly(Dictionary<dynamic, dynamic> props, int hw, int hh, Vector2 pos) { Node n = new Node(this, props); n.Comp<BasicDraw>().active = false; Polygon poly = new Polygon(); poly.body = n.body; poly.body.pos = pos; poly.SetBox(hw, hh); //poly.SetOrient(0f); n.body.shape = poly; n.body.SetStatic(); n.body.orient =(0); //n.body.restitution = 1f; //n.movement.pushable = false; masterGroup.childGroups["Wall Group"].entities.Add(n); return n; }