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_);
 }
 // --- 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;
 }
        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 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 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);
     }
 }
 /// <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 void setCollisionDetector(CollisionDetectorInterface detector)
 {
     if (detector != null)
     {
         detector.register(this);
         collisionDetector_ = detector;
     }
 }
 public override void setCollisionDetector(CollisionDetectorInterface collisionDetector)
 {
     if (detector_ != null)
     {
         detector_.remove(this);
     }
     detector_ = collisionDetector;
     if (detector_ != null)
     {
         detector_.register(this);
     }
 }
 public void setCollisionDetector(CollisionDetectorInterface collisionDetector)
 {
     if (collisionDetector_ != null)
     {
         collisionDetector_.remove(this);
     }
     collisionDetector_ = collisionDetector;
     if (collisionDetector_ != null)
     {
         collisionDetector_.register(this);
     }
 }