/// <summary> /// 通过id获取某一关信息 /// </summary> /// <param name="_id"></param> /// <returns></returns> public LevelData GetLevel(int _id) { LevelData leve = null; for (int i = 0; i < Level.Count; i++) { if (leve != null) { break; } for (int idx = 0; idx < Level[i].Count; idx++) { for (int idx1 = 0; idx1 < Level[i][idx].Count; idx1++) { if (Level[i][idx][idx1].id == _id) { leve = Level[i][idx][idx1]; break; } } } } if (leve == null) { EDebug.LogErrorFormat("Can't find _id:{0} in JsonMgr.GetLevel", _id); return(null); } return(leve); }
/////// <summary> /////// 通过id获取物品道具 /////// </summary> /////// <param name="itemId"></param> /////// <returns></returns> //public ItemData GetItemProp(int itemid) //{ // if (!_itemDic.ContainsKey(itemid)) // { // EDebug.LogErrorFormat("Can't find itemid:{0} in JsonMgr.GetItemPropId", itemid); // return null; // } // return _itemDic[itemid]; //} ///// <summary> ///// 通过类型获取物品道具 ///// </summary> ///// <param name="itemId"></param> ///// <param name="curType"></param> ///// <returns></returns> //public List<ItemData> GetItemPropType(int curType) //{ // if (_itemDic.Count != 0) // { // EDebug.LogErrorFormat("Can't find itemid:{0} in JsonMgr.GetItemPropType", curType); // return null; // } // List<ItemData> data = new List<ItemData>(); // foreach (var item in _itemDic) // { // if (item.Value.ItemType == curType) // { // data.Add(item.Value); // } // } // if (data.Count == 0) // { // EDebug.LogErrorFormat("JsonMgr.GetItemPropType failed, itemId:{0} curType:{1}", curType); // return null; // } // return data; //} ///// <summary> ///// 通过id获取道具类型 ///// </summary> ///// <param name="itemid"></param> ///// <returns></returns> //public int GetPropType(int itemid) //{ // if (!_itemDic.ContainsKey(itemid)) // { // EDebug.LogErrorFormat("Can't find itemid:{0} in JsonMgr.GetItemPropId", itemid); // return 0; // } // return _itemDic[itemid].ItemType; //} /// <summary> /// 通过ID获取谋一章节信息 /// </summary> /// <param name="_id"></param> /// <returns></returns> public BattleData GetChapter(int _id) { BattleData chapterData = null; for (int i = 0; i < Chapter.Count; i++) { if (chapterData != null) { break; } for (int idx = 0; idx < Chapter[i].Count; idx++) { if (Chapter[i][idx].ChapterId == _id) { chapterData = Chapter[i][idx]; break; } } } if (chapterData == null) { EDebug.LogErrorFormat("Can't find _id:{0} in JsonMgr.GetChapter", _id); return(null); } return(chapterData); }
private void _stubChange(int stubPos1, int stubPos2) { if (StubData.ContainsKey(stubPos1)) { if (!StubData.ContainsKey(stubPos2)) { StubData[stubPos2] = StubData[stubPos1]; StubData.Remove(stubPos1); _setStubHero(stubPos1); _setStubHero(stubPos2, true, StubData[stubPos2]); } else { int tmpHero = StubData[stubPos2]; StubData[stubPos2] = StubData[stubPos1]; StubData[stubPos1] = tmpHero; _setStubHero(stubPos1, true, StubData[stubPos1]); _setStubHero(stubPos2, true, StubData[stubPos2]); } } else { EDebug.LogErrorFormat("StubView._stubChange error, stubPos1 not contains, {0} {1}", stubPos1, stubPos2); } }
private void _analyzeSkillRes(int skillId, ref HashSet <int> sound, ref HashSet <int> gos) { Skill jSkill = JsonMgr.GetSingleton().GetSkillByID(skillId); if (jSkill == null) { EDebug.LogErrorFormat("PreloadMgr._analyzeSkillRes failed, no such skill:{0}", skillId); return; } //技能特效 int startEffect = jSkill.starteffect; int fulleffect = jSkill.fulleffect; int attackeffect = jSkill.attackeffect; if (startEffect != 0) { gos.Add(startEffect); } if (fulleffect != 0) { gos.Add(fulleffect); } if (attackeffect != 0) { gos.Add(attackeffect); } //分析技能效果 int[] skillEffects = jSkill.effects; for (int idx = 0; idx < skillEffects.Length; ++idx) { int effectId = skillEffects[idx]; _analyzeEffect(effectId, ref sound, ref gos); } }
/// <summary> /// 字符串转换为具体属性值,返回结果x表示属性类型(0无类型1武力2策略),y表示属性值 /// </summary> /// <param name="str"></param> /// <param name="user"></param> /// <param name="target"></param> /// <returns></returns> private static Vector2 expression2Attr(string str, FightUnit user, FightUnit target) { switch (str) { case "u_atk": return(new Vector2(1, user.Atk)); case "t_atk": return(new Vector2(1, target.Atk)); case "u_matk": return(new Vector2(2, user.Matk)); case "t_matk": return(new Vector2(2, target.Matk)); case "u_hp": return(new Vector2(0, user.MaxHP)); case "t_hp": return(new Vector2(0, target.MaxHP)); case "u_chp": return(new Vector2(0, user.CurHP)); case "t_chp": return(new Vector2(0, target.CurHP)); default: { EDebug.LogErrorFormat("expression2Attr failed, {0} is invalid", str); return(Vector2.zero); } } }
private JObject getSingleData(string fileName, int id, bool showLog = true, params string[] extraFiles) { Dictionary <int, JObject> buffer = getWholeData(fileName); bool find = (buffer != null && buffer.ContainsKey(id)); if (!find) { for (int idx = 0; idx < extraFiles.Length; ++idx) { buffer = getWholeData(extraFiles[idx]); find = (buffer != null && buffer.ContainsKey(id)); if (find) { break; } } } if (!find) { if (showLog) { EDebug.LogErrorFormat("Can't find {0} json, id:{1}", fileName, id); } return(null); } return(buffer[id]); }
/// <summary> /// 按照技能释放顺序选择当前可以释放的技能 /// </summary> /// <returns></returns> public Vector2Int SelectSkill() { if (_noSkill()) { if (_normalSkill != 0) { return(new Vector2Int(_normalSkill, _skillData[_normalSkill])); } else { return(Vector2Int.zero); } } if (_activeSkill != 0 && _waitActiveSkill) { if (!_skillData.ContainsKey(_activeSkill)) { EDebug.LogErrorFormat("SelectSkill failed, ActiveSkill:{0} not in skilldata", _activeSkill); return(Vector2Int.zero); } return(new Vector2Int(_activeSkill, _skillData[_activeSkill])); } int sel = !_skillInited ? _initSkillTurn[_skillFlag] : _skillTurn[_skillFlag]; int skillId = _allSkills[sel]; if (_skillData.ContainsKey(skillId)) { return(new Vector2Int(skillId, _skillData[skillId])); } else { EDebug.LogErrorFormat("SelectSkill failed, skillid:{0} not in skilldata", skillId); return(Vector2Int.zero); } }
/// <summary> /// 注册和登录都走这里,根据AutoLoginOrRegister区分 /// </summary> public void Login() { if (string.IsNullOrEmpty(_userName) || string.IsNullOrEmpty(_passWd)) { return; } EDebug.LogFormat("Login {0} {1} Login Or Regist {2}", _userName, _passWd, AutoLoginOrRegist); MsgHead head = new MsgHead { cmd_id = AutoLoginOrRegist ? (short)ServerMsgId.CCMD_ROLE_AUTH : (short)ServerMsgId.CCMD_ROLE_REG }; LoginMsg loginMsg = new LoginMsg { type = 0, name = _userName, passwd = _passWd }; string loginInfo = JsonUtility.ToJson(loginMsg); byte[] bMsg = System.Text.Encoding.UTF8.GetBytes(loginInfo); head.len = bMsg.Length; byte[] bHead = ProtocolByt.StructToBytes(head, 16); byte[] buffer = new byte[bHead.Length + bMsg.Length]; System.Array.Copy(bHead, buffer, bHead.Length); System.Array.Copy(bMsg, 0, buffer, bHead.Length, bMsg.Length); try { client.BeginSend(buffer, 0, buffer.Length, SocketFlags.None, null, null); } catch (Exception e) { EDebug.LogErrorFormat("Client.Login Socket Exception {0}", e.ToString()); OnDisconnect(); } }
private void _setStubHero(int stubPos, bool isCreate = false, int heroId = 0) { //不管是创建还是删除,都得先删除了 if (_stubHeroDic.ContainsKey(stubPos)) { DestroyImmediate(_stubHeroDic[stubPos]); _stubHeroDic.Remove(stubPos); _stubPosDic[stubPos].SetStubState(StubState.Open); } if (isCreate) { UIBillboard _bb = null; if (0 == stubPos) { _bb = StubDrag_bb; } else { _bb = StubShow_bb; } if (_bb == null) { EDebug.LogErrorFormat("StubView._setStubHero error, stubPos:{0}", stubPos); return; } Hero heroData = JsonMgr.GetSingleton().GetHeroByID(heroId); GameObject heroGo = null; if (stubPos != 0) { int stubX = stubPos / 10; int stubY = stubPos % 10; heroGo = GameObject.Instantiate(ResourceMgr.Instance.LoadResource(heroData.ID) as GameObject, _bb.GetCamPos() + new Vector3((stubX - 1) * StubXSpace3D + (6 - stubY) * LeanOffset3D - 15f, (6 - stubY) * StubYSpace3D - 11f, 5), Quaternion.Euler(0, 125.75f, 0)); heroGo.transform.localScale = Vector3.one * 1.8f; } else { heroGo = GameObject.Instantiate(ResourceMgr.Instance.LoadResource(heroData.ID) as GameObject, _bb.GetCamPos() + new Vector3(0, 0, 5), Quaternion.Euler(0, 125.75f, 0)); } if (heroGo != null) { _stubHeroDic.Add(stubPos, heroGo); if (heroData.horseid != 0) { GameObject horseGo = GameObject.Instantiate(ResourceMgr.Instance.LoadResource(heroData.horseid) as GameObject, heroGo.transform); horseGo.transform.localPosition = Vector3.zero; horseGo.transform.localScale = Vector3.one; } heroGo.SetLayer(_bb.Layer); } else { EDebug.LogErrorFormat("StubView._setStubHero error, load heroGo failed, heroId:{0}", heroData.ID); } _stubPosDic[stubPos].SetStubState(StubState.Stubed); } }
public void SetInfo(int headid, string playername, int herocnt, string corpsName, Dictionary <int, int> stubData, bool isPvp = false, int arenaRank = 0, int arenaWin = 0) { //TODO:headid this.name_txt.text = playername; this.herocnt_txt.text = herocnt.ToString(); this.corpsname_txt.text = corpsName; foreach (var p in _stubui) { p.Value.sprite = StubEmpty; } foreach (var p in stubData) { if (_stubui.ContainsKey(p.Key)) { JsonData.Hero heroData = JsonMgr.GetSingleton().GetHeroByID(p.Value); _stubui[p.Key].sprite = ResourceMgr.Instance.LoadSprite(heroData.headid); } else { EDebug.LogErrorFormat("PlayerInfoDetailView.SetInfo failed, _stubui doesn't contains stubpos {0}", p.Key); } } this.arena_obj.SetActive(isPvp); if (isPvp) { this.arenarank_txt.text = arenaRank.ToString(); this.arenawin_txt.text = arenaWin.ToString(); } }
// Use this for initialization void Start() { if (PopTexts == null) { return; } for (int idx = 0; idx < PopTexts.Count; ++idx) { RectTransform popRect = PopTexts[idx].GetComponent <RectTransform>(); Text popText = PopTexts[idx].GetComponentInChildren <Text>(); CanvasGroup groupComp = PopTexts[idx].GetComponentInChildren <CanvasGroup>(); if (popText == null) { EDebug.LogErrorFormat("PopMgr.Start Get Text Component in {0} failed", PopTexts[idx]); continue; } if (groupComp == null) { EDebug.LogErrorFormat("PopMgr.Start Get CanvasGroup Component in {0} failed", PopTexts[idx]); continue; } oldSize.Add(popRect.localScale); oldPos.Add(popRect.anchoredPosition); _textPool.Add(new List <TextObject>()); } if (Duration == 0) { Duration = 1; } }
/// <summary> /// 召唤怪物 /// </summary> /// <param name="monsterId"></param> /// <param name="isEnemy"></param> /// <param name="ambush"></param> public void Summon(int monsterId, int level, bool isEnemy, int num, bool ambush = false) { if (num <= 0) { EDebug.LogErrorFormat("FightLogic.Summon failed, invalid monster num : {0}", num); return; } monsterId += (level - 1); for (int idx = AllFighters.Count - 1; idx > 0; --idx) { FightUnit unit = AllFighters[idx]; if (unit.IsDead || !unit.IsSummon) { continue; } if (unit.HeroId == monsterId) { ZEventSystem.Dispatch(EventConst.ForceDestroyView, unit); AllFighters.RemoveAt(idx); } } for (int idx = 0; idx < num; ++idx) { int summonPos = -1; for (int stubX = 0; stubX < PathFinder.H_GRID; ++stubX) { for (int stubY = 0; stubY < PathFinder.V_GRID; ++stubY) { int fightPos = PathFinder.Stub2InitPos(CurRound, (ambush ? !isEnemy : isEnemy), (stubX + 1) * 10 + (stubY + 1)); if (!CheckGridPosOccupy(fightPos)) { summonPos = fightPos; break; } } } if (summonPos >= 0) { Monster monster = JsonMgr.GetSingleton().GetMonsterByID(monsterId); if (monster == null) { EDebug.LogErrorFormat("Summon failed, could not find monster {0} from json", monsterId); return; } FightUnit summon = new FightUnit(monster, 0, isEnemy, true); summon.UID = ++UID; _createFightUnitView(summon); summon.PathFinderObj.SetPos(summonPos); AllFighters.Add(summon); ZEventSystem.Dispatch(EventConst.OnCreateSummon, summon); } else { EDebug.Log("Summon failed, could not find summonPos"); } } }
private Dictionary <int, JObject> getWholeData(string fileName) { if (!_allJsonData.ContainsKey(fileName)) { EDebug.LogErrorFormat("Can't find {0} json", fileName); return(null); } return(_allJsonData[fileName]); }
/// <summary> /// 设置某个Tab的Enable状态 /// </summary> /// <param name="idx"></param> /// <param name="enable"></param> public void SetTabEnable(int idx, bool enable) { if (idx < 0 || idx >= TabList.Count) { EDebug.LogErrorFormat("UITabs.SetTabEnable failed, invalid idx {0}", idx); return; } _tabState[idx] = enable; TabList[idx].SetActive(enable); }
/// <summary> /// 返回LevelDataList /// </summary> /// <param name="_type"></param> /// <param name="_chapeer"></param> /// <returns></returns> public List <List <List <LevelData> > > GetLevelData() { List <List <List <LevelData> > > levelData = null; if (Level.Count == 0) { EDebug.LogErrorFormat("Can't find _id:{0} in JsonMgr.GetLevel"); return(null); } levelData = Level; return(levelData); }
/// <summary> /// 计算伤害(治疗) /// </summary> /// <param name="isNormal">是否普攻</param> /// <param name="isAtk">是否物理</param> /// <param name="baseHarm">基础数值,正数代表治疗负数代表伤害</param> /// <param name="user">发起者</param> /// <param name="target">承受者</param> /// <returns>返回值x表示EffectState,y表示伤害值</returns> public static Vector2Int CalHarm(bool isNormal, bool isAtk, float baseHarm, FightUnit user, FightUnit target) { float harmOffsetMin = JsonMgr.GetSingleton().GetGlobalIntArrayByID(1013).value; float harmOffsetMax = JsonMgr.GetSingleton().GetGlobalIntArrayByID(1014).value; float harmOffset = Random.Range(harmOffsetMin, harmOffsetMax); if (baseHarm > 0) { //治疗 bool crit = false; if (Random.Range(0, 1.0f) < (user.CritRate / 2)) { crit = true; } return(new Vector2Int((int)(crit ? EffectState.HealCrit : EffectState.Heal), (int)(baseHarm * (target.HealRate + user.MdefBreak) * (crit ? (user.CritInc) : 1) * harmOffset))); } else if (baseHarm < 0) { EffectState estate = EffectState.None; if (isNormal) { if (Random.Range(0, 1.0f) < Mathf.Max(0, (target.DodgeRate - user.HitRate))) { estate = EffectState.Dodge; } else if (Random.Range(0, 1.0f) < Mathf.Max(0, (target.BlockRate - user.RoutRate))) { estate = EffectState.Block; } } if (estate == EffectState.None) { if (Random.Range(0, 1.0f) < Mathf.Max(0, (user.CritRate - target.FirmRate))) { estate = EffectState.Crit; } } float addition = estate == EffectState.None ? 1 : (estate == EffectState.Dodge ? 0 : (estate == EffectState.Block ? BASE_BLOCK : user.CritInc)); float finalHarm = baseHarm * (1 - (Mathf.Min((isAtk ? target.DefRate : target.MdefRate) - (isAtk ? user.DefBreak : user.MdefBreak), 1))) * target.HarmRate * addition * harmOffset; return(new Vector2Int((int)estate, (int)finalHarm)); } else { EDebug.LogErrorFormat("AttrUtil.CalHarm, baseHarm is zero"); return(Vector2Int.zero); } }
private void openSimpleTip(int tipid, Vector2 pos, int align, Vector2 offset, object[] args) { JsonData.Tips tipsJson = JsonMgr.GetSingleton().GetTipsByID(tipid); if (tipsJson == null) { EDebug.LogErrorFormat("openSimpleTip, invalid tips id {0}", tipid); return; } Vector2 size = new Vector2(tipsJson.sizex, tipsJson.sizey); this.simpletips_rect.sizeDelta = size; this.simpletips_rect.anchoredPosition = calAlignment(pos, size, align, offset); this.simpletipst_txt.text = string.Format(tipsJson.content, args); this.simpletips_rect.gameObject.SetActive(true); }
private void openItemTip(int itemId, Vector2 pos, int align, Vector2 offset) { JsonData.ItemConfig itemJson = JsonMgr.GetSingleton().GetItemConfigByID(itemId); if (itemJson == null) { EDebug.LogErrorFormat("openItemTip, invalid item id {0}", itemId); return; } itemTipsView.SetInfo(itemId, 0); string itemColor = ColorMgr.Colors[itemJson.rare - 1]; this.ItemName_txt.text = itemJson.name.AddColorLabel(itemColor); this.ItemNum_txt.text = string.Format(JsonMgr.GetSingleton().GetGlobalStringArrayByID(2005).desc, ItemMgr.Instance.GetItemNum(itemId).ToString()); this.ItemPrice_txt.text = itemJson.price.ToString(); if (itemJson.type == FuncType.EQUIP) { _sb.Length = 0; JsonData.Equip equipJson = JsonMgr.GetSingleton().GetEquipByID(itemId); if (equipJson != null) { for (int idx = 0; idx < equipJson.Attribute.Length; ++idx) { Pro p = equipJson.Attribute[idx]; _sb.AppendLine(string.Format(" {0} +{1}", AttrUtil.GetAttribute(p.attr), AttrUtil.ShowText(p.attr, p.num, p.per))); } for (int idx = 0; idx < equipJson.Innate.Length; ++idx) { Pro p = equipJson.Innate[idx]; _sb.AppendLine(string.Format(" {0} +{1}", AttrUtil.GetAttribute(p.attr), AttrUtil.ShowText(p.attr, p.num, p.per))); } _sb.Remove(_sb.Length - 1, 1); this.ItemIntroduce_txt.alignment = TextAnchor.MiddleLeft; this.ItemIntroduce_txt.text = _sb.ToString(); } else { EDebug.LogErrorFormat("openItemTip invalid equip id {0}", itemId); } } else { this.ItemIntroduce_txt.alignment = TextAnchor.UpperLeft; this.ItemIntroduce_txt.text = itemJson.propertydes; } this.itemtips_rect.anchoredPosition = calAlignment(pos, this.itemtips_rect.sizeDelta, align, offset); this.itemtips_rect.gameObject.SetActive(true); }
public string LoadData(string name) { #if USE_ASSETBUNDLE if (_allData.ContainsKey(name)) { return(_allData[name]); } else { EDebug.LogErrorFormat("Load {0} from assetbundle failed", name); return(""); } #else return((Resources.Load(string.Format(PathUtil.Instance.DataPath, name), typeof(TextAsset)) as TextAsset).text); #endif }
void Awake() { if (TabList.Count == 0 || TabList.Count != TabObjList.Count) { EDebug.LogErrorFormat("UITabs.Start, TabList and TabObjList not compaticable."); return; } foreach (GameObject tab in TabList) { EventListener.Get(tab).OnClick = onClickTab; } for (int idx = 0; idx < TabList.Count; ++idx) { _tabState.Add(true); } }
public byte[] LoadLua(string name) { #if USE_ASSETBUNDLE if (_allLua.ContainsKey(name)) { return(_allLua[name].bytes); } else { EDebug.LogErrorFormat("Load {0} from assetbundle failed", name); return(null); } #else return((Resources.Load(name, typeof(TextAsset)) as TextAsset).bytes); #endif }
/// <summary> /// 退出战场 /// </summary> public void ExitBattleField() { int lastPos = -1; for (int idx = 0; idx < AllFighters.Count; ++idx) { FightUnit unit = AllFighters[idx]; if (unit.IsDead) { continue; } if (lastPos < 0 || unit.GridPos < lastPos) { lastPos = unit.GridPos; } } if (lastPos < 0) { EDebug.LogError("FightLogic.ExitBattleField failed, lastPos < 0"); return; } int gridOffset = (lastPos - ((CurRound - 1) * 3 + 1) * PathFinder.AREA_TOTAL) / PathFinder.V_GRID; gridOffset = PathFinder.H_GRID * 2 - gridOffset; if (gridOffset < 0) { EDebug.LogErrorFormat("FightLogic.ExitBattleFIeld failed, lastpos:{0} gridOffset:{1}", lastPos, gridOffset); } for (int idx = 0; idx < AllFighters.Count; ++idx) { FightUnit unit = AllFighters[idx]; if (unit.IsDead) { continue; } int endPos = unit.GridPos + gridOffset * PathFinder.V_GRID; //unit.PathFinderObj.StartFind(endPos); unit.GridPos = endPos; unit.TargetPos = PathFinder.Grid2Pos(endPos); unit.CurRot.SetLookRotation(Vector3.right); unit.State = FightUnitState.Move; } }
public void InitAreanDefend() { List <Vector2Int> stubData = Role.Instance.GetStubData(StubType.PVPDefend); int needHead = stubData.Count - _heroHeads.Count; if (needHead > 0) { for (int idx = 0; idx < needHead; ++idx) { GameObject HeroHeadGo = GameObject.Instantiate(HeroHead.gameObject, this.defend_obj.transform); HeroHeadView view = HeroHeadGo.GetComponent <HeroHeadView>(); view.Init(); _heroHeads.Add(view); } } for (int idx = 0; idx < _heroHeads.Count; ++idx) { if (idx < stubData.Count) { int heroId = (int)stubData[idx].y; JsonData.Hero jHero = JsonMgr.GetSingleton().GetHeroByID(heroId); if (jHero == null) { EDebug.LogErrorFormat("couldn't find hero {0} in json", heroId); return; } HeroData hero = HeroMgr.GetSingleton().GetHeroData(heroId); if (hero == null) { EDebug.LogErrorFormat("couldn't find hero {0}", heroId); } else { _heroHeads[idx].SetHeroInfo(jHero.headid, hero.Rare, hero.Star, hero.Level); } } else { _heroHeads[idx].gameObject.SetActive(false); } } }
public void AddBuff(FightUnit caster, int tplId, int buffLevel) { JObject buffJson = JsonMgr.GetSingleton().GetBuff(tplId); if (buffJson == null) { EDebug.LogErrorFormat("BuffMgr.AddBuff, failed to get buff json, id:{0}", tplId); return; } int type = buffJson["type"].ToObject <int>(); int layers = buffJson["layers"].ToObject <int>(); int resid = buffJson["resid"].ToObject <int>(); bool onfoot = buffJson["onfoot"].ToObject <int>() != 0; int calType = buffJson["caltype"].ToObject <int>(); JArray buffParam = buffJson["buffparam"].ToObject <JArray>(); int buffPriority = buffJson["priority"].ToObject <int>(); Vector3 effectParam = AttrUtil.CalExpression(calType, buffParam, caster, this._unit, buffLevel); Buff buff = new Buff(this, caster, buffLevel, ++_uid, tplId, effectParam); if (checkPriority(buffPriority)) { int curLayer = getCurLayer(tplId); if (curLayer >= layers) { removeFirstBuff(tplId); } if (0 == getCurLayer(tplId) && resid > 0) { //通知显示层显示特效 ZEventSystem.Dispatch(EventConst.OnFightUnitAddBuff, this._unit, resid, onfoot, true); } if (type == (int)BuffType.Time) { TakeEffect(buff); } _allBuff.Add(buff); } }
private void _makeEffect() { if (this.User == null || this.Target == null || this.Target.IsDead) { EDebug.LogErrorFormat("BulletObj._makeEffect failed, User {0} Target {1}", this.User, this.Target); return; } for (int idx = 0; idx < this.Effects.Length; ++idx) { JObject ceffect = JsonMgr.GetSingleton().GetSkillEffect(this.Effects[idx]); int effectType = ceffect["effect"].ToObject <int>(); if (effectType == (int)EffectType.BULLET) { EDebug.LogErrorFormat("BulletId {0} effect {1} create bullet again", this.TplId, this.Effects[idx]); continue; } this.User.MakeEffect(ceffect, CSkill.ID, SkillLevel, Target); } }
/// <summary> /// 直接打开某个Tab /// </summary> /// <param name="idx"></param> public void OpenTab(int idx) { if (idx < 0 || idx >= TabList.Count) { EDebug.LogErrorFormat("UITabs.OpenTab failed, invalid idx {0}", idx); return; } if (!_tabState[idx]) { EDebug.LogErrorFormat("UITabs.OpenTab failed, tab {0} is disable", idx); return; } GameObject tab = TabList[idx]; Toggle togCom = tab.GetComponent <Toggle>(); if (togCom != null) { togCom.isOn = true; } onClickTab(tab); }
/// <summary> /// 通过ID获取某一关卡星数 /// </summary> /// <param name="_id"></param> /// <returns></returns> public int GetStar(int _id) { int star = 0; for (int idx = 0; idx < Genlevel.Count; idx++) { for (int idx1 = 0; idx1 < Genlevel[idx].Count; idx1++) { for (int idx2 = 0; idx2 < Genlevel[idx][idx1].GenStage.Count; idx2++) { if (Genlevel[idx][idx1].GenStage[idx2].LevelID == _id) { star = Genlevel[idx][idx1].GenStage[idx2].StarCount; return(star); } } } } EDebug.LogErrorFormat("Can't find itemid:{0} in Battlemgr.GetStar", _id); return(0); }
private void _analyzeBullet(int bulletId, ref HashSet <int> sound, ref HashSet <int> gos) { var jBullet = JsonMgr.GetSingleton().GetBulletByID(bulletId); if (jBullet == null) { EDebug.LogErrorFormat("PreloadMgr._analyzeBullet failed, no such bullet:{0}", bulletId); return; } int resId = jBullet.resid; if (resId != 0) { gos.Add(resId); } int[] effects = jBullet.effects; for (int idx = 0; idx < effects.Length; ++idx) { _analyzeEffect(effects[idx], ref sound, ref gos); } }
private void _analyzeEffect(int effectId, ref HashSet <int> sound, ref HashSet <int> gos) { JObject jEffect = JsonMgr.GetSingleton().GetSkillEffect(effectId); if (jEffect == null) { EDebug.LogErrorFormat("PreloadMgr._analyzeEffect failed, no such effect:{0}", effectId); return; } int hitEffect = jEffect["hiteffect"].ToObject <int>(); if (hitEffect != 0) { gos.Add(hitEffect); } int effect = jEffect["effect"].ToObject <int>(); int paramType = jEffect["paramtype"].ToObject <int>(); if (1 == paramType) { return; } Vector3 EffectParams = AttrUtil.CalExpression(paramType, jEffect["effectparam"].ToObject <JArray>()); switch (effect) { case (int)EffectType.BULLET: _analyzeBullet((int)EffectParams.y, ref sound, ref gos); break; case (int)EffectType.BUFF: _analyzeBuffRes((int)EffectParams.y, ref sound, ref gos); break; case (int)EffectType.Summon: _analyzeFighterRes((int)EffectParams.x, true, ref sound, ref gos); break; } }
private void openMonsterTip(int monsterId, Vector2 pos, int align, Vector2 offset, bool isBoss) { Monster monsterJson = JsonMgr.GetSingleton().GetMonsterByID(monsterId); if (monsterJson == null) { EDebug.LogErrorFormat("openMonsterTip invalid monster id {0}", monsterId); return; } this.monsterhead_img.sprite = ResourceMgr.Instance.LoadSprite(monsterJson.headid); this.monsterlevel_img.sprite = ResourceMgr.Instance.LoadSprite(ColorMgr.Border[monsterJson.rare - 1]); HeroRare rareData = JsonMgr.GetSingleton().GetHeroRareByID(monsterJson.rare); this.monsterlevel_img.sprite = ResourceMgr.Instance.LoadSprite(rareData.HeadBorder); string monsterName = string.Format("{0}({1})", monsterJson.name, rareData.Name); this.monstername_txt.text = monsterName.AddColorLabel(rareData.Color); this.monsterlevel_txt.text = string.Format(JsonMgr.GetSingleton().GetGlobalStringArrayByID(2004).desc, monsterJson.level); this.monsterisboss_obj.SetActive(isBoss); this.monsterintroduce_txt.text = monsterJson.desc; this.monstertips_rect.anchoredPosition = calAlignment(pos, this.monstertips_rect.sizeDelta, align, offset); this.monstertips_rect.gameObject.SetActive(true); }