public CoverObject(CollisionDetectorInterface detector, List<Vector2> points, Vector2 position, Vector2 leftOrTop, Vector2 rightOrBottom) { if (detector != null) { detector.register(this); } collisionDetector_ = detector; boundsPolygon_ = new ConvexPolygon(points, Vector2.Zero); radius_ = 0; foreach (Vector2 vec in points) { if (vec.Length() > radius_) { radius_ = vec.Length(); } } position_ = position; direction_ = DIRECTION; boundsPolygon_.rotate(direction_, position_); leftOrTop_ = leftOrTop; rightOrBottom_ = rightOrBottom; if (leftOrTop_.X == rightOrBottom_.X) { orientation_ = CoverOrientationEnum.VERTICAL; } else { orientation_ = CoverOrientationEnum.HORIZONTAL; } coverDirection_ = needsToFace(position_); }
public Projectile(List<DrawableObjectAbstract> pipeline, GameTexture texture, CollisionDetectorInterface detector, ConvexPolygonInterface bounds, float radius, Height height, Vector2 velocity, Vector2 position, Vector2 direction, float depth) : base(pipeline, velocity, position, direction, depth) { texture_ = texture; if (detector != null) { detector.register(this); collisionDetector_ = detector; } boundsPolygon_ = bounds; radius_ = radius; height_ = height; }
public DummyEnemy(List<DrawableObjectAbstract> pipeline, Vector2 pos) : base(pipeline, new CharacterHealth(), new CharacterAmmo(), new CharacterWeapon(), "dummy", null, null, FRAMELENGTHMODIFIER, Vector2.Zero, pos, new Vector2(1.0f, 0.0f), 0.49f) { AI_ = new DummyAI(this); List<GameTexture> animationTextures = new List<GameTexture>(); animationTextures.Add(TextureMap.getInstance().getTexture("basic_enemy_walk")); animations_ = new AnimationSet(animationTextures); movingToward_ = new Vector2(150.0f, 260.0f); lookingAt_ = new Vector2(250.0f, 60.0f); atLocation_ = false; collisionDetector_ = null; radius_ = RADIUS; Allegiance_ = 2; height_ = new Height(true, false); boundsPolygon_ = new CircularConvexPolygon(radius_, position_); AnimationInterface run = new LoopAnimation(TextureMap.getInstance().getTexture("basic_enemy_walk"), frameLengthModifier_, depth_, boundsPolygon_); AnimationInterface runTo = new LoopAnimation(TextureMap.getInstance().getTexture("basic_enemy_walk"), frameLengthModifier_, depth_, boundsPolygon_); AnimationInterface rest = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Blank"), frameLengthModifier_, depth_, boundsPolygon_); AnimationInterface rest2 = new LoopAnimation(TextureMap.getInstance().getTexture("basic_enemy_walk"), frameLengthModifier_, depth_, boundsPolygon_); AnimationInterface[] restAnims = new AnimationInterface[2]; restAnims[0] = rest; restAnims[1] = rest2; AnimationInterface[] shoot = new AnimationInterface[1]; shoot[0] = rest; List<string> levels = new List<string>(); levels.Add("look"); levels.Add("lower"); Dictionary<string, Dictionary<string, CharacterActionInterface>> actions = new Dictionary<string, Dictionary<string, CharacterActionInterface>>(); actions.Add("default", new Dictionary<string, CharacterActionInterface>()); actions["default"].Add("move", new CharacterRunAction(this, run, 2.0f, "lower")); actions["default"].Add("moveTo", new CharacterRunToAction(this, runTo, 2.0f, "lower")); actions["default"].Add("rest", new CharacterStayStillAction(this, restAnims, levels, "lower", "lower")); actions["default"].Add("crouch", new NoAction("lower")); actions["default"].Add("cover", new NoAction("lower")); actions["default"].Add("shoot", new CharacterShootAction(this, shoot, "lower", 0)); actions["default"].Add("look", new CharacterLookAction(this, "look")); actions["default"].Add("lookAt", new CharacterLookAtAction(this, "look")); actions["default"].Add("reload", new NoAction("lower")); actions["default"].Add("throw", new NoAction("lower")); actuator_ = new MultiLevelActuator(actions, levels, this, "default", "rest", "lower", "lower"); currentDrawColor_ = Color.White; health_.update(15); Weapon_ = new DroneGun(pipeline_, this, new Vector2(GUNHANDLEX, GUNHANDLEY)); }
public ItemAbstract(CollisionDetectorInterface detector, List<Vector2> points, Vector2 center, float radius, Height height, List<DrawableObjectAbstract> pipeline, GameTexture image, Vector2 position, Vector2 direction, float depth) : base(pipeline, image, position, direction, depth) { bounds_ = new ConvexPolygon(points, center); bounds_.rotate(direction_, position_); radius_ = radius; height_ = height; hasBeenPickedUp_ = false; if (detector != null) { detector.register(this); } detector_ = detector; }
public NonLoopAnimation(GameTexture sprites, float frameLengthModifier, float depth, ConvexPolygonInterface polygon) { sprites_ = sprites; currentFrame_ = 0; totalFrames_ = sprites.getNumberOfImages(); position_ = Vector2.Zero; rotation_ = Vector2.Zero; frameLengthModifier_ = frameLengthModifier; moved_ = Vector2.Zero; depth_ = depth; boundsPolygon_ = new ConvexPolygonInterface[1]; boundsPolygon_[0] = polygon; perFrameBounds_ = false; }
public ComplexConvexPolygon(ConvexPolygonInterface low, ConvexPolygonInterface high) { lowPolygon_ = low; highPolygon_ = high; }
public BoxObject(List<Vector2> points, Vector2 center, Height height) { position_ = center; boundsPolygon_ = new ConvexPolygon(points, Vector2.Zero); height_ = height; }
public HumanEnemy(List<DrawableObjectAbstract> pipeline, Vector2 pos) : base(pipeline, new CharacterHealth(), new CharacterAmmo(), new CharacterWeapon(), "human", null, null, 8.0f, Vector2.Zero, pos, new Vector2(1.0f, 0.0f), Constants.DEPTH_HIGH) { AI_ = new HumanAI(this); boundsPolygonLow_ = new ConvexPolygon(BOUNDSPOINTSLOW, Vector2.Zero); boundsPolygonHigh_ = new ConvexPolygon(BOUNDSPOINTSHIGH, Vector2.Zero); boundsPolygonHigh_.rotate(direction_, position_); boundsPolygonLow_.rotate(direction_, position_); radius_ = RADIUS; Allegiance_ = 2; /* AnimationInterface run = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Stand_Rifle_Walk"), frameLengthModifier_, depth_); AnimationInterface runTo = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Stand_Rifle_Walk"), frameLengthModifier_, depth_); AnimationInterface rest = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Stand_Rifle_Walk"), frameLengthModifier_, depth_); AnimationInterface crouch = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Stand_Rifle_Walk"), frameLengthModifier_, depth_); AnimationInterface cover = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Stand_Rifle_Walk"), frameLengthModifier_, depth_); AnimationInterface crouch_run = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Rifle_Walk"), frameLengthModifier_, depth_); AnimationInterface crouch_runTo = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Rifle_Walk"), frameLengthModifier_, depth_); AnimationInterface crouch_rest = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Rifle"), frameLengthModifier_, depth_); AnimationInterface crouch_crouch = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Rifle"), frameLengthModifier_, depth_); AnimationInterface crouch_cover = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Rifle_Walk"), frameLengthModifier_, depth_); AnimationInterface cover_run = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Rifle_Walk"), frameLengthModifier_, depth_); AnimationInterface cover_runTo = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Rifle_Walk"), frameLengthModifier_, depth_); AnimationInterface cover_rest = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Rifle"), frameLengthModifier_, depth_); AnimationInterface cover_crouch = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Rifle"), frameLengthModifier_, depth_); AnimationInterface cover_cover = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Rifle_Walk"), frameLengthModifier_, depth_); AnimationInterface cover_shoot = new NonLoopAnimation(TextureMap.fetchTexture("GreenPlayer_StandToShoot_Rifle"), 1.0f, depth_); AnimationInterface pistol_run = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Stand_Pistol_Walk"), frameLengthModifier_, depth_); AnimationInterface pistol_runTo = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Stand_Pistol_Walk"), frameLengthModifier_, depth_); AnimationInterface pistol_rest = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Stand_Pistol_Walk"), frameLengthModifier_, depth_); AnimationInterface pistol_crouch = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Stand_Pistol_Walk"), frameLengthModifier_, depth_); AnimationInterface pistol_cover = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Stand_Pistol_Walk"), frameLengthModifier_, depth_); AnimationInterface pistol_crouch_run = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Pistol_Walk"), frameLengthModifier_, depth_); AnimationInterface pistol_crouch_runTo = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Pistol_Walk"), frameLengthModifier_, depth_); AnimationInterface pistol_crouch_rest = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Pistol"), frameLengthModifier_, depth_); AnimationInterface pistol_crouch_crouch = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Pistol"), frameLengthModifier_, depth_); AnimationInterface pistol_crouch_cover = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Pistol_Walk"), frameLengthModifier_, depth_); AnimationInterface pistol_cover_run = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Pistol_Walk"), frameLengthModifier_, depth_); AnimationInterface pistol_cover_runTo = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Pistol_Walk"), frameLengthModifier_, depth_); AnimationInterface pistol_cover_rest = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Pistol"), frameLengthModifier_, depth_); AnimationInterface pistol_cover_crouch = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Pistol"), frameLengthModifier_, depth_); AnimationInterface pistol_cover_cover = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Crouch_Pistol_Walk"), frameLengthModifier_, depth_); AnimationInterface pistol_cover_shoot = new NonLoopAnimation(TextureMap.fetchTexture("GreenPlayer_StandToShoot_Pistol"), 1.0f, depth_); Dictionary<string, Dictionary<string, CharacterActionInterface>> actions = new Dictionary<string, Dictionary<string, CharacterActionInterface>>(); //actions.Add("default", new Dictionary<string, CharacterActionInterface>()); //actions["default"].Add("move", new CharacterRunAction(this, run, 3.0f)); //actions["default"].Add("moveTo", new CharacterRunToAction(this, runTo, 3.0f)); //actions["default"].Add("rest", new CharacterStayStillAction(this, rest)); actions.Add("crouch", new Dictionary<string, CharacterActionInterface>()); actions["crouch"].Add("move", new CharacterRunAction(this, crouch_run, SPEED)); actions["crouch"].Add("moveTo", new CharacterRunToAction(this, crouch_runTo, SPEED)); actions["crouch"].Add("rest", new CharacterStayStillAction(this, crouch_rest)); actions["crouch"].Add("crouch", new CrouchAction(this, crouch, "stand", new Height(true, true))); actions["crouch"].Add("cover", new AttachToCoverAction(this, crouch_cover, "cover", new Height(true, false), SPEED)); actions["crouch"].Add("shoot", new CharacterShootAction()); actions["crouch"].Add("throw", new ThrowGrenadeAction(this, crouch_rest, new Vector2(30f, 0f))); actions.Add("stand", new Dictionary<string, CharacterActionInterface>()); actions["stand"].Add("move", new CharacterRunAction(this, run, SPEED)); actions["stand"].Add("moveTo", new CharacterRunToAction(this, runTo, SPEED)); actions["stand"].Add("rest", new CharacterStayStillAction(this, rest)); actions["stand"].Add("crouch", new CrouchAction(this, crouch_crouch, "crouch", new Height(true, false))); actions["stand"].Add("cover", new AttachToCoverAction(this, cover, "cover", new Height(true, false), SPEED)); actions["stand"].Add("shoot", new CharacterShootAction()); actions["stand"].Add("throw", new ThrowGrenadeAction(this, rest, new Vector2(30f, 0f))); actions.Add("cover", new Dictionary<string, CharacterActionInterface>()); actions["cover"].Add("move", new CharacterCoverMoveAction(this, cover_run, SPEED)); actions["cover"].Add("moveTo", new CharacterCoverMoveAction(this, cover_runTo, SPEED)); actions["cover"].Add("rest", new CharacterStayStillAction(this, cover_rest)); actions["cover"].Add("crouch", new CrouchAction(this, cover_crouch, "cover", new Height(true, false))); actions["cover"].Add("cover", new DetachFromCoverAction(this, cover_cover, "stand", new Height(true, true), SPEED)); actions["cover"].Add("shoot", new CharacterCoverShootAction(this, cover_shoot, 1)); actions["cover"].Add("throw", new ThrowGrenadeAction(this, cover_rest, new Vector2(30f, 0f))); actions.Add("pistol_crouch", new Dictionary<string, CharacterActionInterface>()); actions["pistol_crouch"].Add("move", new CharacterRunAction(this, pistol_crouch_run, SPEED)); actions["pistol_crouch"].Add("moveTo", new CharacterRunToAction(this, pistol_crouch_runTo, SPEED)); actions["pistol_crouch"].Add("rest", new CharacterStayStillAction(this, pistol_crouch_rest)); actions["pistol_crouch"].Add("crouch", new CrouchAction(this, pistol_crouch, "pistol_stand", new Height(true, true))); actions["pistol_crouch"].Add("cover", new AttachToCoverAction(this, pistol_crouch_cover, "pistol_cover", new Height(true, false), SPEED)); actions["pistol_crouch"].Add("shoot", new CharacterShootAction()); actions["pistol_crouch"].Add("throw", new ThrowGrenadeAction(this, pistol_crouch_rest, new Vector2(30f, 0f))); actions.Add("pistol_stand", new Dictionary<string, CharacterActionInterface>()); actions["pistol_stand"].Add("move", new CharacterRunAction(this, pistol_run, SPEED)); actions["pistol_stand"].Add("moveTo", new CharacterRunToAction(this, pistol_runTo, SPEED)); actions["pistol_stand"].Add("rest", new CharacterStayStillAction(this, pistol_rest)); actions["pistol_stand"].Add("crouch", new CrouchAction(this, pistol_crouch_crouch, "pistol_crouch", new Height(true, false))); actions["pistol_stand"].Add("cover", new AttachToCoverAction(this, pistol_cover, "pistol_cover", new Height(true, false), SPEED)); actions["pistol_stand"].Add("shoot", new CharacterShootAction()); actions["pistol_stand"].Add("throw", new ThrowGrenadeAction(this, pistol_rest, new Vector2(30f, 0f))); actions.Add("pistol_cover", new Dictionary<string, CharacterActionInterface>()); actions["pistol_cover"].Add("move", new CharacterCoverMoveAction(this, pistol_cover_run, SPEED)); actions["pistol_cover"].Add("moveTo", new CharacterCoverMoveAction(this, pistol_cover_runTo, SPEED)); actions["pistol_cover"].Add("rest", new CharacterStayStillAction(this, pistol_cover_rest)); actions["pistol_cover"].Add("crouch", new CrouchAction(this, pistol_cover_crouch, "pistol_cover", new Height(true, false))); actions["pistol_cover"].Add("cover", new DetachFromCoverAction(this, pistol_cover_cover, "pistol_stand", new Height(true, true), SPEED)); actions["pistol_cover"].Add("shoot", new CharacterCoverShootAction(this, pistol_cover_shoot, 1)); actions["pistol_cover"].Add("throw", new ThrowGrenadeAction(this, pistol_cover_rest, new Vector2(30f, 0f))); actuator_ = new DefaultActuator(actions, this, "pistol_stand"); */ //YOU MUST CHANGE THIS CODE List<string> levels = new List<string>(); levels.Add("transition"); levels.Add("turning"); levels.Add("lower"); levels.Add("upper"); List<Vector2> boundsPointsLow = BOUNDSPOINTSLOW; List<Vector2> boundsPointsHigh = BOUNDSPOINTSHIGH; AnimationInterface[] restAnimations = new AnimationInterface[8]; restAnimations[0] = new LoopAnimation(TextureMap.fetchTexture("GreenPlayer_Blank"), frameLengthModifier_, depth_ - 0.02f, boundsPointsLow); restAnimations[1] = restAnimations[0]; restAnimations[2] = restAnimations[0]; restAnimations[3] = restAnimations[0]; restAnimations[4] = new LoopAnimation(TextureMap.fetchTexture("GreenPlayer_Walk_Stand"), frameLengthModifier_, depth_ - 0.01f, boundsPointsLow); restAnimations[5] = restAnimations[4]; restAnimations[6] = new LoopAnimation(TextureMap.fetchTexture("RedPlayer_Pistol_Stand"), frameLengthModifier_, depth_, boundsPointsHigh); restAnimations[7] = new LoopAnimation(TextureMap.fetchTexture("RedPlayer_Rifle_Stand"), frameLengthModifier_, depth_, boundsPointsHigh); AnimationInterface[] crouchRestAnimations = new AnimationInterface[8]; crouchRestAnimations[0] = new LoopAnimation(TextureMap.fetchTexture("GreenPlayer_Blank"), frameLengthModifier_, depth_ - 0.02f, BOUNDSPOINTSLOWCROUCH); crouchRestAnimations[1] = crouchRestAnimations[0]; crouchRestAnimations[2] = crouchRestAnimations[0]; crouchRestAnimations[3] = crouchRestAnimations[0]; crouchRestAnimations[4] = new LoopAnimation(TextureMap.fetchTexture("GreenPlayer_Crouch_Stationary"), frameLengthModifier_, depth_ - 0.01f, BOUNDSPOINTSLOWCROUCH); crouchRestAnimations[5] = crouchRestAnimations[4]; crouchRestAnimations[6] = new LoopAnimation(TextureMap.fetchTexture("RedPlayer_Pistol_Crouch"), frameLengthModifier_, depth_, BOUNDSPOINTSLOWCROUCH); crouchRestAnimations[7] = new LoopAnimation(TextureMap.fetchTexture("RedPlayer_Rifle_Crouch"), frameLengthModifier_, depth_, BOUNDSPOINTSLOWCROUCH); AnimationInterface runAnimation = new LoopAnimation(TextureMap.fetchTexture("GreenPlayer_Walk_Stand"), frameLengthModifier_, depth_ - 0.01f, boundsPointsLow); AnimationInterface runToAnimation = new LoopAnimation(TextureMap.fetchTexture("GreenPlayer_Walk_Stand"), frameLengthModifier_, depth_ - 0.01f, boundsPointsLow); AnimationInterface coverAnimation = new LoopAnimation(TextureMap.fetchTexture("GreenPlayer_Walk_Stand"), frameLengthModifier_, depth_ - 0.01f, boundsPointsLow); AnimationInterface crouchAnimation = new LoopAnimation(TextureMap.fetchTexture("GreenPlayer_Walk_Stand"), frameLengthModifier_, depth_ - 0.01f, boundsPointsLow); AnimationInterface crouchedRunAnimation = new LoopAnimation(TextureMap.fetchTexture("GreenPlayer_Walk_Crouch"), frameLengthModifier_, depth_ - 0.01f, BOUNDSPOINTSLOWCROUCH); AnimationInterface crouchedRunToAnimation = new LoopAnimation(TextureMap.fetchTexture("GreenPlayer_Walk_Crouch"), frameLengthModifier_, depth_ - 0.01f, BOUNDSPOINTSLOWCROUCH); AnimationInterface crouchedCoverAnimation = new LoopAnimation(TextureMap.fetchTexture("GreenPlayer_Walk_Crouch"), frameLengthModifier_, depth_ - 0.01f, BOUNDSPOINTSLOWCROUCH); AnimationInterface crouchedCrouchAnimation = new LoopAnimation(TextureMap.fetchTexture("GreenPlayer_Walk_Crouch"), frameLengthModifier_, depth_ - 0.01f, BOUNDSPOINTSLOWCROUCH); AnimationInterface[] shootAnimations = new AnimationInterface[2]; shootAnimations[0] = new LoopAnimation(TextureMap.fetchTexture("RedPlayer_Pistol_Stand"), frameLengthModifier_, depth_, boundsPointsHigh); shootAnimations[1] = new LoopAnimation(TextureMap.fetchTexture("RedPlayer_Rifle_Stand"), frameLengthModifier_, depth_, boundsPointsHigh); AnimationInterface[] throwGrenadeAnimations = new AnimationInterface[2]; throwGrenadeAnimations[0] = new LoopAnimation(TextureMap.fetchTexture("RedPlayer_Pistol_Stand"), frameLengthModifier_, depth_, boundsPointsHigh); throwGrenadeAnimations[1] = new LoopAnimation(TextureMap.fetchTexture("RedPlayer_Rifle_Stand"), frameLengthModifier_, depth_, boundsPointsHigh); AnimationInterface[] crouchedShootAnimations = new AnimationInterface[2]; crouchedShootAnimations[0] = new NonLoopAnimation(TextureMap.fetchTexture("RedPlayer_Pistol_Crouch"), frameLengthModifier_, depth_, boundsPointsHigh); crouchedShootAnimations[1] = new NonLoopAnimation(TextureMap.fetchTexture("RedPlayer_Rifle_Crouch"), frameLengthModifier_, depth_, boundsPointsHigh); AnimationInterface[] crouchedThrowGrenadeAnimations = new AnimationInterface[2]; crouchedThrowGrenadeAnimations[0] = new LoopAnimation(TextureMap.fetchTexture("RedPlayer_Pistol_Crouch"), frameLengthModifier_, depth_, boundsPointsHigh); crouchedThrowGrenadeAnimations[1] = new LoopAnimation(TextureMap.fetchTexture("RedPlayer_Rifle_Crouch"), frameLengthModifier_, depth_, boundsPointsHigh); Dictionary<string, Dictionary<string, CharacterActionInterface>> actions = new Dictionary<string, Dictionary<string, CharacterActionInterface>>(); actions.Add("crouch", new Dictionary<string, CharacterActionInterface>()); actions["crouch"].Add("move", new CharacterRunAction(this, crouchedRunAnimation, SPEED, "lower")); actions["crouch"].Add("moveTo", new CharacterRunToAction(this, crouchedRunToAnimation, SPEED, "lower")); actions["crouch"].Add("rest", new CharacterStayStillAction(this, crouchRestAnimations, levels, "upper", "lower")); actions["crouch"].Add("crouch", new CrouchAction(this, crouchedCrouchAnimation, "stand", new Height(true, true), "transition")); actions["crouch"].Add("cover", new AttachToCoverAction(this, crouchedCoverAnimation, "cover", new Height(true, false), SPEED, "lower")); actions["crouch"].Add("shoot", new CharacterShootAction(this, crouchedShootAnimations, "upper", 0)); actions["crouch"].Add("throw", new ThrowGrenadeAction(this, crouchedThrowGrenadeAnimations, new Vector2(30f, 0f), "upper")); actions["crouch"].Add("look", new CharacterLookAction(this, "turning")); actions["crouch"].Add("lookAt", new CharacterLookAtAction(this, "turning")); actions["crouch"].Add("reload", new NoAction("upper")); actions.Add("stand", new Dictionary<string, CharacterActionInterface>()); actions["stand"].Add("move", new CharacterRunAction(this, runAnimation, SPEED, "lower")); actions["stand"].Add("moveTo", new CharacterRunToAction(this, runToAnimation, SPEED, "lower")); actions["stand"].Add("rest", new CharacterStayStillAction(this, restAnimations, levels, "upper", "lower")); actions["stand"].Add("crouch", new CrouchAction(this, crouchAnimation, "crouch", new Height(true, false), "transition")); actions["stand"].Add("cover", new AttachToCoverAction(this, coverAnimation, "cover", new Height(true, false), SPEED, "lower")); actions["stand"].Add("shoot", new CharacterShootAction(this, shootAnimations, "upper", 0)); actions["stand"].Add("throw", new ThrowGrenadeAction(this, throwGrenadeAnimations, new Vector2(30f, 0f), "upper")); actions["stand"].Add("look", new CharacterLookAction(this, "turning")); actions["stand"].Add("lookAt", new CharacterLookAtAction(this, "turning")); actions["stand"].Add("reload", new NoAction("upper")); actions.Add("cover", new Dictionary<string, CharacterActionInterface>()); actions["cover"].Add("move", new CharacterCoverMoveAction(this, crouchedRunAnimation, SPEED, "lower")); actions["cover"].Add("moveTo", new CharacterCoverMoveToAction(this, crouchedRunToAnimation, SPEED, "lower")); actions["cover"].Add("rest", new CharacterStayStillAction(this, crouchRestAnimations, levels, "upper", "lower")); actions["cover"].Add("crouch", new CrouchAction(this, crouchedCrouchAnimation, "stand", new Height(true, true), "transition")); actions["cover"].Add("cover", new DetachFromCoverAction(this, crouchedCoverAnimation, "stand", new Height(true, true), SPEED, "lower")); actions["cover"].Add("shoot", new CharacterCoverShootAction(this, crouchedShootAnimations, 0, "upper")); actions["cover"].Add("throw", new ThrowGrenadeAction(this, crouchedThrowGrenadeAnimations, new Vector2(30f, 0f), "upper")); actions["cover"].Add("look", new CharacterLookAction(this, "turning")); actions["cover"].Add("lookAt", new CharacterLookAtAction(this, "turning")); actions["cover"].Add("reload", new NoAction("upper")); actuator_ = new MultiLevelActuator(actions, levels, this, "stand", "rest", "lower", "upper"); //END CHANGE NEEDED Weapon_ = new Pistol(pipeline, this, new Vector2(60f - 37.5f, 33.5f - 37.5f)); height_ = new Height(true, true); health_.update(25); }
public Vector2 checkCollision(ConvexPolygonInterface polygonA, ConvexPolygonInterface polygonB, float radDistance, Vector2 velocity) { int edgesCountPolygonA = polygonA.getNumberOfPoints(); int edgesCountPolygonB = polygonB.getNumberOfPoints(); Vector2 centerA = polygonA.getCenter(); Vector2 centerB = polygonB.getCenter(); if (polygonA is CircularConvexPolygon && polygonB is CircularConvexPolygon) { Vector2 tempRet = centerA - centerB; tempRet.Normalize(); return tempRet * radDistance; } else if (polygonA is CircularConvexPolygon) { edgesCountPolygonA = edgesCountPolygonB; } else if (polygonB is CircularConvexPolygon) { edgesCountPolygonB = edgesCountPolygonA; } float minDistance = float.PositiveInfinity; Vector2 minAxis = Vector2.Zero; Vector2 currentEdgeNormal; for (int i = 0; i < edgesCountPolygonA + edgesCountPolygonB; i++) { if (i < edgesCountPolygonA) { if (polygonA is CircularConvexPolygon) { currentEdgeNormal = polygonB.getPoint(i) - centerA; } else { currentEdgeNormal = polygonA.getEdge(i); } } else { if (polygonB is CircularConvexPolygon) { currentEdgeNormal = polygonA.getPoint(i - edgesCountPolygonA) - centerB; } else { currentEdgeNormal = polygonB.getEdge(i - edgesCountPolygonA); } } currentEdgeNormal.Normalize(); float minA = 0, minB = 0, maxA = 0, maxB = 0; polygonA.projectPolygonOnAxis(currentEdgeNormal, new Height(), ref minA, ref maxA); polygonB.projectPolygonOnAxis(currentEdgeNormal, new Height(), ref minB, ref maxB); float velocityProjection = ConvexPolygon.dotProduct(velocity, currentEdgeNormal); if (velocityProjection < 0) { minA += velocityProjection; } else { maxA += velocityProjection; } float distance = distanceBetweenProjections(minA, maxA, minB, maxB); if (distance > 0) { return Vector2.Zero; } distance = Math.Abs(distance); if (distance < minDistance) { minDistance = distance; if (ConvexPolygon.dotProduct(centerA - centerB, currentEdgeNormal) < 0) { minAxis = -currentEdgeNormal; } else { minAxis = currentEdgeNormal; } } } return minAxis * minDistance; }