Ejemplo n.º 1
0
        public void Update(IEventArgs args)
        {
            foreach (string key in currentBufs.Keys)
            {
                List <EffectBuf> list = currentBufs[key];
                for (int i = list.Count - 1; i >= 0; i--)
                {
                    if (args.Rule.ServerTime - list[i].startTime > list[i].time && list[i].time > 0)
                    {
                        list.Remove(list[i]);
                    }
                }
            }

            float[] effects = new float[lastEffects.Length];

            foreach (string key in currentBufs.Keys)
            {
                List <EffectBuf> list = currentBufs[key];
                if (list.Count > 0)
                {
                    EffectBuf buf = currentBufs[key][0];
                    effects[(int)buf.type] += buf.level;
                }
            }

            for (int i = 0; i < effects.Length; i++)
            {
                float last    = lastEffects[i];
                float current = effects[i];
                if (last != current)
                {
                    SimpleProto sp = null;

                    switch ((EffectType)i)
                    {
                    case EffectType.SpeedUp:
                        player.stateInterface.State.SetSpeedAffect(current);
                        sp     = FreePool.Allocate();
                        sp.Key = FreeMessageConstant.PlayerMoveSpeedSet;
                        sp.Fs.Add(current);
                        FreeMessageSender.SendMessage(player, sp);
                        break;

                    case EffectType.SlowDown:
                        player.stateInterface.State.SetSpeedAffect(current * -1);
                        sp     = FreePool.Allocate();
                        sp.Key = FreeMessageConstant.PlayerMoveSpeedSet;
                        sp.Fs.Add(current * -1);
                        FreeMessageSender.SendMessage(player, sp);
                        break;

                    default:
                        break;
                    }
                }
            }

            lastEffects = effects;
        }
Ejemplo n.º 2
0
 public override void DoAction(IEventArgs args)
 {
     if (inter)
     {
         if (fd != null)
         {
             fd.freeInventory.StopUseItem(args, fd, inter);
             SimpleProto msg = FreePool.Allocate();
             msg.Key = FreeMessageConstant.ChickenTip;
             msg.Ss.Add("word72," + ip.key.GetName());
             FreeMessageSender.SendMessage(fd.Player, msg);
             PlayerAnimationAction.DoAnimation(args.GameContext, PlayerAnimationAction.Stop, fd.Player);
             //FreeSoundUtil.Stop("use", args, fd);
             PlayerStateUtil.RemoveGameState(EPlayerGameState.InterruptItem, fd.Player.gamePlay);
             PlayerStateUtil.RemoveGameState(EPlayerGameState.UseItem, fd.Player.gamePlay);
         }
     }
     else
     {
         if (ip != null && fd != null)
         {
             UseItem(ip, fd, (ISkillArgs)args);
             fd.freeInventory.StopUseItem(args, fd, inter);
             PlayerAnimationAction.DoAnimation(args.GameContext, PlayerAnimationAction.Interrupt, fd.Player);
             PlayerStateUtil.RemoveGameState(EPlayerGameState.UseItem, fd.Player.gamePlay);
         }
     }
 }
