public Grenade(List<DrawableObjectAbstract> pipeline, GameTexture texture, CollisionDetectorInterface detector, Vector2 direction, Vector2 position, Vector2 directionFacing) : base(pipeline, texture, detector, null, RADIUS, HEIGHT, CommonFunctions.normalizeNonmutating(direction) * SPEED, position, directionFacing, DEPTH) { boundsPolygon_ = new ConvexPolygon(BOUNDS_POINTS, Vector2.Zero); fuseTime_ = FUSE; started_ = false; }
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 Missile(List<DrawableObjectAbstract> pipeline, CollisionDetectorInterface detector, CharacterAbstract target) : base(pipeline, TextureMap.fetchTexture(TEXTURE_NAME), detector, null, RADIUS, HEIGHT, Vector2.Zero, Vector2.Zero, Vector2.Zero, DEPTH) { damage_ = DAMAGE; boundsPolygon_ = new ConvexPolygon(BOUNDS_POINTS, Vector2.Zero); target_ = target; }
public virtual Vector2 checkCollisionInto(CollisionObjectInterface obj, CollisionDetectorInterface detector, Height height, float radDistance, Vector2 translate) { if (!hasBeenPickedUp_ && obj is PlayableCharacterAbstract) { handleCollision(obj); } return Vector2.Zero; }
public virtual Vector2 checkCollisionWith(CollisionObjectInterface obj, CollisionDetectorInterface detector, HeightEnum height, float radDistance, Vector2 velocity) { if (detector.checkCollision(obj.getBounds(height), getBounds(height), radDistance, velocity) != Vector2.Zero) { handleCollision(obj); } return Vector2.Zero; }
public override Vector2 checkCollisionInto(CollisionObjectInterface obj, CollisionDetectorInterface detector, Height height, float radDistance, Vector2 translate) { Vector2 normal = translate; //normal.Normalize(); //velocity_ = velocity_ - velocity_.Length() * (CommonFunctions.dotProduct(velocity_, normal)) * normal; velocity_ /= 2f; velocity_ = velocity_ - 2 * (CommonFunctions.dotProduct(velocity_, normal) / normal.LengthSquared()) * normal; return 2 * translate; }
public virtual Vector2 checkCollisionWith(CollisionObjectInterface obj, CollisionDetectorInterface detector, HeightEnum height, float radDistance, Vector2 velocity) { if (!hasBeenPickedUp_ && detector.checkCollision(obj.getBounds(height), getBounds(height), radDistance, velocity) != Vector2.Zero && (obj is PlayableCharacterAbstract)) { handleCollision(obj); } return Vector2.Zero; }
// --- Implemented Functions --- public TransitionObjectAbstract(List<DrawableObjectAbstract> pipeline, CollisionDetectorInterface detector, GameTexture image, Vector2 position, Vector2 direction, float depth, float radius, Height height) : base(pipeline, image, position, direction, depth) { if (detector != null) { detector.register(this); } detector_ = detector; radius_ = radius; height_ = height; }
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 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; }
/// <summary> /// Create a Character with the specified health, ammo, and weapon objects, plus the given name /// </summary> /// <param name="health">CharacterStatusElement for health</param> /// <param name="ammo">CharacterStatusElement for ammo</param> /// <param name="weapon">CharacterStatusElement for the current weapon</param> /// <param name="name">The character's name</param> /// <param name="collisionDetector">Collision detector with which this object should register.</param> public CharacterAbstract(CharacterHealth health, CharacterAmmo ammo, CharacterWeapon weapon, string name, CollisionDetectorInterface collisionDetector) : base() { health_ = health; ammo_ = ammo; weapon_ = weapon; name_ = name; collisionDetector_ = collisionDetector; if (collisionDetector_ != null) { collisionDetector_.register(this); } height_ = new Height(true, true); Inventory_ = new Inventory(); }
public virtual Vector2 checkCollisionInto(CollisionObjectInterface obj, CollisionDetectorInterface detector, Height height, float radDistance, Vector2 translate) { if (objectChangesHeight(obj)) { if (height.blocksHigh_) { height_.blocksHigh_ = false; } if(height.blocksLow_) { height_.blocksLow_ = false; } } if (obj is CharacterAbstract) { height_ = new Height(false, false); } if (height_.blocksHigh_ || height_.blocksLow_) { return Vector2.Zero; } return translate; }
public void setCollisionDetector(CollisionDetectorInterface collisionDetector) { if (collisionDetector_ != null) { collisionDetector_.remove(this); } collisionDetector_ = collisionDetector; Weapon_.setCollisionDetector(collisionDetector_); foreach (RangedWeaponAbstract weap in Inventory_.Weapons_) { weap.setCollisionDetector(collisionDetector_); } if (collisionDetector_ != null) { collisionDetector_.register(this); } }
public virtual Vector2 checkCollisionWith(CollisionObjectInterface obj, CollisionDetectorInterface detector, HeightEnum height, float radDistance, Vector2 velocity) { return detector.checkCollision(obj.getBounds(height), getBounds(height), radDistance, velocity); }
public virtual Vector2 checkCollisionInto(CollisionObjectInterface obj, CollisionDetectorInterface detector, Height height, float radDistance, Vector2 translate) { return translate; }
/// <summary> /// Create a Character with the specified health, ammo, and weapon objects, plus the given name. /// Also, specify the AnimationSet, frameLengthModifier, velocity, position, direction, /// and depth of the character. /// </summary> /// <param name="pipeline">List of objects from which the object should be drawn.</param> /// <param name="health">CharacterStatusElement for health</param> /// <param name="ammo">CharacterStatusElement for ammo</param> /// <param name="weapon">CharacterStatusElement for the current weapon</param> /// <param name="name">The character's name</param> /// <param name="collisionDetector">Collision detector with which this object should register.</param> /// <param name="animations">AnimationSet containing all animations for this object</param> /// <param name="frameLengthModifier">Float representing the ratio of frames in an animation to movement along the screen</param> /// <param name="velocity">Vector of velocity, representing both direction of movement and magnitude</param> /// <param name="position">Position of object relative to the top left corner</param> /// <param name="direction">Vector representing the direction of the object</param> /// <param name="depth">Depth the object is to be drawn to</param> public CharacterAbstract(List<DrawableObjectAbstract> pipeline, CharacterHealth health, CharacterAmmo ammo, CharacterWeapon weapon, string name, CollisionDetectorInterface collisionDetector, AnimationSet animations, float frameLengthModifier, Vector2 velocity, Vector2 position, Vector2 direction, float depth) : base(pipeline, animations, frameLengthModifier, velocity, position, direction, depth) { health_ = health; ammo_ = ammo; weapon_ = weapon; name_ = name; collisionDetector_ = collisionDetector; if (collisionDetector_ != null) { collisionDetector_.register(this); } height_ = new Height(true, true); Inventory_ = new Inventory(); }
public virtual Vector2 checkCollisionWith(CollisionObjectInterface obj, CollisionDetectorInterface detector, HeightEnum height, float radDistance, Vector2 velocity) { Vector2 translate = detector.checkCollision(obj.getBounds(height), getBounds(height), radDistance, velocity); if (translate != Vector2.Zero) { obj.collidedInto(this); collidedWith(obj); if (objectChangesHeight(obj)) { if (height == HeightEnum.HIGH) { height_.blocksHigh_ = false; } else { height_.blocksLow_ = false; } } if (obj is CharacterAbstract) { height_ = new Height(false, false); } } return Vector2.Zero; }
public Bullet(List<DrawableObjectAbstract> pipeline, CollisionDetectorInterface detector, Vector2 position, Vector2 direction) : base(pipeline, TextureMap.fetchTexture(TEXTURE_NAME), detector, null, RADIUS, HEIGHT, direction * SPEED, position, direction, DEPTH) { damage_ = DAMAGE; boundsPolygon_ = new ConvexPolygon(BOUNDS_POINTS, Vector2.Zero); }
internal BulletLimitedRange(List<DrawableObjectAbstract> pipeline, CollisionDetectorInterface detector, Vector2 position, Vector2 direction, float range) : base(pipeline, detector, position, direction) { maxDistanceSq_ = range * range; origPosition_ = position; }
public void setCollisionDetector(CollisionDetectorInterface detector) { if (detector != null) { detector.register(this); collisionDetector_ = detector; } }
public Vector2 checkCollisionWith(CollisionObjectInterface obj, CollisionDetectorInterface detector, HeightEnum height, float radDistance, Vector2 velocity) { if (detector.checkCollision(obj.getBounds(height), getBounds(height), radDistance, velocity) != Vector2.Zero) { collidedWith(obj); obj.collidedInto(this); } return Vector2.Zero; }
public virtual Vector2 checkCollisionInto(CollisionObjectInterface obj, CollisionDetectorInterface detector, Height height, float radDistance, Vector2 translate) { handleCollision(obj); return Vector2.Zero; }
public void setCollisionDetector(CollisionDetectorInterface collisionDetector) { if (collisionDetector_ != null) { collisionDetector_.remove(this); } collisionDetector_ = collisionDetector; if (collisionDetector_ != null) { collisionDetector_.register(this); } }
public override void setCollisionDetector(CollisionDetectorInterface collisionDetector) { if (detector_ != null) { detector_.remove(this); } detector_ = collisionDetector; if (detector_ != null) { detector_.register(this); } }
internal FragGrenade(List<DrawableObjectAbstract> pipeline, CollisionDetectorInterface detector, Vector2 direction, Vector2 position, Vector2 directionFacing) : base(pipeline, TextureMap.fetchTexture(TEXTURE_KEY), detector, direction, position, directionFacing) { }
public void loadLevel(Level level) { myLevel_ = level; drawPipeline_ = myLevel_.Pipeline_; collisionDetector_ = myLevel_.CollisionDetector_; if (player_ != null && myLevel_.getPlayerStartLocation() != null && myLevel_.getPlayerStartLocation() != Vector2.Zero) { player_.setPosition(myLevel_.getPlayerStartLocation()); player_.setDrawPipeline(drawPipeline_); } else if (myLevel_.getPlayerStartLocation() != null && myLevel_.getPlayerStartLocation() != Vector2.Zero) { player_ = new ActuatedMainPlayer(drawPipeline_, collisionDetector_, myLevel_.getPlayerStartLocation(), new Vector2(1.0f, 0.0f)); myLevel_.setPlayer(player_); } else { player_ = null; } // Initialize mouse and/or camera if (player_ == null) { engine_.IsMouseVisible = true; } else { GlobalHelper.getInstance().getCurrentCamera().setCenter(player_.getPosition().X, player_.getPosition().Y); engine_.IsMouseVisible = false; } WorldState.reset(); myLevel_.initializeForGameplay(); // Initialize player and HUD if (player_ != null) { List<GameTexture> myTextures = new List<GameTexture>(); myTextures.Add(TextureMap.getInstance().getTexture(PISTOL_TEX_NAME)); myTextures.Add(TextureMap.getInstance().getTexture(SHOTGUN_TEX_NAME)); myTextures.Add(TextureMap.getInstance().getTexture(MACHINEGUN_TEX_NAME)); healthBarPos_ = HEALTH_BAR_POSITION; weaponIconPos_ = WEAPON_ICON_POSITION; healthTextPos_ = new Vector2(healthBarPos_.X + HEALTH_TEXT_OFFSET_X, healthBarPos_.Y + HEALTH_TEXT_OFFSET_Y); ammoTextPos_ = AMMO_TEXT_POSITION; healthBar_ = new HeadsUpDisplayObject(drawPipeline_, TextureMap.getInstance().getTexture(HEALTH_BAR_FILL_TEX_NAME), healthBarPos_, Vector2.Zero, HUD_DRAW_DEPTH); weapon_ = new HeadsUpDisplayWeapon(drawPipeline_, TextureMap.getInstance().getTexture(WEAPON_TEX_NAME), myTextures, weaponIconPos_, Vector2.Zero, HUD_DRAW_DEPTH); ammo_ = new HeadsUpDisplayText(ammoTextPos_, FONT_DRAW_DEPTH, FontEnum.Kootenay14, player_.Weapon_.CurrentAmmo_); player_.getHealth().addObserver(healthBar_); player_.getWeapon().addObserver(weapon_); player_.getAmmo().addObserver(ammo_); player_.setCollisionDetector(collisionDetector_); } }
public ActuatedMainPlayer(List<DrawableObjectAbstract> pipeline, CollisionDetectorInterface detector, Vector2 position, Vector2 direction) : base(pipeline, new CharacterHealth(), new CharacterAmmo(), new CharacterWeapon(), "Woger Ru", detector, null, 8.0f, Vector2.Zero, position, direction, 0.5f) { /* boundsPolygonHigh_ = new ConvexPolygon(BOUNDSPOINTSHIGH, Vector2.Zero); boundsPolygonHigh_.rotate(direction_, position_); boundsPolygonLow_ = new ConvexPolygon(BOUNDSPOINTSLOW, Vector2.Zero); boundsPolygonLow_.rotate(direction_, position_); boundsPolygonLowCrouch_ = new ConvexPolygon(BOUNDSPOINTSLOWCROUCH, Vector2.Zero); boundsPolygonLowCrouch_.rotate(direction_, position_); */ Allegiance_ = 1; 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("GreenPlayer_UpperBody_Pistol_Stand"), frameLengthModifier_, depth_, boundsPointsHigh); restAnimations[7] = new LoopAnimation(TextureMap.fetchTexture("GreenPlayer_UpperBody_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("GreenPlayer_Pistol_Crouch"), frameLengthModifier_, depth_, BOUNDSPOINTSLOWCROUCH); crouchRestAnimations[7] = new LoopAnimation(TextureMap.fetchTexture("GreenPlayer_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 NonLoopAnimation(TextureMap.fetchTexture("GreenPlayer_UpperBody_Pistol_Stand"), frameLengthModifier_, depth_, boundsPointsHigh); shootAnimations[1] = new NonLoopAnimation(TextureMap.fetchTexture("GreenPlayer_UpperBody_Rifle_Stand"), frameLengthModifier_, depth_, boundsPointsHigh); AnimationInterface[] throwGrenadeAnimations = new AnimationInterface[2]; throwGrenadeAnimations[0] = new NonLoopAnimation(TextureMap.fetchTexture("GreenPlayer_Throw_Stand_Pistol"), frameLengthModifier_, depth_, boundsPointsHigh); throwGrenadeAnimations[1] = new NonLoopAnimation(TextureMap.fetchTexture("GreenPlayer_Throw_Stand_Rifle"), frameLengthModifier_, depth_, boundsPointsHigh); AnimationInterface[] reloadAnimations = new AnimationInterface[2]; reloadAnimations[0] = new NonLoopAnimation(TextureMap.fetchTexture("GreenPlayer_Reload_Stand_Pistol"), frameLengthModifier_, depth_, boundsPointsHigh); reloadAnimations[1] = new NonLoopAnimation(TextureMap.fetchTexture("GreenPlayer_Reload_Stand_Rifle"), frameLengthModifier_, depth_, boundsPointsHigh); AnimationInterface[] crouchedShootAnimations = new AnimationInterface[2]; crouchedShootAnimations[0] = new NonLoopAnimation(TextureMap.fetchTexture("GreenPlayer_Pistol_Crouch"), frameLengthModifier_, depth_, boundsPointsHigh); crouchedShootAnimations[1] = new NonLoopAnimation(TextureMap.fetchTexture("GreenPlayer_Rifle_Crouch"), frameLengthModifier_, depth_, boundsPointsHigh); AnimationInterface[] crouchedThrowGrenadeAnimations = new AnimationInterface[2]; crouchedThrowGrenadeAnimations[0] = new NonLoopAnimation(TextureMap.fetchTexture("GreenPlayer_Throw_Crouch_Pistol"), frameLengthModifier_, depth_, boundsPointsHigh); crouchedThrowGrenadeAnimations[1] = new NonLoopAnimation(TextureMap.fetchTexture("GreenPlayer_Throw_Crouch_Rifle"), frameLengthModifier_, depth_, boundsPointsHigh); AnimationInterface[] crouchedReloadAnimations = new AnimationInterface[2]; crouchedReloadAnimations[0] = new NonLoopAnimation(TextureMap.fetchTexture("GreenPlayer_Reload_Crouch_Pistol"), frameLengthModifier_, depth_, boundsPointsHigh); crouchedReloadAnimations[1] = new NonLoopAnimation(TextureMap.fetchTexture("GreenPlayer_Reload_Crouch_Rifle"), frameLengthModifier_, depth_, boundsPointsHigh); /* AnimationInterface run = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Walk_Stand"), frameLengthModifier_, depth_); AnimationInterface runTo = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Walk_Stand"), frameLengthModifier_, depth_); AnimationInterface rest = new LoopAnimation(TextureMap.getInstance().getTexture("GreenPlayer_Walk_Stand"), 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_); */ 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, 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(40.5f, 7.5f), "upper", 4, 10)); actions["crouch"].Add("look", new CharacterLookAction(this, "turning")); actions["crouch"].Add("lookAt", new CharacterLookAtAction(this, "turning")); actions["crouch"].Add("reload", new CharacterReloadAction(this, crouchedReloadAnimations, "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(30.5f, 7.5f), "upper", 4, 10)); actions["stand"].Add("look", new CharacterLookAction(this, "turning")); actions["stand"].Add("lookAt", new CharacterLookAtAction(this, "turning")); actions["stand"].Add("reload", new CharacterReloadAction(this, reloadAnimations, "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(40.5f, 7.5f), "upper", 4, 10)); actions["cover"].Add("look", new CharacterLookAction(this, "turning")); actions["cover"].Add("lookAt", new CharacterLookAtAction(this, "turning")); actions["cover"].Add("reload", new CharacterReloadAction(this, crouchedReloadAnimations, "upper")); actuator_ = new MultiLevelActuator(actions, levels, this, "stand", "rest", "lower", "upper"); List<GameTexture> anims = new List<GameTexture>(); anims.Add(TextureMap.getInstance().getTexture("PlayerWalk")); animations_ = new AnimationSet(anims); if (RADIUS < RADIUSCROUCH) { radius_ = RADIUSCROUCH; } else { radius_ = RADIUS; }; //collisionDetector_ = new SeparatingAxisCollisionDetector(); collisionDetector_ = detector; if (collisionDetector_ != null) { collisionDetector_.register(this); } // Give the player his currently active weapon Weapon_ = new Pistol(pipeline, this, new Vector2(60f - 37.5f, 33.5f - 37.5f)); //Weapon_.update(); //Weapon_ = new Pistol(pipeline, this, new Vector2(60f - 37.5f, 33.5f - 37.5f)); // Add the other weapons to the character's inventory //Inventory_.Weapons_.Enqueue(new MachineGun(pipeline, this, new Vector2(42f - 37.5f, 47f - 37.5f))); //Inventory_.Weapons_.Enqueue(new Shotgun(pipeline, this, new Vector2(42f - 37.5f, 47f - 37.5f))); height_ = new Height(true, true); }
/// <summary> /// Create a NonPlayableCharacter with the specified health, ammo, and weapon objects, plus the given name. /// Also, specify the AnimationSet, frameLengthModifier, velocity, position, direction, /// and depth of the character. /// </summary> /// <param name="pipeline">List of objects from which the object should be drawn.</param> /// <param name="health">CharacterStatusElement for health</param> /// <param name="ammo">CharacterStatusElement for ammo</param> /// <param name="weapon">CharacterStatusElement for the current weapon</param> /// <param name="name">The character's name</param> /// <param name="detector">Collision detector with which this object should register.</param> /// <param name="animations">AnimationSet containing all animations for this object</param> /// <param name="frameLengthModifier">Float representing the ratio of frames in an animation to movement along the screen</param> /// <param name="velocity">Vector of velocity, representing both direction of movement and magnitude</param> /// <param name="position">Position of object relative to the top left corner</param> /// <param name="direction">Vector representing the direction of the object</param> /// <param name="depth">Depth the object is to be drawn to</param> public NonPlayableCharacterAbstract(List<DrawableObjectAbstract> pipeline, CharacterHealth health, CharacterAmmo ammo, CharacterWeapon weapon, string name, CollisionDetectorInterface detector, AnimationSet animations, float frameLengthModifier, Vector2 velocity, Vector2 position, Vector2 direction, float depth) : base(pipeline, health, ammo, weapon, name, detector, animations, frameLengthModifier, velocity, position, direction, depth) { }
public Buckshot(List<DrawableObjectAbstract> pipeline, CollisionDetectorInterface detector, Vector2 position, Vector2 direction) : base(TextureMap.fetchTexture(TEXTURE_NAME), pipeline, detector, position, direction) { damage_ = DAMAGE; }
public Bullet(GameTexture texture, List<DrawableObjectAbstract> pipeline, CollisionDetectorInterface detector, Vector2 position, Vector2 direction) : base(pipeline, texture, detector, new ConvexPolygon(BOUNDS_POINTS, Vector2.Zero), RADIUS, HEIGHT, direction * SPEED, position, direction, DEPTH) { damage_ = DAMAGE; }