-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLevel.cs
More file actions
92 lines (81 loc) · 2.4 KB
/
Level.cs
File metadata and controls
92 lines (81 loc) · 2.4 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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 = .35;
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 string name;
public int enterLives;
public Dictionary<string, bool> enterPowerUps;
public ContentManager content;
public Level(Player p, string levelName, ContentManager c)
{
player = p;
enterPowerUps = new Dictionary<string, bool>(p.powerup);
enterLives = p.lives;
enemies = new List<Enemy>();
projectiles = new List<Sprite>();
items = new List<Sprite>();
message = null;
message_point = 0;
name = levelName;
content = c;
}
public Level(Level l)
{
player = l.player;
enterPowerUps = new Dictionary<string,bool>(l.enterPowerUps);
enterLives = l.player.lives;
enemies = new List<Enemy>(l.enemies);
projectiles = new List<Sprite>(l.projectiles);
items = new List<Sprite>(l.items);
message = l.message;
message_point = l.message_point;
name = l.name;
content = l.content;
}
public void Update()
{
count++;
if (String.IsNullOrEmpty(message) && (count - message_point) >= 400)
message = null;
// Move shots
foreach (Sprite s in projectiles)
s.Update(this);
foreach (Enemy e in enemies)
e.Update(this);
foreach (Sprite s in items)
s.Update(this);
// DESTROY
enemies.RemoveAll(enemy => enemy.destroyed);
projectiles.RemoveAll(shot => shot.destroyed);
items.RemoveAll(item => item.destroyed);
}
public virtual void Draw(SpriteBatch sb)
{
foreach (Sprite item in items)
item.Draw(sb);
foreach (Sprite s in projectiles)
s.Draw(sb);
foreach (Enemy e in enemies)
e.Draw(sb);
player.Draw(sb);
}
}
}