Merge remote-tracking branch 'origin/main'

This commit is contained in:
Nadar 2024-03-17 00:01:42 +03:00
commit 950a804652
13 changed files with 150 additions and 10 deletions

View File

@ -165,6 +165,8 @@ MonoBehaviour:
syncMode: 0 syncMode: 0
syncInterval: 0.1 syncInterval: 0.1
state: 0 state: 0
openClip: {fileID: 8300000, guid: 9c008e5df09e6a9468f26639dc43fb1c, type: 3}
closeClip: {fileID: 8300000, guid: de03bb61d997f68419fe5c9c7eb6a3d6, type: 3}
duration: 2 duration: 2
offset: 2.5 offset: 2.5
oCurva: oCurva:

View File

@ -530,7 +530,7 @@ AudioSource:
OutputAudioMixerGroup: {fileID: 0} OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: 089ede39b7c6649a881da9b3834212c9, type: 3} m_audioClip: {fileID: 8300000, guid: 089ede39b7c6649a881da9b3834212c9, type: 3}
m_PlayOnAwake: 0 m_PlayOnAwake: 0
m_Volume: 1 m_Volume: 0.5
m_Pitch: 1 m_Pitch: 1
Loop: 0 Loop: 0
Mute: 0 Mute: 0
@ -646,6 +646,8 @@ MonoBehaviour:
syncMode: 0 syncMode: 0
syncInterval: 0.1 syncInterval: 0.1
state: 0 state: 0
openClip: {fileID: 8300000, guid: 9c008e5df09e6a9468f26639dc43fb1c, type: 3}
closeClip: {fileID: 8300000, guid: de03bb61d997f68419fe5c9c7eb6a3d6, type: 3}
duration: 2 duration: 2
offset: 2.5 offset: 2.5
oCurva: oCurva:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: eeb6f6857c4a4b0439a759086260ce48
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Resources/Audio/Env/door-close.mp3 (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 39e43d5108f3a1246b562f102863e60f
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Resources/Audio/Env/door-close2.mp3 (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: de03bb61d997f68419fe5c9c7eb6a3d6
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Resources/Audio/Env/door-open.mp3 (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 36f2743cdc7732b479c91ebb0220c2bc
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Resources/Audio/Env/door-open2.mp3 (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 9c008e5df09e6a9468f26639dc43fb1c
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -149,8 +149,8 @@ Transform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2719641} m_GameObject: {fileID: 2719641}
m_LocalRotation: {x: -0.7071068, y: 0, z: -0, w: 0.7071068} m_LocalRotation: {x: 0.22161405, y: 0.6785788, z: -0.22698912, w: 0.6624908}
m_LocalPosition: {x: -3.0000353, y: 0.000001136496, z: 11.999991} m_LocalPosition: {x: -309.30713, y: 209.22267, z: 24.826782}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
@ -7371,7 +7371,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6573182459455165619, guid: 41cf1eab2df798c4788c87b706a519d1, type: 3} - target: {fileID: 6573182459455165619, guid: 41cf1eab2df798c4788c87b706a519d1, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 5 value: 4
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6573182459455165619, guid: 41cf1eab2df798c4788c87b706a519d1, type: 3} - target: {fileID: 6573182459455165619, guid: 41cf1eab2df798c4788c87b706a519d1, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
@ -20502,7 +20502,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6573182459455165619, guid: 41cf1eab2df798c4788c87b706a519d1, type: 3} - target: {fileID: 6573182459455165619, guid: 41cf1eab2df798c4788c87b706a519d1, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 2 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6573182459455165619, guid: 41cf1eab2df798c4788c87b706a519d1, type: 3} - target: {fileID: 6573182459455165619, guid: 41cf1eab2df798c4788c87b706a519d1, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
@ -23785,7 +23785,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6573182459455165619, guid: 41cf1eab2df798c4788c87b706a519d1, type: 3} - target: {fileID: 6573182459455165619, guid: 41cf1eab2df798c4788c87b706a519d1, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 4 value: 3
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6573182459455165619, guid: 41cf1eab2df798c4788c87b706a519d1, type: 3} - target: {fileID: 6573182459455165619, guid: 41cf1eab2df798c4788c87b706a519d1, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
@ -77915,7 +77915,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 13385339066235970, guid: 66df3c5eb0b75424582840a6f8405e9b, type: 3} - target: {fileID: 13385339066235970, guid: 66df3c5eb0b75424582840a6f8405e9b, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 7 value: 6
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 13385339066235970, guid: 66df3c5eb0b75424582840a6f8405e9b, type: 3} - target: {fileID: 13385339066235970, guid: 66df3c5eb0b75424582840a6f8405e9b, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
@ -144879,7 +144879,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6573182459455165619, guid: 41cf1eab2df798c4788c87b706a519d1, type: 3} - target: {fileID: 6573182459455165619, guid: 41cf1eab2df798c4788c87b706a519d1, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 3 value: 2
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6573182459455165619, guid: 41cf1eab2df798c4788c87b706a519d1, type: 3} - target: {fileID: 6573182459455165619, guid: 41cf1eab2df798c4788c87b706a519d1, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
@ -144943,9 +144943,13 @@ PrefabInstance:
propertyPath: sceneId propertyPath: sceneId
value: 2022339728 value: 2022339728
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3933189198333053099, guid: 089b20c70699d924f8f39ed04504fe64, type: 3}
propertyPath: m_Volume
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 3933189198339639135, guid: 089b20c70699d924f8f39ed04504fe64, type: 3} - target: {fileID: 3933189198339639135, guid: 089b20c70699d924f8f39ed04504fe64, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 6 value: 5
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3933189198339639135, guid: 089b20c70699d924f8f39ed04504fe64, type: 3} - target: {fileID: 3933189198339639135, guid: 089b20c70699d924f8f39ed04504fe64, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x

View File

@ -3,11 +3,15 @@ using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using Mirror; using Mirror;
[RequireComponent(typeof(AudioSource))]
public class SciFiDoor : NetworkBehaviour, IInteractable public class SciFiDoor : NetworkBehaviour, IInteractable
{ {
[SyncVar] [SyncVar]
public bool state = false; public bool state = false;
public AudioClip openClip;
public AudioClip closeClip;
public float duration = 2f, offset; public float duration = 2f, offset;
public AnimationCurve oCurva; public AnimationCurve oCurva;
public List<Transform> doorList; public List<Transform> doorList;
@ -15,10 +19,12 @@ public class SciFiDoor : NetworkBehaviour, IInteractable
private float _posX, _originX; private float _posX, _originX;
private float _timeElapsed; private float _timeElapsed;
private AudioSource _audioSource;
void Start() void Start()
{ {
_originX = doorList[0].localPosition.x; _originX = doorList[0].localPosition.x;
_audioSource = GetComponent<AudioSource>();
} }
public void Interact() public void Interact()
{ {
@ -29,6 +35,10 @@ public class SciFiDoor : NetworkBehaviour, IInteractable
private void CmdInteract(NetworkConnectionToClient sender = null) private void CmdInteract(NetworkConnectionToClient sender = null)
{ {
state = !state; state = !state;
_audioSource.clip = state ? openClip : closeClip;
_audioSource.pitch = duration / _audioSource.clip.length;
_audioSource.Play();
} }
void Update() void Update()
@ -38,9 +48,23 @@ public class SciFiDoor : NetworkBehaviour, IInteractable
float progress = _timeElapsed / duration; float progress = _timeElapsed / duration;
_posX = Mathf.Lerp(_originX, _originX + offset, oCurva.Evaluate(progress)); if (progress >= 1f)
{
_audioSource.Stop();
return;
}
var t = oCurva.Evaluate(progress);
_posX = Mathf.Lerp(_originX, _originX + offset, t);
// _posX = Mathf.Lerp(_originX, _originX + offset, Mathf.SmoothStep(0, 1, progress)); // _posX = Mathf.Lerp(_originX, _originX + offset, Mathf.SmoothStep(0, 1, progress));
if (_audioSource.clip)
{
_audioSource.timeSamples = Mathf.FloorToInt(Mathf.Abs(_audioSource.clip.samples * t));
}
for (int i = 1; i <= doorList.Count; i++) for (int i = 1; i <= doorList.Count; i++)
{ {
float side = i % 2 == 0 ? -1 : 1; float side = i % 2 == 0 ? -1 : 1;