Example #1
0
 public virtual Vector2 checkCollisionInto(CollisionObjectInterface obj, CollisionDetectorInterface detector, Height height, float radDistance, Vector2 translate)
 {
     if (!hasBeenPickedUp_ && obj is PlayableCharacterAbstract)
     {
         handleCollision(obj);
     }
     return Vector2.Zero;
 }
Example #2
0
 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;
 }
 // --- 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;
 }
Example #4
0
 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 void projectPolygonOnAxis(Vector2 axis, Height height, ref float min, ref float max)
 {
     axis.Normalize();
     min = ConvexPolygon.dotProduct(axis, center_);
     max = min + radius_;
     min -= radius_;
     if (min > max)
     {
         float temp = min;
         min = max;
         max = temp;
     }
 }
Example #6
0
        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));
        }
Example #7
0
 public CrouchAction(CharacterAbstract character,
     AnimationInterface animation,
     String nextActionSet,
     Height newHeight,
     string actionLevel)
 {
     priority_ = PRIORITY;
     character_ = character;
     animation_ = animation;
     nextActionSet_ = nextActionSet;
     finished_ = false;
     newHeight_ = newHeight;
     actionLevel_ = actionLevel;
 }
Example #8
0
 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 DetachFromCoverAction(CharacterAbstract character,
     AnimationInterface animation,
     String nextActionSet,
     Height nextHeight,
     float speed,
     string actionLevel)
 {
     character_ = character;
     animation_ = animation;
     priority_ = PRIORITY;
     coverObject_ = null;
     positionToMoveTo_ = Vector2.Zero;
     finished_ = false;
     speed_ = speed;
     nextActionSet_ = nextActionSet;
     nextHeight_ = nextHeight;
     actionLevel_ = actionLevel;
 }
Example #10
0
 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;
 }
Example #11
0
 public BoxObject(List<Vector2> points, Vector2 center, Height height)
 {
     position_ = center;
     boundsPolygon_ = new ConvexPolygon(points, Vector2.Zero);
     height_ = height;
 }
 public virtual Vector2 checkCollisionInto(CollisionObjectInterface obj, CollisionDetectorInterface detector, Height height, float radDistance, Vector2 translate)
 {
     handleCollision(obj);
     return Vector2.Zero;
 }
Example #13
0
 public bool collides(Height rhs, float radius)
 {
     bool lowCollision = rhs.blocksLow_ && this.lowDistance_ <= radius;
     bool highCollision = rhs.blocksHigh_ && this.highDistance_ <= radius;
     return (lowCollision || highCollision);
 }
        private static TileIndex getNearest(TileGrid grid, TileIndex start, TileIndex destination, float radius, Height height)
        {
            radius = radius / (TileGrid.TILEHEIGHT + TileGrid.TILEWIDTH) / 2;

            Tile dest = grid.getTile(destination);

            if (!dest.collides(height, radius))
            {
                return destination;
            }

            short manhattan = 1;

            // Expand outward by increasing the manhattan distance
            // Until finding some subset of tiles which we can walk on
            // TODO
            // Don't use heap space here
            List<TileIndex> closest = new List<TileIndex>();
            while (closest.Count == 0)
            {
                Tile cur;
                int newX;
                int newY;

                for (short i = 0; i < manhattan - 1; i++)
                {
                    // Quadrant I
                    newX = destination.x_ + i;
                    newY = destination.y_ + (manhattan - i);
                    cur = grid.getTile(newX, newY);
                    if (!cur.collides(height, radius))
                    {
                        closest.Add(new TileIndex((short)newX, (short)newY));
                    }

                    // Quadrant II
                    newX = destination.x_ - i;
                    newY = destination.y_ + (manhattan - i);
                    cur = grid.getTile(newX, newY);
                    if (!cur.collides(height, radius))
                    {
                        closest.Add(new TileIndex((short)newX, (short)newY));
                    }

                    // Quadrant III
                    newX = destination.x_ - i;
                    newY = destination.y_ - (manhattan - i);
                    cur = grid.getTile(newX, newY);
                    if (!cur.collides(height, radius))
                    {
                        closest.Add(new TileIndex((short)newX, (short)newY));
                    }

                    // Quadrant IV
                    newX = destination.x_ + i;
                    newY = destination.y_ - (manhattan - i);
                    cur = grid.getTile(newX, newY);
                    if (!cur.collides(height, radius))
                    {
                        closest.Add(new TileIndex((short)newX, (short)newY));
                    }
                }

                manhattan++;
                if (manhattan > 10)
                {
                    return new TileIndex(-1, -1);
                }
            }

            // We've found walkable tiles, and they are all the same manhattan
            //  distance from the destination, so pick closest to the start
            // TODO
            // Determine whether it's better to pick closest real distance to
            //  destination first
            TileIndex best = new TileIndex(-1, -1);
            float bestScore = float.MaxValue;
            for (int i = 0; i < closest.Count; i++)
            {
                float score = CommonFunctions.distance(closest[i], start);
                if (score < bestScore)
                {
                    bestScore = score;
                    best = closest[i];
                }
            }

            return best;
        }
