Beispiel #1
0
        private void HandleBullet(IEventArgs args)
        {
            if ("SetWeaponClip" == code)
            {
                FreeData fd       = (FreeData)((FreeRuleEventArgs)args).GetUnit("current");
                int      ClipType = FreeUtil.ReplaceInt("{item.ClipType}", args);

                fd.Player.WeaponController().SetReservedBullet((EBulletCaliber)ClipType, CarryClipUtil.GetClipCount(ClipType, fd, args));
            }
            else if ("ClearWeaponClip" == code)
            {
                FreeData fd       = (FreeData)((FreeRuleEventArgs)args).GetUnit("current");
                int      ClipType = FreeUtil.ReplaceInt("{item.ClipType}", args);
                if (fd != null)
                {
                    fd.Player.WeaponController().SetReservedBullet((EBulletCaliber)ClipType, 0);
                }
            }
            else if ("SetItemClip" == code)
            {
                FreeData fd        = (FreeData)((FreeRuleEventArgs)args).GetUnit("current");
                int      ClipType  = FreeUtil.ReplaceInt("{state.ClipType}", args);
                int      count     = fd.Player.WeaponController().GetReservedBullet((EBulletCaliber)ClipType);
                int      itemCount = CarryClipUtil.GetClipCount(ClipType, fd, args);
                int      delta     = count - itemCount;
                if (delta > 0)
                {
                    CarryClipUtil.AddClip(Math.Abs(delta), ClipType, fd, args);
                }
                else
                {
                    CarryClipUtil.DeleteClip(Math.Abs(delta), ClipType, fd, args);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 处理武器相关的特殊逻辑
        /// </summary>
        /// <param name="args"></param>
        public override void DoAction(IEventArgs args)
        {
            IParable para         = args.GetUnit("state");
            var      contexts     = args.GameContext;
            var      playerEntity = (PlayerEntity)((SimpleParable)para).GetFieldObject(0);

            if (para != null)
            {
                var controller = playerEntity.WeaponController();
                //TODO 确认逻辑
                var lastId    = controller.GetWeaponAgent(EWeaponSlotType.LastPointer).ConfigId;
                var currentId = controller.HeldWeaponAgent.ConfigId;

                //if(null != weaponData)
                //{
                //    currentId = weaponData.WeaponId;
                //}
                //if(null != lastWeaponData)
                //{
                //    lastId = lastWeaponData.WeaponId;
                //}

                FreeData fd = (FreeData)((FreeRuleEventArgs)args).GetUnit(FreeArgConstant.PlayerCurrent);

                if (currentId > 0)
                {
                    WeaponResConfigItem item = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(currentId);
                    if (item.Type == (int)EWeaponType_Config.ThrowWeapon)
                    {
                        CarryClipUtil.DeleteGrenade(1, lastId, fd, args);
                        if (lastId != currentId)
                        {
                            ItemInventory grenade = fd.freeInventory.GetInventoryManager().GetInventory(ChickenConstant.BagGrenadeWeapon);
                        }
                    }
                    else
                    {
                        int ClipType  = FreeUtil.ReplaceInt("{state.ClipType}", args);
                        int count     = fd.Player.WeaponController().GetReservedBullet((EBulletCaliber)ClipType);
                        int itemCount = CarryClipUtil.GetClipCount(ClipType, fd, args);
                        int delta     = count - itemCount;
                        if (delta > 0)
                        {
                            CarryClipUtil.AddClip(Math.Abs(delta), ClipType, fd, args);
                        }
                        else
                        {
                            CarryClipUtil.DeleteClip(Math.Abs(delta), ClipType, fd, args);
                        }
                    }
                }
                else
                {
                    if (lastId != 0)
                    {
                        CarryClipUtil.DeleteGrenade(1, lastId, fd, args);
                        ItemInventory grenade = fd.freeInventory.GetInventoryManager().GetInventory(ChickenConstant.BagGrenadeWeapon);
                        grenade.RemoveItem((ISkillArgs)args, grenade.posList[0]);
                    }
                }
            }
        }