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


C# MabiCreature.GiveItem方法代码示例

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


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

示例1: CreatureCompletesQuest

        public void CreatureCompletesQuest(MabiCreature creature, MabiQuest quest, bool rewards)
        {
            if (rewards)
            {
                // Owl
                WorldManager.Instance.Broadcast(new MabiPacket(Op.QuestOwlComplete, creature.Id).PutLong(quest.Id), SendTargets.Range, creature);

                // Rewards
                foreach (var reward in quest.Info.Rewards)
                {
                    switch (reward.Type)
                    {
                        case RewardType.Exp:
                            creature.GiveExp(reward.Amount);
                            creature.Client.Send(PacketCreator.AcquireExp(creature, reward.Amount));
                            this.CreatureStatsUpdate(creature);
                            break;

                        case RewardType.Gold:
                            creature.GiveItem(2000, reward.Amount);
                            creature.Client.Send(PacketCreator.AcquireItem(creature, reward.Id, reward.Amount));
                            break;

                        case RewardType.Item:
                            creature.GiveItem(reward.Id, reward.Amount);
                            creature.Client.Send(PacketCreator.AcquireItem(creature, reward.Id, reward.Amount));
                            break;

                        case RewardType.Skill:
                            var id = (SkillConst)reward.Id;
                            var rank = (SkillRank)reward.Amount;

                            // Only give skill if char doesn't have it or rank is lower.
                            var skill = creature.Skills.Get(id);
                            if (skill == null || skill.Rank < rank)
                            {
                                creature.Skills.Give(id, rank);
                                WorldManager.Instance.CreatureStatsUpdate(creature);
                            }
                            break;

                        default:
                            Logger.Warning("Unsupported reward type '{0}'.", reward.Type);
                            break;
                    }
                }

                // Only call this if there were rewards, we're using this
                // method to clear quests as well.
                var script = ScriptManager.Instance.GetQuestScript(quest.Info.Id);
                if (script != null)
                    script.OnCompleted(creature.Client as WorldClient, quest);
            }

            Send.ItemInfo(creature.Client, creature, quest.QuestItem);

            // Remove from quest log.
            creature.Client.Send(new MabiPacket(Op.QuestClear, creature.Id).PutLong(quest.Id));
        }
开发者ID:pjm0616,项目名称:aura,代码行数:59,代码来源:WorldManager.cs


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