void Awake()
    {
        // State machine
        // -- IDLE --
        idle_state = new CameraIdleState(this);
        // -- ALERT --
        alert_state = new CameraAlertState(this);
        // -- FOLLOWING --
        following_state = new CameraFollowingState(this);

        foreach (Transform childs in transform.getChilds())
        {
            if (childs.gameObject.name == "camera_lens")
            {
                camera_lens = childs;
            }
        }

        initial_forward_direction = camera_lens.transform.forward;
        initial_rotation          = camera_lens.rotation;

        alarm_system          = GameObject.FindGameObjectWithTag(Tags.game_controller).GetComponent <AlarmSystem>();
        last_spotted_position = GameObject.FindGameObjectWithTag(Tags.game_controller).GetComponent <LastSpottedPosition>();
        players = GameObject.FindGameObjectsWithTag(Tags.player);

        // Camera sweep
        mid_angle     = angle_range / 2.0f;
        current_speed = max_rotation_speed;
        left_zone     = zone_for_acceleration * angle_range;
        right_zone    = angle_range - (zone_for_acceleration * angle_range);
    }
Example #2
0
    /// <summary>
    /// initialized by Gameplay controller
    /// </summary>
    public void Init(IInput input)
    {
        _camera             = GetComponent <Camera>();
        _cameraStateMachine = GetComponent <StateMachine>();

        _cameraIdleState    = new CameraIdleState(_settings.Idle, _camera);
        _startSequenceState = new CameraStartSequenceState(_settings.StartSequence, _camera);
        _orbitState         = new CameraOrbitState(input, _settings.Orbit, _camera);
        _levelFinishedState = new CameraLevelFinishedState(_settings.levelFinished, _camera);
    }