コード例 #1
0
    public IEnumerator <WaitCommand> AnimateToMount(ICameraMount mount, TimeSpan duration)
    {
        if (_transitionActive)
        {
            Debug.LogError("Attempting to transition between mounts while another transition is still active");
            yield break;
        }

        _transitionActive = true;

        yield return(Routines.Animate(_clock.PollDeltaTime, duration, lerp => {
            _rig.transform.position = Vector3.Lerp(_mount.transform.position, mount.transform.position, lerp);
            _rig.transform.rotation = Quaternion.Slerp(_mount.transform.rotation, mount.transform.rotation, lerp);
        }).AsWaitCommand());

        if (_mount != null)
        {
            _mount.OnDismount(Rig);
        }

        _mount = mount;
        if (_mount != null)
        {
            _mount.OnMount(Rig);
        }

        _transitionActive = false;
    }
コード例 #2
0
    public void SwitchMount(ICameraMount mount)
    {
        if (_transitionActive)
        {
            Debug.LogError("Attempting to transition between mounts while another transition is still active");
            return;
        }

        if (mount == null)
        {
            throw new ArgumentException("Mount cannot be null");
        }

        if (_mount != null)
        {
            _mount.OnDismount(Rig);
        }

        _mount = mount;
        if (_mount != null)
        {
            _mount.OnMount(Rig);
        }

        // Timeless transition implies teleportation, so inform the mounts
        _rig.Teleport();
    }
コード例 #3
0
 public SpectatorMode(IStateMachine machine, Data data) : base(machine)
 {
     _data = data;
     _spectatorCameraMount = _data.SpectatorCamera.GetComponent <ICameraMount>();
 }