First commit

This commit is contained in:
Regalis
2015-05-25 01:04:03 +03:00
commit fadb89ae9e
320 changed files with 32186 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
using System.Xml.Linq;
using Microsoft.Xna.Framework;
namespace Subsurface
{
class MonsterEvent : ScriptedEvent
{
private string characterFile;
private int minAmount, maxAmount;
private Character[] monsters;
public MonsterEvent(XElement element)
: base (element)
{
characterFile = ToolBox.GetAttributeString(element, "characterfile", "");
minAmount = ToolBox.GetAttributeInt(element, "minamount", 1);
maxAmount = ToolBox.GetAttributeInt(element, "maxamount", 1);
}
protected override void Start()
{
WayPoint randomWayPoint = WayPoint.GetRandom(WayPoint.SpawnType.Enemy);
int amount = Game1.random.Next(minAmount, maxAmount);
monsters = new Character[amount];
for (int i = 0; i < amount; i++)
{
monsters[i] = new Character(characterFile,
(randomWayPoint == null) ? Vector2.Zero : randomWayPoint.SimPosition);
}
}
public override void Update(float deltaTime)
{
base.Update(deltaTime);
if (!isStarted) return;
if (!isFinished)
{
bool monstersDead = true;
for (int i = 0; i < monsters.Length; i++)
{
if (monsters[i].IsDead) continue;
monstersDead = false;
break;
}
if (monstersDead) Finished();
}
}
}
}