MusicBeat
This commit is contained in:
141
Assets/Scripts/MainGame/Items/MainWeapons/DualHarmony.cs
Normal file
141
Assets/Scripts/MainGame/Items/MainWeapons/DualHarmony.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using Cielonos.MainGame.Characters;
|
||||
using SLSUtilities.FunctionalAnimation;
|
||||
using SLSUtilities.WwiseAssistance;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Inventory.Collections
|
||||
{
|
||||
public partial class DualHarmony : MainWeaponBase
|
||||
{
|
||||
private MusicBeatSystem MusicBeatSystem => CombatManager.GetCombatSystem<MusicBeatSystem>();
|
||||
|
||||
public CharacterBase currentTarget;
|
||||
public override void OnEquipped()
|
||||
{
|
||||
base.OnEquipped();
|
||||
RegisterFunctionsToAnimSc();
|
||||
/*if(!player.inputSc.IsMoving) PlayTargetedAnimation("Equip");
|
||||
viewObjects["Wand"].SetFadeAnim(0.5f);*/
|
||||
}
|
||||
|
||||
public override void OnPrimaryPress()
|
||||
{
|
||||
if (functionSm["LightAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
|
||||
{
|
||||
comboSm.main.NextCombo("L");
|
||||
string funcAnimName = "Attack" + comboSm.main.GetCurrentNodeName();
|
||||
FuncAnimData data = fullBodyFuncAnimSm.collection[funcAnimName];
|
||||
|
||||
float startUpTime = data.Interval(IntervalType.Active).StartTime;
|
||||
float nextBeatTime = MusicBeatSystem.GetNextBeat().time - MusicBeatSystem.CurrentSongTime;
|
||||
BeatMarker lastMarker = MusicBeatSystem.GetLastBeat();
|
||||
float compensation = lastMarker.time - MusicBeatSystem.CurrentSongTime;
|
||||
|
||||
functionSm["LightAttack"].Execute();
|
||||
|
||||
float difference;
|
||||
if (compensation > -startUpTime)
|
||||
{
|
||||
difference = startUpTime - nextBeatTime;
|
||||
if (difference < 0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
difference = startUpTime;
|
||||
}
|
||||
|
||||
currentTarget = CombatManager.EnemySm.GetNearestEnemy(25f);
|
||||
if (currentTarget != null)
|
||||
{
|
||||
PlayTargetedAnimation(funcAnimName, currentTarget, 5f);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayTargetedAnimation(funcAnimName);
|
||||
}
|
||||
|
||||
fullBodyFuncAnimSm.currentRuntimeFuncAnim.currentPlayTime = difference;
|
||||
Debug.Log($"StartUpTime: {nextBeatTime}, FuncAnim Active StartTime: {startUpTime}, Difference: {difference}, Compensation: {compensation}");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSecondaryPress()
|
||||
{
|
||||
/*if (functionSm["HeavyAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
|
||||
{
|
||||
comboSm.main.NextCombo("R");
|
||||
float startUpTime = MusicBeatSystem.GetNextBeat().time - MusicBeatSystem.CurrentSongTime;
|
||||
string funcAnimName = "Attack" + comboSm.main.GetCurrentNodeName();
|
||||
FuncAnimData data = fullBodyFuncAnimSm.collection[funcAnimName];
|
||||
|
||||
float difference = data.Interval(IntervalType.Active).StartTime - startUpTime;
|
||||
if (difference < 0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
currentTarget = CombatManager.EnemySm.GetNearestEnemy(25f);
|
||||
if (currentTarget != null)
|
||||
{
|
||||
PlayTargetedAnimation(funcAnimName, currentTarget, 5f);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayTargetedAnimation(funcAnimName);
|
||||
}
|
||||
|
||||
fullBodyFuncAnimSm.currentRuntimeFuncAnim.currentPlayTime = difference;
|
||||
Debug.Log($"StartUpTime: {startUpTime}, FuncAnim Active StartTime: {data.Interval(IntervalType.Active).StartTime}, Difference: {difference}");
|
||||
}*/
|
||||
}
|
||||
|
||||
public override void OnSpecialAPress()
|
||||
{
|
||||
CombatManager.GetCombatSystem<MusicBeatSystem>().Activate();
|
||||
}
|
||||
}
|
||||
|
||||
public partial class DualHarmony
|
||||
{
|
||||
private void FAPF_GenerateBullet(RuntimeFuncAnim rtFuncAnim)
|
||||
{
|
||||
CustomFunction.PC_StringStringFloat p = rtFuncAnim.GetParams<CustomFunction.PC_StringStringFloat>();
|
||||
GenerateProjectile(p.str0, attackData[p.str1], currentTarget, p.float0);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class DualHarmony
|
||||
{
|
||||
private void GenerateProjectile(string vfxName, AttackUnit attackUnit,
|
||||
CharacterBase target, float speed, bool hasMuzzleEffect = true, Transform muzzle = null)
|
||||
{
|
||||
if (hasMuzzleEffect)
|
||||
{
|
||||
muzzle ??= player.bodyPartsSc.leftHand;
|
||||
vfxData.SpawnMuzzleVFX(vfxName, player, muzzle);
|
||||
}
|
||||
|
||||
Projectile projectile = vfxData.SpawnVFX(vfxName, player).GetComponentInChildren<Projectile>();
|
||||
Vector3 direction = player.transform.forward;
|
||||
if (target != null)
|
||||
{
|
||||
direction = (target.centerPoint.position - projectile.transform.position).normalized;
|
||||
}
|
||||
|
||||
projectile.Initialize(player, this, false, 1, Fraction.Enemy)
|
||||
.SetAttackSubmodule<Projectile>(attackUnit)
|
||||
.SetTimeSubmodule<Projectile>(10f)
|
||||
.SetHitSubmodule<Projectile>()
|
||||
.SetAdaptiveTraceMoveModule<Projectile>(target, speed, 5f, 180f, 30f, direction, detectRadius: 25f)
|
||||
.SetRaycastSubmodule<Projectile>(default, 0.25f, 0.5f);
|
||||
projectile.hitSm.AddHitSound(AK.EVENTS.FUTUREWAND_WEAKATTACKHIT);
|
||||
projectile.SetImpulseSubmodule().WithDynamicForce(1f);
|
||||
AudioManager.Post(AK.EVENTS.FUTUREWAND_NORMALBOLTRELEASE, projectile.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user