Example #1
0
        public void CheckCollision(Lane[] lanes, Camera camera, int current)
        {
            for (int i = 0; i < characters.Length; i++)
            {
                if (characters[i] != null && !characters[i].isInvulnerable)
                {
                    int checkingDepth = 10;
                    int limit = lanes[i].obstacles.Count;
                    if (limit > checkingDepth)
                        limit = checkingDepth;

                    for (int j = 0; j < limit; j++)
                    {
                        Obstacle obstacle = lanes[i].obstacles[current + j];
                        if (obstacle.Collides(characters[i].position, characters[i].collisionSize, camera.Position.X))
                        {
                            if (obstacle.Type == ObstacleType.Breakable &&
                                characters[i].CurrentAction == Character.Action.Slash)
                            {
                                var breakable = (BreakableObstacle)obstacle;
                                breakable.IsExploding = true;
                            }
                            else
                            {
                                characters[i].CurrentAction = Character.Action.Knockback;
                                soundBank.PlayCue("Collision");
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        public void Draw(SpriteBatch spriteBatch, Camera camera)
        {
            for (int i = 0; i < camera.Position.X + 1500; i += background.Width)
            {
                spriteBatch.Draw(background, new Vector2(position.X + i - camera.Position.X, position.Y), Color.White);
                if (i > WIDTH)
                {
                    spriteBatch.Draw(line, new Vector2(position.X + i - camera.Position.X, position.Y + 155), new Rectangle(0, 0, background.Width, 15), Color.White);

                }
                if (i < 700)
                {
                    spriteBatch.Draw(line, new Vector2(position.X + i - camera.Position.X, position.Y + 155), new Rectangle(0,0, background.Width, 15) , Color.White);
                }
            }
            foreach (Obstacle o in obstacles)
            {
                if (o != null)
                {
                    if (o.worldPosition.X > camera.Position.X + 1500)
                    {
                        return;
                    }
                    camera.DrawPosition(o, spriteBatch);
                }
            }
        }
Example #3
0
 public LumberjackBustle(Player[] players)
 {
     Players = players;
     camera = new Camera();
     instruction = new LumberjackInstruction();
     playerManager = new PlayerManager(Players);
 }