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


C# User.MessageHandler方法代码示例

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


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

示例1: OnlyLeaderLoots

 private void OnlyLeaderLoots(User.User looter, List<string> commands, Character.Iactor npc)
 {
     if (string.Equals(looter.UserID, LeaderID)) {
         ((Character.NPC)npc).Loot(looter, commands, true);
     }
     else {
         looter.MessageHandler("Only the group leader can loot corpses killed by the group.");
     }
 }
开发者ID:vadian,项目名称:Novus,代码行数:9,代码来源:Group.cs

示例2: Loot

        public bool Loot(User.User looter, List<string> commands, bool bypassCheck = false)
        {
            bool looted = false;
            if (IsDead()) {
                List<Items.Iitem> result = new List<Items.Iitem>();
                StringBuilder sb = new StringBuilder();

                if (!bypassCheck) {
                    if (CanLoot(looter.UserID)) {
                        looter.MessageHandler("You did not deal the killing blow and can not loot this corpse at this time.");
                        return false;
                    }
                }

                if (commands.Contains("all")) {
                    sb.AppendLine("You loot the following items from " + FirstName + ":");
                    Inventory.GetInventoryAsItemList().ForEach(i => {
                        sb.AppendLine(i.Name);
                        looter.Player.Inventory.AddItemToInventory(i);
                    });
                    looted = true;
                }
                else if (commands.Count > 2) { //the big one, should allow to loot individual item from the inventory
                    string itemName = Items.Items.ParseItemName(commands);
                    int index = 1;
                    int position = 1;
                    string[] positionString = commands[0].Split('.'); //we are separating based on using the decimal operator after the name of the npc/item
                    if (positionString.Count() > 1) {
                        int.TryParse(positionString[positionString.Count() - 1], out position);
                    }

                    Inventory.GetInventoryAsItemList().ForEach(i => {
                        if (string.Equals(i.Name, itemName, StringComparison.InvariantCultureIgnoreCase) && index == position) {
                            looter.Player.Inventory.AddItemToInventory(i);
                            sb.AppendLine("You loot " + i.Name + " from " + FirstName);
                            index = -1; //we found it and don't need this to match anymore
                            looted = true;
                            //no need to break since we are checking on index and I doubt a player will have so many items in their inventory that it will
                            //take a long time to go through each of them
                        }
                        else {
                            index++;
                        }
                    });
                }
                else {
                    sb.AppendLine(FirstName + " is carrying: ");
                    Inventory.GetInventoryAsItemList().ForEach(i => sb.AppendLine(i.Name));
                }
            }
            return looted;
        }
开发者ID:vadian,项目名称:Novus,代码行数:52,代码来源:Character.cs

