private void Awake() { instance = this; if (GetComponent <Camera>() == null) { Debug.LogError("No Camera found to render on! Use this script on a gameObject with a Camera Component."); } }
private void Awake() { Instance = this; Tiles = new Tile[GridSizeX, GridSizeY]; _sprites = new Dictionary <string, Sprite>(); foreach (var spriteTexture in _spriteTextures) { _sprites.Add(spriteTexture.name, spriteTexture); } CreateMap(); CenterCamera(); }
protected override void Initialize() { // TODO: Add your initialization logic here _graphics.PreferredBackBufferWidth = _gameWindowedSize.Width; _graphics.PreferredBackBufferHeight = _gameWindowedSize.Height; _graphics.IsFullScreen = _isFullscreen; _graphics.ApplyChanges(); _defaultFont = Content.Load <SpriteFont>("default_font"); Player.Initialize(Content); LevelDrawer.Initialize(Content); PlayerDrawer.Initialize(Content); base.Initialize(); // Generate Level _currentLevel = LevelGenerator.GenerateLevel(6, 15, 15, 1, false); _player = new Player(_currentLevel.StartX, _currentLevel.StartY); _gameAreaScale = CalculateGameScale(_currentLevel, 50, 3 / 5f); }
public GameScreen(MyGameWindow gameWindow, Level level, string fileDirectory = "") : base(gameWindow) { levelAttempt = new LevelAttempt(level); gameLogic = new GameLogic(levelAttempt); levelDrawer = new LevelDrawer(levelAttempt.Level); AddKeyToSingleUserActionMapping(Key.W, UserAction.Jump); AddKeyToSingleUserActionMapping(Key.Space, UserAction.Jump); AddKeyToProlongedUserActionMapping(Key.D, UserAction.Defend); AddKeyToProlongedUserActionMapping(Key.S, UserAction.Duck); AddKeyToProlongedUserActionMapping(Key.ControlLeft, UserAction.Duck); AddKeyToSingleUserActionMapping(Key.H, UserAction.ToggleAlwaysDefending); AddKeyToSingleUserActionMapping(Key.P, UserAction.TogglePauseGame); AddKeyToSingleUserActionMapping(Key.Escape, UserAction.TogglePauseGame); AddKeyToSingleUserActionMapping(Key.F10, UserAction.ResetLevel); AddKeyToSingleUserActionMapping(Key.N, UserAction.JumpToNextLevel); AddKeyToSingleUserActionMapping(Key.X, UserAction.ReturnToMainMenu); AddSingleUserActionToFunctionMapping(UserAction.Jump, Jump); AddProlongedUserActionToFunctionMapping(UserAction.Duck, Duck); AddProlongedUserActionToFunctionMapping(UserAction.Defend, Defend); AddSingleUserActionToFunctionMapping(UserAction.ToggleAlwaysDefending, ToggleAlwaysDefending); AddSingleUserActionToFunctionMapping(UserAction.ResetLevel, ResetLevel); AddSingleUserActionToFunctionMapping(UserAction.TogglePauseGame, TogglePauseGame); AddSingleUserActionToFunctionMapping(UserAction.JumpToNextLevel, JumpToNextLevel); AddSingleUserActionToFunctionMapping(UserAction.ReturnToMainMenu, ReturnToMainMenu); if (fileDirectory.Length > 0) { musicPlayer = new MusicPlayer(fileDirectory); musicPlayer.InitAudio(); } Utils.Logger.StartNewLog(levelAttempt.Level.Name); }
void Awake() { m_instance = this; }