Example #15
0
 public bool collides(Height rhs)
 {
     return (this.blocksLow_ && rhs.blocksLow_ || this.blocksHigh_ && rhs.blocksHigh_);
 }
 public void start()
 {
     if (actuator_ == null)
     {
         actuator_ = character_.getActuator();
     }
     finished_ = false;
     holding_ = false;
     currentFrame_ = 0;
     foreach (AnimationInterface anim in animation_)
     {
         anim.reset();
         anim.setPosition(character_.getPosition());
         anim.setRotation(character_.getDirection());
     }
     oldHeight_ = character_.getHeight();
     character_.setHeight(new Height(true, true));
     weapon_ = character_.Weapon_;
 }
        protected static void setupSearch(TileGrid grid, TileIndex start, TileIndex destination, float radius, Height height)
        {
            // Initialize the static structures used by the search
            reset();

            start_ = start;
            goal_ = destination;

            // Project our start and goal nodes into the search space, if possible
            // TODO
            // For now, if they are farther apart than the size of the search space in
            // any dimension, we give up - in the future, they will try to get as close
            // as possible
            short manhattanX = (short)Math.Abs(start_.x_ - goal_.x_);
            short manhattanY = (short)Math.Abs(start_.y_ - goal_.y_);
            short leftOffset = (short)Math.Floor((SEARCH_SPACE_WIDTH - manhattanX) / 2.0f);
            short rightOffset = (short)Math.Ceiling((SEARCH_SPACE_WIDTH - manhattanX) / 2.0f);
            short bottomOffset = (short)Math.Floor((SEARCH_SPACE_HEIGHT - manhattanY) / 2.0f);
            short topOffset = (short)Math.Ceiling((SEARCH_SPACE_HEIGHT - manhattanY) / 2.0f);
            gridXOffset_ = (short)(Math.Min(start_.x_, goal_.x_) - leftOffset);
            gridYOffset_ = (short)(Math.Min(start_.y_, goal_.y_) - topOffset);

            if (gridXOffset_ < 0) gridXOffset_ = 0;
            if (gridYOffset_ < 0) gridYOffset_ = 0;
            start_.x_ -= gridXOffset_;
            start_.y_ -= gridYOffset_;
            goal_.x_ -= gridXOffset_;
            goal_.y_ -= gridYOffset_;

            searchRadius_ =
                (float)(radius / ((TileGrid.TILEWIDTH + TileGrid.TILEHEIGHT) / 2.0f));
            grid_ = grid;
            searchHeight_ = height;
        }
Example #18
0
        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);
        }
 /// <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)
 {
     return translate;
 }
Example #21
0
        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;
        }
