本文整理汇总了C#中Level.Load方法的典型用法代码示例。如果您正苦于以下问题:C# Level.Load方法的具体用法?C# Level.Load怎么用?C# Level.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level
的用法示例。
在下文中一共展示了Level.Load方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
Level model = new Level();
model = model.Load(path);
foreach (Enemy e in model.Enemies)
{
GameObject prefab = (GameObject)Resources.Load("Prefabs/" + e.TypeName);
GameObject enemy = Instantiate(prefab);
enemy.GetComponent<NavMeshAgent>().speed = e.MoveSpeed;
enemy.GetComponent<EnemyAttack>().timeBetweenAttacks = e.AttackSpeed;
enemy.GetComponent<EnemyAttack>().attackDamage = e.Damage;
enemy.GetComponent<EnemyHealth>().startingHealth = e.Health;
enemy.GetComponent<EnemyHealth>().scoreValue = e.ScoreValue;
PrefabUtility.ReplacePrefab(enemy, PrefabUtility.CreateEmptyPrefab("Assets/Resources/Prefabs/" + e.TypeName + ".prefab"));
AddManager(e.TypeName, e.SpawnTime);
Destroy(enemy);
}
/*foreach (Component m in copy.GetComponents(typeof(Component))) {
Type t = m.GetType();
enemy.AddComponent(m);
}*/
}
示例2: LoadLevel
public static void LoadLevel(int level)
{
CurrentLevel = levels[level - 1];
CurrentLevel.Load();
}
示例3: ImportLevel
/// <summary>
/// Goes through the xml file and translates the information
/// </summary>
/// <param name="filename">Name of the file we are importing</param>
/// <returns>A level object</returns>
public Level ImportLevel(Level level)
{
XElement xLevel;
#if XBOX360
xLevel = XElement.Load("Content\\Levels\\" + level.Name + ".xml");
#else
xLevel = XElement.Load("..\\..\\..\\Content\\Levels\\" + level.Name + ".xml");
#endif
//Gets all the information for a level and places it into the level object
foreach (var item in xLevel.Elements())
{
if (item.Name == XmlKeys.Name)
level.Name = item.Value;
if (item.Name == XmlKeys.Size && !level.IsMainMenu)
level.Size = GridSpace.GetDrawingCoord(new Vector2(int.Parse(item.Attribute(XName.Get("X", "")).Value),
int.Parse(item.Attribute(XName.Get("Y", "")).Value)));
if (item.Name == XmlKeys.Background)
level.Load(_mContent, item.Value);
if (item.Name == "Entities")
foreach (var element in item.Elements())
_mEntities.Add(new EntityInfo(element));
}
if(!level.IsMainMenu)
GetPlayerStart(level);
return level;
}
示例4: SwitchToLevel
internal void SwitchToLevel(MetaLevel meta)
{
Level level = LevelFactory.CreateLevelFromMetaLevel(meta, this);
if (level == null) {
return;
}
if (state == GameState.MENU) {
/* Transition from the menu to the level. Don't dispose MENU. */
currentLevel = level;
currentLevel.Load();
mainMenu.Sound = false;
state = GameState.LEVEL;
} else if (state == GameState.LEVEL) {
/* Transition from the prior level to the new level. Dispose resources immediately. */
if (currentLevel != null) {
currentLevel.Unload();
}
currentLevel = level;
currentLevel.Load();
}
currentView = currentLevel;
currentView.Sound = true;
}