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


C# ICharacter.MapDropItem方法代码示例

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


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

示例1: DamageCharacter

        private static void DamageCharacter(ICharacter character, IMap map, int dmg, Enums.KillType killType, PacketHitList hitlist, bool checkDeath)
        {
            int point = 0;
            try {
                character.HP -= dmg;

                if (dmg <= 0) {
                    hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " took no damage!", Text.BrightRed), character.X, character.Y, 10);
                    //BothWaysBattleMsg(setup, setup.Defender.Name + " took no damage!", Text.BrightRed);
                } else {
                    hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " took " + dmg + " damage!", Text.BrightRed), character.X, character.Y, 10);
                    //BothWaysBattleMsg(setup, setup.Defender.Name + " took " + damage + " damage!", Text.BrightRed);
                }

                point = 1;

                if (checkDeath && character.HP <= 0) {
                    if (character.CharacterType == Enums.CharacterType.Recruit) {

                        point = 2;
                        hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg("Oh, no!  " + character.Name + " fainted!", Text.BrightRed));
                        point = 3;
                        OnDeath(((Recruit)character).Owner, Enums.KillType.Other);
                        point = 4;

                    } else {

                        if (character.HeldItem != null) {
                            character.MapDropItem(character.HeldItem.Amount, null);
                        }

                        OnNpcDeath(hitlist, null, (MapNpc)character);
                        //((MapNpc)character).Num = 0;
                        //((MapNpc)character).HP = 0;
                        map.ActiveNpc[((MapNpc)character).MapSlot] = new MapNpc(character.MapID, ((MapNpc)character).MapSlot);

                        hitlist.AddPacketToMap(map, TcpPacket.CreatePacket("npcdead", ((MapNpc)character).MapSlot));

                    }
                }
            } catch(Exception ex) {
                Messenger.AdminMsg("Error: DamageCharacter", Text.Black);
                Messenger.AdminMsg(ex.ToString(), Text.Black);
                Messenger.AdminMsg(character.Name + " took " + dmg + " dmg at " + map.Name + " from " + killType + " with checkDeath=" + checkDeath + " and point=" + point, Text.Black);
                throw new Exception();
            }
        }
开发者ID:MandL27,项目名称:Server,代码行数:47,代码来源:BattleScript.cs


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