/// <summary> /// 获取所有人员信息 /// </summary> /// <returns></returns> public List <CharacterBean> GetAllCharacterData() { List <CharacterBean> listData = new List <CharacterBean>(); //添加主角 if (userCharacter != null) { listData.Add(userCharacter); } //添加孩子 FamilyDataBean familyData = GetFamilyData(); List <CharacterForFamilyBean> listFamily = familyData.GetAllFamilyData(); for (int i = 0; i < listFamily.Count; i++) { CharacterForFamilyBean characterForFamily = listFamily[i]; if (characterForFamily.GetFamilyType() != FamilyTypeEnum.Mate && characterForFamily.CheckIsGrowUp(gameTime)) { listData.Add(characterForFamily); } } //添加工作者 if (listWorkerCharacter != null) { listData.AddRange(listWorkerCharacter); } return(listData); }
/// <summary> /// 设置角色形象 /// </summary> /// <param name="characterData"></param> public void SetCharacterUI(CharacterForFamilyBean characterData) { GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData(); if (characterData.GetFamilyType() != FamilyTypeEnum.Mate && !characterData.CheckIsGrowUp(gameData.gameTime)) { ui_CharacterChild.gameObject.SetActive(true); ui_CharacterUI.gameObject.SetActive(false); } else { ui_CharacterChild.gameObject.SetActive(false); ui_CharacterUI.gameObject.SetActive(true); } if (ui_CharacterUI) { ui_CharacterUI.SetCharacterData(characterData.body, characterData.equips); } }
/// <summary> /// 创建家族成员 /// </summary> /// <param name="characterForFamily"></param> public void CreateFamilyCharacter(CharacterForFamilyBean characterForFamily) { if (characterForFamily == null) { return; } FamilyTypeEnum familyType = characterForFamily.GetFamilyType(); GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData(); FamilyDataBean familyData = gameData.GetFamilyData(); if (familyType == FamilyTypeEnum.Daughter || familyType == FamilyTypeEnum.Son) { //如果是女儿或者儿子 需要3年后才能移动 if (!characterForFamily.CheckIsGrowUp(gameData.gameTime)) { return; } } else if (familyType == FamilyTypeEnum.Mate) { //如果是伴侣需要结婚日之后才刷新 if (!familyData.CheckMarry(gameData.gameTime)) { return; } } //获取门的坐标 并在门周围生成NPC Vector3 doorPosition = InnHandler.Instance.GetRandomEntrancePosition(); //向下3个单位 doorPosition += new Vector3(0, -3f, 0); GameObject objFamily = BuildNpc(listHideNpc, objNormalModel, characterForFamily, doorPosition); if (objFamily == null) { return; } NpcAIFamilyCpt npcAIFamily = objFamily.GetComponent <NpcAIFamilyCpt>(); listFamilyCharacter.Add(npcAIFamily); }