86 lines
1.8 KiB
C#
86 lines
1.8 KiB
C#
using System;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
using Animancer;
|
|
using DarkTonic.MasterAudio;
|
|
|
|
public class PlayerAIAnimator : MonoBehaviour
|
|
{
|
|
public Enemy enemy;
|
|
|
|
private void Start()
|
|
{
|
|
enemy = GetComponentInParent<Enemy>();
|
|
}
|
|
|
|
[Header("出生音效")]
|
|
[SoundGroup]
|
|
public string bothSound;
|
|
[Header("死亡音效")]
|
|
[SoundGroup]
|
|
public string dieSound;
|
|
|
|
[Header("移动音效")]
|
|
[SoundGroup]
|
|
public string moveSound;
|
|
|
|
|
|
[Header("攻击音效")]
|
|
[SoundGroup]
|
|
public string attackSound;
|
|
|
|
[Header("受击音效")]
|
|
[SoundGroup]
|
|
public string hitSound;
|
|
|
|
public void PlaySound(int id)
|
|
{
|
|
string curSound = "";
|
|
switch (id)
|
|
{
|
|
case 0:
|
|
curSound = bothSound;
|
|
break;
|
|
case 1:
|
|
curSound = moveSound;
|
|
break;
|
|
case 2:
|
|
curSound = attackSound;
|
|
break;
|
|
case 3:
|
|
curSound = dieSound;
|
|
break;
|
|
case 4:
|
|
curSound = hitSound;
|
|
break;
|
|
}
|
|
PlaySound3DRPC(curSound,transform,true);
|
|
}
|
|
|
|
public void PlaySound3DRPC(string sound,Transform tran,bool isStop)
|
|
{
|
|
if(isStop)
|
|
MasterAudio.StopAllSoundsOfTransform(tran);
|
|
MasterAudio.PlaySound3DAtTransform(sound, tran);
|
|
}
|
|
|
|
public void StopAttack()
|
|
{
|
|
enemy.StopAttack();
|
|
}
|
|
|
|
public void SelfDie()
|
|
{
|
|
if (enemy.type == EnemyType.ExplosionDog)
|
|
{
|
|
GameManager.Ins.CreateExplosion(transform);
|
|
}
|
|
}
|
|
|
|
public void Die()
|
|
{
|
|
if(enemy.isServer)
|
|
GameManager.Ins.DeleteEnemy(enemy.id,transform);
|
|
}
|
|
}
|