您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
37 行
982 B
37 行
982 B
using ConsoleUtility;
|
|
using GameplayIngredients;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[AutoRegisterConsoleCommand]
|
|
public class LoadLevelConsoleCommand : IConsoleCommand
|
|
{
|
|
public string name => "load";
|
|
|
|
public string summary => "Loads a level";
|
|
|
|
public string help => "load <level-Id>";
|
|
|
|
public IEnumerable<Console.Alias> aliases
|
|
{
|
|
get
|
|
{
|
|
yield return new Console.Alias() { AliasString = "mainmenu", Command = "load -1" } ;
|
|
}
|
|
}
|
|
|
|
public void Execute(string[] args)
|
|
{
|
|
if(args.Length == 1)
|
|
{
|
|
int idx;
|
|
if(int.TryParse(args[0], out idx))
|
|
{
|
|
var manager = GameplayIngredients.Manager.Get<GameManager>();
|
|
idx = Mathf.Clamp(idx, -1, manager.MainGameLevels.Length-1);
|
|
Console.Log(name, $"Loading Game level #{idx} ...");
|
|
manager.SwitchLevel(idx, true, null);
|
|
}
|
|
}
|
|
}
|
|
}
|