void Awake() { main = this; }
private void Start() { gm = GetComponent <GridManager>(); // Setup level characteristics for GridManager if (currentLevel == 0) { currentLevel = 1; } if (overrideLevelData) { LevelData newLevelData = new LevelData(inspectorGridWidth, inspectorGridHeight, 4, 0); gm.ReceiveLevelData(newLevelData.LevelTable[0]); } else { gm.ReceiveLevelData(levelData.LevelTable[LevelDataIndex]); } gm.Init(); // Setup GridObjectManager gom = GetComponent <GridObjectManager>(); if (overrideSpawnSequence.Length > 0) { for (int i = 0; i < overrideSpawnSequence.Length; i++) { gom.insertSpawnSequences.Add(overrideSpawnSequence[i].Clone()); } } if (VerboseConsole) { debugHUD = GameObject.FindGameObjectWithTag("Debug HUD").GetComponent <DebugHUD>(); } display = GameObject.FindGameObjectWithTag("Game Display").GetComponent <GameDisplay>(); // Setup Player Vector2Int startLocation = new Vector2Int(0, 0); if (overrideSpawnSequence.Length > 0) { startLocation = overrideSpawnSequence[0].playerSpawnLocation; } GameObject player = Instantiate(gom.playerPrefab, gm.GridToWorld(startLocation), Quaternion.identity); if (VerboseConsole) { Debug.Log(player.name + " has been instantiated."); } if (VerboseConsole) { Debug.Log("Adding Player to Grid."); } gm.AddObjectToGrid(player, startLocation); this.player = player.GetComponent <Player>(); this.player.currentWorldLocation = gm.GridToWorld(startLocation); this.player.targetWorldLocation = gm.GridToWorld(startLocation); if (VerboseConsole) { Debug.Log("Player successfully added to Grid."); } this.player.NextLevel(levelData.LevelTable[LevelDataIndex].jumpFuelAmount); // Initialize Game Object Manager now that player exists gom.Init(); this.player.OnPlayerAdvance += OnTick; }