public virtual void AttackMelee(Object args) { if (!isServer) { return; } /*@switch = !@switch; * if (@switch) * return;*/ MeleeAttackInfo info = (MeleeAttackInfo)args; List <GameObject> gos = Physics2D .OverlapBoxAll( new Vector2(info.Point.x * (int)transform.localScale.x, info.Point.y) + new Vector2(gameObject.transform.position.x, gameObject.transform.position.y), info.Size, 0 ).ToList().ConvertAll(x => x.gameObject); gos.RemoveAll(x => x.gameObject.transform.IsChildOf(gameObject.transform)); if (info.Splash) { gos.ForEach(x => AttackTarget(x, info)); } else { GameObject target = Utils.FindNearestGameObject(gos, info.Point + Utils.ToVector2(gameObject.transform.position)); AttackTarget(target, info); } }
private void OnUserMeleeAttack(InPacket packet) { packet.Decode <byte>(); var attackInfo = new MeleeAttackInfo(Character); attackInfo.Decode(packet); OnUserAttack(attackInfo); }
public void OnHitEnvrionment(PlayerEntity src, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { if (!src.weaponLogic.Weapon.EmptyHand) { RaycastHit effectHit; if (TryGetEffectShowHit(src, out effectHit, config.Range)) { ClientEffectFactory.AdHitEnvironmentEffectEvent(src, effectHit.point, effectHit.normal, EEnvironmentType.Wood); } } }
public void CreateSetMeleeAttackInfo(MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { if (entity.hasMeleeAttackInfo) { entity.meleeAttackInfo.AttackInfo = attackInfo; entity.meleeAttackInfo.AttackConfig = config; } else { entity.AddMeleeAttackInfo(); entity.meleeAttackInfo.AttackInfo = attackInfo; entity.meleeAttackInfo.AttackConfig = config; } }
public void CreateSetMeleeAttackInfo(MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { if (entity.hasMeleeAttackInfo) { RelatedMeleeAttackInfo = attackInfo; RelatedMeleeAttackInfoCfg = config; } else { entity.AddMeleeAttackInfo(); RelatedMeleeAttackInfo = attackInfo; RelatedMeleeAttackInfoCfg = config; } }
public void OnHitVehicle(Contexts contexts, PlayerEntity src, VehicleEntity target, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { VehiclePartIndex partIndex; var baseDamage = MeleeHitUtil.GetVehicleFactor(hit, target, out partIndex) * MeleeHitUtil.GetBaseDamage(attackInfo, config); var gameData = target.GetGameData(); gameData.DecreaseHp(partIndex, baseDamage); if (!src.WeaponController().IsHeldSlotEmpty) { RaycastHit effectHit; if (MeleeHitUtil.CanMeleeAttackShowHit(src, out effectHit, config.Range)) { ClientEffectFactory.AddHitVehicleEffectEvent(src, target.entityKey.Value, effectHit.point, effectHit.point - target.position.Value, effectHit.normal); } } }
public void OnHitPlayer(Contexts contexts, PlayerEntity src, PlayerEntity target, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config, int seq) { EBodyPart part = BulletPlayerUtil.GetBodyPartByHitBoxName(hit.collider); var baseDamage = MeleeHitUtil.GetPlayerFactor(hit, config, part) * MeleeHitUtil.GetBaseDamage(attackInfo, config); if (src.hasStatisticsData) { src.statisticsData.Statistics.AttackType = (int)attackInfo.AttackType; } //有效命中 /*if (target.gamePlay.IsLastLifeState(EPlayerLifeState.Alive)) * { * src.statisticsData.Statistics.ShootingPlayerCount++; * }*/ var playerWeaponId = src.WeaponController().HeldConfigId; WeaponResConfigItem newConfig = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(playerWeaponId); EUIDeadType euiDeadType = (null != newConfig && newConfig.SubType == (int)EWeaponSubType.Hand) ? EUIDeadType.Unarmed : EUIDeadType.Weapon; BulletPlayerUtil.ProcessPlayerHealthDamage(contexts, _damager, src, target, new PlayerDamageInfo(Mathf.CeilToInt(baseDamage), (int)euiDeadType, (int)part, src.WeaponController().HeldWeaponAgent.ConfigId, false, false, false, hit.point, target.position.Value - src.position.Value)); // Logger.InfoFormat("[Hit] process damage sucess,dvalue:{0}", baseDamage); //由于动画放在客户端做了,服务器调用的命令会被忽视,需要发送事件到客户端 // if (target.hasStateInterface && target.stateInterface.State.CanBeenHit()) // { // target.stateInterface.State.BeenHit(); // } ClientEffectFactory.AddBeenHitEvent(src, target, AttackUtil.GeneraterUniqueHitId(src, seq), contexts.session.currentTimeObject.CurrentTime); int audioId = SingletonManager.Get <AudioWeaponManager>().FindById(playerWeaponId).HitList.Body; ClientEffectFactory.AddHitPlayerEffectEvent(src, target.entityKey.Value, hit.point, audioId, part); }
private void AttackTarget(GameObject target, MeleeAttackInfo info) { if (!isServer) { return; } if (target.GetComponent <Health>() != null) { target.GetComponent <Health>().Damage(new DamageBase(gameObject, info.Damage)); ObjectMaterial objectMaterial = target.GetComponent <ObjectMaterial>(); RpcDamage(target, info, objectMaterial.HitParticleColorMin, objectMaterial.HitParticleColorMax); } if (target.GetComponent <Kickable>() != null) { target.GetComponent <Kickable>() .Kick(new Vector2((int)gameObject.transform.localScale.x * info.Kick.x, info.Kick.y)); } }
public static float GetBaseDamage(MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { var damage = 0; switch (attackInfo.AttackType) { case EMeleeAttackType.Soft: damage = config.LeftDamage; break; case EMeleeAttackType.Hard: damage = config.RightDamage; break; default: MeleeAttackSystem.Logger.ErrorFormat("[HitErr]Melee AttackType {0} is illegal ", attackInfo.AttackType); break; } return(damage); }
private float GetBaseDamage(MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { var damage = 0; switch (attackInfo.AttackType) { case MeleeAttckType.LeftMeleeAttack: damage = config.LeftDamage; break; case MeleeAttckType.RightMeleeAttack: damage = config.RightDamage; break; default: damage = 1; Logger.ErrorFormat("AttackType {0} is illegal ", attackInfo.AttackType); break; } return(damage); }
public void StartMeleeAttack(int attackTime, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { if (_playerEntity.hasMeleeAttackInfoSync) { _playerEntity.meleeAttackInfoSync.AttackTime = attackTime; } else { _playerEntity.AddMeleeAttackInfoSync(attackTime); } if (_playerEntity.hasMeleeAttackInfo) { _playerEntity.meleeAttackInfo.AttackInfo = attackInfo; _playerEntity.meleeAttackInfo.AttackConfig = config; } else { _playerEntity.AddMeleeAttackInfo(); _playerEntity.meleeAttackInfo.AttackInfo = attackInfo; _playerEntity.meleeAttackInfo.AttackConfig = config; } }
public void OnPostprocessModel(GameObject gameObject) { if (!gameObject.name.Contains("_auto")) { return; } ModelImporter importer = (ModelImporter)assetImporter; //Кадр;Урон;ОтталкиваниеX;ОтталкиваниеY;СмещениеX;СмещениеY;РазмерX;РазмерY if (!importer.importCameras) { importer.importCameras = true; return; } if (File.Exists(LocalPath)) { File.Delete(LocalPath); } string meshName = gameObject.name.Substring(0, gameObject.name.Length - 5); RestClient disk = new RestClient(AccesToken); WebClient web = new WebClient { Encoding = Encoding.ASCII }; File.WriteAllBytes(LocalPath, web.DownloadData(disk.GetResourceDownloadLink(string.Format(DiskPath, meshName)).Href)); using (FileStream file = new FileStream(LocalPath, FileMode.Open)) { XSSFWorkbook book = new XSSFWorkbook(file); ISheet sheet = book.GetSheetAt(0); int animationCount = (int)sheet.GetRow(2).GetCell(7).NumericCellValue; int animationIndex = (int)sheet.GetRow(4).GetCell(7).NumericCellValue; ModelImporterClipAnimation[] animations = new ModelImporterClipAnimation[animationCount]; ClipAnimationInfoCurve[] defaultCurve = importer.defaultClipAnimations[animationIndex].curves; for (int i = 0; i < animationCount; i++) { ModelImporterClipAnimation clip = importer.defaultClipAnimations[animationIndex]; string[] timings = sheet.GetRow(i + 1).GetCell(3).StringCellValue.Split(new [] { '-' }, StringSplitOptions.RemoveEmptyEntries); clip.curves = defaultCurve; clip.name = sheet.GetRow(i + 1).GetCell(2).StringCellValue; clip.firstFrame = float.Parse(timings[0].Replace('.', ',')); clip.lastFrame = float.Parse(timings[1].Replace('.', ',')); clip.loopTime = true; string[] attacksString = sheet.GetRow(i + 1).GetCell(5) == null ? null : sheet.GetRow(i + 1).GetCell(5).StringCellValue.Split('/'); string[] rangeString = sheet.GetRow(i + 1).GetCell(6) == null ? null : sheet.GetRow(i + 1).GetCell(6).StringCellValue.Split('/'); if ((attacksString != null || rangeString != null) && ((rangeString != null && (!rangeString[0].Equals("") && !rangeString[0].Equals(" "))) || (attacksString != null && (!attacksString[0].Equals("") && !attacksString[0].Equals(" "))))) { clip.loopTime = false; if (!AssetDatabase.IsValidFolder(AssetInfoPath + "/" + meshName)) { AssetDatabase.CreateFolder(AssetInfoPath, meshName); } List <AnimationEvent> events = new List <AnimationEvent>(); if (attacksString != null && !attacksString[0].Equals("") && !attacksString[0].Equals(" ")) { for (int j = 0; j < attacksString.Length; j++) { int[] attacksData = Array.ConvertAll(attacksString[j].Split(';'), int.Parse); AnimationEvent @event = new AnimationEvent { time = attacksData[0] / (clip.lastFrame - clip.firstFrame + 1f), functionName = "AttackMelee" }; MeleeAttackInfo info = (MeleeAttackInfo)ScriptableObject.CreateInstance(typeof(MeleeAttackInfo)); info.Index = j; info.Damage = attacksData[1]; info.Kick = new Vector2(attacksData[2], attacksData[3]); info.Point = new Vector2(attacksData[4], attacksData[5]); info.Size = new Vector2(attacksData[6], attacksData[7]); info.Splash = attacksData[8] == 1; AssetDatabase.CreateAsset(info, $"Assets/Resources/AttackInfoData/{meshName}/{clip.name}_{info.Index}_M.asset"); AssetDatabase.SaveAssets(); @event.objectReferenceParameter = (ScriptableObject)AssetDatabase.LoadMainAssetAtPath( $"Assets/Resources/AttackInfoData/{meshName}/{clip.name}_{info.Index}_M.asset"); events.Add(@event); } events.Add(new AnimationEvent { time = 0.95f, functionName = "EndAttack" }); } if (rangeString != null && !rangeString[0].Equals("") && !rangeString[0].Equals(" ")) { for (int j = 0; j < rangeString.Length; j++) { string[] rangeData = rangeString[j].Split(';'); AnimationEvent @event = new AnimationEvent { time = int.Parse(rangeData[0]) / (clip.lastFrame - clip.firstFrame + 1f), functionName = "AttackProjectile" }; ProjectileAttackInfo info = (ProjectileAttackInfo)ScriptableObject.CreateInstance(typeof(ProjectileAttackInfo)); info.Index = j; info.Name = rangeData[1]; info.TrustForce = int.Parse(rangeData[2]); AssetDatabase.CreateAsset(info, $"Assets/Resources/AttackInfoData/{meshName}/{clip.name}_{info.Index}_R.asset"); AssetDatabase.SaveAssets(); @event.objectReferenceParameter = (ScriptableObject)AssetDatabase.LoadMainAssetAtPath( $"Assets/Resources/AttackInfoData/{meshName}/{clip.name}_{info.Index}_R.asset"); events.Add(@event); } } clip.events = events.ToArray(); } animations[i] = clip; } importer.clipAnimations = animations; } }
private void RpcDamage(GameObject target, MeleeAttackInfo info, Color min, Color max) { Instantiate(GameManager.singleton.HitObjectParticle).GetComponent <HitObjectParticle>().Initialize(new Vector2(info.Point.x * (int)transform.localScale.x, info.Point.y) + Utils.ToVector2(transform.position), info.Size, target, min, max); }
public void OnHitEnvrionment(PlayerEntity src, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { DebugDraw.DebugPoint(hit.point, color: Color.blue, duration: 10); }
public void OnHitVehicle(PlayerEntity src, VehicleEntity target, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { DebugDraw.DebugPoint(hit.point, color: Color.yellow, duration: 10); }
public void OnHitVehicle(PlayerEntity src, VehicleEntity target, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { VehiclePartIndex partIndex; var baseDamage = GetVehicleFactor(hit, target, out partIndex) * GetBaseDamage(attackInfo, config); var gameData = target.GetGameData(); gameData.DecreaseHp(partIndex, baseDamage); if (!src.weaponLogic.Weapon.EmptyHand) { RaycastHit effectHit; if (TryGetEffectShowHit(src, out effectHit, config.Range)) { ClientEffectFactory.AddHitVehicleEffectEvent( src, target.entityKey.Value, effectHit.point, effectHit.point - target.position.Value, effectHit.normal); } } }
public void CreateSetMeleeAttackInfo(MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { weaponInteract.CreateSetMeleeAttackInfo(attackInfo, config); }
private void StartMeleeAttack(PlayerWeaponController controller, int attackTime, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { controller.CreateSetMeleeAttackInfo(attackInfo, config); controller.CreateSetMeleeAttackInfoSync(attackTime); }
public void OnHitPlayer(PlayerEntity src, PlayerEntity target, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { var baseDamage = GetPlayerFactor(hit, config) * GetBaseDamage(attackInfo, config); Collider collider = hit.collider; EBodyPart part = BulletPlayerUtility.GetBodyPartByHitBoxName(collider); //有效命中 if (target.gamePlay.IsLastLifeState(EPlayerLifeState.Alive)) { src.statisticsData.Statistics.ShootingPlayerCount++; } NewWeaponConfigItem newConfig = SingletonManager.Get <WeaponConfigManager>().GetConfigById(src.weaponLogicInfo.WeaponId); if (null != newConfig && newConfig.SubType == (int)EWeaponSubType.Hand) { BulletPlayerUtility.ProcessPlayerHealthDamage(_damager, src, target, new PlayerDamageInfo(Mathf.CeilToInt(baseDamage), (int)EUIDeadType.Unarmed, (int)part, 0), _damageInfoCollector); } else { BulletPlayerUtility.ProcessPlayerHealthDamage(_damager, src, target, new PlayerDamageInfo(Mathf.CeilToInt(baseDamage), (int)EUIDeadType.Weapon, (int)part, src.weaponLogicInfo.WeaponId), _damageInfoCollector); } if (target.hasStateInterface && target.stateInterface.State.CanBeenHit()) { target.stateInterface.State.BeenHit(); } ClientEffectFactory.AddHitPlayerEffectEvent(src, target.entityKey.Value, hit.point, hit.point - target.position.Value); }
public void OnHitEnvrionment(Contexts contexts, PlayerEntity src, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { var heldConfigId = src.WeaponController().HeldConfigId; RaycastHit effectHit; bool showAttackEffect = (MeleeHitUtil.CanMeleeAttackShowHit(src, out effectHit, config.Range)); var collider = effectHit.collider != null ? effectHit.collider : hit.collider; FracturedHittable fracturedHittable = collider.GetComponent <FracturedHittable>(); FracturedAbstractChunk fracturedChunk = HitFracturedHandler.HitFracturedObj(src, effectHit, fracturedHittable); var hasHole = fracturedChunk == null || (fracturedChunk.HasBulletHole && !fracturedChunk.IsBroken()); if (showAttackEffect && hasHole) { int audioId = SingletonManager.Get <AudioWeaponManager>().FindById(heldConfigId).HitList.Body; ClientEffectFactory.AdHitEnvironmentEffectEvent(src, effectHit.point, effectHit.normal, EEnvironmentType.Wood, audioId, 0, heldConfigId != WeaponUtil.EmptyHandId); } }
public void OnHitPlayer(Contexts contexts, PlayerEntity src, PlayerEntity target, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config, int seq) { var baseDamage = GetPlayerFactor(hit, config) * GetBaseDamage(attackInfo, config); Collider collider = hit.collider; EBodyPart part = BulletPlayerUtility.GetBodyPartByHitBoxName(collider); //有效命中 /*if (target.gamePlay.IsLastLifeState(EPlayerLifeState.Alive)) * { * src.statisticsData.Statistics.ShootingPlayerCount++; * }*/ WeaponResConfigItem newConfig = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(src.WeaponController().HeldWeaponAgent.ConfigId); if (null != newConfig && newConfig.SubType == (int)EWeaponSubType.Hand) { BulletPlayerUtility.ProcessPlayerHealthDamage(contexts, _damager, src, target, new PlayerDamageInfo(Mathf.CeilToInt(baseDamage), (int)EUIDeadType.Unarmed, (int)part, 0), _damageInfoCollector); } else { BulletPlayerUtility.ProcessPlayerHealthDamage(contexts, _damager, src, target, new PlayerDamageInfo(Mathf.CeilToInt(baseDamage), (int)EUIDeadType.Weapon, (int)part, src.WeaponController().HeldWeaponAgent.ConfigId), _damageInfoCollector); } //由于动画放在客户端做了,服务器调用的命令会被忽视,需要发送事件到客户端 // if (target.hasStateInterface && target.stateInterface.State.CanBeenHit()) // { // target.stateInterface.State.BeenHit(); // } ClientEffectFactory.AddBeenHitEvent(src, target.entityKey.Value, BulletHitHandler.GeneraterUniqueHitId(src, seq), contexts.session.currentTimeObject.CurrentTime); ClientEffectFactory.AddHitPlayerEffectEvent(src, target.entityKey.Value, hit.point, hit.point - target.position.Value); }
public DamageMelee(GameObject sourse, MeleeAttackInfo info) : base(sourse, info.Damage) { Info = info; }
public void OnHitPlayer(Contexts contexts, PlayerEntity src, PlayerEntity target, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config, int seq) { DebugDraw.DebugPoint(hit.point, color: Color.red, duration: 10); }
public void OnHitEnvrionment(Contexts contexts, PlayerEntity src, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { if (!src.WeaponController().IsHeldSlotEmpty) { RaycastHit effectHit; if (TryGetEffectShowHit(src, out effectHit, config.Range)) { ClientEffectFactory.AdHitEnvironmentEffectEvent(src, effectHit.point, effectHit.normal, EEnvironmentType.Wood); } } }
public void CreateSetMeleeAttackInfo(MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { RelatedMeleeAttackInfo = attackInfo; RelatedMeleeAttackInfoCfg = config; }
private void StartMeleeAttack(PlayerWeaponController controller, int attackTime, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { controller.CreateSetMeleeAttackInfo(attackInfo, config); controller.CreateSetMeleeAttackInfoSync(attackTime); if (controller.AudioController != null) { controller.AudioController.PlayMeleeAttackAudio(controller.HeldConfigId, (int)attackInfo.AttackType); } }