Ejemplo n.º 3
0
        public override void DoAction(IEventArgs args)
        {
            if (string.IsNullOrEmpty(this.player))
            {
                this.player = "current";
            }
            var unit = GetPlayer(args);

            if (skills != null && unit != null)
            {
                foreach (var skill in skills)
                {
                    unit.GetUnitSkill().AddSkill((ISkill)SerializeUtil.Clone(skill));
                }

                byte[] bs = SerializeUtil.ObjectToByte(skills);

                SimpleProto msg = FreePool.Allocate();
                msg.Key = FreeMessageConstant.ClientSkill;
                for (int i = 0; i < bs.Length; i++)
                {
                    msg.Ins.Add(bs[i]);
                }

                FreeMessageSender.SendMessage(unit.Player, msg);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 手雷加入背包
        /// </summary>
        /// <param name="args"></param>
        private void HandleAddGrenade(IEventArgs args)
        {
            PlayerEntity playerEntity = ((FreeRuleEventArgs)args).GetPlayer(FreeArgConstant.PlayerCurrent);

            if (playerEntity != null)
            {
                int itemId = FreeUtil.ReplaceInt(ParaItemId, args);
                int count  = FreeUtil.ReplaceInt(ParaItemCount, args);
                for (int i = 0; i < count; i++)
                {
                    var helper = playerEntity.WeaponController().GrenadeHelper;
                    playerEntity.WeaponController().TryHoldGrenade(itemId);
                    SimpleProto message = new SimpleProto();
                    message.Ks.Add(8);
                    message.Ins.Add(itemId);
                    message.Bs.Add(true);
                    message.Key = FreeMessageConstant.ChangeAvatar;
                    FreeMessageSender.SendMessage(playerEntity, message);



                    //playerEntity.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, message);
                }
            }
        }
Ejemplo n.º 5
0
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity player = GetPlayerEntity(args);

            if (player == null)
            {
                return;
            }

            if (args.Rule.ServerTime - player.statisticsData.Statistics.LastDeadTime <= 2900L)
            {
                return;
            }

            int oldObserveId = player.gamePlay.CameraEntityId;

            bool success = ObservePlayer(args, player, args.GetBool(observeEnemy), args.GetBool(wise));

            if (!success)
            {
                if (noOneAction != null)
                {
                    noOneAction.Act(args);
                }
            }

            if (oldObserveId != player.gamePlay.CameraEntityId)
            {
                SimpleProto sp = FreePool.Allocate();
                sp.Key = FreeMessageConstant.PlayerObserveTrigger;
                sp.Bs.Add(true);
                FreeMessageSender.SendMessage(player, sp);
            }
        }
Ejemplo n.º 6
0
        private void StopSave(PlayerEntity playerEntity, bool isInterrupted)
        {
            if (SharedConfig.IsServer)
            {
                playerEntity.gamePlay.SaveTime = 0;
                if (playerEntity.gamePlay.IsSave)
                {
                    PlayerAnimationAction.DoAnimation(_contexts, PlayerAnimationAction.RescueEnd, playerEntity, true);
                    playerEntity.gamePlay.IsSave = false;
                }
                if (playerEntity.gamePlay.IsBeSave)
                {
                    if (!isInterrupted)
                    {
                        playerEntity.gamePlay.IsStandPosture = false;
                        //PlayerAnimationAction.DoAnimation(_contexts, PlayerAnimationAction.Revive, playerEntity, true);
                    }
                    playerEntity.gamePlay.IsBeSave = false;
                }

                SimpleProto data = FreePool.Allocate();
                data.Key = FreeMessageConstant.CountDown;
                data.Bs.Add(false);
                data.Fs.Add(0);
                data.Bs.Add(!isInterrupted);
                if (isInterrupted)
                {
                    data.Ins.Add((int)ETipType.CanNotRescure);
                }
                FreeMessageSender.SendMessage(playerEntity, data);
            }
        }
Ejemplo n.º 7
0
        private void SendCmd(PlayerEntity player)
        {
            SimpleProto proto = FreePool.Allocate();

            proto.Key = FreeMessageConstant.PlayerCmd;
            proto.Ks.Add(0);
            FreeMessageSender.SendMessage(player, proto);
        }
Ejemplo n.º 8
0
        public override void DoAction(IEventArgs args)
        {
            SimpleProto builder = FreePool.Allocate();

            builder.Key = FreeMessageConstant.GroupTechStatUI;

            builder.Ins.Add(args.GameContext.player.count);

            List <TechStat> list = new List <TechStat>();

            int  index    = 0;
            bool needSort = true;

            foreach (PlayerEntity p in args.GameContext.player.GetInitializedPlayerEntities())
            {
                TechStat ts = new TechStat(p, index++);
                builder.Ps.Add(ts.ToMessage());
                list.Add(ts);
                if (!p.statisticsData.Statistics.DataCollectSwitch)
                {
                    needSort = false;
                }
            }

            if (needSort)
            {
                list.Sort(KillComparater);
                if (list.Count > 0 && list[0].kill > 0)
                {
                    TechStat ts = list[0];
                    builder.Ps[ts.index].Ins[2] |= (1 << (int)EUIGameTitleType.Ace);
                }
                if (list.Count > 1 && list[1].kill > 0)
                {
                    TechStat ts = list[1];
                    builder.Ps[ts.index].Ins[2] |= (1 << (int)EUIGameTitleType.Second);
                }
                if (list.Count > 2 && list[2].kill > 0)
                {
                    TechStat ts = list[2];
                    builder.Ps[ts.index].Ins[2] |= (1 << (int)EUIGameTitleType.Third);
                }

                list.Sort(KdComparater);
                if (list.Count > 0 && list[0].kd > 0)
                {
                    TechStat ts = list[0];
                    builder.Ps[ts.index].Ins[2] |= (1 << (int)EUIGameTitleType.KdKing);
                }
            }

            foreach (PlayerEntity p in args.GameContext.player.GetInitializedPlayerEntities())
            {
                FreeMessageSender.SendMessage(p, builder);
            }
        }
Ejemplo n.º 9
0
        public static void DoNothing(PlayerEntity player)
        {
            SimpleProto proto = FreePool.Allocate();

            proto.Key = FreeMessageConstant.PlayerCmd;
            proto.Ks.Add((int)PlayerActEnum.CmdType.Idle);
            proto.Ks.Add(player.entityKey.Value.EntityId);

            FreeMessageSender.SendMessage(player, proto);
        }
Ejemplo n.º 10
0
        public override void DoAction(IEventArgs args)
        {
            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

            IGameUnit unit = GetPlayer(args);

            if (unit != null)
            {
                PlayerEntity p = ((FreeData)unit).Player;


                int itemId = FreeUtil.ReplaceInt(weaponId, args);

                int index = FreeUtil.ReplaceInt(weaponKey, args);

                EWeaponSlotType st = FreeWeaponUtil.GetSlotType(index);

                Debug.LogFormat("add weapon: " + itemId + "," + index);
                Logger.Debug("add weapon to team " + p.playerInfo.Camp + " player " + p.playerInfo.PlayerName);

                SimpleProto message = new SimpleProto();
                if (index == 0)
                {
                    p.WeaponController().PickUpWeapon(WeaponUtil.CreateScan(itemId));
                    //p.bag.Bag.SetWeaponBullet(30);
                    //p.bag.Bag.SetReservedCount(100);
                }
                else
                {
                    p.WeaponController().ReplaceWeaponToSlot(st, WeaponUtil.CreateScan(itemId));

                    if (p.stateInterface.State.CanDraw() && p.WeaponController().HeldSlotType == EWeaponSlotType.None)
                    {
                        p.WeaponController().TryArmWeapon(st);
                    }

                    //SwitchWeaponAction.WeaponToHand(p, st);
                }

                message.Ins.Add(itemId);
                if (index > 0)
                {
                    message.Ins.Add((int)st);
                }
                else
                {
                    message.Ins.Add(-1);
                }

                message.Ks.Add(2);
                message.Key = FreeMessageConstant.ChangeAvatar;
                FreeMessageSender.SendMessage(p, message);
                //p.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, message);
            }
        }
Ejemplo n.º 11
0
        public override void DoAction(IEventArgs args)
        {
            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

            IGameUnit unit = GetPlayer(args);

            if (unit != null)
            {
                PlayerEntity p = ((FreeData)unit).Player;

                int             itemId = FreeUtil.ReplaceInt(weaponId, args);
                int             index  = FreeUtil.ReplaceInt(weaponKey, args);
                EWeaponSlotType st     = FreeWeaponUtil.GetSlotType(index);

                WeaponBaseAgent agent = null;
                if (index == 0)
                {
                    agent = p.WeaponController().HeldWeaponAgent;
                }
                else
                {
                    agent = p.WeaponController().GetWeaponAgent(st);
                }
                if (agent != null && agent.IsValid() && !FreeUtil.ReplaceBool(replace, args))
                {
                    return;
                }

                var scan = WeaponUtil.CreateScan(itemId);
                if (FreeUtil.ReplaceBool(fullAmmo, args))
                {
                    var weaponAllConfig = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(itemId);
                    scan.Bullet         = weaponAllConfig.PropertyCfg.Bullet;
                    scan.ReservedBullet = weaponAllConfig.PropertyCfg.Bulletmax;
                }
                if (index == 0)
                {
                    p.WeaponController().PickUpWeapon(scan);
                }
                else
                {
                    p.WeaponController().ReplaceWeaponToSlot(st, scan);
                    if (p.stateInterface.State.CanDraw() && p.WeaponController().HeldSlotType == EWeaponSlotType.None)
                    {
                        p.WeaponController().TryArmWeaponImmediately(st);
                    }
                }
                SimpleProto message = new SimpleProto();
                message.Key = FreeMessageConstant.PlaySound;
                message.Ks.Add(2);
                message.Ins.Add((int)EAudioUniqueId.PickupWeapon);
                message.Bs.Add(true);
                FreeMessageSender.SendMessage(p, message);
            }
        }
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity playerEntity = GetPlayerEntity(args);

            if (null != playerEntity)
            {
                playerEntity.statisticsData.Battle.Reset();
                SimpleProto sp = new SimpleProto();
                sp.Key = FreeMessageConstant.ResetBattleData;
                FreeMessageSender.SendMessage(playerEntity, sp);
            }
        }
