コード例 #1
0
        /// <summary>
        /// select packet
        /// </summary>
        /// <param name="selectPacket"></param>
        public void SelectCharacter(SelectPacket selectPacket)
        {
            try
            {
                if (Session?.Account != null && !Session.HasSelectedCharacter)
                {
                    if (DAOFactory.CharacterDAO.LoadBySlot(Session.Account.AccountId, selectPacket.Slot) is Character character)
                    {
                        character.GeneralLogs   = DAOFactory.GeneralLogDAO.LoadByAccount(Session.Account.AccountId).Where(s => s.CharacterId == character.CharacterId).ToList();
                        character.MapInstanceId = ServerManager.Instance.GetBaseMapInstanceIdByMapId(character.MapId);
                        character.PositionX     = character.MapX;
                        character.PositionY     = character.MapY;
                        character.Authority     = Session.Account.Authority;
                        Session.SetCharacter(character);
                        if (!Session.Character.GeneralLogs.Any(s => s.Timestamp == DateTime.Now && s.LogData == "World" && s.LogType == "Connection"))
                        {
                            Session.Character.SpAdditionPoint += Session.Character.SpPoint;
                            Session.Character.SpPoint          = 10000;
                        }
                        if (Session.Character.Hp > Session.Character.HPLoad())
                        {
                            Session.Character.Hp = (int)Session.Character.HPLoad();
                        }
                        if (Session.Character.Mp > Session.Character.MPLoad())
                        {
                            Session.Character.Mp = (int)Session.Character.MPLoad();
                        }
                        Session.Character.Respawns        = DAOFactory.RespawnDAO.LoadByCharacter(Session.Character.CharacterId).ToList();
                        Session.Character.StaticBonusList = DAOFactory.StaticBonusDAO.LoadByCharacterId(Session.Character.CharacterId).ToList();
                        Session.Character.LoadInventory();
                        Session.Character.LoadQuicklists();
                        Session.Character.GenerateMiniland();
                        DAOFactory.MateDAO.LoadByCharacterId(Session.Character.CharacterId).ToList().ForEach(s =>
                        {
                            Mate mate  = (Mate)s;
                            mate.Owner = Session.Character;
                            mate.GeneateMateTransportId();
                            mate.Monster = ServerManager.Instance.GetNpc(s.NpcMonsterVNum);
                            Session.Character.Mates.Add(mate);
                        });
                        Observable.Interval(TimeSpan.FromMilliseconds(300)).Subscribe(x =>
                        {
                            Session.Character.CharacterLife();
                        });
                        Session.Character.GeneralLogs.Add(new GeneralLogDTO {
                            AccountId = Session.Account.AccountId, CharacterId = Session.Character.CharacterId, IpAddress = Session.IpAddress, LogData = "World", LogType = "Connection", Timestamp = DateTime.Now
                        });

                        Session.SendPacket("OK");

                        // Inform everyone about connected character
                        CommunicationServiceClient.Instance.ConnectCharacter(ServerManager.Instance.WorldId, character.CharacterId);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log.Error("Select character failed.", ex);
            }
        }
コード例 #2
0
        public void SelectCharacter(SelectPacket selectPacket)
        {
            try
            {
                if (Session?.Account == null || Session.HasSelectedCharacter)
                {
                    return;
                }

                var characterDto =
                    DAOFactory.CharacterDAO.FirstOrDefault(s =>
                                                           s.AccountId == Session.Account.AccountId && s.Slot == selectPacket.Slot &&
                                                           s.State == CharacterState.Active);
                if (characterDto == null)
                {
                    return;
                }

                if (!(characterDto is Character character))
                {
                    return;
                }

                character.MapInstanceId = ServerManager.Instance.GetBaseMapInstanceIdByMapId(character.MapId);
                character.MapInstance   = ServerManager.Instance.GetMapInstance(character.MapInstanceId);
                character.PositionX     = character.MapX;
                character.PositionY     = character.MapY;
                character.Account       = Session.Account;
                Session.SetCharacter(character);
                if (Session.Character.Hp > Session.Character.HPLoad())
                {
                    Session.Character.Hp = (int)Session.Character.HPLoad();
                }

                if (Session.Character.Mp > Session.Character.MPLoad())
                {
                    Session.Character.Mp = (int)Session.Character.MPLoad();
                }

                Session.SendPacket(new OkPacket());
            }
            catch (Exception ex)
            {
                Logger.Log.Error("Select character failed.", ex);
            }
        }
コード例 #3
0
    public void packetArrives(GameObject node, GameObject packet)
    {
        SelectNode   selectNode   = GameObject.FindGameObjectWithTag("GameController").GetComponent <SelectNode>();
        SelectPacket selectPacket = GameObject.FindGameObjectWithTag("GameController").GetComponent <SelectPacket>();

        bool             reselectNode   = false;
        bool             reselectPacket = false;
        ReferencedPacket packetToReset  = null;

        if (selectNode.getSelectedNode() == node)
        {
            reselectNode = true;
            if (selectPacket.getSelectedPacket())
            {
                packetToReset  = selectPacket.getReferencedPacket();
                reselectPacket = true;
            }
        }

        GameObject.FindGameObjectWithTag("PacketArrive").GetComponent <AudioSource>().Play();
        node.GetComponent <Packets>().addPacket(packet);    // add packet to the new node
        node.GetComponent <Packets>().checkPacketTargets(); // destroy packet if it has reached the target
        packet.GetComponent <Packet>().getPacketChild().SetActive(false);
        if (node.GetComponent <Packets>().getPacketCount() == 0)
        {
            node.GetComponentInChildren <Text>().text = "";
        }
        else
        {
            node.GetComponentInChildren <Text>().text = "" + node.GetComponent <Packets>().getPacketCount();//update packet count on arrival node
        }
        if (reselectNode)
        {
            //selectNode.selectNode(selectNode.getSelectedNode());// reselect currently selected node -- unneccesary now, so commented
            if (reselectPacket)
            {
                selectPacket.setSelectedPacket(packetToReset);
                selectPacket.resetDisplays(packetToReset);
            }
        }
        //if the arrived at node is selected it does not show the updated packet information without being reselected
    }
コード例 #4
0
        public void SelectCharacter(SelectPacket selectPacket)
        {
            try
            {
                if (Session?.Account == null || Session.HasSelectedCharacter)
                {
                    return;
                }

                var characterDto =
                    DaoFactory.CharacterDao.FirstOrDefault(s =>
                                                           s.AccountId == Session.Account.AccountId && s.Slot == selectPacket.Slot &&
                                                           s.State == CharacterState.Active);
                if (characterDto == null)
                {
                    return;
                }

                var character = _characterBuilderService.LoadCharacter(characterDto);

                character.MapInstanceId = _mapInstanceAccessService.GetBaseMapInstanceIdByMapId(character.MapId);
                character.MapInstance   = _mapInstanceAccessService.GetMapInstance(character.MapInstanceId);
                character.PositionX     = character.MapX;
                character.PositionY     = character.MapY;
                character.Account       = Session.Account;
                character.Group.JoinGroup(character);
                Session.SetCharacter(character);

                var inventories = DaoFactory.ItemInstanceDao.Where(s => s.CharacterId == character.CharacterId)
                                  .ToList();
                inventories.ForEach(k => character.Inventory[k.Id] = _itemBuilderService.Convert(k));
#pragma warning disable CS0618
                Session.SendPackets(Session.Character.GenerateInv());
#pragma warning restore CS0618

                if (Session.Character.Hp > Session.Character.HpLoad())
                {
                    Session.Character.Hp = (int)Session.Character.HpLoad();
                }

                if (Session.Character.Mp > Session.Character.MpLoad())
                {
                    Session.Character.Mp = (int)Session.Character.MpLoad();
                }

                var relations =
                    DaoFactory.CharacterRelationDao.Where(s => s.CharacterId == Session.Character.CharacterId);
                var relationsWithCharacter =
                    DaoFactory.CharacterRelationDao.Where(s => s.RelatedCharacterId == Session.Character.CharacterId);

                var characters = DaoFactory.CharacterDao
                                 .Where(s => relations.Select(v => v.RelatedCharacterId).Contains(s.CharacterId)).ToList();
                var relatedCharacters = DaoFactory.CharacterDao.Where(s =>
                                                                      relationsWithCharacter.Select(v => v.RelatedCharacterId).Contains(s.CharacterId)).ToList();

                foreach (var relation in relations.Adapt <IEnumerable <CharacterRelation> >())
                {
                    relation.CharacterName = characters.Find(s => s.CharacterId == relation.RelatedCharacterId)?.Name;
                    Session.Character.CharacterRelations[relation.CharacterRelationId] = relation;
                }

                foreach (var relation in relationsWithCharacter.Adapt <IEnumerable <CharacterRelation> >())
                {
                    relation.CharacterName =
                        relatedCharacters.Find(s => s.CharacterId == relation.RelatedCharacterId)?.Name;
                    Session.Character.RelationWithCharacter[relation.CharacterRelationId] = relation;
                }

                Session.SendPacket(new OkPacket());
            }
            catch (Exception ex)
            {
                _logger.Error("Select character failed.", ex);
            }
        }
コード例 #5
0
        /// <summary>
        /// select packet
        /// </summary>
        /// <param name="selectPacket"></param>
        public void SelectCharacter(SelectPacket selectPacket)
        {
            try
            {
                if (Session?.Account == null || Session.HasSelectedCharacter)
                {
                    return;
                }
                if (!(DaoFactory.CharacterDao.LoadBySlot(Session.Account.AccountId, selectPacket.Slot) is Character character))
                {
                    return;
                }
                character.GeneralLogs   = DaoFactory.GeneralLogDao.LoadByAccount(Session.Account.AccountId).Where(s => s.CharacterId == character.CharacterId).ToList();
                character.MapInstanceId = ServerManager.Instance.GetBaseMapInstanceIdByMapId(character.MapId);
                Map currentMap = ServerManager.Instance.GetMapInstance(character.MapInstanceId)?.Map;
                if (currentMap != null && currentMap.IsBlockedZone(character.MapX, character.MapY))
                {
                    MapCell pos = currentMap.GetRandomPosition();
                    character.PositionX = pos.X;
                    character.PositionY = pos.Y;
                }
                else
                {
                    character.PositionX = character.MapX;
                    character.PositionY = character.MapY;
                }
                character.Authority = Session.Account.Authority;
                Session.SetCharacter(character);
                if (!Session.Character.GeneralLogs.Any(s => s.Timestamp == DateTime.Now && s.LogData == "World" && s.LogType == "Connection"))
                {
                    Session.Character.SpAdditionPoint += Session.Character.SpPoint;
                    Session.Character.SpPoint          = 10000;
                }
                if (Session.Character.Hp > Session.Character.HpLoad())
                {
                    Session.Character.Hp = (int)Session.Character.HpLoad();
                }
                if (Session.Character.Mp > Session.Character.MpLoad())
                {
                    Session.Character.Mp = (int)Session.Character.MpLoad();
                }
                Session.Character.Respawns        = DaoFactory.RespawnDao.LoadByCharacter(Session.Character.CharacterId).ToList();
                Session.Character.StaticBonusList = DaoFactory.StaticBonusDao.LoadByCharacterId(Session.Character.CharacterId).ToList();
                Session.Character.LoadInventory();
                Session.Character.LoadQuicklists();
                Session.Character.GenerateMiniland();
                if (!DaoFactory.CharacterQuestDao.LoadByCharacterId(Session.Character.CharacterId).Any(s => s.IsMainQuest))
                {
                    CharacterQuestDTO firstQuest = new CharacterQuestDTO {
                        CharacterId = Session.Character.CharacterId, QuestId = 1997, IsMainQuest = true
                    };
                    DaoFactory.CharacterQuestDao.InsertOrUpdate(firstQuest);
                }
                DaoFactory.CharacterQuestDao.LoadByCharacterId(Session.Character.CharacterId).ToList().ForEach(q => Session.Character.Quests.Add(q as CharacterQuest));
                DaoFactory.MateDao.LoadByCharacterId(Session.Character.CharacterId).ToList().ForEach(s =>
                {
                    Mate mate  = (Mate)s;
                    mate.Owner = Session.Character;
                    mate.GenerateMateTransportId();
                    mate.Monster = ServerManager.Instance.GetNpc(s.NpcMonsterVNum);
                    Session.Character.Mates.Add(mate);
                    if (!mate.IsTeamMember)
                    {
                        mate.MapX = ServerManager.Instance.MinilandRandomPos().X;
                        mate.MapY = ServerManager.Instance.MinilandRandomPos().Y;
                    }
                });
                Session.Character.Life = Observable.Interval(TimeSpan.FromMilliseconds(300)).Subscribe(x =>
                {
                    Session?.Character?.CharacterLife();
                });
                Session.Character.GeneralLogs.Add(new GeneralLogDTO {
                    AccountId = Session.Account.AccountId, CharacterId = Session.Character.CharacterId, IpAddress = Session.IpAddress, LogData = "World", LogType = "Connection", Timestamp = DateTime.Now
                });

                Session.SendPacket("OK");

                // Inform everyone about connected character
                CommunicationServiceClient.Instance.ConnectCharacter(ServerManager.Instance.WorldId, character.CharacterId);
            }
            catch (Exception ex)
            {
                Logger.Log.Error("Select character failed.", ex);
            }
        }
コード例 #6
0
        public void SelectCharacter(SelectPacket selectPacket)
        {
            try
            {
                if (Session?.Account == null || Session.HasSelectedCharacter)
                {
                    return;
                }

                var characterDto =
                    DAOFactory.CharacterDAO.FirstOrDefault(s =>
                                                           s.AccountId == Session.Account.AccountId && s.Slot == selectPacket.Slot &&
                                                           s.State == CharacterState.Active);
                if (characterDto == null)
                {
                    return;
                }

                GameObject.Character character = characterDto.Adapt <GameObject.Character>();

                character.MapInstanceId = ServerManager.Instance.GetBaseMapInstanceIdByMapId(character.MapId);
                character.MapInstance   = ServerManager.Instance.GetMapInstance(character.MapInstanceId);
                character.PositionX     = character.MapX;
                character.PositionY     = character.MapY;
                character.Account       = Session.Account;
                Session.SetCharacter(character);

                var inventories = DAOFactory.ItemInstanceDAO.Where(s => s.CharacterId == character.CharacterId).ToList();
                character.Inventory = new Inventory()
                {
                    Configuration = _worldConfiguration
                };
                inventories.ForEach(k => character.Inventory[k.Id] = k.Adapt <ItemInstance>());
                #pragma warning disable CS0618
                Session.SendPackets(Session.Character.GenerateInv());
                #pragma warning restore CS0618

                if (Session.Character.Hp > Session.Character.HPLoad())
                {
                    Session.Character.Hp = (int)Session.Character.HPLoad();
                }

                if (Session.Character.Mp > Session.Character.MPLoad())
                {
                    Session.Character.Mp = (int)Session.Character.MPLoad();
                }

                IEnumerable <CharacterRelation> relations = DAOFactory.CharacterRelationDAO.Where(s => s.CharacterId == Session.Character.CharacterId).Cast <CharacterRelation>();
                IEnumerable <CharacterRelation> relationsWithCharacter = DAOFactory.CharacterRelationDAO.Where(s => s.RelatedCharacterId == Session.Character.CharacterId).Cast <CharacterRelation>();

                List <CharacterDTO> characters        = DAOFactory.CharacterDAO.Where(s => relations.Select(v => v.RelatedCharacterId).Contains(s.CharacterId)).ToList();
                List <CharacterDTO> relatedCharacters = DAOFactory.CharacterDAO.Where(s => relationsWithCharacter.Select(v => v.RelatedCharacterId).Contains(s.CharacterId)).ToList();

                foreach (CharacterRelation relation in relations)
                {
                    relation.CharacterName = characters.FirstOrDefault(s => s.CharacterId == relation.RelatedCharacterId)?.Name;
                    Session.Character.CharacterRelations[relation.CharacterRelationId] = relation;
                }

                foreach (CharacterRelation relation in relationsWithCharacter)
                {
                    relation.CharacterName = relatedCharacters.FirstOrDefault(s => s.CharacterId == relation.RelatedCharacterId)?.Name;
                    Session.Character.RelationWithCharacter[relation.CharacterRelationId] = relation;
                }

                Session.SendPacket(new OkPacket());
            }
            catch (Exception ex)
            {
                Logger.Log.Error("Select character failed.", ex);
            }
        }