Esempio n. 1
0
    /// <summary>
    /// 获取满足出现条件队伍
    /// </summary>
    /// <param name="gameData"></param>
    /// <param name="listData"></param>
    /// <returns></returns>
    public List <NpcTeamBean> GetMeetConditionTeam(GameDataBean gameData, List <NpcTeamBean> listData)
    {
        List <NpcTeamBean> listMeet = new List <NpcTeamBean>();

        foreach (NpcTeamBean itemTeam in listData)
        {
            if (CheckUtil.StringIsNull(itemTeam.condition) || ShowConditionTools.CheckIsMeetAllCondition(gameData, itemTeam.condition))
            {
                listMeet.Add(itemTeam);
            }
        }
        return(listMeet);
    }
Esempio n. 2
0
    private NpcAIImportantCpt BuildNpc(CharacterBean characterData)
    {
        GameObject npcObj = null;

        try
        {
            if (objNpcModel == null || objNpcContainer == null)
            {
                return(null);
            }
            //检测是否已经招募
            GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData();
            if (gameData.CheckHasWorker(characterData.baseInfo.characterId))
            {
                return(null);
            }
            //检测是否是老婆
            FamilyDataBean familyData = gameData.GetFamilyData();
            if (familyData.CheckIsMate(characterData.npcInfoData.id))
            {
                return(null);
            }
            if (gameData.gameTime.year == 0 &&
                gameData.gameTime.month == 0 &&
                gameData.gameTime.day == 0)
            {
                //如果是测试 这默认生成所有NPC
            }
            else
            {
                //检测是否满足出现条件
                if (!CheckUtil.StringIsNull(characterData.npcInfoData.condition) && !ShowConditionTools.CheckIsMeetAllCondition(gameData, characterData.npcInfoData.condition))
                {
                    return(null);
                }
            }

            npcObj = Instantiate(objNpcContainer, objNpcModel);
            npcObj.transform.position   = new Vector3(characterData.npcInfoData.position_x, characterData.npcInfoData.position_y);
            npcObj.transform.localScale = new Vector3(1, 1);
            NpcAIImportantCpt aiCpt = npcObj.GetComponent <NpcAIImportantCpt>();
            aiCpt.SetCharacterData(characterData);

            if (characterData.npcInfoData.GetNpcType() == NpcTypeEnum.Special || characterData.npcInfoData.GetNpcType() == NpcTypeEnum.RecruitTown)
            {
                if (!GameCommonInfo.DailyLimitData.CheckIsTalkNpc(characterData.npcInfoData.id))
                {
                    if (characterData.npcInfoData.GetTalkTypes().Contains(NpcTalkTypeEnum.OneTalk) ||
                        characterData.npcInfoData.GetTalkTypes().Contains(NpcTalkTypeEnum.Recruit))
                    {
                        aiCpt.SetExpression(CharacterExpressionCpt.CharacterExpressionEnum.Doubt, -1);
                    }
                }
            }

            //如果没有对话选项则不能互动
            BoxCollider2D talkBox = npcObj.GetComponent <BoxCollider2D>();
            if (talkBox != null)
            {
                if (CheckUtil.StringIsNull(characterData.npcInfoData.talk_types))
                {
                    talkBox.enabled = false;
                }
            }
            return(aiCpt);
        }
        catch
        {
            if (npcObj != null)
            {
                Destroy(npcObj);
            }
            return(null);
        }
    }