public void BuildTownFriendsForTeam(NpcTeamBean teamData, Vector3 npcPosition) { if (teamData == null) { return; } if (listExistTeamId.Contains(teamData.id)) { return; } //设置小队相关 string teamCode = SystemUtil.GetUUID(SystemUtil.UUIDTypeEnum.N); Color teamColor = new Color(UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f)); //获取小队成员数据 teamData.GetTeamCharacterData(out List <CharacterBean> listLeader, out List <CharacterBean> listMembers); GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData(); //设置小队人数(团队领袖全生成,小队成员随机生成) int npcNumber = listLeader.Count + listMembers.Count; for (int i = 0; i < npcNumber; i++) { CharacterBean characterData = null; if (i < listLeader.Count) { characterData = listLeader[i]; } else { characterData = listMembers[i - listLeader.Count]; } //获取好感 CharacterFavorabilityBean characterFavorability = gameData.GetCharacterFavorability(characterData.npcInfoData.id); GameObject npcObj = Instantiate(objContainer, objFriendModel); npcObj.transform.localScale = new Vector3(1, 1); npcObj.transform.position = npcPosition + new Vector3(UnityEngine.Random.Range(-0.5f, 0.5f), UnityEngine.Random.Range(-0.5f, 0.5f)); BaseNpcAI baseNpcAI = npcObj.GetComponent <BaseNpcAI>(); baseNpcAI.SetCharacterData(characterData); baseNpcAI.AddStatusIconForFriend(); baseNpcAI.AddStatusIconForGuestTeam(teamColor); baseNpcAI.SetFavorabilityData(characterFavorability); NpcAICostomerForFriendCpt customerAI = baseNpcAI.GetComponent <NpcAICostomerForFriendCpt>(); customerAI.SetTeamData(teamCode, teamData, i, teamColor); customerAI.SetIntent(NpcAICustomerCpt.CustomerIntentEnum.Want); } listExistTeamId.Add(teamData.id); }
public void BuildTownFriendsForOne(CharacterBean characterData, CharacterFavorabilityBean characterFavorability, Vector3 npcPosition) { //生成NPC GameObject npcObj = BuildNpc(listFriendHide, objFriendModel, characterData, npcPosition); BaseNpcAI baseNpcAI = npcObj.GetComponent <BaseNpcAI>(); baseNpcAI.SetCharacterData(characterData); baseNpcAI.SetFavorabilityData(characterFavorability); baseNpcAI.AddStatusIconForFriend(); NpcAICostomerForFriendCpt customerAI = baseNpcAI.GetComponent <NpcAICostomerForFriendCpt>(); customerAI.SetIntent(NpcAICustomerCpt.CustomerIntentEnum.Want); listExistNpcId.Add(characterData.npcInfoData.id); }