Пример #1
0
        internal static void Execute(object msg, User user)
        {
            Msg_CR_PickUpNpc pickUpNpcMsg = msg as Msg_CR_PickUpNpc;

            if (null != pickUpNpcMsg)
            {
                UserInfo userInfo = user.Info;
                if (null != userInfo)
                {
                    Scene scene = user.OwnRoom.GetActiveScene();
                    if (null != scene)
                    {
                        NpcInfo npc = scene.SceneContext.GetCharacterInfoById(pickUpNpcMsg.npc_id) as NpcInfo;
                        if (null != npc && npc.OwnerId == userInfo.GetId())
                        {
                            npc.NeedDelete = true;
                            DropOutInfo info = npc.GetAiStateInfo().AiDatas.GetData <DropOutInfo>();
                            if (null != info)
                            {
                                userInfo.Money += info.Value;
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        private void DropNpc(Vector3 pos, int money, string model, string particle)
        {
            //给每个玩家掉落一个
            Data_Unit unit = new Data_Unit();

            unit.m_Id       = -1;
            unit.m_LinkId   = 100001;
            unit.m_AiLogic  = (int)AiStateLogicId.DropOut_AutoPick;
            unit.m_RotAngle = 0;
            for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                UserInfo userInfo = linkNode.Value;
                if (null != userInfo)
                {
                    float x = CrossEngineHelper.Random.NextFloat() * 4 - 2;
                    float z = CrossEngineHelper.Random.NextFloat() * 4 - 2;
                    pos.X += x;
                    pos.Z += z;

                    NpcInfo npcInfo = NpcManager.AddNpc(unit);
                    npcInfo.GetMovementStateInfo().SetPosition(pos);
                    npcInfo.GetMovementStateInfo().SetFaceDir(0);
                    npcInfo.GetMovementStateInfo().IsMoving = false;
                    npcInfo.SetAIEnable(true);
                    npcInfo.SetCampId((int)CampIdEnum.Friendly);
                    npcInfo.OwnerId   = userInfo.GetId();
                    npcInfo.DropMoney = money;

                    DropOutInfo dropInfo = new DropOutInfo();
                    dropInfo.DropType = DropOutType.GOLD;
                    dropInfo.Value    = money;
                    dropInfo.Model    = model;
                    dropInfo.Particle = particle;
                    npcInfo.GetAiStateInfo().AiDatas.AddData <DropOutInfo>(dropInfo);
                    npcInfo.SetModel(dropInfo.Model);

                    User us = userInfo.CustomData as User;
                    if (null != us)
                    {
                        Msg_RC_CreateNpc builder = DataSyncUtility.BuildCreateNpcMessage(npcInfo);
                        us.SendMessage(builder);
                    }
                }
            }
        }
Пример #3
0
        internal void DropNpc(int ownerId, int fromNpcId, DropOutType dropType, string model, string particle, int num)
        {
            if (ownerId > 0)
            {
                UserInfo user = UserManager.GetUserInfo(ownerId);
                if (null == user)
                {
                    NpcInfo npc = NpcManager.GetNpcInfo(ownerId);
                    while (null != npc)
                    {
                        user = UserManager.GetUserInfo(npc.OwnerId);
                        if (null != user)
                        {
                            break;
                        }
                        else
                        {
                            npc = NpcManager.GetNpcInfo(npc.OwnerId);
                        }
                    }
                }
                if (null != user)
                {
                    Data_Unit unit = new Data_Unit();
                    unit.m_Id = -1;
                    switch (dropType)
                    {
                    case DropOutType.GOLD:
                        unit.m_LinkId = (int)DropNpcTypeEnum.GOLD;
                        break;

                    case DropOutType.HP:
                        unit.m_LinkId = (int)DropNpcTypeEnum.HP;
                        break;

                    case DropOutType.MP:
                        unit.m_LinkId = (int)DropNpcTypeEnum.MP;
                        break;

                    case DropOutType.MULT_GOLD:
                        unit.m_LinkId = (int)DropNpcTypeEnum.MUTI_GOLD;
                        break;
                    }
                    unit.m_RotAngle = 0;

                    NpcInfo npcInfo = NpcManager.AddNpc(unit);
                    npcInfo.GetMovementStateInfo().SetFaceDir(0);
                    npcInfo.GetMovementStateInfo().IsMoving = false;
                    npcInfo.SetAIEnable(true);
                    npcInfo.SetCampId(user.GetCampId());
                    npcInfo.OwnerId = user.GetId();

                    DropOutInfo dropInfo = new DropOutInfo();
                    dropInfo.DropType = dropType;
                    dropInfo.Value    = num;
                    dropInfo.Model    = model;
                    dropInfo.Particle = particle;

                    npcInfo.GetAiStateInfo().AiDatas.AddData <DropOutInfo>(dropInfo);
                    npcInfo.SetModel(dropInfo.Model);

                    User us = user.CustomData as User;
                    if (null != us)
                    {
                        Msg_RC_DropNpc builder = DataSyncUtility.BuildDropNpcMessage(npcInfo, fromNpcId, (int)dropType, num, model);
                        us.SendMessage(builder);
                    }
                }
            }
            else
            {
                int      ct   = UserManager.Users.Count;
                int      rd   = CrossEngineHelper.Random.Next(0, ct);
                UserInfo user = null;
                if (UserManager.Users.TryGetValue(rd, out user))
                {
                    Data_Unit unit = new Data_Unit();
                    unit.m_Id = -1;
                    switch (dropType)
                    {
                    case DropOutType.GOLD:
                        unit.m_LinkId = (int)DropNpcTypeEnum.GOLD;
                        break;

                    case DropOutType.HP:
                        unit.m_LinkId = (int)DropNpcTypeEnum.HP;
                        break;

                    case DropOutType.MP:
                        unit.m_LinkId = (int)DropNpcTypeEnum.MP;
                        break;

                    case DropOutType.MULT_GOLD:
                        unit.m_LinkId = (int)DropNpcTypeEnum.MUTI_GOLD;
                        break;
                    }
                    unit.m_RotAngle = 0;

                    NpcInfo npcInfo = NpcManager.AddNpc(unit);
                    npcInfo.GetMovementStateInfo().SetFaceDir(0);
                    npcInfo.GetMovementStateInfo().IsMoving = false;
                    npcInfo.SetAIEnable(true);
                    npcInfo.SetCampId(user.GetCampId());
                    npcInfo.OwnerId = user.GetId();

                    DropOutInfo dropInfo = new DropOutInfo();
                    dropInfo.DropType = dropType;
                    dropInfo.Value    = num;
                    dropInfo.Model    = model;
                    dropInfo.Particle = particle;

                    npcInfo.GetAiStateInfo().AiDatas.AddData <DropOutInfo>(dropInfo);
                    npcInfo.SetModel(dropInfo.Model);

                    User us = user.CustomData as User;
                    if (null != us)
                    {
                        Msg_RC_DropNpc builder = DataSyncUtility.BuildDropNpcMessage(npcInfo, fromNpcId, (int)dropType, num, model);
                        us.SendMessage(builder);
                    }
                }
            }
        }