/// <summary> /// 打开简易Tips /// </summary> /// <param name="pos">位置</param> /// <param name="tipId">模板Id</param> /// <param name="align">对齐方式</param> /// <param name="offset">偏移</param> /// <param name="args">参数</param> public static void OpenSimpleTip(Vector2 pos, int tipId, Alignment align, Vector2 offset, params object[] args) { UIFace.GetSingleton().Open(UIID.Tips); ZEventSystem.Dispatch(EventConst.OnOpenTips, (int)TipsType.SimpleTip, tipId, pos, align, offset, new List <object>(args)); }
public void TakeEffect(Buff buff, bool inverse = false) { JObject cbuff = JsonMgr.GetSingleton().GetBuff(buff.BuffId); int buffeffect = cbuff["effect"].ToObject <int>(); int calType = cbuff["caltype"].ToObject <int>(); string buffparam = cbuff["buffparam"].ToString(); float effectParamKey = buff.EffectParam.x; float effectParamValue = (inverse ? -1 : 1) * buff.EffectParam.y; switch (buffeffect) { case (int)BuffEffect.AddHPMax: this._unit.MaxHP += (int)(effectParamValue * this._unit.BaseMaxHp); break; case (int)BuffEffect.AddVigour: { this._unit.AddVigour((int)effectParamValue); if (effectParamValue > 0) { ZEventSystem.Dispatch(EventConst.OnFightUnitPop, this._unit, new Vector2Int((int)EffectState.HealVigour, (int)effectParamValue)); } } break; case (int)BuffEffect.AddAtk: this.Atk += effectParamValue; break; case (int)BuffEffect.AddMatk: this.Matk += effectParamValue; break; case (int)BuffEffect.AddDefRate: this.DefRate += effectParamValue; break; case (int)BuffEffect.AddMdefRate: this.MdefRate += effectParamValue; break; case (int)BuffEffect.AddDefBreak: this.DefBreak += effectParamValue; break; case (int)BuffEffect.AddMdefBreak: this.MdefBreak += effectParamValue; break; case (int)BuffEffect.AddDeSowRate: this.DeSowRate += effectParamValue; break; case (int)BuffEffect.AddDeFaintRate: this.DeFaintRate += effectParamValue; break; case (int)BuffEffect.AddDeSpoofRate: this.DeSpoofRate += effectParamValue; break; case (int)BuffEffect.AddHealRate: this.HealRate += effectParamValue; break; case (int)BuffEffect.AddHarmRate: this.HarmRate += effectParamValue; break; case (int)BuffEffect.AddAsp: this.AspRate += effectParamValue; break; case (int)BuffEffect.AddDodgeRate: this.DodgeRate += effectParamValue; break; case (int)BuffEffect.AddHitRate: this.HitRate += effectParamValue; break; case (int)BuffEffect.AddBlockRate: this.BlockRate += effectParamValue; break; case (int)BuffEffect.AddRoutRate: this.RoutRate += effectParamValue; break; case (int)BuffEffect.AddCritRate: this.CritRate += effectParamValue; break; case (int)BuffEffect.AddFirmRate: this.FirmRate += effectParamValue; break; case (int)BuffEffect.AddCritInc: this.CritInc += effectParamValue; break; case (int)BuffEffect.LastHeal: { if (buff.EffectParam.x == 0) { this._unit.HarmHp(new Vector2Int(0, (int)buff.EffectParam.y), buff.Caster, buff.SklId); } else { this._unit.HarmHp(AttrUtil.CalHarm(false, buff.EffectParam.x == 1, buff.EffectParam.y, buff.Caster, this._unit), buff.Caster, buff.SklId); } } break; case (int)BuffEffect.LastHarm: { if (buff.EffectParam.x == 0) { this._unit.HarmHp(new Vector2Int(0, -(int)buff.EffectParam.y), buff.Caster, buff.SklId); } else { this._unit.HarmHp(AttrUtil.CalHarm(false, buff.EffectParam.x == 1, -(int)buff.EffectParam.y, buff.Caster, this._unit), buff.Caster, buff.SklId); } } break; case (int)BuffEffect.Sow: { this._unit.CState = (inverse ? ControlState.None : ControlState.Sow); } break; case (int)BuffEffect.Faint: { this._unit.CState = (inverse ? ControlState.None : ControlState.Faint); } break; case (int)BuffEffect.Spoof: { this._unit.CState = (inverse ? ControlState.None : ControlState.Spoof); if (!inverse) { this._unit.PathFinderObj.StartFind(); } } break; case (int)BuffEffect.Sneer: { this._unit.CState = (inverse ? ControlState.None : ControlState.Sneer); this._unit.SneerTarget = !inverse ? buff.Caster : null; } break; case (int)BuffEffect.Scared: { if (inverse) { this._unit.RemoveSpecialState(SpecialState.Scared); } else { this._unit.AddSpecialState(SpecialState.Scared); } } break; case (int)BuffEffect.Betray: { this._unit.CState = (inverse ? ControlState.None : ControlState.Betray); } break; case (int)BuffEffect.Slient: { if (inverse) { this._unit.RemoveSpecialState(SpecialState.Slient); } else { this._unit.AddSpecialState(SpecialState.Slient); } this._unit.Interrupt(); } break; case (int)BuffEffect.AddBuff: { this.AddBuff(buff.Caster, (int)effectParamValue, buff.BuffLevel); } break; case (int)BuffEffect.UsePromotSkill: { if (Random.Range(0, 1.0f) < effectParamKey) { Skill cskill = JsonMgr.GetSingleton().GetSkillByID((int)effectParamValue); if (cskill != null) { this._unit.UseSKill(cskill, buff.BuffLevel); } } } break; case (int)BuffEffect.Invincible: this._unit.Invincible = !inverse; break; case (int)BuffEffect.DeInvincible: this._unit.DeInvincible = !inverse; break; case (int)BuffEffect.HpSuck: this.HpSuck += effectParamValue; break; case (int)BuffEffect.UseSkill: { Skill cskill = JsonMgr.GetSingleton().GetSkillByID((int)effectParamValue); if (cskill != null) { this._unit.UseSKill(cskill, buff.BuffLevel); } } break; default: break; } }
private void SetAdvancedView() { int[] targets = equip.JsonData.Advanced; int target = PlayerPrefs.GetInt("advancedtarget"); //处理紫升橙 if (targets.Length > 1) { bool has = false; for (int i = 0; i < targets.Length; ++i) { if (targets[i] == target) { has = true; } } if (target != 0 && has) { advancedequip_img.raycastTarget = true; target_img.raycastTarget = false; EventListener.Get(advancedequip_img.gameObject).OnClick = e => { attr_obj.SetActive(false); null_obj.SetActive(true); for (int i = 0, length = parent_trf.childCount; i < length; ++i) { DestroyImmediate(parent_trf.GetChild(0).gameObject); } target = 0; PlayerPrefs.SetInt("advancedtarget", 0); UIFace.GetSingleton().Open(UIID.EuqipTipCtrl, targets); }; } else { advancedequip_img.gameObject.SetActive(false); advancedborder_img.gameObject.SetActive(false); target_img.gameObject.SetActive(true); attr_obj.SetActive(false); null_obj.SetActive(true); target_img.raycastTarget = true; advancedequip_img.raycastTarget = false; EventListener.Get(target_img.gameObject).OnClick = e => { PlayerPrefs.SetInt("advancedtarget", 0); UIFace.GetSingleton().Open(UIID.EuqipTipCtrl, targets); }; return; } } else if (targets.Length == 0) { advancedequip_img.gameObject.SetActive(false); advancedborder_img.gameObject.SetActive(false); target_img.gameObject.SetActive(true); attr_obj.SetActive(false); null_obj.SetActive(true); target_img.raycastTarget = true; advancedequip_img.raycastTarget = false; EventListener.Get(target_img.gameObject).OnClick = e => { CanvasView.Instance.AddNotice("当前装备已进阶至最大等级"); }; return; } else { advancedequip_img.raycastTarget = false; target = targets[0]; } advancedequip_img.gameObject.SetActive(true); advancedborder_img.gameObject.SetActive(true); target_img.gameObject.SetActive(false); attr_obj.SetActive(true); null_obj.SetActive(false); AdvancedSpend aspend = JsonMgr.GetSingleton().GetAdvancedSpendByID(target); SetSpendView(aspend); EventListener.Get(advanced_btn.gameObject).OnClick = e => { if (equip.JsonData.Advanced.Length == 0) { CanvasView.Instance.AddNotice("当前装备已进阶至最大等级"); return; } else if (equip.StrengthenLv < equip.JsonData.AdvancedCondition) { CanvasView.Instance.AddNotice(string.Format("进阶失败!需要强化等级达到{0},才能继续进阶。", equip.JsonData.AdvancedCondition)); return; } else if (target == 0) { return; } for (int i = 0, length = parent_trf.childCount; i < length; ++i) { DestroyImmediate(parent_trf.GetChild(0).gameObject); } equip.EquipId = target; SetAdvancedView(); HeroData hero = HeroMgr.GetSingleton().GetHeroData(equip.HeroId); if (hero == null) { return; } hero.ClearEquipAttr(); ZEventSystem.Dispatch(EventConst.REFRESHRIGHT); }; StringBuilder sb = new StringBuilder(); Pro[] p = equip.Attribute; for (int i = 0, length = p.Length; i < length; ++i) { sb.Append(AttrUtil.GetAttribute(p[i].attr)); sb.Append(": +"); sb.Append(AttrUtil.ShowText(p[i].attr, equip.JsonData.Attribute[i].num + p[i].num, equip.JsonData.Attribute[i].per + p[i].per)); sb.Append("\n"); } name_txt.supportRichText = true; string color = ColorMgr.Colors[equip.ItemData.rare - 1]; name_txt.text = string.Format("<color=#{0}>{1}{2}</color>", color, equip.JsonData.Name, equip.StrengthenLv > 0 ? " +" + equip.StrengthenLv : ""); baseattr_txt.text = string.Format("<color=#{0}>{1}</color>", color, sb); Equip q = JsonMgr.GetSingleton().GetEquipByID(target); StringBuilder append = new StringBuilder(); p = q.Attribute; for (int i = 0, length = p.Length; i < length; ++i) { append.Append(AttrUtil.GetAttribute(p[i].attr)); append.Append(": +"); append.Append(AttrUtil.ShowText(p[i].attr, p[i].num + p[i].num * equip.StrengthenLv, p[i].per + p[i].per * equip.StrengthenLv)); append.Append("\n"); } ItemConfig ic = JsonMgr.GetSingleton().GetItemConfigByID(target); color = ColorMgr.Colors[ic.rare - 1]; advanced_txt.supportRichText = true; advanced_txt.text = string.Format("<color=#{0}>{1}{2}</color>", color, q.Name, equip.StrengthenLv > 0 ? " +" + equip.StrengthenLv : ""); advancedattr_txt.text = string.Format("<color=#{0}>{1}</color>", color, append); sb = null; append = null; }
/// <summary> /// 打开某一个商店 /// </summary> /// <param name="type"></param> public void OpenUnitShop(int type, bool isRefresh) { ZEventSystem.Dispatch(EventConst.GetShopItemByType, type, isRefresh); }
public void GMorder(string _gmmo) { GMCommand _gmmos = new GMCommand(); try { _gmmos = (GMCommand)Enum.Parse(typeof(GMCommand), _gmmo); } catch (Exception e) { Debug.Log("不存在的GM命令" + ":" + e.ToString()); } switch (_gmmos) { case GMCommand.modifylevel: //主公满级 if (Role.Instance.Level == LEVEL) { return; } Role.Instance.Level = LEVEL; ZEventSystem.Dispatch(EventConst.UpdateData); break; case GMCommand.modifycopper: //增加铜钱 Role.Instance.Cash += COPPER; if (Role.Instance.Cash > 99999999) { Role.Instance.Cash = 99999999; } break; case GMCommand.clearclear: ClearsClose(); break; case GMCommand.modifyPower: //增加体力 if (Role.Instance.Power < POWER * 10) { Role.Instance.Power = POWER; } break; case GMCommand.modifyviplevel: if (Role.Instance.Vip < 15) { Role.Instance.Vip = Role.Instance.Vip + 1; } Debug.Log("VIP等级" + Role.Instance.Vip); break; case GMCommand.modifyglevel: Debug.Log("未实现"); break; case GMCommand.modifygold: Role.Instance.Gold += COPPER; Role.Instance.LockedGold += COPPER; ZEventSystem.Dispatch(EventConst.UpdateData); if (Role.Instance.Gold > 99999999) { Role.Instance.Gold = 99999999; Role.Instance.LockedGold = 99999999; } break; case GMCommand.clearsection: Simulate(); break; case GMCommand.modifydynamic: Debug.Log("未实现"); break; case GMCommand.equip: Debug.Log("未实现"); break; case GMCommand.modifyarena: Debug.Log("未实现"); break; case GMCommand.modifyhonor: if (Role.Instance.Honor < HONOR * 10) { Role.Instance.Honor += HONOR; Debug.Log("荣誉" + Role.Instance.Honor); } break; case GMCommand.modifyskill: Debug.Log("未实现"); break; case GMCommand.modifyggzj: Debug.Log("未实现"); break; case GMCommand.intensify: Debug.Log("未实现"); break; case GMCommand.modifyvigor: Debug.Log("未实现"); break; case GMCommand.divination: Debug.Log("未实现"); break; case GMCommand.sophistication: Debug.Log("未实现"); break; } GMOrder_input.text = ""; }
public void GamePause(bool pause) { this.mView.OpenPause(pause); ZEventSystem.Dispatch(EventConst.OnGamePause, pause); Time.timeScale = pause ? 0 : 1; }
public void OnStubSaveOver(ServerMsgObj msg) { Debug.LogFormat("OnStubSaveOver {0}", msg.Msg); ZEventSystem.Dispatch(EventConst.OnStubSaveOver); }
public override void OnOpen() { base.OnOpen(); _InitChapter(true); ZEventSystem.Dispatch(EventConst.OpLevel, int.Parse(this.mView.KeyChapter[0]) - 1, int.Parse(this.mView.KeyChapter[1] + this.mView.KeyChapter[2]) - 1, 0);// 执行从其他界面进去章节 }
private void _initEvent(bool open) { if (open) { ZEventSystem.Register(EventConst.OnCreateFight, this, "OnCreateFight"); ZEventSystem.Register(EventConst.OnFightUnitPop, this, "OnFightUnitPop"); ZEventSystem.Register(EventConst.OnAutoFightStateChange, this, "OnAutoFightStateChange"); ZEventSystem.Register(EventConst.OnGameSpeedChange, this, "OnGameSpeedChange"); ZEventSystem.Register(EventConst.OnNewRound, this, "OnNewRound"); ZEventSystem.Register(EventConst.OnUnitPause, this, "OnUnitPause"); ZEventSystem.Register(EventConst.OnMusicMute, this, "OnMusicMute"); ZEventSystem.Register(EventConst.OnSoundMute, this, "OnSoundMute"); ZEventSystem.Register(EventConst.OnCameraChangeOver, this, "OnCameraChangeOver"); ZEventSystem.Register(EventConst.OnFightStateChange, this, "OnFightStateChange"); ZEventSystem.Register(EventConst.OnTreasureFly, this, "OnTreasureFly"); ZEventSystem.Register(EventConst.OnTreasureFlyOver, this, "OnTreasureFlyOver"); ZEventSystem.Register(EventConst.OnCreateSummon, this, "OnCreateSummon"); ZEventSystem.Register(EventConst.DropOutItem, this, "DropOutItem"); ZEventSystem.Register(EventConst.OnInitEvent, this, "OnInitEvent"); this.mView.auto_fight_btn.onClick.AddListener(delegate() { this.OnAutoFightClick(); }); this.mView.speed_btn.onClick.AddListener(delegate() { this.OnSpeedClick(); }); this.mView.pause_btn.onClick.AddListener(delegate() { this.GamePause(true); }); this.mView.continue_btn.onClick.AddListener(delegate() { this.GamePause(false); }); this.mView.exit_btn.onClick.AddListener(delegate() { this.ExitFight(); }); this.mView.music_btn.onClick.AddListener(delegate() { this.OnMusicClick(); }); this.mView.sound_btn.onClick.AddListener(delegate() { this.OnSoundClick(); }); this.mView.FailExit_btn.onClick.AddListener(delegate() { this.ExitFight(); }); this.mView.FailTryAgain_btn.onClick.AddListener(delegate() { this.Retry(); }); this.mView.PVERetry_btn.onClick.AddListener(delegate() { this.Retry(); }); this.mView.PVENext_btn.onClick.AddListener(delegate() { this.OpenLevel(); }); this.mView.PVEBack_btn.onClick.AddListener(delegate() { this.ExitFight(); }); this.mView.PVPRetry_btn.onClick.AddListener(delegate() { this.Retry(); }); this.mView.DataAnalyzeClose_btn.onClick.AddListener(delegate() { this.mView.OpenDataAnalyze(false); }); this.mView.PVEDataAnalyze_btn.onClick.AddListener(delegate() { this.mView.OpenDataAnalyze(true); }); this.mView.PVPDataAnalyze_btn.onClick.AddListener(delegate() { this.mView.OpenDataAnalyze(true); }); this.mView.FailDataAnalyze_btn.onClick.AddListener(delegate() { this.mView.OpenDataAnalyze(true); }); } else { ZEventSystem.DeRegister(EventConst.OnInitEvent, this); ZEventSystem.DeRegister(EventConst.OnCreateFight, this); ZEventSystem.DeRegister(EventConst.OnFightUnitPop, this); ZEventSystem.DeRegister(EventConst.OnAutoFightStateChange, this); ZEventSystem.DeRegister(EventConst.OnGameSpeedChange, this); ZEventSystem.DeRegister(EventConst.OnNewRound, this); ZEventSystem.DeRegister(EventConst.OnUnitPause, this); ZEventSystem.DeRegister(EventConst.OnMusicMute, this); ZEventSystem.DeRegister(EventConst.OnSoundMute, this); ZEventSystem.DeRegister(EventConst.OnCameraChangeOver, this); ZEventSystem.DeRegister(EventConst.OnFightStateChange, this); ZEventSystem.DeRegister(EventConst.OnTreasureFly, this); ZEventSystem.DeRegister(EventConst.OnTreasureFlyOver, this); ZEventSystem.DeRegister(EventConst.OnCreateSummon, this); ZEventSystem.DeRegister(EventConst.DropOutItem, this); this.mView.auto_fight_btn.onClick.RemoveAllListeners(); this.mView.speed_btn.onClick.RemoveAllListeners(); this.mView.pause_btn.onClick.RemoveAllListeners(); this.mView.continue_btn.onClick.RemoveAllListeners(); this.mView.exit_btn.onClick.RemoveAllListeners(); this.mView.music_btn.onClick.RemoveAllListeners(); this.mView.sound_btn.onClick.RemoveAllListeners(); this.mView.FailExit_btn.onClick.RemoveAllListeners(); this.mView.FailTryAgain_btn.onClick.RemoveAllListeners(); this.mView.PVERetry_btn.onClick.RemoveAllListeners(); this.mView.PVENext_btn.onClick.RemoveAllListeners(); this.mView.PVEBack_btn.onClick.RemoveAllListeners(); this.mView.PVPRetry_btn.onClick.RemoveAllListeners(); this.mView.DataAnalyzeClose_btn.onClick.RemoveAllListeners(); this.mView.PVEDataAnalyze_btn.onClick.RemoveAllListeners(); this.mView.PVPDataAnalyze_btn.onClick.RemoveAllListeners(); this.mView.FailDataAnalyze_btn.onClick.RemoveAllListeners(); _initAdditionEvent(false); HeroTog(false); } }
/// <summary> /// 战斗状态改变 /// </summary> /// <param name="state"></param> public void OnFightStateChange(FightState state) { switch (state) { case FightState.Init: break; case FightState.Prepare: //设置所有单位初始站位,目标站位 for (int idx = 0; idx < AllFighters.Count; ++idx) { AllFighters[idx].SystemProtect = false; AllFighters[idx].InitPassiveSkill(); } ZEventSystem.Register(EventConst.OnUnitMoveOver, this, "OnUnitMoveOver"); EnterBattileField(); break; case FightState.Fight: EDebug.Log("战斗开始"); CamMgrObj.ChangeCam(true); //使用被动技能 for (int idx = 0; idx < AllFighters.Count; ++idx) { FightUnit u = AllFighters[idx]; if (u.IsDead) { continue; } AllFighters[idx].FightIntervalAcc = 0; AllFighters[idx].FightInterval = 0; } break; case FightState.Continue: CamMgrObj.ChangeCam(false); clearFightState(false); for (int idx = 0; idx < Fighters.Count; ++idx) { FightUnit u = Fighters[idx]; if (u.IsDead) { continue; } u.RoundOver(); u.NewRound(); } ExitBattleField(); break; case FightState.Over: EDebug.Log("战斗结束, 是否胜利:" + HasWin); clearFightState(true); break; default: break; } }
/// <summary> /// 开始下一回合,生成当前回合的出手顺序列表 /// </summary> public void NextRound() { if (CurRound != 0) { List <FightUnit> curEnemy = EnemyFighters[CurRound - 1]; for (int idx = 0; idx < curEnemy.Count; ++idx) { //最好判断一下死没死光 if (!curEnemy[idx].IsDead && !curEnemy[idx].IsSummon) { EDebug.LogErrorFormat("FightLogic.NextRound failed, round {0} has enemy alive", CurRound); return; } } } CurRound++; if (CurRound > TotalRound) { EDebug.LogErrorFormat("FightLogic.NextRound failed, round:{0} total round:{1}", CurRound, TotalRound); return; } ZEventSystem.Dispatch(EventConst.OnNewRound, this.CurRound, this.TotalRound); this.AccRoundTime = 0; AllFighters.Clear(); AllFighters.AddRange(Fighters); List <FightUnit> curRoundEnemy = EnemyFighters[CurRound - 1]; //Test~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int idx = 0; idx < curRoundEnemy.Count; ++idx) { FightUnit enemyUnit = curRoundEnemy[idx]; _createFightUnitView(enemyUnit); } //EndTest~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AllFighters.AddRange(curRoundEnemy); //排出手顺序 AllFighters.Sort((FightUnit a, FightUnit b) => { if (a.Order > b.Order) { return(1); } else if (a.Order < b.Order) { return(-1); } else { if (a.IsEnemy && !b.IsEnemy) { return(IsPvp ? 1 : -1); } else if (!a.IsEnemy && b.IsEnemy) { return(IsPvp ? -1 : 1); } else { return(0); } } }); State = FightState.Prepare; ZEventSystem.Dispatch(EventConst.OnInitEvent); }
/// <summary> /// 有战斗单位死亡 /// </summary> public void OnUnitDie(FightUnit unit) { if (unit == null) { EDebug.LogError("FightLogic.OnUnitDie, unit is null"); return; } bool isEnemyDie = unit.IsEnemy; List <FightUnit> unitList = isEnemyDie ? EnemyFighters[CurRound - 1] : Fighters; bool allUnitDie = true; for (int idx = 0; idx < unitList.Count; ++idx) { if (!unitList[idx].IsDead) { allUnitDie = false; break; } } if (allUnitDie) { for (int idx = 0; idx < AllFighters.Count; ++idx) { FightUnit fightUnit = AllFighters[idx]; if (fightUnit.IsSummon) { ZEventSystem.Dispatch(EventConst.ForceDestroyView, fightUnit); } fightUnit.SystemProtect = true; } if (isEnemyDie) { //敌人死光了 for (int idx = 0; idx < AllFighters.Count; ++idx) { FightUnit u = AllFighters[idx]; if (u.IsDead) { continue; } } if (CurRound < TotalRound) { State = FightState.Continue; } else { //战斗胜利 _terminate(true); } } else { //自己死光了 _terminate(false); } } //宝箱掉落 if (Treasures > 0) { if (isEnemyDie) { if (allUnitDie && CurRound >= TotalRound) { this.DropMgrObj.CreateTreasure(unit.CurPos, Treasures); Treasures = 0; } else { if (Random.Range(0, 1.0f) < this.DropMgrObj.TreasureRate) { this.DropMgrObj.CreateTreasure(unit.CurPos, 1); --Treasures; } } } } }
/// <summary> /// 开始一场战斗 /// </summary> /// <param name="isPvp">比赛性质,pve还是pvp</param> /// <param name="treasures">宝箱数量</param> public void CreateFight(bool isPvp, int treasures = 0) { this.State = FightState.Init; if (this.Fighters == null) { EDebug.LogError("FightLogic.CreateFight failed, fighters is null"); return; } if (this.EnemyFighters == null) { EDebug.LogError("FightLogic.CreateFight failed, fighters is null"); return; } if (this.Fighters.Count == 0) { EDebug.LogError("FightLogic.CreateFight failed, fighters is empty"); return; } if (this.EnemyFighters.Count == 0) { EDebug.LogError("FightLogic.CreateFight failed, enemyFighters is empty"); return; } this.TotalRound = this.EnemyFighters.Count; this.CurRound = 0; this.IsPvp = isPvp; this.Treasures = treasures; this.DropMgrObj = new DropMgr(); aStarFinder = new AStarFinder(PathFinder.V_GRID, (this.TotalRound * 3 + 1) * PathFinder.H_GRID); List <FightUnit> allUnit = new List <FightUnit>(); for (int idx = 0; idx < Fighters.Count; ++idx) { allUnit.Add(Fighters[idx]); } for (int idx = 0; idx < EnemyFighters.Count; ++idx) { for (int idx2 = 0; idx2 < EnemyFighters[idx].Count; ++idx2) { allUnit.Add(EnemyFighters[idx][idx2]); } } for (int idx = 0; idx < allUnit.Count; ++idx) { allUnit[idx].UID = ++UID; } ZEventSystem.Dispatch(EventConst.OnCreateFight, allUnit); //Test~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int idx = 0; idx < Fighters.Count; ++idx) { FightUnit unit = Fighters[idx]; _createFightUnitView(unit); } MapMgr.Instance.CreateFightMap(1, TotalRound); CamMgrObj = GameObject.Find("Main Camera").GetComponent <CamMgr>(); //EndTest~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //注册事件 ZEventSystem.Register(EventConst.OnFightUnitDie, this, "OnUnitDie"); ZEventSystem.Register(EventConst.OnFightStateChange, this, "OnFightStateChange"); ZEventSystem.Register(EventConst.OnRequestUnitPause, this, "OnRequestUnitPause"); ZEventSystem.Register(EventConst.OnFightMaskOver, this, "OnFightMaskOver"); ZEventSystem.Register(EventConst.OnGamePause, this, "OnGamePause"); //CamMgrObj.StartDissolve(); CamMgrObj.PlayStartEffect(); NextRound(); ProcessCtrl.Instance.AddUpdate(this); }
/// <summary> /// 通关某一阶段后 /// </summary> /// <param name="s"></param> public void PassStage(int s) { int num = 0; int LevelId = 0; LevelViews levelvise = null; string[] ids = new string[5]; for (int i = 0; i < BattleMgr.Instance.LevelID.ToString().Length; i++) { ids[i] = BattleMgr.Instance.LevelID.ToString()[i].ToString(); } int typr = int.Parse(ids[0]) - 1; int Chapter = int.Parse(ids[1] + ids[2]) - 1; for (int i = 0; i < BattleMgr.Instance.Genlevel[typr][Chapter].GenStage.Count; i++) { if (BattleMgr.Instance.Genlevel[typr][Chapter].GenStage[i].LevelID == BattleMgr.Instance.LevelID) { num = BattleMgr.Instance.Genlevel[typr][Chapter].GenStage[i].StarCount; levelvise = BattleMgr.Instance.Genlevel[typr][Chapter].GenStage[i]; break; } } if (levelvise == null) { return; } if (levelvise.ResidueTime > 0) { levelvise.ResidueTime--; } if (levelvise.StarCount < 3) { if (levelvise.isZeki) { if (levelvise.StarCount < 3 && s > levelvise.StarCount) { s = s - levelvise.StarCount; } else { // arroParent_obj.SetActive(true); // CustomsPass_obj.SetActive(false); CloseCustoms(); return; } levelvise.StarCount = s + levelvise.StarCount; if (levelvise.StarCount > 3) { levelvise.StarCount = 3; } Genlevel[BattleMgr.Instance.LevelID].transform.Find("pentagon").GetComponent <StarView>().SetStar(levelvise.StarCount); BattleMgr.Instance.Genlevel[int.Parse(ids[0].ToString()) - 1][int.Parse((ids[1].ToString() + ids[2].ToString())) - 1].StarCount += s; InitStar(int.Parse(ids[0].ToString()) - 1, int.Parse((ids[1].ToString() + ids[2].ToString())) - 1); } else { Genlevel[BattleMgr.Instance.LevelID].CloseBtn.enabled = false; } if (isPass != SectionState.Pass && num == 0) { switch (BattleMgr.Instance.SectionKey) { case 0: BattleMgr.Instance.NowLevelId = BattleMgr.Instance.NowLevelId + 1; Indicate(Genlevel[BattleMgr.Instance.NowLevelId]); Genlevel[BattleMgr.Instance.NowLevelId].CloseBtn.enabled = true; break; case 1: BattleMgr.Instance.EliteLevelId = BattleMgr.Instance.EliteLevelId + 1; Indicate(Genlevel[BattleMgr.Instance.EliteLevelId]); Genlevel[BattleMgr.Instance.EliteLevelId].CloseBtn.enabled = true; break; case 2: BattleMgr.Instance.EpicLevelId = BattleMgr.Instance.EpicLevelId + 1; Indicate(Genlevel[BattleMgr.Instance.EpicLevelId]); Genlevel[BattleMgr.Instance.EpicLevelId].CloseBtn.enabled = true; break; } } else if (num == 0) { if (int.Parse(KeyChapter[1] + KeyChapter[2]) + 1 > BattleMgr.Instance.Genlevel[BattleMgr.Instance.SectionKey].Count) { return; } SectionPass(int.Parse(KeyChapter[0]) - 1, int.Parse(KeyChapter[1] + KeyChapter[2])); ZEventSystem.Dispatch(EventConst.OpLevel, int.Parse(KeyChapter[0]) - 1, int.Parse(KeyChapter[1] + KeyChapter[2]), 0);// 执行从其他界面进去章节 LevelId = int.Parse(String.Concat(((int.Parse(KeyChapter[0])) * 100 + (int.Parse(KeyChapter[1] + KeyChapter[2]) + 1)).ToString(), "01")); switch (int.Parse(KeyChapter[0]) - 1) { case 0: BattleMgr.Instance.NowLevelId = LevelId; break; case 1: BattleMgr.Instance.EliteLevelId = LevelId; break; case 2: BattleMgr.Instance.EpicLevelId = LevelId; break; } Genlevel[LevelId].CloseBtn.enabled = true; Indicate(Genlevel[LevelId]); } // arroParent_obj.SetActive(true); //CustomsPass_obj.SetActive(false); CloseCustoms(); } else { CloseCustoms(); // CustomsPass_obj.SetActive(false); } }
public void OnMain(ServerMsgObj msg) { ZEventSystem.Dispatch(EventConst.OnMsgOnMain, msg); }
private void ShowDivination() { showGo = Divination_trf; showGo.SetParent(Right_trf); Divination_obj.SetActive(true); takeoff_btn.gameObject.SetActive(true); take_btn.gameObject.SetActive(true); Dress_btn.gameObject.SetActive(false); Intensify_btn.gameObject.SetActive(false); Equip_obj.SetActive(false); HeroDivinationView hdv = Divination_obj.GetComponent <HeroDivinationView>(); hdv.SetHeroTotemView(heroData); EventListener.Get(gotoDiv_btn.gameObject).OnClick = e => { UIFace.GetSingleton().Open(UIID.Divination); }; int count = divparent_trf.childCount; TotemData[] mData = TotemMgr.GetSingleton().GetUnDressTotem(); while (count > mData.Length) { DestroyImmediate(divparent_trf.GetChild(0).gameObject); count = divparent_trf.childCount; } for (int i = 0; i < mData.Length; ++i) { TotemData data = mData[i]; if (data.HeroID != 0) { continue; } GameObject totem; if (i < count) { totem = divparent_trf.GetChild(i).gameObject; } else { totem = Instantiate(totemGo, divparent_trf); } DivinationItemView div = totem.GetComponent <DivinationItemView>(); div.SetView(data); EventListener.Get(totem).OnClick = e => { ZEventSystem.Register(EventConst.TAKETOTEM, this, "TakeTotem"); UIFace.GetSingleton().Open(UIID.DivinationTip, data, SHOWBUTTON.Etake); }; EventListener.Get(totem).BegineDragEvent = e => { divination_sr.OnBeginDrag(e); }; EventListener.Get(totem).DragEvent = e => { divination_sr.OnDrag(e); }; EventListener.Get(totem).EndDragEvent = e => { divination_sr.OnEndDrag(e); }; } Vector2 size = divination_sr.content.sizeDelta; size.y = Mathf.CeilToInt(mData.Length / 3f) * 159 + 26; divination_sr.content.sizeDelta = size; EventListener.Get(take_btn.gameObject).OnClick = e => { if (mData.Length <= 0) { return; } int index = mData.Length - 1; TotemData[] totems = heroData.GetTotem(); if (totems.Length == 0) { CanvasView.Instance.AddNotice("没有可用的气运槽"); return; } for (int i = 0, length = totems.Length; i < length; ++i) { TotemMgr.GetSingleton().TakeTotem(mData[i], heroData); } ShowSide(false); }; EventListener.Get(takeoff_btn.gameObject).OnClick = e => { TotemData[] totems = heroData.GetTotem(); for (int i = 0, length = totems.Length; i < length; ++i) { if (totems[i] == null) { continue; } TotemMgr.GetSingleton().TakeOffTotem(totems[i]); } ShowSide(false); }; }