示例3: Group

        //The group commands will basically follow this following format:
        //group create The Ragtag Squad
        //group invite willy wonka
        //group disband
        //this will further parse the command line and call the appropriate group commands
        public static void Group(User.User player, List<string> commands)
        {
            bool inGroup = !string.IsNullOrEmpty(player.GroupName);
            string name = RemoveWords(commands[0]);
            User.User user = null;
            if (commands.Count > 2) {
                switch (commands[2]) {
                    case "create":
                        Groups.Groups.GetInstance().CreateGroup(player.UserID, name);
                        break;
                    case "disband":
                        Groups.Groups.GetInstance().DisbandGroup(player.UserID, player.GroupName);
                        break;
                    case "accept":
                        Groups.Groups.GetInstance().AcceptDenyJoinRequest(player.UserID, name, true);
                        break;
                    case "deny":
                        Groups.Groups.GetInstance().AcceptDenyJoinRequest(player.UserID, name, false);
                        break;
                    case "promote":
                        user = MySockets.Server.GetAUserByFullName(name);
                        if (user == null){
                            user = MySockets.Server.GetAUserByFirstName(name).FirstOrDefault();
                        }

                        if (user != null) {
                            Groups.Groups.GetInstance().PromoteToLeader(player.UserID, player.GroupName, user.UserID);
                        }
                        else {
                            player.MessageHandler("No player by that name was found.  If you only used a first name try including the last name as well.");
                        }
                        break;
                    case "join":
                        Groups.Groups.GetInstance().Join(player.UserID, name);
                        break;
                    case "invite":
                        Groups.Groups.GetInstance().InviteToGroup(player.UserID, name, player.GroupName);
                        break;
                    case "decline":
                        Groups.Groups.GetInstance().DeclineInvite(player.UserID, name);
                        break;
                    case "uninvite":
                        Groups.Groups.GetInstance().Uninvite(player.UserID, name, player.GroupName);
                        break;
                    case "kick":
                    case "remove":
                        Groups.Groups.GetInstance().RemovePlayerFromGroup(player.UserID, name, player.GroupName);
                        break;
                    case "list":
                        if (string.IsNullOrEmpty(name) || name.ToLower() == "all") {
                            player.MessageHandler(Groups.Groups.GetInstance().GetGroupNameOnlyList());
                        }
                        else {
                            player.MessageHandler(Groups.Groups.GetInstance().GetAllGroupInfo(name));
                        }
                        break;
                    case "request":
                        Groups.Groups.GetInstance().RequestGroupJoin(player.UserID, name);
                        break;
                    case "master":
                        user = MySockets.Server.GetAUserByFullName(name);
                        if (user == null) {
                            user = MySockets.Server.GetAUserByFirstName(name).FirstOrDefault();
                        }
                        if (user == null) {
                            player.MessageHandler("No player by that name was found.  If you only used a first name try including the last name as well.");
                        }
                        else {
                            Groups.Groups.GetInstance().AssignMasterLooter(player.UserID, name, player.GroupName);
                        }
                        break;
                    case "lootrule":
                        Groups.GroupLootRule newRule = Groups.GroupLootRule.Leader_only;
                        switch (commands[3]) {
                            case "master":
                                newRule = Groups.GroupLootRule.Master_Looter;
                                break;
                            case "leader":
                                newRule = Groups.GroupLootRule.Leader_only;
                                break;
                            case "chance":
                                newRule = Groups.GroupLootRule.Chance_Loot;
                                break;
                            case "first":
                                newRule = Groups.GroupLootRule.First_to_loot;
                                break;
                            case "next":
                                newRule = Groups.GroupLootRule.Next_player_loots;
                                break;
                        }
                        Groups.Groups.GetInstance().ChangeLootingRule(player.UserID, player.GroupName, newRule);
                        break;
                    case "joinrule":
                        Groups.GroupJoinRule joinRule = Groups.GroupJoinRule.Friends_only;
                        if (commands.Count > 3) {
//.........这里部分代码省略.........
开发者ID:vadian,项目名称:Novus,代码行数:101,代码来源:Groups.cs

示例4: Loot

        public bool Loot(User.User looter, List<string> commands, bool byPassCheck = false)
        {
            bool looted = false;
            if (IsDead()) {
                List<Items.Iitem> result = new List<Items.Iitem>();
                StringBuilder sb = new StringBuilder();

                if (!byPassCheck) {
                    //Let's see if who's looting was the killer otherwise we check the time of death
                    //also check if looter is part of a group if so then the group will provide the loot logic.
                    if (!string.Equals(looter.UserID, ((Iactor)this).KillerID, StringComparison.InvariantCultureIgnoreCase)) {
                        if (!CanLoot(looter.UserID)) {
                            //looter not the killer not in group and time to loot has not expired
                            looter.MessageHandler("You did not deal the killing blow and can not loot this corpse at this time.");
                            return false;
                        }
                    }

                    //let's check if looter is in a group
                    if (!string.IsNullOrEmpty(looter.GroupName)) {
                        //looter is part of a group, let's see if the group loot rule is free for all first
                        Groups.Group group = Groups.Groups.GetInstance().GetGroup(looter.GroupName);
                        if (group.GroupRuleForLooting != Groups.GroupLootRule.First_to_loot) {
                            group.Loot(looter, commands, this);
                            return false;
                        }
                    }
                }

                if (commands.Contains("all")) {
                    sb.AppendLine("You loot the following items from " + FirstName + ":");
                    Inventory.GetInventoryAsItemList().ForEach(i => {
                        sb.AppendLine(i.Name);
                        looter.Player.Inventory.AddItemToInventory(Inventory.RemoveInventoryItem(i, this.Equipment));
                    });

                    looted = true;
                }
                else if (commands.Count > 2) { //the big one, should allow to loot individual item from the inventory
                    string itemName = Items.Items.ParseItemName(commands);
                    int index = 1;
                    int position = 1;
                    string[] positionString = commands[0].Split('.'); //we are separating based on using the decimal operator after the name of the npc/item
                    if (positionString.Count() > 1) {
                        int.TryParse(positionString[positionString.Count() - 1], out position);
                    }

                    Inventory.GetInventoryAsItemList().ForEach(i => {
                        if (string.Equals(i.Name, itemName, StringComparison.InvariantCultureIgnoreCase) && index == position) {
                            looter.Player.Inventory.AddItemToInventory(Inventory.RemoveInventoryItem(i, this.Equipment));

                            sb.AppendLine("You loot " + i.Name + " from " + FirstName);
                            Rooms.Room.GetRoom(looter.Player.Location).InformPlayersInRoom(string.Format("{0} loots {1} from {3}'s lifeless body.", looter.Player.FirstName, i.Name, FirstName), new List<string>() { ID });
                            index = -1; //we found it and don't need this to match anymore
                            looted = true;
                        }
                        else {
                            index++;
                        }
                    });
                }
                else {
                    sb.AppendLine(FirstName + " was carrying: ");
                    Inventory.GetInventoryAsItemList().ForEach(i => sb.AppendLine(i.Name));
                }

                looter.MessageHandler(sb.ToString());
            }
            return looted;
        }
开发者ID:vadian,项目名称:Novus,代码行数:70,代码来源:NPC.cs


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