Skip to content

Commit

Permalink
Merge pull request #211 from 2024FALL-SWPP/ref/chaehwan/design-pattern
Browse files Browse the repository at this point in the history
Ref/chaehwan/design pattern
  • Loading branch information
Prown0 authored Dec 21, 2024
2 parents f9c76dc + c8ecacb commit 11a0995
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
4 changes: 3 additions & 1 deletion 302/Assets/Prefabs/Anomaly23/ghost.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -777,9 +777,11 @@ MonoBehaviour:
speedInit: 1
speedDelta: 5
durationChase: 25
durationBlow: 5
durationBlow: 8
timeAudioStart: 3
durationFade: 3
numRotate: 240
speedBlow: 20
--- !u!82 &3035267094544484457
AudioSource:
m_ObjectHideFlags: 0
Expand Down
50 changes: 38 additions & 12 deletions 302/Assets/Scripts/SpecificAnomalyManager/Anomaly23Ghost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class Anomaly23Ghost : AbstractAnomalyObject
public float durationBlow;
public float timeAudioStart;
public float durationFade;
public int numRotate;
public float speedBlow;

// 애니메이터
private Animator _animator;
Expand Down Expand Up @@ -174,12 +176,12 @@ public override bool ResetAnomaly()
{
bool res = base.ResetAnomaly();

_audioSource.enabled = false;
Log("Reset audio source success");

Log("Call `BlowAsync` asynchronously");
StartCoroutine(BlowAsync());

Log("Call `FadeAudioAsync` asynchronously");
StartCoroutine(FadeAudioAsync());

return res;
}

Expand Down Expand Up @@ -216,18 +218,42 @@ private IEnumerator FadeAudioAsync()
private IEnumerator BlowAsync()
{
SCH_Random random = new SCH_Random();
Vector3 originStart = transform.position;
Vector3 origin;
float timeStart = Time.time;
float time;
float time = 0.0f;

yield return new WaitForSeconds(0.1f);

while ((time = Time.time - timeStart) < durationBlow) {
float scale = (float)(random.LogNormalDist(0.0, 1.0) * 1.5);

transform.rotation = Random.rotation;
transform.localScale = new Vector3(scale, scale, scale);
yield return null;

yield return new WaitForSeconds(0.1f);
for (int i = 1; i <= numRotate; i++) {
Vector3 position;
Quaternion a;
Quaternion b;

origin = originStart + Vector3.up * time / durationBlow * 4.0f;
do {
position = new Vector3(
(float)random.NormalDist(),
(float)random.NormalDist(),
(float)random.NormalDist()
);
position += origin - transform.position;
} while (position.magnitude == 0.0f);

a = transform.rotation;
b = transform.rotation;
b.SetLookRotation(position, position);

while ((time = Time.time - timeStart) < durationBlow / numRotate * i) {
float scale = 1.0f - time / durationBlow;
float t = time / durationBlow * numRotate % 1.0f;

transform.localScale = new Vector3(scale, scale, scale);
transform.rotation = Quaternion.Lerp(a, b, t);
transform.Translate(Vector3.forward * speedBlow * Time.deltaTime);

yield return null;
}
}

Destroy(gameObject);
Expand Down

0 comments on commit 11a0995

Please sign in to comment.