Ejemplo n.º 13
0
        private void SendCmd(PlayerEntity player, Vector3 v)
        {
            SimpleProto proto = FreePool.Allocate();

            proto.Key = FreeMessageConstant.PlayerCmd;
            proto.Ks.Add(1);
            proto.Fs.Add(v.x);
            proto.Fs.Add(v.y);
            proto.Fs.Add(v.z);

            FreeMessageSender.SendMessage(player, proto);
        }
Ejemplo n.º 14
0
        public static void AttackPlayer(PlayerEntity player, int targetId)
        {
            SimpleProto proto = FreePool.Allocate();

            proto.Key = FreeMessageConstant.PlayerCmd;
            proto.Ks.Add((int)PlayerActEnum.CmdType.Attack);

            proto.Ks.Add(player.entityKey.Value.EntityId);
            proto.Ks.Add(targetId);

            FreeMessageSender.SendMessage(player, proto);
        }
Ejemplo n.º 15
0
        public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message)
        {
            FreeData fd = (FreeData)player.freeData.FreeData;

            room.ContextsWrapper.FreeArgs.TempUse(PARA_PLAYER_CURRENT, fd);

            string key   = message.Ss[0];
            int    count = message.Ins[0];

            if (key.StartsWith(ChickenConstant.BagDefault))
            {
                ItemPosition ip   = FreeItemManager.GetItemPosition(room.ContextsWrapper.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager());
                FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey());

                if (ip.GetCount() > count)
                {
                    if (info.cat == (int)ECategory.Weapon && SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(info.id).Type == (int)EWeaponType_Config.ThrowWeapon)
                    {
                        CarryClipUtil.DeleteGrenade(count, info.id, fd, room.ContextsWrapper.FreeArgs);
                        for (int i = 0; i < count; i++)
                        {
                            player.WeaponController().RemoveGreande(info.id);
                        }
                    }
                    else
                    {
                        ip.SetCount(ip.GetCount() - count);
                        ip.GetInventory().GetInventoryUI().ReDraw((ISkillArgs)room.ContextsWrapper.FreeArgs, ip.GetInventory(), true);
                    }
                }
                else
                {
                    ip.GetInventory().RemoveItem((ISkillArgs)room.ContextsWrapper.FreeArgs, ip);
                }

                room.RoomContexts.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleObjectEntity(
                    (ECategory)info.cat, info.id, count, fd.Player.position.Value);

                if (info.cat == (int)ECategory.GameItem && SingletonManager.Get <GameItemConfigManager>().GetConfigById(info.id).Type == (int)GameItemType.Bullet)
                {
                    player.WeaponController().SetReservedBullet((EBulletCaliber)info.id, CarryClipUtil.GetClipCount(info.id, fd, room.ContextsWrapper.FreeArgs));
                }

                SimpleProto sp = FreePool.Allocate();
                sp.Key = FreeMessageConstant.PlaySound;
                sp.Ks.Add(2);
                sp.Ins.Add(5017);
                sp.Bs.Add(false);
                FreeMessageSender.SendMessage(fd.Player, sp);
            }

            room.ContextsWrapper.FreeArgs.Resume(PARA_PLAYER_CURRENT);
        }
