stuff
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user