Example #1
0
        protected override void updateLocation(float elapsed)
        {
            if (!this.Hiding)
            {
                if (this.direction != Direction.None)
                {
                    float   moveDistance = (this.movementSpeed * elapsed);
                    Vector2 newPos       = this.activeSprite.Position;
                    if (this.direction == Direction.Up)
                    {
                        newPos = new Vector2(this.activeSprite.Position.X, this.activeSprite.Position.Y - moveDistance);
                    }
                    else if (this.direction == Direction.Right)
                    {
                        newPos = new Vector2(this.activeSprite.Position.X + moveDistance, this.activeSprite.Position.Y);
                    }
                    else if (this.direction == Direction.Down)
                    {
                        newPos = new Vector2(this.activeSprite.Position.X, this.activeSprite.Position.Y + moveDistance);
                    }
                    else if (this.direction == Direction.Left)
                    {
                        newPos = new Vector2(this.activeSprite.Position.X - moveDistance, this.activeSprite.Position.Y);
                    }
                    // check if the new position would result in a collision, if not, assign the sprite the position
                    if (!CollisionManager.getInstance().wallCollisionFound(Helper.getPersonBBox(newPos)))
                    {
                        this.activeSprite.Position = newPos;
                    }
                }
            }

            // call the generic code before continuing
            base.updateLocation(elapsed);

            if (AIManager.getInstance().PlayerDetected)              // if we aren't moving we still need to report where we are if we are detected
            // if we have been detected we need to tell the AI where we are
            {
                AIManager.getInstance().Board[base.Placement.index.Y, base.Placement.index.X] = BasePathFinder.TypeOfSpace.End;
            }
        }
Example #2
0
        public override void render(SpriteBatch spriteBatch)
        {
            // render the floor, treasure, than walls
            this.mapFloor.render(spriteBatch);
            this.treasureText.render(spriteBatch);
            this.treasure.render(spriteBatch);
            foreach (Treasure treasure in this.treasures)
            {
                treasure.render(spriteBatch);
            }
            this.mapWalls.render(spriteBatch);
            foreach (Dumpster dumpster in this.dumpsters)
            {
                dumpster.render(spriteBatch);
            }
            this.player.render(spriteBatch);
            foreach (Guard guard in this.guards)
            {
                guard.render(spriteBatch);
            }
            this.timer.render(spriteBatch);
            if (StateManager.getInstance().CurrentGameState == StateManager.GameState.Reset || StateManager.getInstance().CurrentGameState == StateManager.GameState.Waiting ||
                (StateManager.getInstance().CurrentGameState == StateManager.GameState.InGameMenu && StateManager.getInstance().PreviousGameState == StateManager.GameState.Waiting))
            {
                this.startButton.render(spriteBatch);
            }
            this.dustEmitter.render(spriteBatch);
#if DEBUG
            if (this.showCD)
            {
                Color debugColour = Color.Green;
                DebugUtils.drawBoundingBox(spriteBatch, this.player.BoundingBox, debugColour, ResourceManager.getInstance().ButtonLineTexture);
                foreach (Guard guard in this.guards)
                {
                    DebugUtils.drawBoundingBox(spriteBatch, guard.BoundingBox, debugColour, ResourceManager.getInstance().ButtonLineTexture);
                    DebugUtils.drawBoundingSphere(spriteBatch, guard.Ring.BoundingSphere, debugColour, ResourceManager.getInstance().DebugRing);
                }
                foreach (BoundingBox box in CollisionManager.getInstance().MapBoundingBoxes)
                {
                    DebugUtils.drawBoundingBox(spriteBatch, box, debugColour, ResourceManager.getInstance().ButtonLineTexture);
                }
                foreach (Treasure treasure in this.treasures)
                {
                    DebugUtils.drawBoundingBox(spriteBatch, treasure.BoundingBox, debugColour, ResourceManager.getInstance().ButtonLineTexture);
                }
                foreach (Dumpster dumpster in this.dumpsters)
                {
                    DebugUtils.drawBoundingBox(spriteBatch, dumpster.BoundingBox, debugColour, ResourceManager.getInstance().ButtonLineTexture);
                }
            }
            if (this.showWayPoints)
            {
                List <Point> wayPoints = AIManager.getInstance().WayPoints;
                foreach (Point wayPoint in wayPoints)
                {
                    spriteBatch.Draw(ResourceManager.getInstance().DebugChip, new Placement(wayPoint).worldPosition, Color.Purple);
                }
            }
            if (this.showAI)
            {
                // draw where we cannot walk
                for (int y = 0; y < 18; y++)
                {
                    for (int x = 0; x < 21; x++)
                    {
                        if (AIManager.getInstance().Board[y, x] == BasePathFinder.TypeOfSpace.Unwalkable)
                        {
                            spriteBatch.Draw(ResourceManager.getInstance().DebugChip, new Placement(new Point(x, y)).worldPosition, Color.Red);
                        }
                    }
                }
            }
#endif
        }