public CircleSceneTrigger(int radius) { var j = new CircleCollisionBox(new Circle(this.Position, radius)) { Type = CollisionType.Trigger, Style = TriggerStyle.Enter, CollisionLayer = CollisionLayer.Foreground, CollisionObjectType = CollisionObjectType.Static }; AddPhysicsObject(TRIGGER_INDEX, j); //TODO: Add Circle Outline AddRenderObjects(Helper.GetDebugRenderObjects(this)); }
protected virtual void FillOffsets() // put the offets in here { // this is the offset from player topleft to where the weapon is held (center of player) var distanceToAnchor = new Vector2(GameConstants.PLAYER_SPRITE_SIZE.X / 2, GameConstants.PLAYER_SPRITE_SIZE.Y * 2 / 3); var playerOffsets = new List <Vector2>(); playerOffsets.Add(distanceToAnchor); playerOffsets.Add(distanceToAnchor); playerOffsets.Add(distanceToAnchor + new Vector2(3, 0)); playerOffsets.Add(distanceToAnchor + new Vector2(7, 0)); playerOffsets.Add(distanceToAnchor + new Vector2(12, 0)); float bulbCenter; if (_rectangular) { bulbCenter = -_length + _bulbSize.X / 2; } else { bulbCenter = -_length + _bulbRadius; } var firstFrameCenter = new Vector2(bulbCenter, 0) + playerOffsets[0]; var secondFrameCenter = new Vector2(bulbCenter * MathConstants.COS_45, bulbCenter * MathConstants.SIN_45) + playerOffsets[1]; var thirdFrameCenter = new Vector2(0, bulbCenter) + playerOffsets[2]; var fourthFrameCenter = new Vector2(-bulbCenter * MathConstants.COS_45, -bulbCenter * MathConstants.SIN_45) + playerOffsets[3]; var fifthFrameCenter = new Vector2(-bulbCenter, 0) + playerOffsets[4]; _attackLeftBoxOffsets = new Dictionary <CollisionBox, List <Vector2> >(); _attackRightBoxOffsets = new Dictionary <CollisionBox, List <Vector2> >(); _airAttackLeftBoxOffsets = new Dictionary <CollisionBox, List <Vector2> >(); _airAttackRightBoxOffsets = new Dictionary <CollisionBox, List <Vector2> >(); if (_rectangular) { var collisionBoxes = new List <CollisionBox>(); var boxOffsetsFromCenter = new List <Vector2>(); float radius; if (_bulbSize.X > _bulbSize.Y) // width is greater than height, i think this is opposite way { boxOffsetsFromCenter.Add(new Vector2(-_bulbSize.X / 3, -_bulbSize.Y / 4)); boxOffsetsFromCenter.Add(new Vector2(-_bulbSize.X / 3, _bulbSize.Y / 4)); boxOffsetsFromCenter.Add(new Vector2(0, -_bulbSize.Y / 4)); boxOffsetsFromCenter.Add(new Vector2(0, _bulbSize.Y / 4)); boxOffsetsFromCenter.Add(new Vector2(_bulbSize.X / 3, -_bulbSize.Y / 4)); boxOffsetsFromCenter.Add(new Vector2(_bulbSize.X / 3, _bulbSize.Y / 4)); radius = (_bulbSize.X / 6) / MathConstants.COS_45; } else { boxOffsetsFromCenter.Add(new Vector2(-_bulbSize.X / 4, -_bulbSize.Y / 3)); boxOffsetsFromCenter.Add(new Vector2(-_bulbSize.X / 4, 0)); boxOffsetsFromCenter.Add(new Vector2(-_bulbSize.X / 4, _bulbSize.Y / 3)); boxOffsetsFromCenter.Add(new Vector2(_bulbSize.X / 4, -_bulbSize.Y / 3)); boxOffsetsFromCenter.Add(new Vector2(_bulbSize.X / 4, 0)); boxOffsetsFromCenter.Add(new Vector2(_bulbSize.X / 4, _bulbSize.Y / 3)); radius = (_bulbSize.Y / 6) / MathConstants.COS_45; } collisionBoxes.Add(new CircleCollisionBox(this, firstFrameCenter + boxOffsetsFromCenter[0], radius, GameConstants.STANDARD_COLLISION_MASK + GameConstants.TERRAIN_COLLISION_MASK)); collisionBoxes.Add(new CircleCollisionBox(this, firstFrameCenter + boxOffsetsFromCenter[1], radius, GameConstants.STANDARD_COLLISION_MASK + GameConstants.TERRAIN_COLLISION_MASK)); collisionBoxes.Add(new CircleCollisionBox(this, firstFrameCenter + boxOffsetsFromCenter[2], radius, GameConstants.STANDARD_COLLISION_MASK + GameConstants.TERRAIN_COLLISION_MASK)); collisionBoxes.Add(new CircleCollisionBox(this, firstFrameCenter + boxOffsetsFromCenter[3], radius, GameConstants.STANDARD_COLLISION_MASK + GameConstants.TERRAIN_COLLISION_MASK)); collisionBoxes.Add(new CircleCollisionBox(this, firstFrameCenter + boxOffsetsFromCenter[4], radius, GameConstants.STANDARD_COLLISION_MASK + GameConstants.TERRAIN_COLLISION_MASK)); collisionBoxes.Add(new CircleCollisionBox(this, firstFrameCenter + boxOffsetsFromCenter[5], radius, GameConstants.STANDARD_COLLISION_MASK + GameConstants.TERRAIN_COLLISION_MASK)); for (int i = 0; i < collisionBoxes.Count; i++) { var box = collisionBoxes[i]; _attackLeftBoxOffsets.Add(box, new List <Vector2>() { -firstFrameCenter + boxOffsetsFromCenter[i], -secondFrameCenter + boxOffsetsFromCenter[i], -thirdFrameCenter + boxOffsetsFromCenter[i], -fourthFrameCenter + boxOffsetsFromCenter[i], -fifthFrameCenter + boxOffsetsFromCenter[i] }); _attackRightBoxOffsets.Add(box, new List <Vector2>() { firstFrameCenter + boxOffsetsFromCenter[i], secondFrameCenter + boxOffsetsFromCenter[i], thirdFrameCenter + boxOffsetsFromCenter[i], fourthFrameCenter + boxOffsetsFromCenter[i], fifthFrameCenter + boxOffsetsFromCenter[i] }); _airAttackLeftBoxOffsets.Add(box, new List <Vector2>() { -secondFrameCenter + boxOffsetsFromCenter[i], -thirdFrameCenter + boxOffsetsFromCenter[i], -fourthFrameCenter + boxOffsetsFromCenter[i], -fifthFrameCenter + boxOffsetsFromCenter[i] }); _airAttackRightBoxOffsets.Add(box, new List <Vector2>() { secondFrameCenter + boxOffsetsFromCenter[i], thirdFrameCenter + boxOffsetsFromCenter[i], fourthFrameCenter + boxOffsetsFromCenter[i], fifthFrameCenter + boxOffsetsFromCenter[i] }); } } else { var collisionBox = new CircleCollisionBox(this, firstFrameCenter, _bulbRadius, GameConstants.STANDARD_COLLISION_MASK + GameConstants.TERRAIN_COLLISION_MASK); _attackLeftBoxOffsets.Add(collisionBox, new List <Vector2>() { -firstFrameCenter, -secondFrameCenter, -thirdFrameCenter, -fourthFrameCenter, -fifthFrameCenter }); _attackRightBoxOffsets.Add(collisionBox, new List <Vector2>() { firstFrameCenter, secondFrameCenter, thirdFrameCenter, fourthFrameCenter, fifthFrameCenter }); _airAttackLeftBoxOffsets.Add(collisionBox, new List <Vector2>() { -secondFrameCenter, -thirdFrameCenter, -fourthFrameCenter, -fifthFrameCenter }); _airAttackRightBoxOffsets.Add(collisionBox, new List <Vector2>() { secondFrameCenter, thirdFrameCenter, fourthFrameCenter, fifthFrameCenter }); } }