forked from rliebz/Puddle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLevel.cs
76 lines (66 loc) · 1.69 KB
/
Level.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.GamerServices;
namespace Puddle
{
class Level
{
public int ground = 900;
public double gravity = .5;
public int maxFallSpeed = 10;
public int count = 0;
public List<Enemy> enemies;
public List<Sprite> projectiles;
public List<Sprite> items;
public Player player;
public string message;
public int message_point;
public Level(Player p)
{
player = p;
enemies = new List<Enemy>();
projectiles = new List<Sprite>();
items = new List<Sprite>();
message = "";
message_point = 0;
}
public void Update(ContentManager content)
{
count++;
if (message != "" && (count - message_point) >= 400)
message = "";
// Move shots
foreach (Sprite s in projectiles)
s.Update(this);
foreach (Enemy e in enemies)
{
e.Update(this);
e.Update(this, content);
}
foreach (Sprite s in items)
{
s.Update(this);
s.Update(this, content);
}
// DESTROY
enemies.RemoveAll(enemy => enemy.destroyed);
projectiles.RemoveAll(shot => shot.destroyed);
items.RemoveAll(item => item.destroyed);
}
public virtual void Draw(SpriteBatch sb)
{
foreach (Sprite s in projectiles)
s.Draw(sb);
foreach (Enemy e in enemies)
e.Draw(sb);
foreach (Sprite item in items)
item.Draw(sb);
player.Draw(sb);
}
}
}