添加河南新乡万达广场室内场景
This commit is contained in:
@@ -51,7 +51,8 @@ public enum Place
|
||||
Zhejiang_Hangzhou_Linping_Yintaicheng = 32,
|
||||
Zhejiang_Hangzhou_Linping_Yintaicheng_Shinei = -32,
|
||||
Henan_Xinxiang_Wandaguangchang =33,
|
||||
Yangzhou_Hanjiang_TansuoZhongxin_Waidai=34,
|
||||
Henan_Xinxiang_Wandaguangchang_Shinei=-33,
|
||||
Yangzhou_Hanjiang_TansuoZhongxin_Waidai =34,
|
||||
}
|
||||
|
||||
public class GameLocal : MonoBehaviour
|
||||
@@ -162,6 +163,8 @@ public class GameLocal : MonoBehaviour
|
||||
authInfo.shop = 28;
|
||||
if (place == Place.Zhejiang_Hangzhou_Linping_Yintaicheng_Shinei)
|
||||
authInfo.shop = 32;
|
||||
if (place == Place.Henan_Xinxiang_Wandaguangchang_Shinei)
|
||||
authInfo.shop = 33;
|
||||
#endif
|
||||
authInfo.gameId = 8;
|
||||
string authJson = JsonUtility.ToJson(authInfo);
|
||||
|
||||
@@ -178,7 +178,82 @@ public class GameManager : NetworkBehaviour
|
||||
|
||||
public int roundWaveTime;
|
||||
public int curRoundWaveTime;
|
||||
|
||||
public GameObject player;
|
||||
|
||||
//添加
|
||||
[Header("AI角色")]
|
||||
public GameObject aiCharacterPre;//AI角色预制体
|
||||
private GameObject aiCharacter;//AI角色实例
|
||||
private bool isAIIntroductionComplete = false;
|
||||
|
||||
public void GamePlay()
|
||||
{
|
||||
|
||||
CreateAICharacter();
|
||||
|
||||
|
||||
}
|
||||
|
||||
//修改处:添加AI介绍完成后的游戏开始方法
|
||||
public void StartGameAfterIntroduction()
|
||||
{
|
||||
isAIIntroductionComplete = true;
|
||||
GameStart();
|
||||
|
||||
|
||||
}
|
||||
|
||||
//修改处:添加创建AI角色的方法
|
||||
private void CreateAICharacter()
|
||||
{
|
||||
//检查是否已经存在AI角色
|
||||
if (aiCharacter != null)
|
||||
{
|
||||
Debug.Log("AI角色已经存在,不再创建新的");
|
||||
return;
|
||||
}
|
||||
|
||||
if (aiCharacterPre != null)
|
||||
{
|
||||
Debug.Log("创建AI角色");
|
||||
//获取第一个玩家
|
||||
Transform player = players[0].transform;
|
||||
if (player == null)
|
||||
{
|
||||
Debug.LogError("找不到玩家,无法创建AI角色");
|
||||
return;
|
||||
}
|
||||
//在玩家前方创建AI角色
|
||||
Vector3 spawnPosition = player.transform.position + player.transform.forward * 3f;
|
||||
spawnPosition.y = 0f; // 固定Y坐标为0
|
||||
aiCharacter = Instantiate(aiCharacterPre, spawnPosition, Quaternion.identity);
|
||||
|
||||
//获取AIController并启动开场白
|
||||
AIController aiController = aiCharacter.GetComponent<AIController>();
|
||||
if (aiController != null)
|
||||
{
|
||||
//注册AI介绍完成回调
|
||||
aiController.OnIntroductionComplete += StartGameAfterIntroduction;
|
||||
|
||||
//添加延迟,确保所有组件已经完成初始化
|
||||
StartCoroutine(DelayedStartIntroduction(aiController));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("AI预制体中的AIController组件丢失");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("AI预制体没有在GameManager分配!");
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator DelayedStartIntroduction(AIController aiController)
|
||||
{
|
||||
yield return new WaitForSeconds(0.1f); // 短暂延迟
|
||||
aiController.StartIntroduction();
|
||||
}
|
||||
void Awake()
|
||||
{
|
||||
Ins = this;
|
||||
@@ -1226,7 +1301,7 @@ public class GameManager : NetworkBehaviour
|
||||
[ClientRpc]
|
||||
public void PlaySound3DRPC(string sound,Transform tran,bool isStop)
|
||||
{
|
||||
if(isStop)
|
||||
if (isStop)
|
||||
MasterAudio.StopAllSoundsOfTransform(tran);
|
||||
MasterAudio.PlaySound3DAtTransform(sound, tran);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user