Beispiel #1
0
        public World()
        {
            map = new Map(40, 5);
            towers = new List<Tower>();
            mobs = new List<Mob>();

            map.map[3, 0].Type = 1;
            map.map[4, 0].Type = 1;
            map.map[3, 1].Type = 1;
            map.map[4, 1].Type = 1;

            map.map[5,0] = new TowerTile(new Tower{Range = 10, Rate = 2000});
            map.map[5, 0].Type = 2;

            map.map[1, 0].Walkable = false;
            map.map[1, 1].Walkable = false;
            map.map[1, 3].Walkable = false;
            map.map[1, 4].Walkable = false;

            camera = new Camera(400*Tile.Width, 200*Tile.Height);

            Random rng = new Random(DateTime.Now.Millisecond);

            spawn = new Point(0, rng.Next(0, (int)map.Size.Y));
            goal = new Point((int)map.Size.X - 1, rng.Next(0, (int)map.Size.Y));

            map.map[spawn.X, spawn.Y] = new SpawnTile();
            map.map[goal.X, goal.Y] = new GoalTile();

            Node n = AStar.FindPath(map, spawn, goal);
            path = new List<Node>();

            while(n.Parent != null)
            {
                path.Insert(0, n);
                n = n.Parent;
            }

            towers.Add(((TowerTile)map.map[5,0]).Tower);

            Mob m = new Mob(path, spawn);
            mobs.Add(m);
        }
Beispiel #2
0
 public void Draw(SpriteBatch batch, Camera cam)
 {
     if(cam.OnScreen(Position))
     {
         batch.Draw(SpriteSheet,
                    cam.ScreenCoords(Position),
                    Mob.GetTileFromSheet(Type),
                    Color.White,
                    rotation,
                    new Vector2(0,0),
                    1.0f,
                    SpriteEffects.None,
                    1.0f
             );
     }
 }