Example #1
0
    protected void InitializeObsctacleManager()
    {
        _obstacleManager = (ObstacleManager)GetNode("ObstacleManager");
        _obstacleManager.Initialize(_tileMap);

        if (GetTree().NetworkPeer == null || GetTree().IsNetworkServer())
        {
            _pathFinding = (PathFinding)((PackedScene)GD.Load("res://ai/PathFinding.tscn")).Instance();;
            this.AddChild(_pathFinding);
            _pathFinding.Initialize(_tileMap, _obstacleManager);
        }
    }
    // ---------- INITIALIZATIONS ON AWAKE ----------------------------------------------------+

    #region AWAKE
    private void Awake()
    {
        // ----- GAME STATE -----

        gameState = GameStates.TITLE_SCREEN;

        // ----- EVENT SUBSCRIPTIONS -----

        SubscribeToEvents();

        // ----- GAME ELEMENTS INITIALIZATIONS -----

        // Obstacles and Bosses will have normal game speed
        // Map and hero's speed will be 0.25% slower

        // Obstacles' drag force will be 0.5% slower than the map's

        // Initialize map
        mapManager.Initialize(gameSpeed * 3 / 4, deathDragForce, mainCamera);

        // Initialize hero
        heroManager.Initialize(charactersSpawnPositionY, gameSpeed * 3 / 4);

        // Initialize obstacles
        obstacleManager.Initialize(spawnAndExit_AbsolutePositionX, charactersSpawnPositionY,
                                   gameSpeed, deathDragForce / 2);

        // Initialize bosses
        bossManager.Initialize(spawnAndExit_AbsolutePositionX,
                               charactersSpawnPositionY, bossBase_AbsolutePositionX, gameSpeed, deathAccelerationForce);

        // ----- SET HERO DIRECTION -----

        // Set hero direction
        SetHeroDirection();

        // Set serenity state
        mapManager.SetSerenityState();
    }