/** * Restarts currently shown level. */ public void Restart() { _transition.TransitionTo("Gameplay"); }
void Start() { var player = new GameObject("player"); DontDestroyOnLoad(player); player.AddComponent <AudioPlayer>(); _transition = gameObject.AddComponent <StateTransition>(); { var title = new GameObject("title"); title.transform.parent = gameObject.transform; title.transform.localPosition = new Vector3(0, 4f, 0); title.transform.localScale = Vector3.one * 1.5f; var titleText = title.AddComponent <AnimatedText>(); titleText.text = "player is you"; titleText.align = Align.Center; } { var menu = new GameObject("menu"); menu.transform.localPosition = new Vector3(0, 1f, 0); menu.transform.parent = gameObject.transform; var menuComp = menu.AddComponent <Menu>(); menuComp.AddItem("Play", () => _transition.TransitionTo("LevelSelectMenu")); menuComp.AddItem("Quit", () => Application.Quit()); } { var controls = new GameObject("controls"); controls.transform.parent = gameObject.transform; var controlRen = controls.AddComponent <SpriteRenderer>(); controlRen.sprite = Sprite.Create( _controlsTexture, new Rect(0, 0, 96, 64), new Vector2(0, 0), 32); var controlAnim = controls.AddComponent <AnimatedSprite>(); controlAnim.numberOfSprites = 8; controls.transform.localPosition = new Vector3(-2.5f, -4.5f, 1); } { var cIsM = MakeFakeEntity(EntityType.ConnectorIs); cIsM.transform.parent = gameObject.transform; cIsM.transform.localPosition = new Vector3(0.5f, -4.5f, 0); } { var move = MakeFakeEntity(EntityType.TraitMove); move.transform.parent = gameObject.transform; move.transform.localPosition = new Vector3(1.5f, -4.5f, 0); } { var noun = MakeFakeEntity(EntityType.SubjectNoun); noun.transform.parent = gameObject.transform; noun.transform.localPosition = new Vector3(-7f, -4.5f, 0); } { var nIsV = MakeFakeEntity(EntityType.ConnectorIs); nIsV.transform.parent = gameObject.transform; nIsV.transform.localPosition = new Vector3(-6f, -4.5f, 0); } { var verb = MakeFakeEntity(EntityType.TraitVerb); verb.transform.parent = gameObject.transform; verb.transform.localPosition = new Vector3(-5f, -4.5f, 0); } { var goal = MakeFakeEntity(EntityType.SubjectGoal); goal.transform.parent = gameObject.transform; goal.transform.localPosition = new Vector3(4f, -4.5f, 0); } { var gIsW = MakeFakeEntity(EntityType.ConnectorIs); gIsW.transform.parent = gameObject.transform; gIsW.transform.localPosition = new Vector3(5f, -4.5f, 0); } { var win = MakeFakeEntity(EntityType.TraitWin); win.transform.parent = gameObject.transform; win.transform.localPosition = new Vector3(6f, -4.5f, 0); } }