public Cv_CollisionShape(string shapeID, Vector2 point, float radius, Vector2?anchorPoint, float density, bool isSensor, bool isBullet, Cv_CollisionCategories categories, Cv_CollisionCategories collidesWith, Dictionary <int, string> directions) { ShapeID = shapeID; Points = new List <Vector2>(); Points.Add(point); if (anchorPoint == null) { AnchorPoint = Vector2.Zero; } else { AnchorPoint = (Vector2)anchorPoint; } Radius = radius; IsCircle = true; IsSensor = isSensor; IsBullet = isBullet; Density = density; Friction = 1f; CollisionCategories = categories; CollidesWith = collidesWith; m_CollisionDirections = directions; CircleOutlineTex = Cv_DrawUtils.CreateCircle((int)radius); Owner = null; }
public Cv_CollisionShape(string shapeID, List <Vector2> points, Vector2?anchorPoint, float density, bool isSensor, bool isBullet, Cv_CollisionCategories categories, Cv_CollisionCategories collidesWith, Dictionary <int, string> directions) { ShapeID = shapeID; Points = points; if (anchorPoint == null) { AnchorPoint = Vector2.Zero; } else { AnchorPoint = (Vector2)anchorPoint; } IsSensor = isSensor; IsBullet = isBullet; Density = density; Friction = 1f; CollisionCategories = categories; CollidesWith = collidesWith; m_CollisionDirections = directions; Owner = null; }
private void AddShape(Cv_ShapeData newShape, string id, Vector2 anchor, string material, bool isBullet, Cv_CollisionCategories collisionCategories = null, Cv_CollisionCategories collidesWith = null, Dictionary <int, string> collisionDirections = null) { newShape.IsBullet = isBullet; newShape.Material = material; newShape.ShapeID = id; newShape.Anchor = anchor; if (collisionCategories == null) { var categories = new Cv_CollisionCategories(); categories.AddAllCategories(); newShape.Categories = categories; } else { newShape.Categories = collisionCategories; } if (collidesWith == null) { var categories = new Cv_CollisionCategories(); categories.AddAllCategories(); newShape.CollidesWith = categories; } else { newShape.CollidesWith = collidesWith; } if (collisionDirections == null) { var directions = new Dictionary <int, string>(); var _collidesWith = newShape.CollidesWith.GetCategoriesArray(); foreach (var c in _collidesWith) { directions.Add(c, "All"); } newShape.CollisionDirections = directions; } else { newShape.CollisionDirections = collisionDirections; } m_Shapes.Add(newShape); var newEvt = new Cv_Event_NewCollisionShape(Owner.ID, newShape, this); Cv_EventManager.Instance.QueueEvent(newEvt, true); }
public Cv_ShapeData(Cv_ShapeData toCopy) { ShapeID = toCopy.ShapeID; Type = toCopy.Type; Anchor = toCopy.Anchor; Radius = toCopy.Radius; Dimensions = toCopy.Dimensions; Points = toCopy.Points; IsBullet = toCopy.IsBullet; Material = toCopy.Material; Categories = toCopy.Categories; CollidesWith = toCopy.CollidesWith; CollisionDirections = toCopy.CollisionDirections; }
public void AddPolygonShape(string id, Vector2[] points, Vector2 anchor, string material, bool isBullet, Cv_CollisionCategories collisionCategories = null, Cv_CollisionCategories collidesWith = null, Dictionary <int, string> collisionDirections = null) { var shapeData = new Cv_ShapeData(); shapeData.Points = points; shapeData.Type = ShapeType.Polygon; AddShape(shapeData, id, anchor, material, isBullet, collisionCategories, collidesWith, collisionDirections); }
public void AddTriggerShape(string id, Vector2 dimensions, Vector2 anchor, string material, bool isBullet, Cv_CollisionCategories collisionCategories = null, Cv_CollisionCategories collidesWith = null, Dictionary <int, string> collisionDirections = null) { var shapeData = new Cv_ShapeData(); shapeData.Dimensions = dimensions; shapeData.Type = ShapeType.Trigger; AddShape(shapeData, id, anchor, material, isBullet, collisionCategories, collidesWith, collisionDirections); }
public void AddCircleShape(string id, float radius, Vector2 anchor, string material, bool isBullet, Cv_CollisionCategories collisionCategories = null, Cv_CollisionCategories collidesWith = null, Dictionary <int, string> collisionDirections = null) { var shapeData = new Cv_ShapeData(); shapeData.Radius = radius; shapeData.Type = ShapeType.Circle; AddShape(shapeData, id, anchor, material, isBullet, collisionCategories, collidesWith, collisionDirections); }
public bool CollidesWithFromDirection(Cv_CollisionCategories categories, string direction) { var catArray = categories.GetCategoriesArray(); var collides = false; foreach (var c in catArray) { if (m_CollisionDirections.ContainsKey(c) && (m_CollisionDirections[c].Contains(direction) || m_CollisionDirections[c] == "All")) { collides = true; break; } } return(collides); }