コード例 #1
0
ファイル: NpcEventBuilder.cs プロジェクト: wobushiren79/IL
    public void BuildConvert(NpcTeamBean npcTeam, Vector3 npcPosition)
    {
        if (npcTeam == null || listExistTeamId.Contains(npcTeam.id))
        {
            return;
        }
        //获取小队成员数据
        npcTeam.GetTeamCharacterData(out List <CharacterBean> listLeader, out List <CharacterBean> listMembers);
        //设置小队相关
        string teamCode  = SystemUtil.GetUUID(SystemUtil.UUIDTypeEnum.N);
        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];
            }
            //生成NPC
            GameObject npcObj = BuildNpc(listConvertHide, objConvertModel, characterData, npcPosition + new Vector3(UnityEngine.Random.Range(-0.5f, 0.5f), UnityEngine.Random.Range(-0.5f, 0.5f)));
            //设置意图
            NpcAIConvertCpt           convertCpt            = npcObj.GetComponent <NpcAIConvertCpt>();
            GameDataBean              gameData              = GameDataHandler.Instance.manager.GetGameData();
            CharacterFavorabilityBean characterFavorability = gameData.GetCharacterFavorability(long.Parse(characterData.baseInfo.characterId));
            convertCpt.SetTeamData(teamCode, npcTeam, i);
            convertCpt.SetIntent(NpcAISundryCpt.SundryIntentEnum.GoToInn);
        }
        listExistTeamId.Add(npcTeam.id);
    }
コード例 #2
0
    public void BuildGuestTeam(NpcTeamBean npcTeam, Vector3 npcPosition)
    {
        if (npcTeam == null)
        {
            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));
        //设置是否想吃
        bool isWant = IsWantEat(CustomerTypeEnum.Team);

        //获取小队成员数据
        npcTeam.GetTeamCharacterData(out List <CharacterBean> listLeader, out List <CharacterBean> listMembers);
        //设置小队人数(团队领袖全生成,小队成员随机生成)
        int npcNumber = UnityEngine.Random.Range(listLeader.Count + 1, listLeader.Count + 1 + npcTeam.team_number);

        for (int i = 0; i < npcNumber; i++)
        {
            CharacterBean characterData = null;
            if (i < listLeader.Count)
            {
                characterData = listLeader[i];
            }
            else
            {
                characterData = RandomUtil.GetRandomDataByList(listMembers);
            }
            //如果发现成员数据为空 默认取领导的
            if (characterData == null)
            {
                characterData = listLeader[0];
            }
            //随机生成身体数据
            characterData.body.CreateRandomEye();


            GameObject npcObj    = BuildNpc(listGuestTeamHide, objGuestTeamModel, characterData, 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.AddStatusIconForGuestTeam(teamColor);
            NpcAICustomerForGuestTeamCpt customerAI = baseNpcAI.GetComponent <NpcAICustomerForGuestTeamCpt>();
            customerAI.SetTeamData(teamCode, npcTeam, i, teamColor);
            if (GameTimeHandler.Instance.GetDayStatus() == GameTimeHandler.DayEnum.Work && isWant)
            {
                customerAI.SetIntent(NpcAICustomerCpt.CustomerIntentEnum.Want);
            }
            else
            {
                customerAI.SetIntent(NpcAICustomerCpt.CustomerIntentEnum.Walk);
            }
        }
    }
コード例 #3
0
ファイル: NpcEventBuilder.cs プロジェクト: wobushiren79/IL
    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);
    }
コード例 #4
0
ファイル: NpcEventBuilder.cs プロジェクト: wobushiren79/IL
    public void BuildRascal(NpcTeamBean npcTeam, Vector3 npcPosition)
    {
        if (npcTeam == null)
        {
            return;
        }
        //if (listExistTeamId.Contains(npcTeam.id))
        //改成了每日一次
        if (listExistTeamId.Count > 0)
        {
            return;
        }
        //获取小队成员数据
        npcTeam.GetTeamCharacterData(out List <CharacterBean> listLeader, out List <CharacterBean> listMembers);
        //设置小队相关
        string teamCode  = SystemUtil.GetUUID(SystemUtil.UUIDTypeEnum.N);
        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];
            }
            //生成NPC
            GameObject npcObj = BuildNpc(listRascalHide, objRascalModel, characterData, npcPosition + new Vector3(UnityEngine.Random.Range(-0.5f, 0.5f), UnityEngine.Random.Range(-0.5f, 0.5f)));
            //设置意图
            NpcAIRascalCpt            rascalCpt             = npcObj.GetComponent <NpcAIRascalCpt>();
            GameDataBean              gameData              = GameDataHandler.Instance.manager.GetGameData();
            CharacterFavorabilityBean characterFavorability = gameData.GetCharacterFavorability(long.Parse(characterData.baseInfo.characterId));
            rascalCpt.SetTeamData(teamCode, npcTeam, i);
            rascalCpt.SetFavorabilityData(characterFavorability);
            rascalCpt.AddStatusIconForRascal();
            rascalCpt.SetIntent(NpcAIRascalCpt.RascalIntentEnum.GoToInn);

            //设置捣乱者血量
            characterData.GetAttributes(out CharacterAttributesBean characterAttributes);
            rascalCpt.characterMaxLife = characterAttributes.life;
            rascalCpt.characterLife    = characterAttributes.life;
        }
        listExistTeamId.Add(npcTeam.id);
    }