public override void Update(float deltaTime) { base.Update(deltaTime); // // Has Entity been assigned yet? // if (CompEntity == null) { return; } if (!Enabled) { return; } // // update location of box containing the collider // if (!fixedCollider) { boxContainer.x = Transform.Position.X - OriginLocal.X; boxContainer.y = Transform.Position.Y - OriginLocal.Y; BoxPoints = new List <Vector2>(); Vector2 topL = new Vector2(boxContainer.x, boxContainer.y); Vector2 topR = new Vector2(topL.X + boxContainer.width, topL.Y); Vector2 botL = new Vector2(topL.X, topL.Y + boxContainer.height); Vector2 botR = new Vector2(topR.X, topR.Y + boxContainer.height); BoxPoints.Add(topL); BoxPoints.Add(botL); BoxPoints.Add(botR); BoxPoints.Add(topR); // // Find the min & max vectors for collision // CollisionBox.Fit(BoxPoints); //updates the position of this collider } if (!setSceneColliders) { // // update the database of colliders in this scene (happens only once) // SceneColliderDatabase.SetCollider(CompEntity, CollidreShape.Box); setSceneColliders = true; } }
public override void Update(float deltaTime) { base.Update(deltaTime); // // Has Entity been assigned yet? // if (CompEntity == null) { return; } // // update location of box containing the collider // boxContainer.x = Transform.Position.X; boxContainer.y = Transform.Position.Y; BoxPoints = new List <Vector2>(); Vector2 topL = new Vector2(boxContainer.x, boxContainer.y - Radius); //north Vector2 topR = new Vector2(boxContainer.x - Radius, boxContainer.y); //west Vector2 botL = new Vector2(boxContainer.x + Radius, boxContainer.y); //east Vector2 botR = new Vector2(boxContainer.x, boxContainer.y + Radius); //south BoxPoints.Add(topL); BoxPoints.Add(botL); BoxPoints.Add(botR); BoxPoints.Add(topR); // // Find the min & max vectors for collision // CollisionBox.Fit(BoxPoints); //updates the position of this collider if (!setScenColliders) { // // update the database of colliders in this scene (happens only once) // SceneColliderDatabase.SetCollider(CompEntity, CollidreShape.Circle); setScenColliders = true; } }