public CharacterManager(string conString, string providerName)
     : base(conString, providerName)
 {
     itemDataManager = new ItemDataManager(conString, providerName);
     mapManager = new MapManager(conString, providerName);
     petManager = new PetManager(conString, providerName);
     guildManager = new GuildManager(conString, providerName);
 }
Example #2
0
 public CharacterManager(string conString, string providerName)
     : base(conString, providerName)
 {
     itemDataManager = new ItemDataManager(conString, providerName);
     mapManager      = new MapManager(conString, providerName);
     petManager      = new PetManager(conString, providerName);
     guildManager    = new GuildManager(conString, providerName);
 }
 public CharacterManager()
     : base(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString,
         ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName)
 {
     itemDataManager = new ItemDataManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString,
         ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
     mapManager = new MapManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString,
         ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
     petManager = new PetManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString,
         ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
     guildManager = new GuildManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString,
       ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
 }
Example #4
0
 public CharacterManager()
     : base(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString,
            ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName)
 {
     itemDataManager = new ItemDataManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString,
                                           ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
     mapManager = new MapManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString,
                                 ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
     petManager = new PetManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString,
                                 ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
     guildManager = new GuildManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString,
                                     ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
 }
Example #5
0
        //private void MobThread_Execute()
        //{
        //    foreach (Map m in mapEngine.Maps)
        //    {
        //        foreach (Monster mo in m.Monsters)
        //        {
        //            if (mo.Alive)
        //            {
        //                foreach (Client c in clients)
        //                {
        //                    if (c.MyCharacter != null && c.MyCharacter.MapId == mo.MapID && c.MyCharacter.Alive)
        //                    {
        //                        if (mapEngine.GetDistance(mo.X, mo.Y, c.MyCharacter.Position.X, c.MyCharacter.Position.Y) <= mo.SightRange + 15)
        //                        {
        //                            OnSeeEntityInfo info = mo.OnSeeEntity(c.MyCharacter);
        //                            if (info != null && info.TargetID != 0)
        //                            {
        //                                if (info.Moving)
        //                                {
        //                                    if (mo.MoveInfo == null)
        //                                        mo.Status = MonsterMoveStatus.StartMoving;
        //                                    if (mo.Status == MonsterMoveStatus.StartMoving )
        //                                    {
        //                                        mo.MoveInfo = mo.OnMove(c.MyCharacter);
        //                                        int distance = mapEngine.GetDistance(mo.X, mo.Y, mo.MoveInfo.ToX, mo.MoveInfo.ToY);
        //                                        mo.Time = (distance / mo.MovementSpeed) * 1000;
        //                                        mo.LastStart = DateTime.Now;
        //                                        mo.LastKeep = DateTime.Now;
        //                                        mo.Status = MonsterMoveStatus.KeepMoving;
        //                                        if (mapEngine.GetDistance(mo.X, mo.Y, c.MyCharacter.Position.X, c.MyCharacter.Position.Y) <= mo.AttackRange)
        //                                        {
        //                                            mo.Attacking = true;
        //                                            mo.TargetID = c.MyCharacter.CharacterId;
        //                                            info.Attacking = true;
        //                                        }
        //                                        SendInRange(mo.X, mo.Y, mo.MapID, PacketManager.SendMonsterStartMoving(mo, mo.MoveInfo));
        //                                    }
        //                                    else if (mo.Status == MonsterMoveStatus.KeepMoving && DateTime.Now >= mo.LastKeep.AddMilliseconds(mo.Time / 2))
        //                                    {
        //                                        mo.Status = MonsterMoveStatus.StopMoving;
        //                                        mo.LastStart = DateTime.Now;
        //                                        if (mapEngine.GetDistance(mo.X, mo.Y, c.MyCharacter.Position.X, c.MyCharacter.Position.Y) <= mo.AttackRange)
        //                                        {
        //                                            mo.Attacking = true;
        //                                            mo.TargetID = c.MyCharacter.CharacterId;
        //                                            info.Attacking = true;
        //                                        }
        //                                    }
        //                                    else if (mo.Status == MonsterMoveStatus.StopMoving && DateTime.Now >= mo.LastStart.AddMilliseconds(mo.Time))
        //                                    {
        //                                        mo.X = mo.MoveInfo.ToX;
        //                                        mo.Y = mo.MoveInfo.ToY;
        //                                        mo.MoveInfo.FromX = mo.X;
        //                                        mo.MoveInfo.FromY = mo.Y;
        //                                        mo.Status = MonsterMoveStatus.StartMoving;
        //                                        mo.LastStart = DateTime.Now;
        //                                        if (mapEngine.GetDistance(mo.X, mo.Y, c.MyCharacter.Position.X, c.MyCharacter.Position.Y) <= mo.AttackRange)
        //                                        {
        //                                            mo.Attacking = true;
        //                                            mo.TargetID = c.MyCharacter.CharacterId;
        //                                            info.Attacking = true;
        //                                        }
        //                                        SendInRange(mo.X, mo.Y, mo.MapID, PacketManager.SendMonsterStopMoving(mo, mo.MoveInfo));
        //                                    }
        //                                }
        //                                if (info.Attacking)
        //                                {
        //                                    if (DateTime.Now >= mo.LastAttack.AddSeconds(2))
        //                                    {
        //                                        Client target = null;
        //                                        target = GetClientByCharacterID(mo.TargetID);
        //                                        if (target == null)
        //                                        {
        //                                            mo.TargetID = 0;
        //                                            mo.Attacking = false;
        //                                        }
        //                                        if (target.MyCharacter.Alive && mo.Alive)
        //                                        {
        //                                            Client[] nearbyClients = GetNearByClients(target);
        //                                            int distance = mapEngine.GetDistance(mo.X, mo.Y, target.MyCharacter.X, target.MyCharacter.Y);
        //                                            if (distance < mo.AttackRange + 15)
        //                                            {
        //                                                AttackInfo atk = target.MyCharacter.OnAttack(mo);
        //                                                if (atk != null)
        //                                                {
        //                                                    byte[] SendTargetHealMana = PacketManager.SendHealMana(target.MyCharacter.MaxHp, target.MyCharacter.CurrentHp, target.MyCharacter.MaxMana, target.MyCharacter.CurrentMana, 0);
        //                                                    target.Send(SendTargetHealMana);
        //                                                    byte[] SendAttack1 = PacketManager.SendAttack1(atk);
        //                                                    SendSpecific(nearbyClients, SendAttack1);
        //                                                    byte[] SendAttack2 = PacketManager.SendAttack2(atk, target.MyCharacter);
        //                                                    SendSpecific(nearbyClients, SendAttack2);
        //                                                    if (atk.DoRefDamage && !atk.Dead)
        //                                                    {
        //                                                        BaseSkill skill = target.MyCharacter.FindSkill((int)HardSkills.Reflection);
        //                                                        CastSkillInfo RefInfo = mo.OnCast(target.MyCharacter, skill);
        //                                                        RefInfo.CasterType = 1;
        //                                                        byte[] SendRefdamage = PacketManager.SendCast2(skill, RefInfo, mo);
        //                                                        SendSpecific(nearbyClients, SendRefdamage);
        //                                                        if (RefInfo.Dead)
        //                                                        {
        //                                                            CharacterGainExperience(target, mo, target.MyCharacter, false);
        //                                                            MonsterDropItem(nearbyClients, mo, target.MyCharacter);
        //                                                            byte[] SendMonsterDie = PacketManager.SendMonsterDie(mo);
        //                                                            SendSpecific(nearbyClients, SendMonsterDie);
        //                                                        }
        //                                                    }
        //                                                    if (atk.PetDamaged)
        //                                                    {
        //                                                        if (target.MyCharacter.tempPet != null)
        //                                                        {
        //                                                            byte[] SendPetHealth = PacketManager.SendPetHealth(target.MyCharacter.tempPet);
        //                                                            target.Send(SendPetHealth);
        //                                                            if (atk.PetDied)
        //                                                            {
        //                                                                BaseSkill skill = new BaseSkill();
        //                                                                if (target.MyCharacter.RemoveActiveSkill((int)HardSkills.Shadow_Strike))
        //                                                                {
        //                                                                    skill.SkillID = (int)HardSkills.Shadow_Strike;
        //                                                                    skill.SkillLevel = 1;
        //                                                                    target.Send(PacketManager.SendEndSkill(target.MyCharacter, skill));
        //                                                                }
        //                                                                if (target.MyCharacter.RemoveActiveSkill((int)AbsorbSkills.Shadow_Focus))
        //                                                                {
        //                                                                    skill.SkillID = (int)AbsorbSkills.Shadow_Focus;
        //                                                                    skill.SkillLevel = 1;
        //                                                                    target.Send(PacketManager.SendEndSkill(target.MyCharacter, skill));
        //                                                                }
        //                                                                if (target.MyCharacter.RemoveActiveSkill((int)RebirthSkills.Duplicate_Attack))
        //                                                                {
        //                                                                    skill.SkillID = (int)RebirthSkills.Duplicate_Attack;
        //                                                                    skill.SkillLevel = 1;
        //                                                                    target.Send(PacketManager.SendEndSkill(target.MyCharacter, skill));
        //                                                                }
        //                                                                byte[] RemovePet = PacketManager.SendMonsterDie(target.MyCharacter.tempPet);
        //                                                                SendInRange(target.MyCharacter.tempPet.X, target.MyCharacter.tempPet.Y, target.MyCharacter.tempPet.MapID, RemovePet);
        //                                                                target.MyCharacter.tempPet = null;
        //                                                            }
        //                                                        }
        //                                                    }
        //                                                    if (atk.Dead)
        //                                                    {
        //                                                        byte[] SendPlayerDead = PacketManager.SendPlayerDie(target.MyCharacter);
        //                                                        SendSpecific(nearbyClients, SendPlayerDead);
        //                                                    }
        //                                                }
        //                                                mo.LastAttack = DateTime.Now;
        //                                            }
        //                                            else
        //                                            {
        //                                                mo.TargetID = 0;
        //                                                mo.Attacking = false;
        //                                            }
        //                                        }
        //                                        else
        //                                            mo.Attacking = false;
        //                                    }
        //                                }
        //                            }
        //                        }
        //                    }
        //                }
        //                if (!mo.Attacking)
        //                {
        //                    if (mo.Status == MonsterMoveStatus.StartMoving && DateTime.Now >= mo.LastStart.AddSeconds(2))
        //                    {
        //                        int randomDirection = mapEngine.Random.Next(0, 4);
        //                        switch (randomDirection)
        //                        {
        //                            case 0:
        //                                mo.ToX = (short)mapEngine.Random.Next(mo.SpawnX - mo.WanderRange, mo.SpawnX + mo.WanderRange);
        //                                mo.StepX = (short)((mo.ToX - mo.SpawnX) / 2);
        //                                break;
        //                            case 1:
        //                                mo.ToX = (short)mapEngine.Random.Next(mo.SpawnX - mo.WanderRange, mo.SpawnX + mo.WanderRange);
        //                                mo.StepX = (short)((mo.ToX - mo.SpawnX) / 2);
        //                                break;
        //                            case 2:
        //                                mo.ToY = (short)mapEngine.Random.Next(mo.SpawnY - mo.WanderRange, mo.SpawnY + mo.WanderRange);
        //                                mo.StepY = (short)((mo.ToY - mo.SpawnY) / 2);
        //                                break;
        //                            case 3:
        //                                mo.ToY = (short)mapEngine.Random.Next(mo.SpawnY - mo.WanderRange, mo.SpawnY + mo.WanderRange);
        //                                mo.StepY = (short)((mo.ToY - mo.SpawnY) / 2);
        //                                break;
        //                        }
        //                        int distance = mapEngine.GetDistance(mo.X, mo.Y, mo.ToX, mo.ToY);
        //                        mo.Time = (distance / mo.MovementSpeed) * 1000;
        //                        MovementInfo mi = new MovementInfo
        //                        {
        //                            FromX = mo.X,
        //                            FromY = mo.Y,
        //                            ToX = mo.ToX,
        //                            ToY = mo.ToY,
        //                            FromZ = 0,
        //                            ToZ = 0,
        //                            Rotation = 0,
        //                        };
        //                        double rotation = Math.Atan2(mo.ToY - mo.Y, mo.ToX - mo.X);
        //                        rotation = rotation * 180 / Math.PI;
        //                        mi.Rotation = (int)Math.Abs(rotation);
        //                        mo.LastStart = DateTime.Now;
        //                        mo.LastKeep = DateTime.Now;
        //                        mo.Status = MonsterMoveStatus.KeepMoving;
        //                        SendInRange(mo.X, mo.Y, mo.MapID, PacketManager.SendMonsterStartMoving(mo, mi));
        //                    }
        //                    else if (mo.Status == MonsterMoveStatus.KeepMoving && DateTime.Now >= mo.LastKeep.AddMilliseconds(mo.Time / 2))
        //                    {
        //                        mo.Status = MonsterMoveStatus.StopMoving;
        //                        mo.LastStart = DateTime.Now;
        //                    }
        //                    else if (mo.Status == MonsterMoveStatus.StopMoving && DateTime.Now >= mo.LastStart.AddMilliseconds(mo.Time))
        //                    {
        //                        mo.X = mo.ToX;
        //                        mo.Y = mo.ToY;
        //                        MovementInfo mi = new MovementInfo
        //                        {
        //                            FromX = mo.X,
        //                            FromY = mo.Y,
        //                            ToX = mo.X,
        //                            ToY = mo.Y,
        //                            FromZ = 0,
        //                            ToZ = 0,
        //                            Rotation = 0,
        //                        };
        //                        double rotation = Math.Atan2(mo.ToY - mo.Y, mo.ToX - mo.X);
        //                        rotation = rotation * 180 / Math.PI;
        //                        mi.Rotation = (int)Math.Abs(rotation);
        //                        mo.Status = MonsterMoveStatus.StartMoving;
        //                        mo.LastStart = DateTime.Now;
        //                        SendInRange(mo.X, mo.Y, mo.MapID, PacketManager.SendMonsterStopMoving(mo, mi));
        //                    }
        //                }
        //            }
        //            else
        //            {
        //                int respawntime = 15;
        //                if (mo.MonsterType == 112 || mo.MonsterType == 187 || mo.MonsterType == 188) // king, phx, gb
        //                    respawntime = 3600;
        //                if (mo.MonsterType == 113) // emp
        //                    respawntime = 7200;
        //                if (DateTime.Now >= mo.DeathTime.AddSeconds(respawntime))
        //                {
        //                    mo.X = mo.SpawnX;
        //                    mo.Y = mo.SpawnY;
        //                    mo.Alive = true;
        //                    mo.CurHealth = mo.MaxHealth;
        //                    // send maybe spawn or something here
        //                }
        //            }
        //        }
        //    }
        //}
        public ChannelServer(string ipAddress, int port, int expRate, int itemDropRate, int moneyDropRate, int stoneDropRate, int bookDropRate, int pillDropRate, int stoneCombineChance)
            : base(ipAddress, port)
        {
            gameEngine = new GameEngine(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString, ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
            //mapEngine = new MapEngine(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString, ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
            accountManager = new AccountManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString, ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
            characterManager = new CharacterManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString, ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
            itemDataManager = new ItemDataManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString, ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
            channelManager = new ChannelManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString, ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
            petManager = new PetManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString, ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
            mapManager = new MapManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString, ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
            guildManager = new GuildManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString, ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
            InitiateMapEngines();
            InitiateChannels();
            //StartMonsters();
            StartRegenThread();
            StartMapItemThread();

            ExperienceMultiper = expRate;
            ItemDropChance = itemDropRate;
            MoneyDropChance = moneyDropRate;
            StoneDropChance = stoneDropRate;
            BookDropChance = bookDropRate;
            PillDropChance = pillDropRate;
            StoneCombineChance = stoneCombineChance;
        }