This commit is contained in:
GoaLitiuM
2021-12-30 16:30:16 +02:00
parent cccbf334aa
commit 99637255da
22 changed files with 4950 additions and 47 deletions

View File

@@ -33,6 +33,10 @@ namespace Game
public float MoveSpeed { get; set; } = 320;
public AudioClip JumpLandSound;
public AudioClip JumpLandSound2;
public AudioClip JumpLandSound3;
private AudioClip lastJumpLandSound;
private Random soundRandom;
private float viewPitch;
private float viewYaw;
@@ -52,8 +56,8 @@ namespace Game
{
base.OnAwake();
//input = new PlayerInputLocal(@"C:\dev\GoakeFlax\testdemo.gdem");
input = new PlayerInputDemo(@"C:\dev\GoakeFlax\testdemo.gdem");
input = new PlayerInputLocal(@"C:\dev\GoakeFlax\testdemo.gdem"); // record
//input = new PlayerInputDemo(@"C:\dev\GoakeFlax\testdemo.gdem"); //playback
onExit.Triggered += () =>
{
@@ -64,6 +68,8 @@ namespace Game
rootActor = Actor.GetChild(0);
rigidBody = Actor.As<RigidBody>();
soundRandom = new Random();
//rigidBody.CollisionEnter += OnCollisionEnter;
//rigidBody.TriggerEnter += OnTriggerEnter;
//rigidBody.TriggerExit += OnTriggerExit;
@@ -776,16 +782,32 @@ namespace Game
jumped = true;
lastJumped = Time.GameTime;
if (JumpLandSound != null && JumpLandSound.IsLoaded)
var jumpLandSound = JumpLandSound;
for (int i = 0; i < 10; i++)
{
var r = soundRandom.Next(3);
if (r == 1)
jumpLandSound = JumpLandSound2;
else if (r == 2)
jumpLandSound = JumpLandSound3;
// avoid repetition
if (jumpLandSound != lastJumpLandSound)
break;
}
if (jumpLandSound != null && jumpLandSound.IsLoaded)
{
var audioSource = new AudioSource();
audioSource.Clip = JumpLandSound;
audioSource.Clip = jumpLandSound;
audioSource.Position = rootActor.Position; //new Vector3(-350, 176, 61);//rootActor.Position;
audioSource.Parent = Actor.Parent;
audioSource.Pitch = 1f;
audioSource.Name = jumpLandSound.Path;
audioSource.Play();
Destroy(audioSource, JumpLandSound.Length);
Destroy(audioSource, jumpLandSound.Length);
lastJumpLandSound = jumpLandSound;
}
}