Example #22
0
        /// <summary>
        /// Constructs a TileSet from an XmlDocument.
        /// </summary>
        /// <param name="doc">XML data containing Tileset related tags.</param>
        /// <param name="spriteBatch">Sprite batch which will draw the tiles.</param>
        /// <param name="graphics">Graphics device which will draw the tiles.</param>
        /// <returns>The constructed TileSet.</returns>
        protected static Tileset getTilesetFromXML(XmlDocument doc, SpriteBatch spriteBatch, GraphicsDevice graphics)
        {
            Tileset returnTileset = new Tileset();
            XmlElement ele = (XmlElement)doc.GetElementsByTagName("image-file")[0];
            string image_file = ele.InnerText;
            ele = (XmlElement)doc.GetElementsByTagName("tile-size")[0];
            int tile_size_x = Convert.ToInt32(ele.GetAttribute("x"));
            int tile_size_y = Convert.ToInt32(ele.GetAttribute("y"));
            ele = (XmlElement)doc.GetElementsByTagName("total-tiles")[0];
            int total_tiles = Convert.ToInt32(ele.InnerText);
            ele = (XmlElement)doc.GetElementsByTagName("tiles-high")[0];
            int tiles_high = Convert.ToInt32(ele.InnerText);
            ele = (XmlElement)doc.GetElementsByTagName("tiles-wide")[0];
            int tiles_wide = Convert.ToInt32(ele.InnerText);
            XmlNodeList heightsNodes = doc.GetElementsByTagName("tile-heights");
            if (heightsNodes.Count != 1)
            {
                throw new Exception("Error in Tileset XML, should be exactly one tile-heights tag");
            }
            XmlNode heightsNode = heightsNodes[0];
            if (heightsNode.ChildNodes.Count != total_tiles)
            {
                throw new Exception("Number of height tags do not match total-tiles");
            }
            for (int i = 0; i < heightsNode.ChildNodes.Count; i++)
            {
                XmlElement e = (XmlElement)heightsNode.ChildNodes[i];
                bool lowH = e.GetAttribute("l").ToLower() == "true";
                bool highH = e.GetAttribute("h").ToLower() == "true";
                Height h = new Height(lowH, highH);
                returnTileset.heights_.Add(i, h);
            }

            returnTileset.TILE_SIZE_X = tile_size_x;
            returnTileset.TILE_SIZE_Y = tile_size_y;

            returnTileset.texture_ = new GameTexture(image_file,
                spriteBatch,
                graphics,
                calculateImageDimensions(total_tiles, tiles_wide, tiles_high, tile_size_x, tile_size_y));

            return returnTileset;
        }
 /// <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 projectPolygonOnAxis(Vector2 axis, Height height, ref float min, ref float max)
 {
     throw new NotImplementedException();
 }
 public void setHeight(Height height)
 {
     height_ = height;
 }
        /// <summary>
        /// Run the A* algorithm to get a navigation path.
        /// </summary>
        /// <param name="grid">The area being searched</param>
        /// <param name="start">Index of the start tile.</param>
        /// <param name="destination">Index of the destination tile.</param>
        /// <param name="radius">Radius of the character performing the search</param>
        /// <param name="tileHeight">Height of the character performing the search</param>
        /// <returns>Waypoints which should allow the character to reach the goal.</returns>
        public static List<TileIndex> calculateExactPath(TileGrid grid, TileIndex start, TileIndex destination, float radius, Height height)
        {
            #if DEBUG
            clock.Start();
            #endif

            setupSearch(grid, start, destination, radius, height);

            //Console.WriteLine("Pathfind Start: " + start_.x_ + "," + start_.y_);
            //Console.WriteLine("Pathfind Goal: " + goal_.x_ + "," + goal_.y_);

            TileIndex cur = start_;
            searchSpace_[cur.x_, cur.y_].g = 0;
            searchSpace_[cur.x_, cur.y_].f = heuristicDistance(cur.x_, cur.y_);
            searchSpace_[cur.x_, cur.y_].parent = new TileIndex(-1, -1); // stack
            touched_[cur.x_, cur.y_] = true;

            // As long as we aren't at the goal, keep expanding outward and checking
            // the next most promising node
            while (!TileIndex.equals(goal_, cur))
            {
                searchSpace_[cur.x_, cur.y_].open = false;
                expand(ref cur, searchSpace_[cur.x_, cur.y_].g);

                // If we are out of nodes to check, no path exists
                if (openlist_.Count == 0)
                {
            #if DEBUG
                    clock.Stop();
            #endif
                    return null;
                }
                else
                {
                    cur = getNext();
                }
            }
            #if DEBUG
            clock.Stop();
            #endif
            return recreatePath();
        }
        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);
        }
 public static List<TileIndex> calculateNearbyPath(TileGrid grid, TileIndex start, TileIndex destination, float radius, Height height)
 {
     TileIndex newdest = getNearest(grid, start, destination, radius, height);
     if (newdest.x_ == -1 || newdest.y_ == -1)
     {
         //throw new Exception("AStarPathfinder failed to find a nearest tile!");
         return null;
     }
     return calculateExactPath(grid, start, newdest, radius, height);
 }
        public void projectPolygonOnAxis(Vector2 axis, Height height, ref float min, ref float max)
        {
            float dotProd = dotProduct(axis, points_[0]);
            min = dotProd;
            max = dotProd;

            for (int i = 1; i < numPoints_; i++)
            {
                dotProd = dotProduct(axis, points_[i]);
                if (dotProd < min)
                {
                    min = dotProd;
                }
                else if (dotProd > max)
                {
                    max = dotProd;
                }
            }
            float velocityProjection = dotProduct(curVelocity_, axis);
            if (velocityProjection < 0)
            {
                min += velocityProjection;
            }
            else
            {
                max += velocityProjection;
            }
        }
 public static List<TileIndex> calculateNearbyPath(TileGrid grid, Vector2 start, Vector2 destination, float radius, Height height)
 {
     return calculateNearbyPath(grid, grid.getTileIndex(start), grid.getTileIndex(destination), radius, height);
 }