public void CreateShip(CharacterTypeEnum characterType, long shipId, Action callBack) { CptUtil.RemoveChild(transform); GameLevelBean gameLevelData = handler_Game.GetGameLevelData(); GameBean gameData = handler_Game.GetGameData(); switch (characterType) { case CharacterTypeEnum.Player: manager.GetShipDataById((shipData) => { shipData.ship_damage = gameData.playerForDamage; shipData.characterType = CharacterTypeEnum.Player; shipData.intervalForFire = handler_GameData.GetFireCD(); StartCoroutine(CoroutineForCreateShip(shipData, callBack)); }, shipId); break; case CharacterTypeEnum.Enemy: manager.GetShipDataById((shipData) => { shipData.intervalForFire = gameLevelData.enemy_fire_interval; shipData.characterType = CharacterTypeEnum.Enemy; shipData.limitForFireNumber = gameLevelData.enemy_fire_limit_number; StartCoroutine(CoroutineForCreateShip(shipData, callBack)); }, shipId); break; } }
/// <summary> /// 清理灶台 /// </summary> public void ClearStove() { if (gameObject && objFoodContainer) { CptUtil.RemoveChild(objFoodContainer.transform); } SetStoveStatus(StoveStatusEnum.Idle); }
/// <summary> /// 改变衣服 /// </summary> /// <param name="clothesId"></param> public void ChangeClothes(long clothesId, Action <GameObject> callBack = null) { this.characterData.clothesId = clothesId; CptUtil.RemoveChild(objClothesContainer.transform); if (clothesId == 0) { //没有衣服 return; } ItemsInfoBean itemsInfo = ItemsHandler.Instance.manager.GetItemsInfoById(clothesId); if (itemsInfo == null) { LogUtil.LogError($"查询道具数据失败,没有ID为 {clothesId} 的服装数据"); } else { ItemsHandler.Instance.manager.GetItemsObjById(clothesId, (itemsObj) => { if (itemsObj == null) { LogUtil.LogError($"查询道具模型失败,没有ID为 {clothesId} 的道具模型"); } else { GameObject objModel = ItemsHandler.Instance.Instantiate(objClothesContainer, itemsObj); objModel.transform.localPosition = Vector3.zero; objModel.transform.localEulerAngles = Vector3.zero; ItemsHandler.Instance.manager.GetItemsTexById(itemsInfo.id, (itemTex) => { if (objModel == null) { return; } MeshRenderer meshRebderer = objModel.GetComponent <MeshRenderer>(); meshRebderer.material.mainTexture = itemTex; }); callBack?.Invoke(objModel); } }); } }
/// <summary> /// 改变发型 /// </summary> /// <param name="hairId"></param> public void ChangeHair(long hairId) { this.characterData.hairId = hairId; CptUtil.RemoveChild(objHairContainer.transform); if (hairId == 0) { //没有头发 return; } CharacterInfoBean characterInfo = CreatureHandler.Instance.manager.GetCharacterInfoHair(hairId); if (characterInfo == null) { LogUtil.LogError($"查询发型数据失败,没有ID为 {hairId} 的发型数据"); } else { CreatureHandler.Instance.manager.GetCharacterHairModel(characterInfo.model_name, (data) => { if (data == null) { LogUtil.LogError($"查询发型失败,没有名字为 {characterInfo.model_name} 的发型模型"); } else { GameObject objHair = CreatureHandler.Instance.Instantiate(objHairContainer, data); objHair.transform.localPosition = Vector3.zero; //objHair.transform.localEulerAngles = Vector3.zero; MeshRenderer hairMeshRebderer = objHair.GetComponent <MeshRenderer>(); hairMeshRebderer.material = hairMatModel; hairMat = hairMeshRebderer.material; } }); } }
public IEnumerator InitCharacterData() { CptUtil.RemoveChild(transform); //加载模型 yield return(CoroutineForLoadCharacterModel("Pirate_2", "Pirate_1")); }
/// <summary> /// 清理所有玩家 /// </summary> public void DestoryPlayer() { CptUtil.RemoveChild(objPlayerContainer.transform); listGamePlayer.Clear(); }
public void DestoryBullet() { CptUtil.RemoveChild(objBulletContainer.transform); }
/// <summary> /// 清理所有的发射器 /// </summary> public void DestoryEjector() { CptUtil.RemoveChild(objEjectorContainer.transform); listEjector.Clear(); }
/// <summary> /// 清空所有工作者 /// </summary> public void ClearAllWork() { listNpcWorker.Clear(); CptUtil.RemoveChild(objContainer); }