Esempio n. 1
0
 public Arrow(LineBatch lineBatch, Vector2 position, float angle)
 {
     this.lineBatch = lineBatch;
     this.position = position;
     this.angle = angle;
     this.speed = 0;
 }
Esempio n. 2
0
 public EnemySpawn(LineBatch lineBatch, Level level, Player player)
 {
     this.lineBatch = lineBatch;
     this.level = level;
     this.player = player;
     this.random = new Random();
     this.timer = new Timer(this.random.Next(SPIDER_MAX_DELAY));
     spiders = new List<Spider>();
     zombies = new List<Zombie>();
 }
Esempio n. 3
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
            lineBatch = new LineBatch(graphics.GraphicsDevice);

            arialFont = Content.Load<SpriteFont>("Arial");

            level1 = new Level(lineBatch, "Level1");

            currentLevel = level1;

            player = new Player(lineBatch, currentLevel, Player.PLAYER_START);
            enemySpawn = new EnemySpawn(lineBatch, currentLevel, player);
        }
Esempio n. 4
0
        public Level(LineBatch lineBatch, string fileName)
        {
            this.lineBatch = lineBatch;

            Rectangle screen = this.lineBatch.getView();

            this.lines = new List<Line>();

            try
            {
                using (StreamReader streamReader = new StreamReader(fileName + ".txt"))
                {
                    string levelString = "";
                    int lastX = -1, lastY = -1;
                    while ((levelString = streamReader.ReadLine()) != null)
                    {
                        if (levelString.Trim() == ">>")
                        {
                            lastX = -1;
                            lastY = -1;
                            continue;
                        }
                        string[] orderedPairs = levelString.Split('~');

                        string[] values = orderedPairs[0].Trim().Split(',');

                        int x = Convert.ToInt32(values[0]), y = Convert.ToInt32(values[1]);

                        if (lastX != -1 && lastY != -1)
                            this.lines.Add(new Line(new Vector2(lastX, screen.Bottom - lastY), new Vector2(x, screen.Bottom - y)));
                        lastX = x;
                        lastY = y;
                    }
                }
            }
            catch { }

            foreach (Line line in lines)
            {
                size.X = line.vertexOne.X > size.X ? line.vertexOne.X : size.X;
                size.X = line.vertexTwo.X > size.X ? line.vertexTwo.X : size.X;

                size.Y = line.vertexOne.Y > size.Y ? line.vertexOne.Y : size.Y;
                size.Y = line.vertexTwo.Y > size.Y ? line.vertexTwo.Y : size.Y;
            }

            this.offset = Vector2.Zero;
            this.color = Color.Pink;
        }
Esempio n. 5
0
        public Player(LineBatch lineBatch, Level level, Vector2 position)
        {
            this.lineBatch = lineBatch;
            this.level = level;
            this.position = position;

            this.bow = new Bow(this.lineBatch, position + leftHand);

            this.yVelocity = 0;
            this.moveValue = 0;

            this.health = MAX_HEALTH;

            this.jumpDelay = new Timer(JUMP_DELAY);
        }
Esempio n. 6
0
        public Bow(LineBatch lineBatch, Vector2 position)
        {
            this.lineBatch = lineBatch;

            this.curve = new Curve();
            this.curve.Keys.Add(new CurveKey(0, 0));
            this.curve.Keys.Add(new CurveKey(BOW_HEIGHT / 2, BOW_WIDTH));
            this.curve.Keys.Add(new CurveKey(BOW_HEIGHT, 0));

            this.timer = new Timer(SHOOT_DELAY);

            this.arrows = new List<Arrow>();

            this.position = position;

            this.arrowPower = 0;
            this.mousePressed = false;
        }
Esempio n. 7
0
        public Zombie(LineBatch lineBatch, Level level, Player player, Color color, float speed, bool rightSide)
        {
            this.lineBatch = lineBatch;
            this.level = level;
            this.player = player;
            this.color = color;
            this.speed = speed;
            this.position = Vector2.UnitY * lineBatch.getView().Top + Vector2.UnitX * (rightSide ? -level.offset.X + lineBatch.getView().Right : -level.offset.X);
            this.faceRight = !rightSide;

            this.rightHand = new Vector2(28, -56);

            this.moveValue = 0;
        }
Esempio n. 8
0
        public Spider(LineBatch lineBatch, Level level, Player player, Color color, float speed, float scale, bool rightSide)
        {
            this.lineBatch = lineBatch;
            this.level = level;
            this.player = player;
            this.color = color;
            this.speed = speed;
            this.scale = scale;
            this.position = Vector2.UnitY * lineBatch.getView().Top + Vector2.UnitX * (rightSide ? -level.offset.X +  lineBatch.getView().Right : -level.offset.X);

            this.moveValue = 0;
        }