125 lines
4.9 KiB
C#
125 lines
4.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Cielonos.MainGame.Characters;
|
|
using DG.Tweening;
|
|
using MoreMountains.FeedbacksForThirdParty;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Inventory
|
|
{
|
|
public partial class Yasha : MainWeaponBase
|
|
{
|
|
public override void OnEquipped()
|
|
{
|
|
RegisterFunctionsToAnimSc(
|
|
LightAttack0, LightAttack1, LightAttack2_0, LightAttack2_1, LightAttack3, LightAttack4, LightAttack5_0, LightAttack5_1,
|
|
OnAirAttackEnd, GroundImpact);
|
|
}
|
|
|
|
public override void OnPrimaryPress()
|
|
{
|
|
if (player.landMovementSc.isJumping)
|
|
{
|
|
if (player.landMovementSc.groundDetector.GetDistanceToGround() > 2.4f &&
|
|
fullBodyFuncAnimSm.CheckPlayability() && functionSm["AirAttack"].IsAvailable())
|
|
{
|
|
fallDamageMultiplier = (player.landMovementSc.groundDetector.GetDistanceToGround() - 1.4f);
|
|
comboSm.ResetCombo();
|
|
functionSm["AirAttack"].Execute();
|
|
PlayTargetedAnimation("AirAttackStart");
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
if (functionSm["LightAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
|
|
{
|
|
comboSm.NextCombo("L");
|
|
functionSm["LightAttack"].Execute();
|
|
CharacterBase target = BattleManager.EnemySm.GetNearestEnemy(5);
|
|
PlayTargetedAnimation("LightAttack" + comboSm.GetCurrentNodeName(), target, 0.8f);
|
|
}
|
|
}
|
|
}
|
|
|
|
public partial class Yasha
|
|
{
|
|
private void LightAttack0() => GenerateSlash("LightAttack0", new Vector3(-0.5f, -1f, 0.5f).normalized * 0.1f);
|
|
private void LightAttack1() => GenerateSlash("LightAttack1", Vector3.right * 0.2f);
|
|
private void LightAttack2_0() => GenerateSlash("LightAttack2_0", new Vector3(-0.5f, 1f, 0.5f).normalized * 0.1f);
|
|
private void LightAttack2_1() => GenerateSlash("LightAttack2_1", new Vector3(0.5f, 1f, 0.5f).normalized * 0.1f);
|
|
private void LightAttack3() => GenerateSlash("LightAttack3", Vector3.right * 0.15f);
|
|
private void LightAttack4() => GenerateSlash("LightAttack4", Vector3.forward * 0.3f);
|
|
private void LightAttack5_0() => GenerateSlash("LightAttack5_0", Vector3.right * 0.2f);
|
|
private void LightAttack5_1() => GenerateSlash("LightAttack5_1", Vector3.right * 0.4f, 4);
|
|
private void GroundImpact() => GenerateGroundImpact();
|
|
}
|
|
|
|
public partial class Yasha
|
|
{
|
|
private float fallDamageMultiplier;
|
|
|
|
private void GenerateSlash(string vfxName, Vector3 swingForce, int hitCount = 1)
|
|
{
|
|
NormalArea slash = vfxData.SpawnVFX(vfxName).GetComponentInChildren<NormalArea>();
|
|
|
|
slash.Initialize<NormalArea>(player, this, Fraction.Enemy)
|
|
.SetAttackSubmodule<NormalArea>(attackData["LightAttack"])
|
|
.SetTimeSubmodule<NormalArea>(1f);
|
|
|
|
if (hitCount > 1)
|
|
{
|
|
slash.SetHitSubmodule<NormalArea>(0.04f, hitCount);
|
|
}
|
|
else
|
|
{
|
|
slash.SetHitSubmodule<NormalArea>();
|
|
}
|
|
|
|
if (slash.attackSm.modifiedAttackValue.isCritical)
|
|
{
|
|
slash.hitSm.isAutoPlayHitSound = false;
|
|
}
|
|
|
|
slash.hitSm.AddHitSound("LightAttackNormalHit").AddHitSound("LightAttackCriticalHit")
|
|
.AddHitEvent((enemy, hitPosition) =>
|
|
{
|
|
slash.hitSm.PlayHitSound(hitPosition,
|
|
slash.attackSm.modifiedAttackValue.isCritical ? "LightAttackCriticalHit" : "LightAttackNormalHit");
|
|
feedbackSc["Hit"].Play();
|
|
});
|
|
|
|
Swing("LightAttackSwing", "Swing", swingForce);
|
|
}
|
|
|
|
private void OnAirAttackEnd()
|
|
{
|
|
if (player.landMovementSc.groundDetector.DetectGround(0.4f))
|
|
{
|
|
comboSm.ResetCombo();
|
|
PlayTargetedAnimation("AirAttackEnd");
|
|
}
|
|
}
|
|
|
|
private void GenerateGroundImpact()
|
|
{
|
|
NormalArea slash = vfxData.SpawnVFX("GroundImpact").GetComponentInChildren<NormalArea>();
|
|
|
|
AttackUnit newUnit = attackData["GroundImpact"].Clone();
|
|
newUnit.startDamage *= fallDamageMultiplier;
|
|
|
|
slash.Initialize<NormalArea>(player, this, Fraction.Enemy)
|
|
.SetAttackSubmodule<NormalArea>(newUnit)
|
|
.SetTimeSubmodule<NormalArea>(1f)
|
|
.SetHitSubmodule<NormalArea>();
|
|
|
|
slash.hitSm.AddHitEvent((_,_) => feedbackSc["Hit"].Play());
|
|
Swing("GroundImpact", "GroundImpact", Vector3.down * 0.2f * (1 + Mathf.Log10(fallDamageMultiplier)));
|
|
}
|
|
}
|
|
|
|
public partial class Yasha
|
|
{
|
|
|
|
}
|
|
} |