예제 #1
0
    public static void ExitCurrentRoom(Room exited_room, RoomExit exit)
    {
        ControlManager.SetInputEnabled(false);
        var game_camera = GameCamera.GetCamera();

        game_camera.StartFade(instance.room_exit_fade_out_time, 1f, () => {
            Destroy(instance.active_room_instance.gameObject);
            instance.current_room_index++;
            RoomSetupProperties room_setup_properties = new RoomSetupProperties();
            room_setup_properties.enter_from          = exit.exit_direction;
            CreateNextRoom(room_setup_properties);
        });
    }
예제 #2
0
    public static void CreateNextRoom(RoomSetupProperties properties)
    {
        if (instance.room_prefabs.Count > instance.current_room_index)
        {
            var room_instance  = Instantiate(instance.room_prefabs[instance.current_room_index]);
            var room_component = room_instance.GetComponent <Room>();
            room_component.SetupRoom(properties);
            instance.active_room_instance = room_component;

            var game_camera = GameCamera.GetCamera();

            // move camera to player's new location
            var camera_follow = game_camera.gameObject.GetComponent <CameraFollow>();
            var player        = PlayerCharacter.GetPlayerCharacter();
            camera_follow.JumpTo(player.gameObject.transform.position);

            var sequence_manager = instance.gameObject.GetComponent <GameStartupSequence>();
            if (!sequence_manager)
            {
                Debug.LogError("room manager couldnt find startup sequence manager!");
                return;
            }
            // check if the startup sequence is playing... if so don't fade in....
            if (!sequence_manager.IsSequenceActive())
            {
                // start fade in
                game_camera.StartFade(instance.room_exit_fade_out_time, 0f, () => {
                    // @ kinda jank but whatcha gonna do...
                    ControlManager.SetInputEnabled(true);
                    room_component.ActivateRoom();
                });
            }
        }
        else
        {
            // @BOSS ROOM...
            if (instance.bossRoomSceneName == null)
            {
                Debug.LogWarning("No boss room prefab set!");
                return;
            }

            DOTween.Clear();
            SceneManager.LoadScene(instance.bossRoomSceneName, LoadSceneMode.Single);
            var game_camera = GameCamera.GetCamera();
            // @Change first param to whatever fade-in-time you want
            game_camera.StartFade(instance.room_exit_fade_out_time, 0f, () => {
            });
        }
    }
예제 #3
0
    public void SetupRoom(RoomSetupProperties properties)
    {
        var player = PlayerCharacter.GetPlayerCharacter();
        var desired_spawn_location = GetOppositeDirection(properties.enter_from);
        var player_spawn_points    = GetComponentsInChildren <PlayerSpawn>().ToList();
        var player_spawn           = player_spawn_points.Find((x) => x.spawn_direction == desired_spawn_location);

        if (player_spawn == null)
        {
            player_spawn = player_spawn_points[0];
        }
        player.transform.position = player_spawn.transform.position;

        if (enemy_types.Count == 0)
        {
            Debug.LogError("NEED TO SET ENEMY WEIGHTS IN ROOM!");
            return;
        }
        Dictionary <GameObject, int> enemy_spawn_dict = new Dictionary <GameObject, int>();

        enemy_types.ForEach((enemy) => { enemy_spawn_dict.Add(enemy.enemy_prefab, enemy.weight); });
        var enemy_weighted_random = WeightedRandomizer.From(enemy_spawn_dict);
        var enemy_spawn_points    = GetComponentsInChildren <EnemySpawn>().ToList();

        enemy_spawn_points.ForEach((EnemySpawn spawn) => {
            var enemy_type     = enemy_weighted_random.TakeOne();
            var enemy_instance = Instantiate <GameObject>(enemy_type, spawn.transform);
            // make new spawns objectives in order to exit room
            enemy_instance.AddComponent <ObjectiveEnemy>();
            var ai_brain = enemy_instance.GetComponent <AIBrain>();
            // disable AI at start
            ai_brain.EnableBrain(false);
            var distance_to_player = Vector3.Distance(enemy_instance.transform.position, player.gameObject.transform.position);
            if (distance_to_player >= 10f)
            {
                ai_brain.SetEnableOnDistanceOrDamage();
            }
        });
        // @TODO: iterate over AI and set "wake nearby" on wake...

        room_setup_complete = true;
    }
    public void StartGameIntroSequence()
    {
        ControlManager.SetInputEnabled(false);
        // spawn room..
        var room_setup_properties = new RoomSetupProperties();

        room_setup_properties.enter_from = RoomRelativeDirection.NORTH;
        RoomManager.CreateNextRoom(room_setup_properties);
        // camera stuff..
        var game_camera = GameCamera.GetCamera();

        game_camera.StartFade(0f, 1f);
        var follow_component = game_camera.gameObject.GetComponent <CameraFollow>();
        var player           = PlayerCharacter.GetPlayerCharacter();

        follow_component.JumpTo(player.gameObject.transform.position);
        follow_component.SetTarget(player.gameObject.transform);
        // start sequence...
        NextSequenceItem();
    }