Ejemplo n.º 16
0
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity player = GetPlayerEntity(args);

            SimpleProto msg = FreePool.Allocate();

            msg.Key = FreeMessageConstant.PlayerPressKey;
            msg.Bs.Add(args.GetBool(press));
            msg.Ss.Add(key);
            msg.Ins.Add(args.GetInt(time));
            FreeMessageSender.SendMessage(player, msg);
        }
Ejemplo n.º 17
0
        public static bool CanExchangeAttachment(ServerRoom room, FreeData fd, FreeItemInfo fromPart, FreeItemInfo toPart, WeaponBaseAgent fromAgent, WeaponBaseAgent toAgent)
        {
            double capacity = Math.Round(GetCapacity(fd) - GetWeight(fd), 3);

            int toBullet   = SingletonManager.Get <WeaponPartsConfigManager>().GetConfigById(WeaponPartUtil.GetWeaponFstMatchedPartId(toPart.id, fromAgent.ConfigId)).Bullet;
            int fromBullet = SingletonManager.Get <WeaponPartsConfigManager>().GetConfigById(WeaponPartUtil.GetWeaponFstMatchedPartId(fromPart.id, toAgent.ConfigId)).Bullet;

            if (toBullet == fromBullet)
            {
                return(true);
            }

            int overBulletFrom = fromAgent.BaseComponent.Bullet - fromAgent.WeaponConfigAssy.PropertyCfg.Bullet - toBullet;
            int overBulletTo   = toAgent.BaseComponent.Bullet - toAgent.WeaponConfigAssy.PropertyCfg.Bullet - fromBullet;

            float bulletWeight = 0f;

            if (overBulletFrom > 0)
            {
                bulletWeight += SingletonManager.Get <GameItemConfigManager>().GetConfigById((int)fromAgent.Caliber).Weight *overBulletFrom;
            }

            if (overBulletTo > 0)
            {
                bulletWeight += SingletonManager.Get <GameItemConfigManager>().GetConfigById((int)toAgent.Caliber).Weight *overBulletTo;
            }

            if (capacity < bulletWeight)
            {
                SimpleProto msg = FreePool.Allocate();
                msg.Key = FreeMessageConstant.ChickenTip;
                msg.Ss.Add("word79");
                FreeMessageSender.SendMessage(fd.Player, msg);
                return(false);
            }

            if (overBulletFrom > 0)
            {
                fromAgent.BaseComponent.Bullet = fromAgent.WeaponConfigAssy.PropertyCfg.Bullet + toBullet;
                CarryClipUtil.AddClip(overBulletFrom, (int)fromAgent.Caliber, fd, room.ContextsWrapper.FreeArgs);
                fd.Player.WeaponController().SetReservedBullet(fromAgent.Caliber, CarryClipUtil.GetClipCount((int)fromAgent.Caliber, fd, room.ContextsWrapper.FreeArgs));
            }

            if (overBulletTo > 0)
            {
                toAgent.BaseComponent.Bullet = toAgent.WeaponConfigAssy.PropertyCfg.Bullet + fromBullet;
                CarryClipUtil.AddClip(overBulletTo, (int)toAgent.Caliber, fd, room.ContextsWrapper.FreeArgs);
                fd.Player.WeaponController().SetReservedBullet(toAgent.Caliber, CarryClipUtil.GetClipCount((int)toAgent.Caliber, fd, room.ContextsWrapper.FreeArgs));
            }

            return(true);
        }
