| | |
| | | private Vector2 start; |
| | | private Vector2 end; |
| | | |
| | | public StraightBulletCurve(BattleObject caster, SkillConfig skillConfig, BattleEffectPlayer bulletEffect, RectTransform target, HB427_tagSCUseSkill tagUseSkillAttack, Action<int, List<HB427_tagSCUseSkill.tagSCUseSkillHurt>> onHit) |
| | | : base(caster, skillConfig, bulletEffect, target, tagUseSkillAttack, onHit) |
| | | { |
| | | BattleDebug.LogError("StraightBulletCurve created bulletTrans is null = " + (bulletTrans == null).ToString()); |
| | | public StraightBulletCurve(BattleObject caster, SkillConfig skillConfig, BattleEffectPlayer bulletEffect, RectTransform target, List<HB427_tagSCUseSkill.tagSCUseSkillHurt> hurtList, int bulletIndex, Action<int, List<HB427_tagSCUseSkill.tagSCUseSkillHurt>> onHit) |
| | | : base(caster, skillConfig, bulletEffect, target, hurtList, bulletIndex, onHit) |
| | | { |
| | | |
| | | } |
| | | |
| | | public override void Reset() |
| | | { |
| | | base.Reset(); |
| | | start = WorldToLocalAnchoredPosition(bulletTrans.position); |
| | | start = WorldToLocalAnchoredPosition(bulletTrans.position) + bulletOffset; |
| | | end = WorldToLocalAnchoredPosition(target.position); |
| | | |
| | | duration = Vector2.Distance(start, end) / skillConfig.BulletFlySpeed; |
| | | // BattleUtility.MarkStartAndEnd(bulletTrans, target); |
| | | } |
| | | |
| | |
| | | |
| | | if (bulletTrans == null) |
| | | { |
| | | BattleDebug.LogError("BulletTrans is null, cannot run StraightBulletCurve"); |
| | | return; |
| | | Debug.LogError("BulletTrans is null, cannot run StraightBulletCurve"); |
| | | } |
| | | |
| | | elapsed += Time.deltaTime; |
| | | float t = Mathf.Clamp01(elapsed / 0.3f); |
| | | float t = Mathf.Clamp01(elapsed / duration); |
| | | Vector2 pos = Vector2.Lerp(start, end, t); |
| | | bulletTrans.anchoredPosition = pos; |
| | | if (null != bulletTrans) |
| | | { |
| | | bulletTrans.anchoredPosition = pos; |
| | | |
| | | } |
| | | |
| | | Vector2 dir = end - start; |
| | | float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg; |
| | | bulletTrans.localRotation = Quaternion.Euler(0, 0, angle); |
| | | float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg + (caster.Camp == BattleCamp.Red ? 0 : 180); |
| | | if (null != bulletTrans) |
| | | { |
| | | bulletTrans.rotation = Quaternion.Euler(0, 0, angle); |
| | | } |
| | | |
| | | if (t >= 1f) |
| | | { |
| | | finished = true; |
| | | onHit?.Invoke(0, hurts); |
| | | onHit?.Invoke(mBulletIndex, hurts); |
| | | } |
| | | } |
| | | } |