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


C# PlayerCharacter.LocationChangeMapAtEnterWorld方法代码示例

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


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

示例1: handleLogIn


//.........这里部分代码省略.........
                    {
                        LogInNotOkOutgoingMessage msgLogInNotOk =
                            (LogInNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.LOG_IN_NOT_OK);
                        msgLogInNotOk.Message = "The password is wrong!";
                        pc.PutMessageIntoMyQueue(msgLogInNotOk);
                        return;
                    }

                }
                catch (Exception ex)
                {
                    logger.LogError(LogSource.World, "Failed to authenticate player: " + pc.Name, ex);
                    LogInNotOkOutgoingMessage msgLogInNotOk =
                        (LogInNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.LOG_IN_NOT_OK);
                    msgLogInNotOk.Message = "Server could not load the character!";
                    pc.PutMessageIntoMyQueue(msgLogInNotOk);
                    return;
                }

                // Check if already logged in
                if (getPlayerByName(msgLogIn.UserName) != null)
                {
                    LogInNotOkOutgoingMessage msgLogInNotOk =
                        (LogInNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.LOG_IN_NOT_OK);
                    msgLogInNotOk.Message = "You are already logged in!";
                    pc.PutMessageIntoMyQueue(msgLogInNotOk);
                    return;
                }

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

                pc.Name = msgLogIn.UserName; // Temporary setting user name so that deserialization may work

                // Deserialize user data
                try
                {
                    pc.Deserialize(pcDeserializer);
                }
                catch (Exception ex)
                {
                    logger.LogError(LogSource.World, "Failed to deserialize player: " + pc.Name, ex);
                    LogInNotOkOutgoingMessage msgLogInNotOk =
                        (LogInNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.LOG_IN_NOT_OK);
                    msgLogInNotOk.Message = "Server could not load the character!";
                    pc.PutMessageIntoMyQueue(msgLogInNotOk);
                    return;
                }

                try
                {
                    // Add to dictionaries / Get EntityID
                    addEntityImplementationToWorld(pc);
                }
                catch (Exception ex)
                {
                    logger.LogError(LogSource.World, "Failed to register player: " + pc.Name, ex);
                    LogInNotOkOutgoingMessage msgLogInNotOk =
                        (LogInNotOkOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.LOG_IN_NOT_OK);
                    msgLogInNotOk.Message = "Server could not register the character!";
                    pc.PutMessageIntoMyQueue(msgLogInNotOk);
                    return;
                }

                // TODO: Send initial data to client

                // New Minute
                NewMinuteOutgoingMessage msgNewMinute =
                    (NewMinuteOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.NEW_MINUTE);
                msgNewMinute.MinuteOfTheDay = calendar.MinuteOfTheDay;
                pc.PutMessageIntoMyQueue(msgNewMinute);

                // You Are
                YouAreOutgoingMessage msgYouAre =
                    (YouAreOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.YOU_ARE);
                msgYouAre.EntityID = pc.EntityID;
                pc.PutMessageIntoMyQueue(msgYouAre);

                // Change Map
                pc.LocationChangeMapAtEnterWorld();

                // Here Your Inventory
                HereYourInventoryOutgoingMessage msgHereYourInventory =
                    (HereYourInventoryOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.HERE_YOUR_INVENTORY);
                pc.FillOutgoingMessage(msgHereYourInventory);
                pc.PutMessageIntoMyQueue(msgHereYourInventory);

                // Here Your Stats
                HereYourStatsOutgoingMessage msgHereYourStats =
                    (HereYourStatsOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.HERE_YOUR_STATS);
                pc.FillOutgoingMessage(msgHereYourStats);
                pc.PutMessageIntoMyQueue(msgHereYourStats);

                // Log In Ok
                pc.PutMessageIntoMyQueue(msgStdLogInOk);

                // All is OK
                pc.LoginState = PlayerCharacterLoginState.LoginSuccesfull;
            }
        }
开发者ID:rauchc,项目名称:Calindor,代码行数:101,代码来源:WorldSimulationLoginSynchronizationHandling.cs


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