public void BeginNextTurn() { if (CurrentIsHitTarget == true) { TotalHitTargetCount++; } CurrentIsHitTarget = false; m_energy = 240; m_shootCount = 1; m_ballCount = 1; m_flyCoolDown--; CurrentDamagePlus = 1; CurrentShootMinus = 1; if (m_currentBall.ID != m_mainBallId) { m_currentBall = BallMgr.FindBall(m_mainBallId); } if (IsLiving == false) { StartGhostMoving(); TargetPoint = Point.Empty; } }
public override void PrepareNewTurn() { if (this.CurrentIsHitTarget) { this.TotalHitTargetCount++; } this.m_energy = this.m_player.PlayerCharacter.Agility / 30 + 240; this.m_ghostEnergy = (int)((double)this.m_energy * 1.5); this.m_shootCount = 1; this.m_ballCount = 1; this.AttackInformation = true; this.DefenceInformation = true; this.AttackEffectTrigger = false; this.DefenceEffectTrigger = false; this.SetCurrentWeapon(this.PlayerDetail.MainWeapon); if (this.m_currentBall.ID != this.m_mainBallId) { this.m_currentBall = BallMgr.FindBall(this.m_mainBallId); } if (!base.IsLiving) { this.StartGhostMoving(); } base.PrepareNewTurn(); }
public void Reset() { m_maxBlood = (int)((950 + m_player.PlayerCharacter.Grade * 50) * m_player.BaseBlood); if (m_isCaptain) { m_maxBlood *= 2; } m_blood = m_maxBlood; m_dander = 0; m_delay = (int)(1000 * m_player.BaseAgility); m_energy = 240; m_isCaptain = false; m_isFrost = false; m_isHide = false; m_isNoHole = false; m_isLiving = true; m_currentBall = BallMgr.FindBall(m_mainBallId); m_shootCount = 1; m_ballCount = 1; TurnNum = 0; TotalHurt = 0; TotalKill = 0; TotalShootCount = 0; TotalHitTargetCount = 0; GainGP = 0; GainOffer = 0; }
public void Execute(GamePlayer player, ItemInfo item) { //if (player.CurrentGame.Data.CurrentSpell != this) if (player.CurrentGame.Data.CurrentFire == null) { player.CurrentGame.Data.CurrentSpell = this; player.CurrentGame.Data.CurrentPorp = item; //player.CurrentGame.Data.CurrentBall = Bussiness.Managers.BallMgr.FindBall(1); player.CurrentGame.Data.SetCurrentBall(BallMgr.FindBall(1), false); player.CurrentGame.Data.AddAttack = -1; player.CurrentGame.Data.AddBall = 1; } else { if (player.CurrentGame.Data.Players[player].IsFrost == 0) { IceFronzeEffect ice = new IceFronzeEffect(item.Template.Property2); ice.Start(player); } else { player.CurrentGame.Data.Players[player].SetFrost(item.Template.Property2); } } }
public void Execute(GamePlayer player, ItemInfo item) { //if (player.CurrentGame.Data.CurrentSpell != this) if (player.CurrentGame.Data.CurrentFire == null) { player.CurrentGame.Data.CurrentSpell = this; player.CurrentGame.Data.CurrentPorp = item; //player.CurrentGame.Data.CurrentBall = Bussiness.Managers.BallMgr.FindBall(3); player.CurrentGame.Data.SetCurrentBall(BallMgr.FindBall(3), false); player.CurrentGame.Data.AddAttack = -1; player.CurrentGame.Data.AddBall = 1; } else { if (player != player.CurrentGame.Data.CurrentFire) { return; } //player.CurrentGame.Data.Players[player].CarryPoint(); GSPacketIn pkg = player.Out.SendPlayerCarry(player); player.CurrentGame.SendToPlayerExceptSelf(pkg, player); } }
public override void PrepareNewTurn() { if (CurrentIsHitTarget == true) { TotalHitTargetCount++; //Console.WriteLine("TotalHitTargetCount + 1 ------>>>> p.TotalHitTargetCount : {0}", TotalHitTargetCount); } //Game.SendUpdateUiData(this, game); // BufferMgr.BufferList.Clear(); m_energy = m_player.PlayerCharacter.Agility / 30 + 240; m_shootCount = 1; m_ballCount = 1; m_flyCoolDown--; m_secondWeapon--; //if(m_currentBall.ID!=PlayerDetail.MainWeapon) //SetCurrentWeapon(PlayerDetail.MainWeapon); SetCurrentWeapon(PlayerDetail.MainWeapon); if (m_currentBall.ID != m_mainBallId) { m_currentBall = BallMgr.FindBall(m_mainBallId); } if (IsLiving == false) { StartGhostMoving(); TargetPoint = Point.Empty; } base.PrepareNewTurn(); }
public override void PrepareNewTurn() { if (CurrentIsHitTarget == true) { TotalHitTargetCount++; } m_energy = m_player.PlayerCharacter.Agility / 30 + 240; m_shootCount = 1; m_ballCount = 1; m_flyCoolDown--; m_secondWeapon--; SetCurrentWeapon(PlayerDetail.MainWeapon); if (m_currentBall.ID != m_mainBallId) { m_currentBall = BallMgr.FindBall(m_mainBallId); } if (IsLiving == false) { StartGhostMoving(); TargetPoint = Point.Empty; } base.PrepareNewTurn(); }
public void SetBall(int ballId) { if (ballId != m_currentBall.ID) { m_currentBall = BallMgr.FindBall(ballId); GSPacketIn pkg = m_player.Out.SendGameUpdateBall(this); m_game.SendToAll(pkg, m_player); BallCount = m_currentBall.Amount; } }
private void player_AfterPlayerShooted(Player player, int delay) { if (this.m_oldBall != -1) { if (BallMgr.IsExist(this.m_oldBall)) { player.CurrentBall = BallMgr.FindBall(this.m_oldBall); player.Game.SendGameUpdateBall(player, false); this.m_oldBall = -1; } } }
public override void Reset() { m_maxBlood = (int)((950 + m_player.PlayerCharacter.Grade * 50 + LevelPlusBlood + m_player.PlayerCharacter.Defence / 10) * m_player.GetBaseBlood()); if (m_game.RoomType == eRoomType.Treasure || m_game.RoomType == eRoomType.Boss) { m_game.Cards = new int[21]; } else { m_game.Cards = new int[8]; } Dander = 0; m_energy = (m_player.PlayerCharacter.Agility / 30 + 240); IsLiving = true; FinishTakeCard = false; m_weapon = m_player.MainWeapon; //m_mainBallId = m_weapon.Property1; //m_spBallId = m_weapon.Property2; var ballConfig = BallConfigMgr.FindBall(m_weapon.TemplateID); m_mainBallId = ballConfig.Common; m_spBallId = ballConfig.Special; BaseDamage = m_player.GetBaseAttack(); BaseGuard = m_player.GetBaseDefence(); Attack = m_player.PlayerCharacter.Attack; Defence = m_player.PlayerCharacter.Defence; Agility = m_player.PlayerCharacter.Agility; Lucky = m_player.PlayerCharacter.Luck; m_currentBall = BallMgr.FindBall(m_mainBallId); m_shootCount = 1; m_ballCount = 1; CurrentIsHitTarget = false; TotalCure = 0; TotalHitTargetCount = 0; TotalHurt = 0; TotalKill = 0; TotalShootCount = 0; LockDirection = false; GainGP = 0; GainOffer = 0; Ready = false; PlayerDetail.ClearTempBag(); LoadingProcess = 0; base.Reset(); }
public override void Reset() { this.m_maxBlood = this.m_player.PlayerCharacter.hp; if (this.m_game.RoomType == eRoomType.Dungeon) { this.m_game.Cards = new int[21]; } else { this.m_game.Cards = new int[9]; } base.Dander = 0; base.PetMP = 10; base.psychic = 40; this.m_energy = this.m_player.PlayerCharacter.Agility / 30 + 240; base.IsLiving = true; this.FinishTakeCard = false; this.m_DeputyWeapon = this.m_player.SecondWeapon; this.m_weapon = this.m_player.MainWeapon; BallConfigInfo ballConfigInfo = BallConfigMgr.FindBall(this.m_weapon.TemplateID); this.m_mainBallId = ballConfigInfo.Common; this.m_spBallId = ballConfigInfo.Special; this.m_sp2BallId = ballConfigInfo.SpecialII; this.m_AddWoundBallId = ballConfigInfo.CommonAddWound; this.m_MultiBallId = ballConfigInfo.CommonMultiBall; this.BaseDamage = this.m_player.GetBaseAttack(); this.BaseGuard = this.m_player.GetBaseDefence(); this.Attack = (double)this.m_player.PlayerCharacter.Attack; this.Defence = (double)this.m_player.PlayerCharacter.Defence; this.Agility = (double)this.m_player.PlayerCharacter.Agility; this.Lucky = (double)this.m_player.PlayerCharacter.Luck; this.m_currentBall = BallMgr.FindBall(this.m_mainBallId); this.m_shootCount = 1; this.m_ballCount = 1; this.m_prop = 0; this.CurrentIsHitTarget = false; this.TotalCure = 0; this.TotalHitTargetCount = 0; this.TotalHurt = 0; this.TotalKill = 0; this.TotalShootCount = 0; this.LockDirection = false; this.GainGP = 0; this.GainOffer = 0; this.Ready = false; this.PlayerDetail.ClearTempBag(); this.LoadingProcess = 0; this.skillcu = 0; base.Reset(); }
private void ChangeProperty(Player player, int ball) { if (player.CurrentBall.ID != 1 && player.CurrentBall.ID != 3 && player.CurrentBall.ID != 5) { if (AbstractEffect.random.Next(1000000) < this.m_probability * 10000) { player.AttackEffectTrigger = true; player.CurrentBall = BallMgr.FindBall(4); player.Game.SendGameUpdateBall(player, false); this.m_oldBall = ball; player.Game.AddAction(new LivingSayAction(player, LanguageMgr.GetTranslation("AtomBombEquipEffect.msg", new object[0]), 9, 0, 1000)); } } }
public void SetBall(int ballId, bool special) { if (ballId != this.m_currentBall.ID) { if (BallMgr.FindBall(ballId) != null) { this.m_currentBall = BallMgr.FindBall(ballId); } this.BallCount = this.m_currentBall.Amount; if (!special || ballId == 4) { this.ShootCount = 1; } this.m_game.SendGameUpdateBall(this, special); } }
public void GetShootForceAndAngle(ref int x, ref int y, int bombId, int minTime, int maxTime, int bombCount, float time, ref int force, ref int angle) { if (minTime >= maxTime) { return; } BallInfo ballInfo = BallMgr.FindBall(bombId); if (m_game != null && ballInfo != null) { Map map = m_game.Map; Point sp = GetShootPoint(); float dx = x - sp.X; float dy = y - sp.Y; float arf = map.airResistance * ballInfo.DragIndex; float gf = map.gravity * ballInfo.Weight * ballInfo.Mass; float wf = map.wind * ballInfo.Wind; float mass = ballInfo.Mass; for (float t = time; t <= 4; t += 0.6F) { double vx = ComputeVx(dx, mass, arf, wf, t); double vy = ComputeVy(dy, mass, arf, gf, t); if (vy < 0 && vx * m_direction > 0) { double tf = Math.Sqrt(vx * vx + vy * vy); if (tf < 2000) { //Console.WriteLine(string.Format("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< vx:{0} vy:{1}", vx, vy)); force = (int)tf; angle = (int)(Math.Atan(vy / vx) / Math.PI * 180); if (vx < 0) { angle = angle + 180; } break; } } } x = sp.X; y = sp.Y; } }
public override void Reset() { this.m_maxBlood = (int)((double)(950 + this.m_player.PlayerCharacter.Grade * 50 + this.LevelPlusBlood + this.m_player.PlayerCharacter.Defence / 10) * this.m_player.GetBaseBlood()); this.HasPaymentTakeCard = false; base.Dander = 0; this.m_energy = this.m_player.PlayerCharacter.Agility / 30 + 240; this.m_ghostEnergy = this.m_energy; base.IsLiving = true; this.FinishTakeCard = false; this.m_weapon = this.m_player.MainWeapon; this.m_mainBallId = this.m_weapon.Property1; this.m_spBallId = this.m_weapon.Property2; this.BaseDamage = this.m_player.GetBaseAttack(); this.BaseGuard = this.m_player.GetBaseDefence(); this.Attack = (double)this.m_player.PlayerCharacter.Attack; this.Defence = (double)this.m_player.PlayerCharacter.Defence; this.Agility = (double)this.m_player.PlayerCharacter.Agility; this.Lucky = (double)this.m_player.PlayerCharacter.Luck; this.InitBuffer(this.m_player.EquipEffect); this.m_currentBall = BallMgr.FindBall(this.m_mainBallId); this.m_shootCount = 1; this.m_ballCount = 1; this.CurrentIsHitTarget = false; this.m_killedPunishmentOffer = 0; this.TotalCure = 0; this.TotalHitTargetCount = 0; this.TotalHurt = 0; this.TotalKill = 0; this.TotalShootCount = 0; this.LockDirection = false; this.GainGP = 0; this.GainOffer = 0; this.Ready = false; this.PlayerDetail.ClearTempBag(); this.m_delay = this.GetInitDelay(); this.TargetPoint = Point.Empty; this.m_flyCoolDown = 0; this.m_secondWeapon = 0; if (this.PlayerDetail.SecondWeapon != null) { this.AngelCount = this.PlayerDetail.SecondWeapon.StrengthenLevel + 1; } base.Reset(); }
public void GetShootForceAndAngle(ref int x, ref int y, int bombId, int minTime, int maxTime, int bombCount, float time, ref int force, ref int angle) { if (minTime >= maxTime) { return; } BallInfo ballInfo = BallMgr.FindBall(bombId); if (this.m_game != null && ballInfo != null) { Map map = this.m_game.Map; Point shootPoint = this.GetShootPoint(); float num = (float)(x - shootPoint.X); float num2 = (float)(y - shootPoint.Y); float af = map.airResistance * (float)ballInfo.DragIndex; float f = map.gravity * (float)ballInfo.Weight * (float)ballInfo.Mass; float f2 = map.wind * (float)ballInfo.Wind; float m = (float)ballInfo.Mass; for (float num3 = time; num3 <= 4f; num3 += 0.6f) { double num4 = Living.ComputeVx((double)num, m, af, f2, num3); double num5 = Living.ComputeVy((double)num2, m, af, f, num3); if (num5 < 0.0 && num4 * (double)this.m_direction > 0.0) { double num6 = Math.Sqrt(num4 * num4 + num5 * num5); if (num6 < 2000.0) { force = (int)num6; angle = (int)(Math.Atan(num5 / num4) / 3.1415926535897931 * 180.0); if (num4 < 0.0) { angle += 180; break; } break; } } } x = shootPoint.X; y = shootPoint.Y; } }
public void GetShootForceAndAngle(ref int x, ref int y, int bombId, int minTime, int maxTime, int bombCount, float time, ref int force, ref int angle) { if (minTime < maxTime) { BallInfo ballInfo = BallMgr.FindBall(bombId); if (this.m_game != null && ballInfo != null) { Map map = this.m_game.Map; Point sp = this.GetShootPoint(); float dx = (float)(x - sp.X); float dy = (float)(y - sp.Y); float arf = map.airResistance * (float)ballInfo.DragIndex; float gf = map.gravity * (float)ballInfo.Weight * (float)ballInfo.Mass; float wf = map.wind * (float)ballInfo.Wind; float mass = (float)ballInfo.Mass; for (float t = time; t <= 4f; t += 0.6f) { double vx = Living.ComputeVx((double)dx, mass, arf, wf, t); double vy = Living.ComputeVy((double)dy, mass, arf, gf, t); if (vy < 0.0 && vx * (double)this.m_direction > 0.0) { double tf = Math.Sqrt(vx * vx + vy * vy); if (tf < 2000.0) { force = (int)tf; angle = (int)(Math.Atan(vy / vx) / 3.1415926535897931 * 180.0); if (vx < 0.0) { angle += 180; } break; } } } x = sp.X; y = sp.Y; } } }
public override void PrepareNewTurn() { if (this.CurrentIsHitTarget) { this.TotalHitTargetCount++; } this.m_energy = this.m_player.PlayerCharacter.Agility / 30 + 240; this.m_shootCount = 1; this.m_ballCount = 1; this.m_flyCoolDown--; this.SetCurrentWeapon(this.PlayerDetail.MainWeapon); if (this.m_currentBall.ID != this.m_mainBallId) { this.m_currentBall = BallMgr.FindBall(this.m_mainBallId); } if (!base.IsLiving) { this.StartGhostMoving(); this.TargetPoint = Point.Empty; } base.PrepareNewTurn(); }
public void Execute(GamePlayer player, ItemInfo item) { if (player.CurrentGame.Data.CurrentFire == null) { player.CurrentGame.Data.CurrentSpell = this; player.CurrentGame.Data.CurrentPorp = item; player.CurrentGame.Data.SetCurrentBall(BallMgr.FindBall(4), false); } //else //{ // if (player.CurrentGame.Data.Players[player].IsFrost == 0) // { // IceFronzeEffect ice = new IceFronzeEffect(item.Template.Property2); // ice.Start(player); // } // else // { // player.CurrentGame.Data.Players[player].SetFrost(item.Template.Property2); // } //} }
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); }
/// <summary> /// Handles the server action /// </summary> /// <param name="parameters"></param> public void OnAction(Hashtable parameters) { Console.WriteLine("Starting GameServer ... please wait a moment!"); GameServer.CreateInstance(new GameServerConfig()); GameServer.Instance.Start(); GameServer.KeepRunning = true; Console.WriteLine("Server started!"); ConsoleClient client = new ConsoleClient(); while (GameServer.KeepRunning) { try { handler = ConsoleCtrHandler; SetConsoleCtrlHandler(handler, true); Console.Write("> "); string line = Console.ReadLine(); string[] para = line.Split(' '); switch (para[0]) { case "exit": GameServer.KeepRunning = false; break; case "cp": GameClient[] clients = GameServer.Instance.GetAllClients(); int clientCount = clients == null ? 0 : clients.Length; GamePlayer[] players = WorldMgr.GetAllPlayers(); int playerCount = players == null ? 0 : players.Length; List <BaseRoom> rooms = RoomMgr.GetAllUsingRoom(); int roomCount = 0; int gameCount = 0; foreach (BaseRoom r in rooms) { if (!r.IsEmpty) { roomCount++; if (r.IsPlaying) { gameCount++; } } } double memoryCount = GC.GetTotalMemory(false); Console.WriteLine(string.Format("Total Clients/Players:{0}/{1}", clientCount, playerCount)); Console.WriteLine(string.Format("Total Rooms/Games:{0}/{1}", roomCount, gameCount)); Console.WriteLine(string.Format("Total Momey Used:{0} MB", memoryCount / 1024 / 1024)); break; case "shutdown": _count = 6; //_timer = new Timer(new TimerCallback(GameServer.Instance.ShutDownCallBack), null, 0, 60 * 1000); _timer = new Timer(new TimerCallback(ShutDownCallBack), null, 0, 60 * 1000); break; case "savemap": //TODO: break; case "clear": Console.Clear(); break; case "ball&reload": if (BallMgr.ReLoad()) { Console.WriteLine("Ball info is Reload!"); } else { Console.WriteLine("Ball info is Error!"); } break; case "map&reload": if (MapMgr.ReLoadMap()) { Console.WriteLine("Map info is Reload!"); } else { Console.WriteLine("Map info is Error!"); } break; case "mapserver&reload": if (MapMgr.ReLoadMapServer()) { Console.WriteLine("mapserver info is Reload!"); } else { Console.WriteLine("mapserver info is Error!"); } break; case "prop&reload": if (PropItemMgr.Reload()) { Console.WriteLine("prop info is Reload!"); } else { Console.WriteLine("prop info is Error!"); } break; case "item&reload": if (ItemMgr.ReLoad()) { Console.WriteLine("item info is Reload!"); } else { Console.WriteLine("item info is Error!"); } break; case "shop&reload": if (ShopMgr.ReLoad()) { Console.WriteLine("shop info is Reload!"); } else { Console.WriteLine("shop info is Error!"); } break; case "quest&reload": if (QuestMgr.ReLoad()) { Console.WriteLine("quest info is Reload!"); } else { Console.WriteLine("quest info is Error!"); } break; case "fusion&reload": if (FusionMgr.ReLoad()) { Console.WriteLine("fusion info is Reload!"); } else { Console.WriteLine("fusion info is Error!"); } break; case "consortia&reload": if (ConsortiaMgr.ReLoad()) { Console.WriteLine("consortiaMgr info is Reload!"); } else { Console.WriteLine("consortiaMgr info is Error!"); } break; case "rate&reload": if (RateMgr.ReLoad()) { Console.WriteLine("Rate Rate is Reload!"); } else { Console.WriteLine("Rate Rate is Error!"); } break; case "fight&reload": if (FightRateMgr.ReLoad()) { Console.WriteLine("FightRateMgr is Reload!"); } else { Console.WriteLine("FightRateMgr is Error!"); } break; case "dailyaward&reload": if (AwardMgr.ReLoad()) { Console.WriteLine("dailyaward is Reload!"); } else { Console.WriteLine("dailyaward is Error!"); } break; case "language&reload": if (LanguageMgr.Reload("")) { Console.WriteLine("language is Reload!"); } else { Console.WriteLine("language is Error!"); } break; case "nickname": Console.WriteLine("Please enter the nickname"); string nickname = Console.ReadLine(); string state = WorldMgr.GetPlayerStringByPlayerNickName(nickname); Console.WriteLine(state); break; default: if (line.Length <= 0) { break; } if (line[0] == '/') { line = line.Remove(0, 1); line = line.Insert(0, "&"); } try { bool res = CommandMgr.HandleCommandNoPlvl(client, line); if (!res) { Console.WriteLine("Unknown command: " + line); } } catch (Exception e) { Console.WriteLine(e.ToString()); } break; } } catch (Exception ex) { Console.WriteLine(ex); } } if (GameServer.Instance != null) { GameServer.Instance.Stop(); } LogManager.Shutdown(); }
public Orianna() : base("Orianna") { Ball = new BallMgr(); Ball.OnProcessCommand += Ball_OnProcessCommand; }
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 bool ShootImp(int bombId, int x, int y, int force, int angle, int bombCount, int shootCount) { BallInfo ballInfo = BallMgr.FindBall(bombId); Tile shape = BallMgr.FindTile(bombId); BombType ballType = BallMgr.GetBallType(bombId); int _wind = (int)(m_map.wind * 10); if (ballInfo != null)//某些炸弹无图 { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD, Id); pkg.Parameter1 = Id; pkg.WriteByte((byte)eTankCmdType.FIRE); pkg.WriteInt(_wind); pkg.WriteBoolean(_wind > 0); pkg.WriteByte(m_game.GetVane(_wind, 1)); pkg.WriteByte(m_game.GetVane(_wind, 2)); pkg.WriteByte(m_game.GetVane(_wind, 3)); pkg.WriteInt(bombCount); float lifeTime = 0; for (int i = 0; i < bombCount; i++) { double reforce = 1; int reangle = 0; if (i == 1) { reforce = 0.9; reangle = -5; } else if (i == 2) { reforce = 1.1; reangle = 5; } int vx = (int)(force * reforce * Math.Cos((double)(angle + reangle) / 180 * Math.PI)); int vy = (int)(force * reforce * Math.Sin((double)(angle + reangle) / 180 * Math.PI)); SimpleBomb bomb = new SimpleBomb(m_game.PhysicalId++, ballType, this, m_game, ballInfo, shape, ControlBall); bomb.SetXY(x, y); bomb.setSpeedXY(vx, vy); m_map.AddPhysical(bomb); bomb.StartMoving(); pkg.WriteInt(1); //number = _loc_2.readInt(); pkg.WriteInt(1); //shootCount = _loc_2.readInt(); pkg.WriteBoolean(bomb.DigMap); pkg.WriteInt(bomb.Id); pkg.WriteInt(x); pkg.WriteInt(y); pkg.WriteInt(vx); pkg.WriteInt(vy); pkg.WriteInt(bomb.BallInfo.ID); pkg.WriteString(bomb.BallInfo.FlyingPartical); pkg.WriteInt((bomb.BallInfo.Radii * 1000) / 4); //trminhpc pkg.WriteInt((int)bomb.BallInfo.Power * 1000); //trminhpc pkg.WriteInt(bomb.Actions.Count); foreach (BombAction ac in bomb.Actions) { pkg.WriteInt(ac.TimeInt); pkg.WriteInt(ac.Type); pkg.WriteInt(ac.Param1); pkg.WriteInt(ac.Param2); pkg.WriteInt(ac.Param3); pkg.WriteInt(ac.Param4); } lifeTime = Math.Max(lifeTime, bomb.LifeTime); } //pet Attack pkg.WriteInt(0); //foreach (BombAction ac in bombPet.Actions) //{ pkg.WriteInt(1); //_loc_27 = _loc_2.readInt();//target pkg.WriteInt(300); //_loc_29 = _loc_2.readInt//damage pkg.WriteInt(500); //_loc_30 = _loc_2.readInt();//hp pkg.WriteInt(10); //_loc_31 = _loc_2.readInt();//dander //} pkg.WriteInt(102);//_loc_2.readInt();//attackid m_game.SendToAll(pkg); m_game.WaitTime((int)((lifeTime + 2 + bombCount / 3) * 1000)); return(true); } return(false); }
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); }
public bool ShootImp(int bombId, int x, int y, int force, int angle, int bombCount) { BallInfo ballInfo = BallMgr.FindBall(bombId); Tile shape = BallMgr.FindTile(bombId); BombType ballType = BallMgr.GetBallType(bombId); //if (ballInfo != null && shape != null) if (ballInfo != null)//某些炸弹无图 { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD, Id); pkg.Parameter1 = Id; pkg.WriteByte((byte)eTankCmdType.FIRE); pkg.WriteInt(bombCount); float lifeTime = 0; for (int i = 0; i < bombCount; i++) { double reforce = 1; int reangle = 0; if (i == 1) { reforce = 0.9; reangle = -5; } else if (i == 2) { reforce = 1.1; reangle = 5; } int vx = (int)(force * reforce * Math.Cos((double)(angle + reangle) / 180 * Math.PI)); int vy = (int)(force * reforce * Math.Sin((double)(angle + reangle) / 180 * Math.PI)); //Console.WriteLine(string.Format("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< vx:{0} vy:{1}", vx, vy)); SimpleBomb bomb = new SimpleBomb(m_game.PhysicalId++, ballType, this, m_game, ballInfo, shape, ControlBall); bomb.SetXY(x, y); bomb.setSpeedXY(vx, vy); m_map.AddPhysical(bomb); bomb.StartMoving(); pkg.WriteInt(0); pkg.WriteInt(0); pkg.WriteBoolean(bomb.DigMap); pkg.WriteInt(bomb.Id); pkg.WriteInt(x); pkg.WriteInt(y); pkg.WriteInt(vx); pkg.WriteInt(vy); ////FUnny gun //var random = Game.Random.Next(0, 2); //switch (random) //{ // case 0: pkg.WriteInt(51); // break; // case 1: pkg.WriteInt(67); // break; // case 2: pkg.WriteInt(16); // break; //} pkg.WriteInt(bomb.BallInfo.ID); //FlyingPartical //pkg.WriteString(bomb.BallInfo.FlyingPartical); pkg.WriteString(""); pkg.WriteInt(5); pkg.WriteInt(5); //pkg.WriteInt(0); pkg.WriteInt(bomb.Actions.Count); foreach (BombAction ac in bomb.Actions) { pkg.WriteInt((ac.TimeInt != null) ? ac.TimeInt : 0); pkg.WriteInt((ac.Type != null) ? ac.Type : 0); pkg.WriteInt((ac.Param1 != null) ? ac.Param1 : 0); pkg.WriteInt((ac.Param2 != null) ? ac.Param2 : 0); pkg.WriteInt((ac.Param3 != null) ? ac.Param3 : 0); pkg.WriteInt((ac.Param3 != null) ? ac.Param4 : 0); } lifeTime = Math.Max(lifeTime, bomb.LifeTime); } //TrieuLSL //pkg.WriteInt(new Random().Next(50)); pkg.WriteInt(new Random().Next(50)); m_game.SendToAll(pkg); //客户端有爆炸效果,多等待2秒 m_game.WaitTime((int)((lifeTime + 2 + bombCount / 3) * 1000)); return(true); } return(false); }
public void HandleReload(GSPacketIn packet) { eReloadType type = (eReloadType)packet.ReadInt(); bool result = false; switch (type) { case eReloadType.ball: result = BallMgr.ReLoad(); break; case eReloadType.fusion: result = FusionMgr.ReLoad(); break; case eReloadType.item: result = ItemMgr.ReLoad(); break; case eReloadType.map: result = MapMgr.ReLoadMap(); break; case eReloadType.mapserver: result = MapMgr.ReLoadMapServer(); break; case eReloadType.quest: result = QuestMgr.ReLoad(); break; case eReloadType.server: GameServer.Instance.Configuration.Refresh(); break; case eReloadType.rate: result = RateMgr.ReLoad(); break; case eReloadType.fight: result = FightRateMgr.ReLoad(); break; case eReloadType.dailyaward: result = AwardMgr.ReLoad(); break; case eReloadType.language: result = LanguageMgr.Reload(""); break; default: break; case eReloadType.shop: result = ShopMgr.ReLoad(); break; case eReloadType.consortia: result = ConsortiaMgr.ReLoad(); break; //case eReloadType.prop: // result = PropItemMgr.Reload(); // break; } packet.WriteInt(GameServer.Instance.Configuration.ServerID); packet.WriteBoolean(result); SendTCP(packet); }
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 bool HandleCommand(TankGameLogicProcessor process, GamePlayer player, GSPacketIn packet) { if (player.CurrentGame.Data.CurrentIndex == player && player.CurrentGame.Data.Players[player].State != TankGameState.DEAD) { if (player.CurrentGame.Data.CurrentFire == null) { player.CurrentGame.Data.CurrentFire = player; } int x = packet.ReadInt(); int y = packet.ReadInt(); if (Math.Abs(player.CurrentGame.Data.Players[player].X - x) > 100) { //player.Out.SendMessage(eMessageType.ALERT, LanguageMgr.GetTranslation("Game.Server.SceneGames.TankHandle")); StatMgr.LogErrorPlayer(player.PlayerCharacter.ID, player.PlayerCharacter.UserName, player.PlayerCharacter.NickName, ItemRemoveType.FireError, player.CurrentGame.Data.Players[player].X.ToString() + " to " + x.ToString() + ",MapID:" + player.CurrentGame.Data.MapIndex); player.Client.Disconnect(); return(false);; } int force = packet.ReadInt(); int angle = packet.ReadInt(); TankData data = player.CurrentGame.Data; Tile shape = Managers.BallMgr.FindTile(data.CurrentBall.ID); GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD, player.PlayerCharacter.ID); pkg.WriteByte((byte)TankCmdType.FIRE); pkg.WriteInt(data.AddBall); for (int i = 0; i < data.AddBall; i++) { if (player.CurrentGame.Data.ReduceFireBombs) { if (data.IsFastSpeed()) { StatMgr.LogErrorPlayer(player.PlayerCharacter.ID, player.PlayerCharacter.UserName, player.PlayerCharacter.NickName, ItemRemoveType.FastError, "MapID:" + player.CurrentGame.Data.MapIndex); player.Client.Disconnect(); return(false);; } data.FireLogin = true; double reforce = 1; int reangle = 0; if (i == 1) { reforce = 0.9; reangle = -5; } else if (i == 2) { reforce = 1.1; reangle = 5; } int vx = (int)(force * reforce * Math.Cos((double)(angle + reangle) / 180 * Math.PI)); int vy = (int)(force * reforce * Math.Sin((double)(angle + reangle) / 180 * Math.PI)); data.PhyID++; BombObject bomb = new BombObject(data.PhyID, BallMgr.GetBallType(data.CurrentBall.ID), data.Players[player], shape, data.CurrentBall.Radii, data.AddMultiple < 1, data.CurrentBall.Mass, data.CurrentBall.Weight, data.CurrentBall.Wind, data.CurrentBall.DragIndex, data.BallPower); bomb.SetXY(x, y); bomb.setSpeedXY(vx, vy); data.CurrentMap.AddPhysical(bomb); pkg.WriteBoolean(bomb.IsHole); pkg.WriteInt(bomb.Id); pkg.WriteInt(x); pkg.WriteInt(y); pkg.WriteInt(vx); pkg.WriteInt(vy); pkg.WriteInt(bomb.Actions.Count); foreach (BombAction action in bomb.Actions) { pkg.WriteInt(action.TimeInt); pkg.WriteInt(action.Type); pkg.WriteInt(action.Param1); pkg.WriteInt(action.Param2); pkg.WriteInt(action.Param3); pkg.WriteInt(action.Param4); } data.SetRunTime((int)bomb.RunTime); } } player.CurrentGame.SendToAll(pkg); data.FireLogin = false; if (data.Bombs || data.Players[player].State == TankGameState.DEAD) { data.TotalDelay += data.CurrentBall.Delay; process.SendArk(player.CurrentGame, player); player.PropInventory.AddItemTemplate(PropItemMgr.GetRandomFightProp(data.MapIndex)); data.Players[player].SetDander(20); process.SendPlayFinish(player.CurrentGame, player); //GSPacketIn pkgMsg = new GSPacketIn((byte)ePackageType.GAME_CMD); //pkgMsg.WriteByte((byte)TankCmdType.PLAYFINISH); //pkgMsg.WriteInt(player.CurrentGame.Data.TurnNum); //player.CurrentGame.SendToAll(pkgMsg); } return(true); } return(false); }
public static void DoCommand(string CommandName, string[] CommandArgs) { PlayerBussiness bussiness; PlayerInfo userSingleByNickName; Exception exception; string str3; string str4; string str5; ManageBussiness bussiness2; switch (CommandName) { case "exit": GameServer.KeepRunning = false; break; case "cp": { GameClient[] allClients = GameServer.Instance.GetAllClients(); int num = (allClients == null) ? 0 : allClients.Length; GamePlayer[] allPlayers = WorldMgr.GetAllPlayers(); int num2 = (allPlayers == null) ? 0 : allPlayers.Length; List <BaseRoom> allUsingRoom = RoomMgr.GetAllUsingRoom(); int num3 = 0; int num4 = 0; foreach (BaseRoom room in allUsingRoom) { if (!room.IsEmpty) { num3++; if (room.IsPlaying) { num4++; } } } double totalMemory = GC.GetTotalMemory(false); Console.WriteLine(string.Format("Total Clients/Players:{0}/{1}", num, num2)); Console.WriteLine(string.Format("Total Rooms/Games:{0}/{1}", num3, num4)); Console.WriteLine(string.Format("Total Momey Used:{0} MB", (totalMemory / 1024.0) / 1024.0)); break; } case "setlevel": try { string path = Path.Combine(Environment.CurrentDirectory, "LevelList.xml"); if (!File.Exists(path)) { log.Error("LevelList.xml not found!"); } else { int num6; Console.Write("Please enter the level: "); string s = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!int.TryParse(s, out num6)) { log.Error("Level is not valid int!"); } else { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName == null) { log.Error(string.Format("Player not found in db!", new object[0])); break; } if (!IsValidGZip(File.ReadAllBytes(path))) { log.Error("LevelList.xml is not valid!"); } else if (!IsValidXML(GZip.gzuncompress(File.ReadAllBytes(path)))) { log.Error("LevelList.xml is not valid!"); } if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } XmlDocument document = new XmlDocument(); document.LoadXml(GZip.gzuncompress(File.ReadAllBytes(path))); int num7 = -1; int num8 = -1; foreach (XmlNode node in document.SelectNodes("/Result/*")) { if (node.Attributes["Grade"].Value == s) { num7 = int.Parse(s); num8 = int.Parse(node.Attributes["GP"].Value) + 5; break; } } if ((num7 != -1) && (num8 != -1)) { userSingleByNickName.GP = num8; userSingleByNickName.Grade = num7; bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } else { log.Error(string.Format("Level {0} not found!", new object[0])); } } } } } catch (Exception exception1) { exception = exception1; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "addmoney": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of money: "); str3 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str3)) { log.Error("Money is not valid!"); } else { userSingleByNickName.Money += int.Parse(str3); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception3) { exception = exception3; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "addgold": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of gold: "); str4 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str4)) { log.Error("Gold is not valid!"); } else { userSingleByNickName.Gold += int.Parse(str4); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception4) { exception = exception4; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "addgift": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { Console.Write("Please enter the amount of gift token: "); str5 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str5)) { log.Error("Gold is not valid!"); } else { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } userSingleByNickName.GiftToken += int.Parse(str5); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception5) { exception = exception5; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "removemoney": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of money: "); str3 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str3)) { log.Error("Money is not valid!"); } else { userSingleByNickName.Money -= int.Parse(str3); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception6) { exception = exception6; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "removegold": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of gold: "); str4 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str4)) { log.Error("Gold is not valid!"); } else { userSingleByNickName.Gold -= int.Parse(str4); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception7) { exception = exception7; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "removegift": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of gift token: "); str5 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str5)) { log.Error("Gold is not valid!"); } else { userSingleByNickName.GiftToken -= int.Parse(str5); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception8) { exception = exception8; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "shutdown": _count = 6; _timer = new System.Threading.Timer(new TimerCallback(ConsoleStart.ShutDownCallBack), null, 0, 0xea60); break; case "addcps": try { Console.Write("Insira o valor dos Cupons:"); int num9 = int.Parse((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); foreach (GamePlayer player in WorldMgr.GetAllPlayers()) { player.AddMoney(num9); player.SendMessage("Parab\x00e9ns, voc\x00ea recebeu " + num9 + " cupons do evento, bom jogo !"); } } catch (Exception exception9) { exception = exception9; log.Error("Error on AddCps", exception); } break; case "bnick": { Console.Clear(); Console.WriteLine("Digite o NickName do personagem: "); string nickName = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine("Motivo para banir: "); string msg = (CommandArgs.Length > 1) ? CommandArgs[1] : Console.ReadLine(); DateTime date = new DateTime(0x7e1, 7, 2); using (bussiness2 = new ManageBussiness()) { bussiness2.ForbidPlayerByNickName(nickName, date, false); bussiness2.KitoffUserByNickName(nickName, msg); } Console.WriteLine("O Usu\x00e1rio " + nickName + " Foi Banido do servidor."); foreach (GamePlayer player2 in WorldMgr.GetAllPlayers()) { player2.SendMessage("O Usu\x00e1rio " + nickName + " foi banido do servidor, motivo do BAN: " + msg + "."); } break; } case "buser": { Console.Clear(); Console.WriteLine("Digite o UserName do personagem: "); string userName = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine("Motivo para banir: "); string str9 = (CommandArgs.Length > 1) ? CommandArgs[1] : Console.ReadLine(); DateTime time2 = new DateTime(0x7e1, 7, 2); using (bussiness2 = new ManageBussiness()) { bussiness2.ForbidPlayerByUserName(userName, time2, false); bussiness2.KitoffUserByUserName(userName, str9); } Console.WriteLine("O Usu\x00e1rio " + userName + " Foi Banido do servidor."); foreach (GamePlayer player2 in WorldMgr.GetAllPlayers()) { player2.SendMessage("O Usu\x00e1rio " + userName + " foi banido do servidor, motivo do BAN: " + str9 + "."); } break; } case "nkick": { Console.Clear(); Console.WriteLine("Digite o NickName do personagem: "); string name = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine("Motivo para kikar: "); string str11 = (CommandArgs.Length > 1) ? CommandArgs[1] : Console.ReadLine(); using (bussiness2 = new ManageBussiness()) { bussiness2.KitoffUserByNickName(name, str11); } foreach (GamePlayer player2 in WorldMgr.GetAllPlayers()) { player2.SendMessage("O Usu\x00e1rio " + name + " foi kikado do servidor, motivo do KICK: " + str11 + "."); } break; } case "ukick": { Console.Clear(); Console.WriteLine("Digite o NickName do personagem: "); string str12 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine("Motivo para kikar: "); string str13 = (CommandArgs.Length > 1) ? CommandArgs[1] : Console.ReadLine(); using (bussiness2 = new ManageBussiness()) { bussiness2.KitoffUserByUserName(str12, str13); } foreach (GamePlayer player2 in WorldMgr.GetAllPlayers()) { player2.SendMessage("O Usu\x00e1rio " + str12 + " foi kikado do servidor, motivo do KICK: " + str13 + "."); } break; } case "maint": try { int num10; Console.Write("Enter time in minutes to start maintenance: "); string str14 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!int.TryParse(str14, out num10)) { log.Error("Invalid MainTime!"); } else { new Thread(delegate(object mt) { if (mt is string) { Action <string, string> Sys = delegate(string nick, string Text) { Console.WriteLine(Text); foreach (GamePlayer player in WorldMgr.GetAllPlayers()) { player.SendMessage(string.Format("[{0}] {1}", nick, Text)); } }; Action DisconnectAll = delegate { foreach (GamePlayer player in WorldMgr.GetAllPlayers()) { log.Info(string.Format("Saving Player {0} into Database!", player.PlayerCharacter.NickName)); player.SaveIntoDatabase(); log.Info(string.Format("Disconnecting Player {0}!", player.PlayerCharacter.NickName)); player.Disconnect(); } log.Info("Shutdown Server!"); GameServer.Instance.Shutdown(); LogManager.Shutdown(); }; Sys("Auto Maintenance", "Manuten\x00e7\x00e3o agendada, fiquem atentos aos aviso!"); System.Timers.Timer MainTimer = new System.Timers.Timer { Interval = 1000.0 }; DateTime MainTime = DateTime.Parse(string.Format("{0} 00:00:00", "01/27/2011"), CultureInfo.GetCultureInfo("en-US")); MainTime = MainTime.AddMinutes(double.Parse(mt as string)); string CurrentTime = MainTime.ToString("HH:mm:ss"); MainTimer.Elapsed += delegate(object s, ElapsedEventArgs e) { if (CurrentTime != "00:00:00") { if ((MainTime.Minute != 0) && (MainTime.Second == 0)) { Sys("Auto Maintenance", string.Format("Falta {0} {1} para a manuten\x00e7\x00e3o!", MainTime.Minute, (MainTime.Minute == 1) ? "Minuto" : "Minutos")); } else if (MainTime.Second < 11) { Sys("Auto Maintenance", string.Format("Fechando o servidor em {0}", MainTime.Second)); } CurrentTime = MainTime.AddSeconds(-1.0).ToString("HH:mm:ss"); } else { Sys("Auto Maintenance", "Estamos desconectando todos os usu\x00e1rios para a manuten\x00e7\x00e3o, voltamos daqui a alguns minutos, saiam do servidor para evitar perca de itens!"); log.Info("End!"); DisconnectAll(); MainTimer.Stop(); } }; MainTimer.Start(); } }).Start(str14); } } catch (Exception exception10) { exception = exception10; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "savemap": break; case "clear": Console.Clear(); break; case "ball&reload": if (BallMgr.ReLoad()) { Console.WriteLine("Ball info is Reload!"); } else { Console.WriteLine("Ball info is Error!"); } break; case "map&reload": if (!MapMgr.ReLoadMap()) { Console.WriteLine("Map info is Error!"); break; } Console.WriteLine("Map info is Reload!"); break; case "mapserver&reload": if (!MapMgr.ReLoadMapServer()) { Console.WriteLine("mapserver info is Error!"); break; } Console.WriteLine("mapserver info is Reload!"); break; case "prop&reload": if (!PropItemMgr.Reload()) { Console.WriteLine("prop info is Error!"); break; } Console.WriteLine("prop info is Reload!"); break; case "item&reload": if (!ItemMgr.ReLoad()) { Console.WriteLine("item info is Error!"); break; } Console.WriteLine("item info is Reload!"); break; case "shop&reload": if (!ShopMgr.ReLoad()) { Console.WriteLine("shop info is Error!"); break; } Console.WriteLine("shop info is Reload!"); break; case "quest&reload": if (!QuestMgr.ReLoad()) { Console.WriteLine("quest info is Error!"); break; } Console.WriteLine("quest info is Reload!"); break; case "fusion&reload": if (!FusionMgr.ReLoad()) { Console.WriteLine("fusion info is Error!"); break; } Console.WriteLine("fusion info is Reload!"); break; case "consortia&reload": if (!ConsortiaMgr.ReLoad()) { Console.WriteLine("consortiaMgr info is Error!"); break; } Console.WriteLine("consortiaMgr info is Reload!"); break; case "rate&reload": if (!RateMgr.ReLoad()) { Console.WriteLine("Rate Rate is Error!"); break; } Console.WriteLine("Rate Rate is Reload!"); break; case "fight&reload": if (!FightRateMgr.ReLoad()) { Console.WriteLine("FightRateMgr is Error!"); break; } Console.WriteLine("FightRateMgr is Reload!"); break; case "dailyaward&reload": if (!AwardMgr.ReLoad()) { Console.WriteLine("dailyaward is Error!"); break; } Console.WriteLine("dailyaward is Reload!"); break; case "language&reload": if (!LanguageMgr.Reload("")) { Console.WriteLine("language is Error!"); break; } Console.WriteLine("language is Reload!"); break; case "treasure&reload": if (!TreasureAwardMgr.ReLoad()) { Console.WriteLine("TreasureAward is Error!"); break; } Console.WriteLine("TreasureAward is Reload!"); break; case "nickname": { Console.WriteLine("Please enter the nickname"); string str15 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine(WorldMgr.GetPlayerStringByPlayerNickName(str15)); break; } default: { string cmdLine = CommandName + string.Join(" ", CommandArgs); if (cmdLine.Length > 0) { if (cmdLine[0] == '/') { cmdLine = cmdLine.Remove(0, 1).Insert(0, "&"); } try { if (!CommandMgr.HandleCommandNoPlvl(client, cmdLine)) { Console.WriteLine("Unknown command: " + cmdLine); } } catch (Exception exception2) { Console.WriteLine(exception2.ToString()); } } break; } } }