public void Clear() { //反注册事件 clearFightState(true); ZEventSystem.DeRegister(EventConst.OnFightUnitDie, this); ZEventSystem.DeRegister(EventConst.OnFightStateChange, this); ZEventSystem.DeRegister(EventConst.OnUnitMoveOver, this); ZEventSystem.DeRegister(EventConst.OnRequestUnitPause, this); ZEventSystem.DeRegister(EventConst.OnFightMaskOver, this); ZEventSystem.DeRegister(EventConst.OnGamePause, this); ProcessCtrl.Instance.RemoveUpdate(this); Fighters.Clear(); EnemyFighters.Clear(); AllFighters.Clear(); if (aStarFinder != null) { aStarFinder.Clear(); } if (BulletMgrObj != null) { BulletMgrObj.Clear(); } MapMgr.Instance.Clear(); EffectMgr.Instance.Clear(); DropMgrObj = null; CamMgrObj = null; Time.timeScale = 1; IsAutoFight = false; UID = 0; }
private static int GetDropCondiction(eDropType type, string para1, string para2) { int result; try { int dropId = DropMgr.FindCondiction(type, para1, para2); result = dropId; return(result); } catch (Exception ex) { //if (DropInventory.log.IsErrorEnabled) { DropInventory.log.Error(string.Concat(new object[] { "Drop Error:", type, " @ ", ex })); } } result = 0; return(result); }
public static bool VIPRewardDrop(int level, ref List <ItemInfo> info) { int dropId = DropInventory.GetDropCondiction(eDropType.VIP, level.ToString(), "1"); bool result; if (dropId > 0) { List <DropItem> unFiltItems = DropMgr.FindDropItem(dropId); for (int i = 0; i < unFiltItems.Count; i++) { int itemCount = DropInventory.random.Next(unFiltItems[i].BeginData, unFiltItems[i].EndData); ItemTemplateInfo temp = ItemMgr.FindItemTemplate(unFiltItems[i].ItemId); ItemInfo item = ItemInfo.CreateFromTemplate(temp, itemCount, level); if (item != null) { item.IsBinds = unFiltItems[i].IsBind; item.ValidDate = unFiltItems[i].ValueDate; item.IsTips = unFiltItems[i].IsTips; item.IsLogs = unFiltItems[i].IsLogs; if (info == null) { info = new List <ItemInfo>(); } info.Add(item); } } result = true; } else { result = false; } return(result); }
private static int GetDropCondiction(eDropType type, string para1, string para2) { try { return(DropMgr.FindCondiction(type, para1, para2)); } catch (Exception ex) { if (DropInventory.log.IsErrorEnabled) { DropInventory.log.Error(string.Concat(new object[] { "Drop Error:", type, " @ ", ex })); } } return(0); }
public override bool Start() { if (m_isRunning) { return(false); } try { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Thread.CurrentThread.Priority = ThreadPriority.Normal; GameProperties.Refresh(); if (!InitComponent(RecompileScripts(), "Recompile Scripts")) { return(false); } if (!InitComponent(StartScriptComponents(), "Script components")) { return(false); } if (!InitComponent((GameProperties.EDITION == Edition), "Edition:" + Edition)) { return(false); } if (!InitComponent(InitSocket(IPAddress.Parse(Configuration.Ip), Configuration.Port), "InitSocket Port:" + Configuration.Port)) { return(false); } if (!InitComponent(AllocatePacketBuffers(), "AllocatePacketBuffers()")) { return(false); } if (!InitComponent(LogMgr.Setup(Configuration.GAME_TYPE, Configuration.ServerID, Configuration.AreaID), "LogMgr Init")) { return(false); } if (!InitComponent(WorldMgr.Init(), "WorldMgr Init")) { return(false); } if (!InitComponent(MapMgr.Init(), "MapMgr Init")) { return(false); } if (!InitComponent(ItemMgr.Init(), "ItemMgr Init")) { return(false); } if (!InitComponent(ItemBoxMgr.Init(), "ItemBox Init")) { return(false); } if (!InitComponent(BallMgr.Init(), "BallMgr Init")) { return(false); } if (!InitComponent(BallConfigMgr.Init(), "BallConfigMgr Init")) { return(false); } if (!InitComponent(FusionMgr.Init(), "FusionMgr Init")) { return(false); } if (!InitComponent(AwardMgr.Init(), "AwardMgr Init")) { return(false); } if (!InitComponent(NPCInfoMgr.Init(), "NPCInfoMgr Init")) { return(false); } if (!InitComponent(MissionInfoMgr.Init(), "MissionInfoMgr Init")) { return(false); } if (!InitComponent(PveInfoMgr.Init(), "PveInfoMgr Init")) { return(false); } if (!InitComponent(DropMgr.Init(), "Drop Init")) { return(false); } if (!InitComponent(FightRateMgr.Init(), "FightRateMgr Init")) { return(false); } if (!InitComponent(ConsortiaLevelMgr.Init(), "ConsortiaLevelMgr Init")) { return(false); } if (!InitComponent(RefineryMgr.Init(), "RefineryMgr Init")) { return(false); } if (!InitComponent(StrengthenMgr.Init(), "StrengthenMgr Init")) { return(false); } if (!InitComponent(PropItemMgr.Init(), "PropItemMgr Init")) { return(false); } if (!InitComponent(ShopMgr.Init(), "ShopMgr Init")) { return(false); } if (!InitComponent(QuestMgr.Init(), "QuestMgr Init")) { return(false); } if (!InitComponent(RoomMgr.Setup(Configuration.MaxRoomCount), "RoomMgr.Setup")) { return(false); } if (!InitComponent(GameMgr.Setup(Configuration.ServerID, GameProperties.BOX_APPEAR_CONDITION), "GameMgr.Start()")) { return(false); } if (!InitComponent(ConsortiaMgr.Init(), "ConsortiaMgr Init")) { return(false); } if (!InitComponent(LanguageMgr.Setup(@""), "LanguageMgr Init")) { return(false); } if (!InitComponent(RateMgr.Init(Configuration), "ExperienceRateMgr Init")) { return(false); } if (!InitComponent(MacroDropMgr.Init(), "MacroDropMgr Init")) { return(false); } if (!InitComponent(BattleMgr.Setup(), "BattleMgr Setup")) { return(false); } if (!InitComponent(InitGlobalTimer(), "Init Global Timers")) { return(false); } if (!InitComponent(MarryRoomMgr.Init(), "MarryRoomMgr Init")) { return(false); } if (!InitComponent(LogMgr.Setup(1, 4, 4), "LogMgr Setup")) { return(false); } GameEventMgr.Notify(ScriptEvent.Loaded); if (!InitComponent(InitLoginServer(), "Login To CenterServer")) { return(false); } RoomMgr.Start(); GameMgr.Start(); BattleMgr.Start(); MacroDropMgr.Start(); if (!InitComponent(base.Start(), "base.Start()")) { return(false); } GameEventMgr.Notify(GameServerEvent.Started, this); GC.Collect(GC.MaxGeneration); if (log.IsInfoEnabled) { log.Info("GameServer is now open for connections!"); } m_isRunning = true; return(true); } catch (Exception e) { if (log.IsErrorEnabled) { log.Error("Failed to start the server", e); } return(false); } }
public override bool Start() { bool result; try { LogProvider.Default = new LogProvider(new LogConfig { FilePath = "./log/fight/", UseConsole = true, UseFile = true }); this.m_running = true; Thread.CurrentThread.Priority = ThreadPriority.Normal; AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.CurrentDomain_UnhandledException); CrossFightServer.log.Warn("正在初始化…………"); if (!Sql_DbObject.TryConnection()) { result = false; CrossFightServer.log.Error("数据库连接失败,请检查!"); return(result); } CrossFightServer.log.Info("数据库连接成功!"); if (!this.InitSocket(IPAddress.Parse(this.m_config.IP), this.m_config.Port)) { result = false; CrossFightServer.log.Error("初始化监听端口失败,请检查!"); return(result); } CrossFightServer.log.Info("初始化监听端口成功!"); if (!MapMgr.Init()) { result = false; CrossFightServer.log.Error("初始化地图失败,请检查!"); return(result); } CrossFightServer.log.Info("初始化地图成功!"); if (!ItemMgr.Init()) { result = false; CrossFightServer.log.Error("初始化物品失败,请检查!"); return(result); } CrossFightServer.log.Info("初始化物品成功!"); if (!PropItemMgr.Init()) { result = false; CrossFightServer.log.Error("初始化道具失败,请检查!"); return(result); } CrossFightServer.log.Info("初始化道具成功!"); if (!BallMgr.Init()) { result = false; CrossFightServer.log.Error("初始化炸弹失败,请检查!"); return(result); } CrossFightServer.log.Info("初始化炸弹成功!"); if (!DropMgr.Init()) { result = false; CrossFightServer.log.Error("初始化掉落失败,请检查!"); return(result); } CrossFightServer.log.Info("初始化掉落成功!"); if (!NPCInfoMgr.Init()) { result = false; CrossFightServer.log.Error("初始化npc失败,请检查!"); return(result); } CrossFightServer.log.Info("初始化npc成功!"); if (!LanguageMgr.Load()) { result = false; CrossFightServer.log.Error("初始化语言包失败,请检查!"); return(result); } CrossFightServer.log.Info("初始化语言包成功!"); if (!base.Start()) { result = false; CrossFightServer.log.Error("基础服务启动失败,请检查!"); return(result); } CrossFightServer.log.Info("基础服务启动成功!"); if (!ProxyRoomMgr.Setup()) { result = false; CrossFightServer.log.Error("启动房间管理服务失败,请检查!"); return(result); } ProxyRoomMgr.Start(); CrossFightServer.log.Info("启动房间管理服务成功!"); if (!GameMgr.Setup(0, 4)) { result = false; CrossFightServer.log.Error("启动游戏管理服务失败,请检查!"); return(result); } GameMgr.Start(); StartScriptComponents(); GameEventMgr.Notify(ScriptEvent.Loaded); CrossFightServer.log.Info("启动游戏管理服务成功!"); GC.Collect(GC.MaxGeneration); CrossFightServer.log.Warn("战斗服务器已启动!"); result = true; } catch (Exception e) { CrossFightServer.log.Error("Failed to start the server", e); result = false; } return(result); }
public override bool Start() { if (m_running) { return(false); } try { m_running = true; Thread.CurrentThread.Priority = ThreadPriority.Normal; AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); //初始化监听端口 if (!InitComponent(InitSocket(m_config.Ip, m_config.Port), "InitSocket Port:" + m_config.Port)) { return(false); } //初始化脚本 if (!InitComponent(StartScriptComponents(), "Script components")) { return(false); } if (!InitComponent(ProxyRoomMgr.Setup(), "RoomMgr.Setup")) { return(false); } if (!InitComponent(GameMgr.Setup(0, 4), "GameMgr.Setup")) { return(false); } if (!InitComponent(MapMgr.Init(), "MapMgr Init")) { return(false); } if (!InitComponent(ItemMgr.Init(), "ItemMgr Init")) { return(false); } if (!InitComponent(PropItemMgr.Init(), "ItemMgr Init")) { return(false); } //if (!InitComponent(VaneMgr.ByteAray(), "VaneMgr ByteAray")) // return false; if (!InitComponent(BallMgr.Init(), "BallMgr Init")) { return(false); } if (!InitComponent(BallConfigMgr.Init(), "BallConfigMgr Init")) { return(false); } if (!InitComponent(DropMgr.Init(), "DropMgr Init")) { return(false); } if (!InitComponent(NPCInfoMgr.Init(), "NPCInfoMgr Init")) { return(false); } if (!InitComponent(LanguageMgr.Setup(@""), "LanguageMgr Init")) { return(false); } //发布脚本已加载事件 GameEventMgr.Notify(ScriptEvent.Loaded); if (!InitComponent(base.Start(), "base.Start()")) { return(false); } ProxyRoomMgr.Start(); GameMgr.Start(); //发布服务器开始事件 GameEventMgr.Notify(GameServerEvent.Started, this); GC.Collect(GC.MaxGeneration); log.Info("GameServer is now open for connections!"); return(true); } catch (Exception e) { log.Error("Failed to start the server", e); return(false); } }
public void Init() { DropMgr.Init(); }
public override bool Start() { if (this.m_running) { return(false); } bool result; try { this.m_running = true; Thread.CurrentThread.Priority = ThreadPriority.Normal; AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.CurrentDomain_UnhandledException); if (!this.InitComponent(this.InitSocket(this.m_config.Ip, this.m_config.Port), "InitSocket Port:" + this.m_config.Port)) { result = false; } else { if (!this.InitComponent(this.StartScriptComponents(), "Script components")) { result = false; } else { if (!this.InitComponent(ProxyRoomMgr.Setup(), "RoomMgr.Setup")) { result = false; } else { if (!this.InitComponent(GameMgr.Setup(0, 4), "GameMgr.Setup")) { result = false; } else { if (!this.InitComponent(MapMgr.Init(), "MapMgr Init")) { result = false; } else { if (!this.InitComponent(ItemMgr.Init(), "ItemMgr Init")) { result = false; } else { if (!this.InitComponent(PropItemMgr.Init(), "PropItemMgr Init")) { result = false; } else { if (!this.InitComponent(BallMgr.Init(), "BallMgr Init")) { result = false; } else { if (!this.InitComponent(BallConfigMgr.Init(), "BallConfigMgr Init")) { result = false; } else { if (!this.InitComponent(DropMgr.Init(), "DropMgr Init")) { result = false; } else { if (!this.InitComponent(NPCInfoMgr.Init(), "NPCInfoMgr Init")) { result = false; } else { if (!this.InitComponent(WindMgr.Init(), "WindMgr Init")) { result = false; } else { if (!this.InitComponent(GoldEquipMgr.Init(), "GoldEquipMgr Init")) { result = false; } else { if (!this.InitComponent(LanguageMgr.Setup(""), "LanguageMgr Init")) { result = false; } else { GameEventMgr.Notify(ScriptEvent.Loaded); if (!this.InitComponent(base.Start(), "base.Start()")) { result = false; } else { ProxyRoomMgr.Start(); GameMgr.Start(); GameEventMgr.Notify(GameServerEvent.Started, this); GC.Collect(GC.MaxGeneration); FightServer.log.Info("GameServer is now open for connections!"); result = true; } } } } } } } } } } } } } } } } catch (Exception exception) { FightServer.log.Error("Failed to start the server", exception); result = false; } return(result); }
private static bool GetDropItems(eDropType type, int dropId, ref List <ItemInfo> itemInfos) { if (dropId == 0) { return(false); } try { int num = 1; List <DropItem> source = DropMgr.FindDropItem(dropId); int maxRound = ThreadSafeRandom.NextStatic(( from s in source select s.Random).Max()); List <DropItem> list = ( from s in source where s.Random >= maxRound select s).ToList <DropItem>(); int num2 = list.Count <DropItem>(); bool result; if (num2 == 0) { result = false; return(result); } num = ((num > num2) ? num2 : num); int[] randomUnrepeatArray = DropInventory.GetRandomUnrepeatArray(0, num2 - 1, num); int[] array = randomUnrepeatArray; for (int i = 0; i < array.Length; i++) { int index = array[i]; int count = ThreadSafeRandom.NextStatic(list[index].BeginData, list[index].EndData); ItemTemplateInfo itemTemplateInfo = ItemMgr.FindItemTemplate(list[index].ItemId); ItemInfo itemInfo = ItemInfo.CreateFromTemplate(itemTemplateInfo, count, 101); if (itemInfo != null) { itemInfo.IsBinds = list[index].IsBind; itemInfo.ValidDate = list[index].ValueDate; if (itemInfos == null) { itemInfos = new List <ItemInfo>(); } if (DropInfoMgr.CanDrop(itemTemplateInfo.TemplateID)) { itemInfos.Add(itemInfo); } } } result = true; return(result); } catch (Exception ex) { if (DropInventory.log.IsErrorEnabled) { DropInventory.log.Error(string.Concat(new object[] { "Drop Error:", type, " @ ", ex })); } } return(false); }
/// <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); }
private void Init(Object sender, EventArgs e) { LogProvider.Default = new LogProvider(new LogConfig { UseMessageBox = true, LogView = LogView, UseLogView = true, FilePath = @".\log\", UseFile = true }); var log = LogProvider.Default; this.runmgr = new RunMgr(); Web.Server.WebServer.Runmgr = this.runmgr; new Thread(() => { if (!Sql_DbObject.TryConnection()) { log.Error("Fail to connect to SQL!"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to to connect to SQL!"); } if (!LanguageMgr.Load()) { log.Error("Fail to load language"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to load language"); } if (!MapMgr.Init()) { log.Error("Fail to load map"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to load map"); } if (!ItemMgr.Init()) { log.Error("Fail to load item"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to load item"); } if (!PropItemMgr.Init()) { log.Error("Fail to load propitem"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to load propitem"); } if (!BallMgr.Init()) { log.Error("Fail to load ball"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to load ball"); } if (!DropMgr.Init()) { log.Error("Fail to load drop"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to load drop"); } if (!NPCInfoMgr.Init()) { log.Error("Fail to load npc"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to load npc"); } if (!ItemBoxMgr.Init()) { log.Error("Fail to load itembox"); WinForm.Notice("初始化失败,请查看日志。"); return; } else { log.Info("Succeed to load itembox"); } flag = true; }).Start(); Thread thread = new Thread(run); thread.Start(); }
private static bool GetDropItems(eDropType type, int dropId, ref List <ItemInfo> itemInfos) { bool result; if (dropId == 0) { result = false; } else { try { int dropItemCount = 1; List <DropItem> unFiltItems = DropMgr.FindDropItem(dropId); int maxRound = DropInventory.random.Next(( from s in unFiltItems select s.Random).Max()); List <DropItem> filtItems = ( from s in unFiltItems where s.Random >= maxRound select s).ToList <DropItem>(); int maxItems = filtItems.Count <DropItem>(); if (maxItems == 0) { result = false; return(result); } dropItemCount = ((dropItemCount > maxItems) ? maxItems : dropItemCount); int[] randomArray = DropInventory.GetRandomUnrepeatArray(0, maxItems - 1, dropItemCount); int[] array = randomArray; for (int j = 0; j < array.Length; j++) { int i = array[j]; int itemCount = DropInventory.random.Next(filtItems[i].BeginData, filtItems[i].EndData); ItemTemplateInfo temp = ItemMgr.FindItemTemplate(filtItems[i].ItemId); ItemInfo item = ItemInfo.CreateFromTemplate(temp, itemCount, 101); if (item != null) { item.IsBinds = filtItems[i].IsBind; item.ValidDate = filtItems[i].ValueDate; item.IsTips = filtItems[i].IsTips; item.IsLogs = filtItems[i].IsLogs; if (itemInfos == null) { itemInfos = new List <ItemInfo>(); } switch (type) { case eDropType.Cards: case eDropType.Box: case eDropType.NPC: case eDropType.Boss: case eDropType.Special: if (DropInfoMgr.CanDrop(temp.TemplateID)) { itemInfos.Add(item); } break; default: itemInfos.Add(item); break; } } } if (itemInfos != null && itemInfos.Count > 0) { result = true; return(result); } } catch (Exception ex) { //if (DropInventory.log.IsErrorEnabled) { DropInventory.log.Error(string.Concat(new object[] { "Drop Error:", type, " @ ", ex })); } } result = false; } return(result); }