Ejemplo n.º 18
0
        public static void PressKeys(PlayerEntity player, int key, int time)
        {
            SimpleProto proto = FreePool.Allocate();

            proto.Key = FreeMessageConstant.PlayerCmd;
            proto.Ks.Add((int)PlayerActEnum.CmdType.PressKey);
            proto.Ks.Add(player.entityKey.Value.EntityId);

            proto.Ins.Add(time);
            proto.Ins.Add(key);

            FreeMessageSender.SendMessage(player, proto);
        }
Ejemplo n.º 19
0
        private void handleToGround(string from, string to, ServerRoom room, FreeData fd)
        {
            PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, fd.Player.gamePlay);
            FreeItemManager.DragItem(from, fd, room.ContextsWrapper.FreeArgs, ChickenConstant.BagGround);

            SimpleProto sp = FreePool.Allocate();

            sp.Key = FreeMessageConstant.PlaySound;
            sp.Ks.Add(2);
            sp.Ins.Add(5017);
            sp.Bs.Add(false);
            FreeMessageSender.SendMessage(fd.Player, sp);
        }
Ejemplo n.º 20
0
        private void HandleAuto(string from, string to, ServerRoom room, FreeData fd)
        {
            SimpleItemInfo info = PickupItemUtil.GetGroundItemInfo(room, fd, from);

            if (PickupItemUtil.AddItemToPlayer(room, fd.Player, info.entityId, info.cat, info.id, info.count, to))
            {
                SimpleProto sp = FreePool.Allocate();
                sp.Key = FreeMessageConstant.PlaySound;
                sp.Ks.Add(2);
                sp.Ins.Add(5018);
                sp.Bs.Add(false);
                FreeMessageSender.SendMessage(fd.Player, sp);
            }
        }
