You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
937 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using Duality;
using Duality.Input;
using Duality.Components.Physics;
using Duality.Components;
using Duality.Resources;
namespace FlapOrDie.Controllers
{
[RequiredComponent(typeof(Camera))]
public class MainMenuController : Component, ICmpUpdatable
{
public ContentRef<Scene> GameScene { get; set; }
void ICmpUpdatable.OnUpdate()
{
if (DualityApp.Keyboard.KeyHit(Key.Escape))
{
DualityApp.Terminate();
}
if (DualityApp.Keyboard.KeyHit(Key.Space))
{
//preloading materials and sounds
foreach (ContentRef<Material> m in ContentProvider.GetAvailableContent<Material>())
{
m.MakeAvailable();
}
foreach (ContentRef<Sound> s in ContentProvider.GetAvailableContent<Sound>())
{
s.MakeAvailable();
}
GameScene.Res.FindComponent<GameController>().Reset();
Scene.SwitchTo(GameScene);
}
}
}
}