Functional networkevent validation, functional single player saving, requireditem ui texts, titlescreen & loading

This commit is contained in:
Regalis
2015-07-19 02:44:42 +03:00
parent 237df18765
commit baa207985c
78 changed files with 1237 additions and 596 deletions
+2 -4
View File
@@ -92,13 +92,11 @@ namespace Subsurface
}
public static ScriptedEvent LoadRandom(string seed)
public static ScriptedEvent LoadRandom(Random rand)
{
XDocument doc = ToolBox.TryLoadXml(configFile);
if (doc == null) return null;
Random rand = new Random(seed.GetHashCode());
int eventCount = doc.Root.Elements().Count();
//int[] commonness = new int[eventCount];
float[] eventProbability = new float[eventCount];
+20 -2
View File
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
namespace Subsurface
{
@@ -61,8 +62,25 @@ namespace Subsurface
private void CreateScriptedEvents(Level level)
{
ScriptedEvent scriptedEvent = ScriptedEvent.LoadRandom(level.Seed);
AddTask(new ScriptedTask(scriptedEvent));
Random rand = new Random(level.Seed.GetHashCode());
float totalDifficulty = level.Difficulty;
int tries = 0;
do
{
ScriptedEvent scriptedEvent = ScriptedEvent.LoadRandom(rand);
if (scriptedEvent==null || scriptedEvent.Difficulty > totalDifficulty)
{
tries++;
continue;
}
AddTask(new ScriptedTask(scriptedEvent));
totalDifficulty -= scriptedEvent.Difficulty;
tries = 0;
} while (tries < 5);
}
public void TaskStarted(Task task)