当前位置: 首页>>代码示例>>C#>>正文


C# PlayerCharacter.CreateSetInitialAppearance方法代码示例

本文整理汇总了C#中PlayerCharacter.CreateSetInitialAppearance方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerCharacter.CreateSetInitialAppearance方法的具体用法?C# PlayerCharacter.CreateSetInitialAppearance怎么用?C# PlayerCharacter.CreateSetInitialAppearance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PlayerCharacter的用法示例。


在下文中一共展示了PlayerCharacter.CreateSetInitialAppearance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: handleCreateChar

        private PlayerCharacterSerializer pcSerializer = null; // Used for storing pc data

        #endregion Fields

        #region Methods

        private void handleCreateChar(PlayerCharacter pc, IncommingMessage msg)
        {
            if (pc.LoginState == PlayerCharacterLoginState.ClientVersionCorrect)
            {
                CreateCharIncommingMessage msgCreateChar = (CreateCharIncommingMessage)msg;

                // Is acceptable character name
                if (!pcAuthentication.IsAcceptablePlayerName(msgCreateChar.UserName))
                {
                    CreateCharNotOkOutgoingMessage msgCreateCharNotOk =
                        (CreateCharNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.CREATE_CHAR_NOT_OK);
                    msgCreateCharNotOk.Message = "This character name is not acceptable.";
                    pc.PutMessageIntoMyQueue(msgCreateCharNotOk);
                    return;
                }

                // Does character exist?
                if (pcAuthentication.Exists(msgCreateChar.UserName))
                {
                    // Character already exists
                    CreateCharNotOkOutgoingMessage msgCreateCharNotOk =
                        (CreateCharNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.CREATE_CHAR_NOT_OK);
                    msgCreateCharNotOk.Message = "A character with that name already exists.";
                    pc.PutMessageIntoMyQueue(msgCreateCharNotOk);
                    return;
                }

                // TODO: Add check for appearace values

                // All ok. Create a character
                try
                {
                    pcAuthentication.Create(msgCreateChar.UserName, msgCreateChar.Password);
                }
                catch (Exception ex)
                {
                    logger.LogError(LogSource.World, "Failed to create player " + pc.Name, ex);
                    CreateCharNotOkOutgoingMessage msgCreateCharNotOk =
                        (CreateCharNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.CREATE_CHAR_NOT_OK);
                    msgCreateCharNotOk.Message = "Server could not create the character.";
                    pc.PutMessageIntoMyQueue(msgCreateCharNotOk);
                    return;
                }

                // Clear character (current state of character is undefined!)
                pc.ClearEntityImplementation();

                EntityAppearance appearance = new EntityAppearance(msgCreateChar.Type);

                appearance.Head = msgCreateChar.Head;
                appearance.Skin = msgCreateChar.Skin;
                appearance.Hair = msgCreateChar.Hair;
                appearance.Shirt = msgCreateChar.Shirt;
                appearance.Pants = msgCreateChar.Pants;
                appearance.Boots = msgCreateChar.Boots;
                pc.Name = msgCreateChar.UserName;
                pc.CreateSetInitialAppearance(appearance);

                EntityLocation location = new EntityLocation();
                short deviation = mapManager.StartPointDeviation;
                location.X = (short)(mapManager.StartPointX + (sbyte)WorldRNG.Next(-deviation, deviation));
                location.Y = (short)(mapManager.StartPointY + (sbyte)WorldRNG.Next(-deviation, deviation));
                location.Z = 0;
                location.Rotation = 0;
                location.CurrentMap = mapManager.StartPointMap;
                pc.CreateSetInitialLocation(location);

                // TODO: Apply race specific factors

                // Add bonus items
                ItemDefinition itmDef = null;

                // Royals
                itmDef = ItemDefinitionCache.GetItemDefinitionByID(5);
                if (itmDef != null)
                {
                    Item itm = new Item(itmDef);
                    itm.Quantity = 100;
                    pc.InventoryUpdateItem(itm);
                }

                // Recalculate enerigies
                pc.CreateRecalculateInitialEnergies();

                // Store data
                try
                {
                    pc.ForceSerialization();
                    pc.Serialize(pcSerializer);
                }
                catch (Exception ex)
                {
                    logger.LogError(LogSource.World, "Failed to serialize player " + pc.Name, ex);
                    CreateCharNotOkOutgoingMessage msgCreateCharNotOk =
//.........这里部分代码省略.........
开发者ID:rauchc,项目名称:Calindor,代码行数:101,代码来源:WorldSimulationLoginSynchronizationHandling.cs


注:本文中的PlayerCharacter.CreateSetInitialAppearance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。