Ejemplo n.º 21
0
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity player = GetPlayerEntity(args);

            if (player != null && player.gamePlay.CameraEntityId != 0)
            {
                player.gamePlay.CameraEntityId = 0;

                SimpleProto sp = FreePool.Allocate();
                sp.Key = FreeMessageConstant.PlayerObserveTrigger;
                sp.Bs.Add(false);
                FreeMessageSender.SendMessage(player, sp);
            }
        }
Ejemplo n.º 22
0
        public static void WalkTo(PlayerEntity player, Vector3 v)
        {
            SimpleProto proto = FreePool.Allocate();

            proto.Key = FreeMessageConstant.PlayerCmd;
            proto.Ks.Add((int)PlayerActEnum.CmdType.Walk);
            proto.Ks.Add(player.entityKey.Value.EntityId);

            proto.Fs.Add(v.x);
            proto.Fs.Add(v.y);
            proto.Fs.Add(v.z);

            FreeMessageSender.SendMessage(player, proto);
        }
Ejemplo n.º 23
0
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity    playerEntity = GetPlayerEntity(args);
            int             index        = FreeUtil.ReplaceInt(weaponKey, args);
            EWeaponSlotType st           = FreeWeaponUtil.GetSlotType(index);

            playerEntity.WeaponController().PureSwitchIn(st);

            SimpleProto message = FreePool.Allocate();

            message.Key = FreeMessageConstant.ChangeWeapon;
            message.Ins.Add(index);
            FreeMessageSender.SendMessage(playerEntity, message);
        }
Ejemplo n.º 24
0
        public override void DoAction(IEventArgs args)
        {
            if (string.IsNullOrEmpty(player))
            {
                player = "current";
            }

            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

            PlayerEntity playerEntity = (PlayerEntity)fr.GetEntity(player);

            IParable item = args.GetUnit("item");

            if (playerEntity != null && item != null)
            {
                EWeaponSlotType type = FreeWeaponUtil.GetSlotType(FreeUtil.ReplaceInt(weaponKey, args));

                SimpleProto message = FreePool.Allocate();
                message.Key = FreeMessageConstant.ChangeAvatar;

                int itemId = FreeUtil.ReplaceInt("{item.itemId}", args);

                if (!delete)
                {
                    playerEntity.WeaponController().SetWeaponPart(type, itemId);

                    message.Ins.Add((int)type);
                    message.Ins.Add(itemId);
                    message.Ks.Add(3);

                    FreeMessageSender.SendMessage(playerEntity, message);
                    //playerEntity.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, message);
                }
                else
                {
                    var part = SingletonManager.Get <WeaponPartsConfigManager>().GetPartType(SingletonManager.Get <WeaponPartSurvivalConfigManager>().GetDefaultPartBySetId(itemId));

                    playerEntity.WeaponController().DeleteWeaponPart(type, part);

                    message.Ins.Add((int)type);
                    message.Ins.Add((int)part);
                    message.Ks.Add(4);

                    FreeMessageSender.SendMessage(playerEntity, message);
                    //playerEntity.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, message);
                }
            }
        }
