本文整理汇总了C#中Scene.Load方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.Load方法的具体用法?C# Scene.Load怎么用?C# Scene.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scene
的用法示例。
在下文中一共展示了Scene.Load方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartTest
void StartTest()
{
GameObject sceneRoot = new GameObject("SceneRoot");
scene = sceneRoot.AddComponent<Scene>();
scene.Init();
scene.Load("Settings/test_game_s.map");
SpawnWaveSetting spawnWaveSetting = new SpawnWaveSetting();
spawnWaveSetting.WaveIndex = 0;
spawnWaveSetting.IntervalTime = 1;
spawnWaveSetting.SpawnTimes = int.MaxValue;
spawnWaveSetting.SpawnPerTime = 1;
spawnWaveSetting.TemplateID = 0;
SpawnLocationSetting spawnLocationSetting = new SpawnLocationSetting();
spawnLocationSetting.PathIndex = 0;
spawnLocationSetting.Waves = new SpawnWaveSetting[] { spawnWaveSetting };
SpawnSetting spawnSetting = new SpawnSetting();
spawnSetting.Locations = new SpawnLocationSetting[] { spawnLocationSetting };
scene.SpawnManager.Load(spawnSetting);
SceneManager.Init();
SceneManager.Instance.SwitchTo(scene);
scene.StartScene();
scene.SpawnManager.Start();
Player.Me.SelectedTowers.Add(0);
Player.Me.SelectedTowers.Add(1);
UIManager.Instance.CreateUI<SceneEventUI>(UILayer.LayerLow);
}
示例2: StartTest
void StartTest()
{
GameObject sceneRoot = new GameObject("SceneRoot");
scene = sceneRoot.AddComponent<Scene>();
scene.Init();
scene.Load("Settings/test.map");
scene.StartScene();
SceneManager.Init();
SceneManager.Instance.SwitchTo(scene);
float mapWidth = scene.Map.Width;
float mapHeight = scene.Map.Height;
for (int i = 0; i < 100; ++i)
{
MonsterEntity monsterEntity = scene.CreateMonsterEntity(0);
scene.AddEntityToScene(monsterEntity, new Vector3(Random.value * mapWidth, Random.value * mapHeight, 0));
}
tower = scene.CreateTowerEntity(0);
tower.ShowDebugDraw = true;
scene.AddEntityToScene(tower, new Vector3(mapWidth / 2, mapHeight / 2, 0));
towerAtk = tower.AttrComp.AtkBase;
towerAtkSpeed = tower.AttrComp.AtkSpeedBase;
towerAtkRange = tower.AttrComp.AtkRangeBase;
}
示例3: SwitchTo
public void SwitchTo()
{
if (Scene != null)
Scene.Dispose();
GameObject sceneRoot = new GameObject("SceneRoot");
Scene = sceneRoot.AddComponent<Scene>();
Scene.Init();
// TODO:
Scene.Load("Settings/test.map");
Scene.StartScene();
Camera camera = Camera.main;
float cameraHalfHeight = camera.orthographicSize;
float cameraHalfWidth = cameraHalfHeight * camera.aspect;
float left = cameraHalfWidth;
float right = Scene.Map.Width - cameraHalfWidth;
float bottom = cameraHalfHeight;
float top = Scene.Map.Height - cameraHalfHeight;
Vector3 cameraPosition = camera.transform.position;
if (left > right)
cameraPosition.x = (left + right) / 2;
else if (cameraPosition.x < left)
cameraPosition.x = left;
else if (cameraPosition.x > right)
cameraPosition.x = right;
if (bottom > top)
cameraPosition.y = (bottom + top) / 2;
else if (cameraPosition.y < bottom)
cameraPosition.y = bottom;
else if (cameraPosition.y > top)
cameraPosition.y = top;
camera.transform.position = cameraPosition;
}
示例4: LoadContent
public override void LoadContent()
{
mScene = new Scene();
mActorMan = new ActorManager(mViews);
GameResources.ActorManager = mActorMan;
LevelManifest manifest;
using (ContentManager manifestLoader = new ContentManager(SharedResources.Game.Services, "Content"))
{
manifest = manifestLoader.Load<LevelManifest>(mRequest.LevelName);
manifestLoader.Unload(); // a LevelManifest does not use any Disposable resources, so this is ok.
}
// The IScreenHoncho tells this gameplay screen how to set up the PlayerViews and DrawSegments required to play this level
IScreenHoncho screenHoncho = Activator.CreateInstance(Type.GetType(manifest.ScreenHonchoTypeName)) as IScreenHoncho;
mViewContentLoader = new ContentManager(SharedResources.Game.Services, "Content");
foreach (PlayerInfo player in GameResources.PlaySession.Players)
{
mViews.Add(PlayerViewFactory.Create(player,
mRequest.CharacterSelections[player.PlayerId],
screenHoncho,
mViewContentLoader));
}
// Determine screen layout and create DrawSegments
if (screenHoncho.PlayersUseSeparateViewports)
{
switch (GameResources.PlaySession.LocalPlayers.Count)
{
case 1:
mScreenLayout = ViewportLayout.FullScreen;
break;
case 2:
mScreenLayout = GameOptions.PreferHorizontalSplit ? ViewportLayout.HorizontalSplit : ViewportLayout.VerticalSplit;
break;
case 3:
case 4:
mScreenLayout = ViewportLayout.FourWaySplit;
break;
default:
throw new InvalidOperationException("Unsupported number of local players.");
}
foreach (int playerId in GameResources.PlaySession.LocalPlayers.Keys)
{
HumanView playerView = mViews.Single(v => v.PlayerId == playerId) as HumanView;
ICameraProvider cameraPlayerView = playerView as ICameraProvider;
if (cameraPlayerView == null)
throw new LevelManifestException("When IScreenHoncho.PlayersUseSeparateViewports is true, HumanViews must implement the ICameraProvider interface.");
DrawSegment ds = new DrawSegment(mScene, cameraPlayerView.Camera);
mDrawSegments.Add(ds);
playerView.DrawSegment = ds;
}
}
else
{
mScreenLayout = ViewportLayout.FullScreen;
DrawSegment ds = new DrawSegment(mScene);
mDrawSegments.Add(ds);
foreach (int playerId in GameResources.PlaySession.LocalPlayers.Keys)
{
HumanView playerView = mViews.Single(v => v.PlayerId == playerId) as HumanView;
playerView.DrawSegment = ds;
}
}
// TODO: P3: Make sure all non-local players are connected
mScene.Load();
mActorMan.LoadContent(manifest);
// TODO: P3: Make sure all remote clients have loaded their game.
foreach (PlayerView view in mViews)
{
view.Load();
}
GameResources.LoadNewLevelDelegate = LoadNewLevel;
SharedResources.Game.GraphicsDevice.DeviceLost += DeviceLostHandler;
SharedResources.Game.GraphicsDevice.DeviceResetting += DeviceResettingHandler;
SharedResources.Game.GraphicsDevice.DeviceReset += DeviceResetHandler;
}
示例5: Load
public int Load(int slot, Scene s)
{
Log.Debug(() => "Loading a new scene into position {0}.".FormatWith(slot));
if (this.IsLoaded && !s.IsLoaded)
{
s.Load();
}
lock (this.scenes)
{
for (int i = slot; i >= 0; i--)
{
try
{
Log.Debug(() => "Trying to insert scene '{0}' into position {1}.".FormatWith(s.Name ?? "N/A", i));
this.scenes.Add(i, s);
s.Enable();
Log.Debug(() => "Scene inserted successfully.");
return i;
}
catch (ArgumentException)
{
Log.Debug(() => "Position {0} taken, incrementing...".FormatWith(i));
}
}
Log.Warn(() => "Scene insertion failed, all slots below were taken.");
throw new InvalidOperationException("Scene insertion failed, all slots below were taken.");
}
}
示例6: StartTest
void StartTest()
{
GameObject sceneRoot = new GameObject("SceneRoot");
scene = sceneRoot.AddComponent<Scene>();
scene.Init();
//SceneSetting sceneSetting = new SceneSetting(true);
//sceneSetting.Map.CellCountX = 10;
//sceneSetting.Map.CellCountY = 10;
//scene.Load(sceneSetting);
scene.Load("Settings/test.map");
float mapWidth = scene.Map.Width;
float mapHeight = scene.Map.Height;
position = new Vector3(mapWidth / 2, mapHeight / 2, 0);
for (int i = 0; i < 100; ++i)
{
MonsterEntity monsterEntity = scene.CreateMonsterEntity(0);
scene.AddEntityToScene(monsterEntity, new Vector3(Random.value * mapWidth, Random.value * mapHeight, 0));
}
}