//-------------------------------------------------------------------------- // Use this for initialization void Start() { mHighScoreBoard = GetComponentInParent <HighScoreComponent>(); mMainMenu = GameObject.Find("MainMenu"); mLeftBorder = GameObject.Find("LeftBorder"); mRightBorder = GameObject.Find("RightBorder"); mBottomBorder = GameObject.Find("BottomBorder"); mGameStatusPanel = GameObject.Find("GameStatusPanel"); mPausePanel = GameObject.Find("PausePanel"); mGameEndPanel = GameObject.Find("GameEndPanel"); mHighScorePanel = GameObject.Find("HighScorePanel"); mTetrisGame = new TetrisGame(); mTetrisGame.Start(); ReturnToMainMenu(); }
//-------------------------------------------------------------------------- // Use this for initialization void Start() { mHighScoreBoard = GetComponentInParent<HighScoreComponent>(); mMainMenu = GameObject.Find("MainMenu"); mLeftBorder = GameObject.Find("LeftBorder"); mRightBorder = GameObject.Find("RightBorder"); mBottomBorder = GameObject.Find("BottomBorder"); mGameStatusPanel = GameObject.Find("GameStatusPanel"); mPausePanel = GameObject.Find("PausePanel"); mGameEndPanel = GameObject.Find("GameEndPanel"); mHighScorePanel = GameObject.Find("HighScorePanel"); mTetrisGame = new TetrisGame(); mTetrisGame.Start(); ReturnToMainMenu(); }
/// <summary> /// Method responsible for creating every gameobject. /// </summary> private void CreateGameObjects() { keyReader.QuitKeys.Add(ConsoleKey.Enter); sceneChanger = new GameObject("Scene Changer"); SceneChangerComponent sceneChangerComponent = new SceneChangerComponent(sceneHandler); sceneChanger.AddComponent(sceneChangerComponent); sceneChangerComponent.SceneToLoad = "LevelScene"; //////////////////////////////////////////////////////////////////// newLevelCreator = new GameObject("New Level Creator"); CreateNewLevelComponent createLevel = new CreateNewLevelComponent(keyReader, sceneHandler, random); newLevelCreator.AddComponent(createLevel); //////////////////////////////////////////////////////////////////// pacmanLogo = new GameObject("Pacman Logo"); ConsolePixel logoPixel = new ConsolePixel( ' ', ConsoleColor.White, ConsoleColor.DarkYellow); Dictionary <Vector2Int, ConsolePixel> logoPixels = new Dictionary <Vector2Int, ConsolePixel>(); ICollection <Vector2Int[]> positionsList = new List <Vector2Int[]>(); CreatePacmanSprite(positionsList); foreach (Vector2Int[] v in positionsList) { for (int i = v[0].X; i < v[1].X + 1; i++) { for (int j = v[0].Y; j < v[1].Y + 1; j++) { logoPixels[new Vector2Int(i, j)] = logoPixel; } } } pacmanLogo.AddComponent(new TransformComponent(20, 1)); pacmanLogo.AddComponent(new ConsoleSprite(logoPixels)); //////////////////////////////////////////////////////////////////// selector = new GameObject("Selector"); char[,] selectorSprite = { { '-' }, { '-' }, { '>' }, }; MapComponent map = new MapComponent(XSIZE, YSIZE); MoveComponent selectorMovement = new MoveComponent(); selector.AddComponent(keyReader); selector.AddComponent(new TransformComponent(2, 34)); selector.AddComponent(selectorMovement); selector.AddComponent(map); selector.AddComponent(new ConsoleSprite( selectorSprite, ConsoleColor.White, ConsoleColor.DarkBlue)); SelectorMovementBehaviour selectorMovementBehaviour = new SelectorMovementBehaviour( selector, sceneChanger. GetComponent <SceneChangerComponent>()); // Adds a movement behaviour selectorMovement.AddMovementBehaviour(selectorMovementBehaviour); //////////////////////////////////////////////////////////////////// startText = new GameObject("Start Game"); startText.AddComponent(new TransformComponent(6, 34)); RenderableStringComponent renderStartGame = new RenderableStringComponent( () => "START GAME", i => new Vector2Int(i, 0), ConsoleColor.Yellow, ConsoleColor.DarkBlue); startText.AddComponent(renderStartGame); //////////////////////////////////////////////////////////////////// quitText = new GameObject("Quit"); quitText.AddComponent(new TransformComponent(6, 36)); RenderableStringComponent renderQuit = new RenderableStringComponent( () => "QUIT", i => new Vector2Int(i, 0), ConsoleColor.White, ConsoleColor.DarkBlue); quitText.AddComponent(renderQuit); //////////////////////////////////////////////////////////////////// highScoreText = new GameObject("HighScore Text"); highScoreText.AddComponent(new TransformComponent(6, 28)); RenderableStringComponent renderHighScoreText = new RenderableStringComponent( () => $"HighScore:", i => new Vector2Int(i, 0), ConsoleColor.White, ConsoleColor.DarkBlue); highScoreText.AddComponent(renderHighScoreText); //////////////////////////////////////////////////////////////////// highScoreNumberText = new GameObject("HighScore Number Text"); HighScoreComponent highScoreComponent = new HighScoreComponent(); RenderableStringComponent renderHighScoreNumberText = new RenderableStringComponent( () => $"{highScoreComponent.HighScore}", i => new Vector2Int(i, 0), ConsoleColor.White, ConsoleColor.DarkBlue); highScoreNumberText.AddComponent(new TransformComponent(6, 30)); highScoreNumberText.AddComponent(renderHighScoreNumberText); highScoreNumberText.AddComponent(highScoreComponent); //////////////////////////////////////////////////////////////////// controlsText = new GameObject("ControlsText"); controlsText.AddComponent(new TransformComponent(70, 19)); RenderableStringComponent renderControls = new RenderableStringComponent( () => "Controls:", i => new Vector2Int(i, 0), ConsoleColor.White, ConsoleColor.DarkBlue); controlsText.AddComponent(renderControls); //////////////////////////////////////////////////////////////////// movementText = new GameObject("MovementText"); movementText.AddComponent(new TransformComponent(54, 21)); RenderableStringComponent renderMovement = new RenderableStringComponent( () => "Movement Keys: W, A, S, D", i => new Vector2Int(i, 0), ConsoleColor.White, ConsoleColor.DarkBlue); movementText.AddComponent(renderMovement); //////////////////////////////////////////////////////////////////// actionsText = new GameObject("ActionsText"); actionsText.AddComponent(new TransformComponent(50, 22)); RenderableStringComponent renderActions = new RenderableStringComponent( () => "Confirm: Enter , Quit: Escape", i => new Vector2Int(i, 0), ConsoleColor.White, ConsoleColor.DarkBlue); actionsText.AddComponent(renderActions); //////////////////////////////////////////////////////////////////// rules = new GameObject("RulesText"); rules.AddComponent(new TransformComponent(73, 24)); RenderableStringComponent renderRules = new RenderableStringComponent( () => "Rules:", i => new Vector2Int(i, 0), ConsoleColor.White, ConsoleColor.DarkBlue); rules.AddComponent(renderRules); //////////////////////////////////////////////////////////////////// rule1 = new GameObject("Rule1"); rule1.AddComponent(new TransformComponent(52, 26)); RenderableStringComponent renderRule1 = new RenderableStringComponent( () => "Pacman must run from ghosts", i => new Vector2Int(i, 0), ConsoleColor.White, ConsoleColor.DarkBlue); rule1.AddComponent(renderRule1); //////////////////////////////////////////////////////////////////// rule2 = new GameObject("Rule2"); rule2.AddComponent(new TransformComponent(33, 27)); RenderableStringComponent renderRule2 = new RenderableStringComponent( () => "Pacman can pick power pills and eat the ghosts", i => new Vector2Int(i, 0), ConsoleColor.White, ConsoleColor.DarkBlue); rule2.AddComponent(renderRule2); //////////////////////////////////////////////////////////////////// rule3 = new GameObject("Rule3"); rule3.AddComponent(new TransformComponent(37, 28)); RenderableStringComponent renderRule3 = new RenderableStringComponent( () => "Pacman must eat every food to end the game", i => new Vector2Int(i, 0), ConsoleColor.White, ConsoleColor.DarkBlue); rule3.AddComponent(renderRule3); //////////////////////////////////////////////////////////////////// icons = new GameObject("Icons"); icons.AddComponent(new TransformComponent(73, 30)); RenderableStringComponent renderIcons = new RenderableStringComponent( () => "Icons:", i => new Vector2Int(i, 0), ConsoleColor.White, ConsoleColor.DarkBlue); icons.AddComponent(renderIcons); //////////////////////////////////////////////////////////////////// icon1 = new GameObject("Icon1"); icon1.AddComponent(new TransformComponent(68, 32)); RenderableStringComponent renderIcon1 = new RenderableStringComponent( () => "P -> Pacman", i => new Vector2Int(i, 0), ConsoleColor.White, ConsoleColor.DarkBlue); icon1.AddComponent(renderIcon1); //////////////////////////////////////////////////////////////////// icon2 = new GameObject("Icon2"); icon2.AddComponent(new TransformComponent(54, 33)); RenderableStringComponent renderIcon2 = new RenderableStringComponent( () => "Colored Squares -> Ghosts", i => new Vector2Int(i, 0), ConsoleColor.White, ConsoleColor.DarkBlue); icon2.AddComponent(renderIcon2); //////////////////////////////////////////////////////////////////// icon3 = new GameObject("Icon3"); icon3.AddComponent(new TransformComponent(68, 34)); RenderableStringComponent renderIcon3 = new RenderableStringComponent( () => "F -> Fruits", i => new Vector2Int(i, 0), ConsoleColor.White, ConsoleColor.DarkBlue); icon3.AddComponent(renderIcon3); //////////////////////////////////////////////////////////////////// icon4 = new GameObject("Icon4"); icon4.AddComponent(new TransformComponent(62, 35)); RenderableStringComponent renderIcon4 = new RenderableStringComponent( () => "PUP -> Power Pill", i => new Vector2Int(i, 0), ConsoleColor.White, ConsoleColor.DarkBlue); icon4.AddComponent(renderIcon4); //////////////////////////////////////////////////////////////////// icon5 = new GameObject("Icon5"); icon5.AddComponent(new TransformComponent(70, 36)); RenderableStringComponent renderIcon5 = new RenderableStringComponent( () => ". -> Food", i => new Vector2Int(i, 0), ConsoleColor.White, ConsoleColor.DarkBlue); icon5.AddComponent(renderIcon5); }