Ejemplo n.º 1
0
 private void OnHireResultMessage(HireResultMessage msg)
 {
     var res = FollowerPackageModule.GetFollowerPackages();
     if (msg.Result == OkTag)
     {
         foreach (var obj in msg.Followers)
         {
             var follower = res.GetFollowerById(obj.Value, obj.Key);
             PlayerObject.Instance.Self.AllFollower.Followers.Add(follower);
             FollowerObjectManager.Instance.AddObj(follower.ObjectId, follower);
         }
         MessageManager.SendMessage("Message.HireFollower.Success");
     }
     else
     {
         MessageManager.SendMessage("Message.HireFollower.Failed");
     }
 }
Ejemplo n.º 2
0
        private void HireFollowerMessageImpl(NetIncomingMessage im, MessageBase msg)
        {
            var hireMsg     = msg as HireFollowerMessage;
            var r           = new HireResultMessage();

            if(AdventurePluginDB.User.Get(hireMsg.PlayerId) != null)
            {
                r.Result        = OkTag;
                var follower    = AdventurePluginDB.PlayerFollower.GetPlayerFollower(hireMsg.PlayerId);

                var ObjectIdList = new List<int>();
                foreach (var id in hireMsg.FollowerId)
                {
                    var objId   = ObjectId;
                    r.Followers.Add(new KeyValuePair<int, int>(objId, id));
                    ObjectIdList.Add(objId);

                    var info = new FollowerInfo()
                    {
                        FollowerID  = id,
                        ObjectID    = objId,
                    };
                    AdventurePluginDB.Follower.Create(info);
                }

                follower.FollowerList.AddRange(ObjectIdList);
                AdventurePluginDB.PlayerFollower.Update(follower);
            }
            else
            {
                r.Result = ErrorTag;
            }
            SharedServer.SendMessage(r, im.SenderConnection);
        }