/// <summary> /// 获得玩家的心法ID list /// </summary> /// <returns></returns> List <uint> GetHeartSkillIdList() { //int lvLimit = GameTableManager.Instance.GetClientGlobalConst<int>("HeartSkill", "HeartSkillUnlockLv"); int lvLimit = GameTableManager.Instance.GetGlobalConfig <int>("GodOpenLevel"); //100级开放心法 Client.IPlayer mainPlayer = Client.ClientGlobal.Instance().MainPlayer; int playerLv = mainPlayer.GetProp((int)Client.CreatureProp.Level); int playerJob = mainPlayer.GetProp((int)Client.PlayerProp.Job); List <HeartSkillDataBase> heartSkillList = GameTableManager.Instance.GetTableList <HeartSkillDataBase>(); heartSkillList = heartSkillList.FindAll((d) => { return(d.profession == playerJob); });//职业 heartSkillList.Sort((x, y) => x.orderId.CompareTo(y.orderId)); //heartSkillList = new List<HeartSkillDataBase>(orderList); List <uint> idList = new List <uint>(); if (playerLv >= lvLimit) { for (int i = 0; i < heartSkillList.Count; i++) { if (idList.Contains(heartSkillList[i].id) == false) { idList.Add(heartSkillList[i].id); //Engine.Utility.Log.LogGroup(GameDefine.LogGroup.User_LCY, "--->>> 顺序为: {0}", heartSkillList[i].orderId); } } } return(idList); }
/// <summary> /// 使用瞬药 /// </summary> public void UseAtOnceMedicine() { bool canRunning = Engine.Utility.EventEngine.Instance().DispatchVote((int)GameVoteEventID.AUTORECOVER, null); if (!canRunning) { Engine.Utility.Log.LogGroup("ZCX", "canRunning false"); return; } //是否可以使用瞬药 bool canUseAtOnce = Engine.Utility.EventEngine.Instance().DispatchVote((int)GameVoteEventID.AUTOAtOnceRECOVER, null); if (!canUseAtOnce) { Engine.Utility.Log.LogGroup("ZCX", "canUseAtOnce false"); return; } Client.IPlayer mainPlayer = Client.ClientGlobal.Instance().MainPlayer; if (mainPlayer == null || mainPlayer.IsDead()) { Engine.Utility.Log.LogGroup("ZCX", "player dead"); return; } Dictionary <AutoRecoverGrid.MedicalType, UseMedicalInfo> .Enumerator iter = m_dicMedical.GetEnumerator(); while (iter.MoveNext()) { UseMedicalInfo medical = iter.Current.Value; if (medical != null && medical.select) { AutoRecoverGrid.MedicalType mtype = medical.Type; float rate = 1f; if (AutoRecoverGrid.MedicalType.HpAtOnce == mtype) {//瞬药 单独处理 rate = mainPlayer.GetProp((int)CreatureProp.Hp) * 1f / mainPlayer.GetProp((int)CreatureProp.MaxHp); if (rate < medical.triggerValue) { uint itemid = medical.itemid; if (itemid != 0 && CanUse(itemid)) { List <BaseItem> itemdataList = DataManager.Manager <ItemManager>().GetItemByBaseId(itemid); if (itemdataList.Count > 0) { DataManager.Instance.Sender.UseItem( mainPlayer.GetID(), (uint)GameCmd.SceneEntryType.SceneEntry_Player, itemdataList[0].QWThisID, 1); } } } } } } }
//------------------------------------------------------------------------------------------------------- /** * @brief 添加玩家(木偶) * @param strName 名称 * @param nJob 职业 * @param nSex 性别 * @param propList 外观属性 * @param bMainHost 是否是主角对象 */ public IPuppet AddPuppet(string strName, int nJob, int nSex, EntityViewProp[] propList, bool bMainHost = false) { EntityCreateData data = new EntityCreateData(); data.ID = ++m_uEntityID; data.strName = strName; int speed = 0; Client.IPlayer player = ClientGlobal.Instance().MainPlayer; if (player != null) { speed = player.GetProp((int)WorldObjProp.MoveSpeed); } data.PropList = new EntityAttr[(int)PuppetProp.End - (int)EntityProp.Begin]; int index = 0; data.PropList[index++] = new EntityAttr((int)PuppetProp.Job, nJob); data.PropList[index++] = new EntityAttr((int)PuppetProp.Sex, nSex); data.PropList[index++] = new EntityAttr((int)EntityProp.BaseID, 0); data.PropList[index++] = new EntityAttr((int)WorldObjProp.MoveSpeed, speed); data.ViewList = propList; IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { Engine.Utility.Log.Error("严重错误:EntitySystem is null!"); return(null); } IPuppet entity = es.CreateEntity(EntityType.EntityType_Puppet, data) as IPuppet; if (entity == null) { Engine.Utility.Log.Error("AddEntity:创建家园对象失败!"); return(null); } if (bMainHost) { IControllerSystem cs = ClientGlobal.Instance().GetControllerSystem(); if (cs == null) { return(null); } cs.GetActiveCtrl().SetHost(entity); CameraFollow.Instance.target = entity; } m_dicPuppet.Add((int)entity.GetID(), entity); return(entity); }
//------------------------------------------------------------------------------------------------------- public bool Create(Client.IPlayer player, int nSize, GameObject parentObj, Client.SkillSettingState eState = Client.SkillSettingState.StateOne) { if (player == null) { return(false); } Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem(); if (rs == null) { Engine.Utility.Log.Error("获取RenderSystem失败!"); return(false); } // 对象创建 if (m_Root == null) { m_Root = new GameObject("RTObj"); if (parentObj != null) { m_Root.transform.parent = parentObj.transform; } } // m_RenderObj = null; Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem(); if (es == null) { return(false); } List <GameCmd.SuitData> lstSuit = null; player.GetSuit(out lstSuit); return(Create(lstSuit, player.GetProp((int)PlayerProp.Job), player.GetProp((int)PlayerProp.Sex), nSize, parentObj, eState)); }
public bool IsRecommend(uint lvMin, uint lvMax) { Client.IPlayer mainPlayer = Client.ClientGlobal.Instance().MainPlayer; if (mainPlayer != null) { uint lv = (uint)mainPlayer.GetProp((int)CreatureProp.Level); if (lv >= lvMin && lv <= lvMax) { return(true); } } return(false); }
/// <summary> /// 根据玩家等级判断是否开放心法 /// </summary> /// <returns></returns> public bool IsHeartSkillOpen() { int lvLimit = GameTableManager.Instance.GetGlobalConfig <int>("GodOpenLevel"); Client.IPlayer mainPlayer = Client.ClientGlobal.Instance().MainPlayer; int playerLv = mainPlayer.GetProp((int)Client.CreatureProp.Level); if (playerLv >= lvLimit) { return(true); } else { return(false); } }
/// <summary> /// 点心法按钮 /// </summary> void OnClickHeartSkillBtn() { int lvLimit = GameTableManager.Instance.GetGlobalConfig <int>("GodOpenLevel"); Client.IPlayer mainPlayer = Client.ClientGlobal.Instance().MainPlayer; int playerLv = mainPlayer.GetProp((int)Client.CreatureProp.Level); if (playerLv >= lvLimit) { m_trans_LearnSkillContent.gameObject.SetActive(false); m_trans_HeartSkillContent.gameObject.SetActive(true); InitHeartSkillUI(); //初始化心法界面 } else { string des = string.Format("需要玩家等级达到{0}级才开放心法", lvLimit); TipsManager.Instance.ShowTips(des); } }
private IEntity GetNearestMonster() { Client.IPlayer mainplayer = ControllerSystem.m_ClientGlobal.MainPlayer; if (mainplayer == null) { return(null); } IEntitySystem es = ControllerSystem.m_ClientGlobal.GetEntitySystem(); if (es == null) { return(null); } IMapSystem ms = ControllerSystem.m_ClientGlobal.GetMapSystem(); if (ms == null) { return(null); } IEntity monster = null; if (m_nTargetID != 0) { monster = es.FindNPCByBaseId(m_nTargetID, true); } else { PLAYERPKMODEL pkmodel = (PLAYERPKMODEL)mainplayer.GetProp((int)PlayerProp.PkMode); MapAreaType atype = ms.GetAreaTypeByPos(mainplayer.GetPos()); IControllerHelper ch = GetControllerHelper(); if (ch != null) { uint attackPriority = ch.GetAttackPriority(); monster = es.FindEntityByArea_PkModel(atype, pkmodel, m_centerPos, m_nSearchRang, attackPriority); } } return(monster); }
private void UseMedicine() { bool canRunning = Engine.Utility.EventEngine.Instance().DispatchVote((int)GameVoteEventID.AUTORECOVER, null); if (!canRunning) { Engine.Utility.Log.LogGroup("ZCX", "canRunning false"); return; } Client.IPlayer mainPlayer = Client.ClientGlobal.Instance().MainPlayer; if (mainPlayer == null || mainPlayer.IsDead()) { Engine.Utility.Log.LogGroup("ZCX", "player dead"); return; } Dictionary <AutoRecoverGrid.MedicalType, UseMedicalInfo> .Enumerator iter = m_dicMedical.GetEnumerator(); while (iter.MoveNext()) { UseMedicalInfo medical = iter.Current.Value; if (medical != null && medical.select) { AutoRecoverGrid.MedicalType mtype = medical.Type; float rate = 1f; if (AutoRecoverGrid.MedicalType.HpAtOnce == mtype) {//瞬药 单独处理 continue; } if (AutoRecoverGrid.MedicalType.Hp == mtype || (AutoRecoverGrid.MedicalType.HpAtOnce == mtype)) { rate = mainPlayer.GetProp((int)CreatureProp.Hp) * 1f / mainPlayer.GetProp((int)CreatureProp.MaxHp); } else if (AutoRecoverGrid.MedicalType.Mp == mtype) { rate = mainPlayer.GetProp((int)CreatureProp.Mp) * 1f / mainPlayer.GetProp((int)CreatureProp.MaxMp); // string log = string.Format("rate = {0} trigger = {1} mp = {2} max= {3}", rate, medical.triggerValue, mainPlayer.GetProp((int)CreatureProp.Mp), mainPlayer.GetProp((int)CreatureProp.MaxMp)); //UnityEngine.Debug.LogError(log); } else if (AutoRecoverGrid.MedicalType.PetHp == mtype) { if (DataManager.Manager <PetDataManager>().CurFightingPet == 0) { continue; } Client.INPC pet = DataManager.Manager <PetDataManager>().GetNpcByPetID(DataManager.Manager <PetDataManager>().CurFightingPet); if (pet != null) { int a = pet.GetProp((int)CreatureProp.Hp); rate = pet.GetProp((int)CreatureProp.Hp) * 1f / pet.GetProp((int)CreatureProp.MaxHp); } } if (rate < medical.triggerValue) { uint itemid = medical.itemid; if (AutoRecoverGrid.MedicalType.Hp == mtype) { if (UnityEngine.Time.realtimeSinceStartup - m_nhpsendTime < 5f) { continue; } itemid = GetUseItemId(mtype); } else if (AutoRecoverGrid.MedicalType.Mp == mtype) { if (UnityEngine.Time.realtimeSinceStartup - m_nmpsendTime < 5f) { continue; } itemid = GetUseItemId(mtype); } if (itemid != 0 && CanUse(itemid)) { List <BaseItem> itemdataList = DataManager.Manager <ItemManager>().GetItemByBaseId(itemid); if (itemdataList.Count > 0) { if (AutoRecoverGrid.MedicalType.PetHp == mtype) { uint petID = DataManager.Manager <PetDataManager>().GetNpcIDByPetID(DataManager.Manager <PetDataManager>().CurFightingPet); DataManager.Instance.Sender.UseItem( petID, (uint)GameCmd.SceneEntryType.SceneEntry_NPC, itemdataList[0].QWThisID, 1); } else { DataManager.Instance.Sender.UseItem( mainPlayer.GetID(), (uint)GameCmd.SceneEntryType.SceneEntry_Player, itemdataList[0].QWThisID, 1); if (AutoRecoverGrid.MedicalType.Hp == mtype) { m_nhpsendTime = UnityEngine.Time.realtimeSinceStartup; } else if (AutoRecoverGrid.MedicalType.Mp == mtype) { m_nmpsendTime = UnityEngine.Time.realtimeSinceStartup; } } // if (UnityEngine.Application.isEditor) // { // UnityEngine.Debug.Log(string.Format("使用物品 {0}" , itemid)); // } } } } } } }
/// <summary> /// 设置切换技能 /// </summary> void SetChangeStateSkill() { Client.IPlayer player = ClientGlobal.Instance().MainPlayer; int level = player.GetProp((int)CreatureProp.Level); int job = player.GetProp((int)PlayerProp.Job); string secondKey = job.ToString(); SkillSettingState curState = DataManager.Manager <LearnSkillDataManager>().CurState; if (curState == SkillSettingState.StateTwo) { secondKey = (10 + job).ToString(); } m_skillid = GameTableManager.Instance.GetGlobalConfig <uint>("ChangeStateSkillID", secondKey); int needLevel = GameTableManager.Instance.GetGlobalConfig <int>("ChangeStateLevel"); if (level < needLevel) { ResetBtn(); //skillIcon.spriteName = "icon_lock"; skillIcon.mainTexture = null; if (skillName != null) { skillName.text = needLevel.ToString(); } SetBtnEnable(false); SetLongPressEvent(false); return; } else { if (skillBtn != null) { ResetBtn(); } table.SkillDatabase db = GameTableManager.Instance.GetTableItem <table.SkillDatabase>((uint)m_skillid, 1); if (db != null) { UIManager.GetTextureAsyn(DataManager.Manager <UIManager>().GetResIDByFileName(false, db.iconPath, true), ref iuiIconAtlas, () => { if (null != skillIcon) { skillIcon.mainTexture = null; } }, skillIcon, false); } } if (skillIcon != null) { skillIcon.width = overlay.width; skillIcon.height = overlay.height; skillIcon.alpha = 1f; } if (skillBtn != null) { SetLongPressEvent(true); SetBtnEnable(true); } RunCD(); }