Ejemplo n.º 25
0
        public static bool CanTakeOff(IEventArgs args, FreeData fd, int cat, int id)
        {
            FreeItemInfo info = FreeItemConfig.GetItemInfo(cat, id);

            if (info.cat == (int)ECategory.Avatar)
            {
                if (GetCapacity(fd) - GetWeight(fd) < info.capacity)
                {
                    SimpleProto msg = FreePool.Allocate();
                    msg.Key = FreeMessageConstant.ChickenTip;
                    msg.Ss.Add("word74");
                    FreeMessageSender.SendMessage(fd.Player, msg);
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 26
0
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity playerEntity = GetPlayerEntity(args);

            playerEntity.gamePlay.Invisible         = !visibility;
            playerEntity.gamePlay.VisibleToTeammate = teammate;
            foreach (PlayerEntity pe in args.GameContext.player.GetEntities())
            {
                if (playerEntity != pe && (pe.playerInfo.TeamId == playerEntity.playerInfo.TeamId) == teammate)
                {
                    SimpleProto sp = FreePool.Allocate();
                    sp.Key = FreeMessageConstant.PlayerVisibility;
                    sp.Ls.Add(playerEntity.playerInfo.PlayerId);
                    sp.Bs.Add(visibility);
                    FreeMessageSender.SendMessage(pe, sp);
                }
            }
        }
Ejemplo n.º 27
0
        private void MovePartToWeapon(ServerRoom room, FreeData fd, ItemPosition ip, string to, FreeItemInfo info)
        {
            string inv = PickupItemUtil.AutoPutPart(fd, info, to, room);

            if (inv != null && inv != ChickenConstant.BagDefault)
            {
                ItemInventory toInv = fd.freeInventory.GetInventoryManager().GetInventory(inv);
                int[]         xy    = toInv.GetNextEmptyPosition(ip.key);
                ItemInventoryUtil.MovePosition(ip, toInv, xy[0], xy[1], room.ContextsWrapper.FreeArgs);
            }
            else
            {
                SimpleProto msg = FreePool.Allocate();
                msg.Key = FreeMessageConstant.ChickenTip;
                msg.Ss.Add("word76");
                FreeMessageSender.SendMessage(fd.Player, msg);
            }
        }
Ejemplo n.º 28
0
        public override void DoAction(IEventArgs args)
        {
            FreeData fd = GetPlayer(args);

            if (fd != null)
            {
                fd.Player.stateInterface.State.SetSpeedAffect(FreeUtil.ReplaceFloat(speed, args));
                SimpleProto sp = FreePool.Allocate();
                sp.Key = FreeMessageConstant.PlayerMoveSpeedSet;
                sp.Fs.Add(FreeUtil.ReplaceFloat(speed, args));
                FreeMessageSender.SendMessage(fd.Player, sp);

                fd.Player.stateInterface.State.SetJumpAffect(FreeUtil.ReplaceFloat(jump, args));
                SimpleProto ps = FreePool.Allocate();
                ps.Key = FreeMessageConstant.PlayerJumpSpeedSet;
                ps.Fs.Add(FreeUtil.ReplaceFloat(jump, args));
                FreeMessageSender.SendMessage(fd.Player, ps);
            }
        }
Ejemplo n.º 29
0
 public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message)
 {
     if (BagCapacityUtil.CanAddToBagCount(room.ContextsWrapper.FreeArgs, (FreeData)player.freeData.FreeData, message.Ins[1], message.Ins[2], message.Ins[3]) > 0)
     {
         if (PickupItemUtil.AddItemToPlayer(room, player, message.Ins[0], message.Ins[1], message.Ins[2], message.Ins[3]))
         {
             FreeItemInfo item = FreeItemConfig.GetItemInfo(message.Ins[1], message.Ins[2]);
             if (item.subType == "w4" || item.subType == "w6" || item.subType == "w7")
             {
                 SimpleProto sp = FreePool.Allocate();
                 sp.Key = FreeMessageConstant.PlaySound;
                 sp.Ks.Add(2);
                 sp.Ins.Add((int)EAudioUniqueId.PickupWeapon);
                 sp.Bs.Add(true);
                 FreeMessageSender.SendMessage(player, sp);
             }
         }
     }
 }
Ejemplo n.º 30
0
 public static void ShowSplitUI(ServerRoom room, FreeData fd, string key)
 {
     // 分拆道具
     if (key.StartsWith("default"))
     {
         ItemPosition ip   = FreeItemManager.GetItemPosition(room.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager());
         FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey());
         if (ip.count > 1)
         {
             SimpleProto data = FreePool.Allocate();
             data.Key = FreeMessageConstant.ShowSplitUI;
             data.Ins.Add(info.cat);
             data.Ins.Add(info.id);
             data.Ins.Add(ip.count);
             data.Ss.Add(key);
             data.Ss.Add(ip.GetKey().GetName());
             FreeMessageSender.SendMessage(fd.Player, data);
         }
     }
 }