826 lines
24 KiB
C#
826 lines
24 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2021-04-06
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "Cha_Attack" company="Kunpo"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace G
|
|
{
|
|
/// <summary>
|
|
/// 角色攻击脚本
|
|
/// </summary>
|
|
public class Cha_Attack : MonoBehaviour
|
|
{
|
|
public const int MAX_STEP = 5;
|
|
|
|
#region Field
|
|
|
|
public AnimatorOverrideController bladeOverrideController;
|
|
public AnimatorOverrideController dualOverrideController;
|
|
public AnimatorOverrideController spearOverrideController;
|
|
public AnimatorOverrideController bowOverrideController;
|
|
public AnimatorOverrideController staffOverrideController;
|
|
public AnimatorOverrideController magicOverrideController;
|
|
|
|
public Transform magicspear;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
private Transform _ef_swing1;
|
|
private Transform _ef_swing2;
|
|
private Transform _ef_swing_ex1;
|
|
private Transform _ef_swing_ex2;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
private Ef_swing1 _scriptSwing;
|
|
private Ef_swing1 _scriptSwingSub;
|
|
private Ef_swing1 _scriptSwingEx1;
|
|
private Ef_swing1 _scriptSwingEx2;
|
|
|
|
/// <summary>
|
|
/// 刺
|
|
/// </summary>
|
|
private Ef_swing1 _scriptThrust;
|
|
/// <summary>
|
|
/// 扑
|
|
/// </summary>
|
|
private Ef_splash _scriptSplash;
|
|
/// <summary>
|
|
/// 重击
|
|
/// </summary>
|
|
private Ef_thump _scriptThump;
|
|
|
|
/// <summary>
|
|
/// 冲
|
|
/// </summary>
|
|
private Bullet_punch _scriptPunch;
|
|
|
|
private EntityMainPlayer _scriptCha;
|
|
private Cha_Effect _scriptEffect;
|
|
private Cha_Moves _scriptMoves;
|
|
private Cha_Sound _scriptSound;
|
|
|
|
private int _weaponAttackStyle;
|
|
private int _weaponKind;
|
|
private int _attackStep;
|
|
|
|
#endregion
|
|
|
|
#region Property
|
|
|
|
/// <summary>
|
|
/// 攻击步
|
|
/// </summary>
|
|
public int attackStep => _attackStep;
|
|
|
|
/// <summary>
|
|
/// 攻速产生时间
|
|
/// </summary>
|
|
public float attackSpeedTime
|
|
{
|
|
get => _scriptCha.attackSpeed * 0.02f;
|
|
}
|
|
|
|
public MoveState moveState
|
|
{
|
|
get => _scriptCha.moveState;
|
|
set => _scriptCha.moveState = value;
|
|
}
|
|
|
|
public bool attackRising
|
|
{
|
|
get { return _scriptCha.attackRising; }
|
|
set => _scriptCha.attackRising = value;
|
|
}
|
|
|
|
private Transform _targetEnemy
|
|
{
|
|
get => _scriptCha.targetEnemy;
|
|
}
|
|
|
|
public float comboTime
|
|
{
|
|
get { return _scriptCha.comboTime; }
|
|
set { _scriptCha.comboTime = value; }
|
|
}
|
|
|
|
public GameCamera scriptCamera
|
|
{
|
|
get { return GameCamera.Instance; }
|
|
}
|
|
|
|
public Transform ef_thump => _scriptEffect.ef_thump;
|
|
public Transform ef_splash => _scriptEffect.ef_splash;
|
|
public Transform ef_punch => _scriptEffect.ef_punch;
|
|
|
|
#endregion
|
|
|
|
#region Method
|
|
|
|
public void LoadEffect()
|
|
{
|
|
_ef_swing1 = transform.Find("ef_swing1");
|
|
_ef_swing1.gameObject.SetActive(true);
|
|
_scriptSwing = _ef_swing1.GetComponent<Ef_swing1>();
|
|
|
|
_ef_swing2 = transform.Find("ef_swing2");
|
|
_ef_swing2.gameObject.SetActive(true);
|
|
_scriptSwingSub = _ef_swing2.GetComponent<Ef_swing1>();
|
|
|
|
_ef_swing_ex1 = transform.Find("ef_swing_ex1");
|
|
_ef_swing_ex1.gameObject.SetActive(true);
|
|
_scriptSwingEx1 = _ef_swing_ex1.GetComponent<Ef_swing1>();
|
|
|
|
_ef_swing_ex2 = transform.Find("ef_swing_ex2");
|
|
_ef_swing_ex2.gameObject.SetActive(true);
|
|
_scriptSwingEx2 = _ef_swing_ex2.GetComponent<Ef_swing1>();
|
|
|
|
_scriptThrust = transform.Find("ef_thrust").GetComponent<Ef_swing1>();
|
|
//script_thrust2 = _transform.Find("ef_thrust2").GetComponent<Ef_swing1>();
|
|
|
|
_scriptSplash = ef_splash.GetComponent<Ef_splash>();
|
|
//script_rotfog = ef_rotfog.GetComponent<Ef_rotfog>();
|
|
_scriptThump = ef_thump.GetComponent<Ef_thump>();
|
|
|
|
_scriptPunch = ef_punch.GetComponent<Bullet_punch>();
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="kind"></param>
|
|
/// <param name="specialKind"></param>
|
|
/// <param name="specialAmount"></param>
|
|
public void SetWeapon(int kind, int specialKind, int specialAmount)
|
|
{
|
|
_weaponKind = kind;
|
|
switch ((WeaponKind)kind)
|
|
{
|
|
case WeaponKind.blade:
|
|
//_colliderCenter = new Vector3(0f, 0.05f, 0.17f);
|
|
//_colliderRadius = 0.13f;
|
|
//_weaponAttackRange = 0.3f * 0.3f;//0.13+0.17
|
|
_weaponAttackStyle = 0;
|
|
_ef_swing1.localScale = new Vector3(1.6f, 2f, 2f);
|
|
_scriptCha.SetAnimatorController(this.bladeOverrideController);
|
|
break;
|
|
case WeaponKind.dual:
|
|
//_colliderCenter = new Vector3(0f, 0.05f, 0.16f);
|
|
//_colliderRadius = 0.13f;
|
|
//_weaponAttackRange = 0.29f * 0.29f;//0.13+0.16
|
|
_weaponAttackStyle = 10;
|
|
_ef_swing1.localScale = new Vector3(1.3f, 1.7f, 1.7f);
|
|
//_attackSpeed -= 0.02f;
|
|
_scriptCha.SetAnimatorController(this.dualOverrideController);
|
|
break;
|
|
case WeaponKind.spear:
|
|
//_colliderCenter = new Vector3(0f, 0.05f, 0.2f);
|
|
//_colliderRadius = 0.15f;
|
|
//_weaponAttackRange = 0.35f * 0.35f;//0.15+0.2
|
|
_weaponAttackStyle = 20;
|
|
//if (!isGeneral)
|
|
{
|
|
_ef_swing1.localScale = new Vector3(2f, 2.6f, 2.6f);
|
|
}
|
|
//else
|
|
//{
|
|
// ef_swing1.localScale = new Vector3(1.6f, 2f, 2f);
|
|
//}
|
|
_scriptCha.SetAnimatorController(this.spearOverrideController);
|
|
break;
|
|
case WeaponKind.bow:
|
|
//_colliderCenter = new Vector3(0f, 0.05f, 0.25f);
|
|
//_colliderRadius = 0.15f;
|
|
_weaponAttackStyle = 30;
|
|
//_attackSpeed += 0.02f;
|
|
_scriptCha.SetAnimatorController(this.bowOverrideController);
|
|
break;
|
|
case WeaponKind.staff:
|
|
//_colliderCenter = new Vector3(0f, 0.05f, 0.2f);
|
|
//_colliderRadius = 0.15f;
|
|
_weaponAttackStyle = 40;
|
|
//_attackSpeed -= 0.02f;
|
|
_scriptCha.SetAnimatorController(this.staffOverrideController);
|
|
break;
|
|
case WeaponKind.magic:
|
|
//_colliderCenter = new Vector3(0f, 0.05f, 0.25f);
|
|
//_colliderRadius = 0.15f;
|
|
_ef_swing1.localScale = new Vector3(1.6f, 2f, 2f);
|
|
_weaponAttackStyle = 50;
|
|
//_attackSpeed += 0.04f;
|
|
_scriptCha.SetAnimatorController(this.magicOverrideController);
|
|
break;
|
|
}
|
|
|
|
switch (specialKind)
|
|
{
|
|
case 0:
|
|
_scriptSwing.ChangeAttribute(0, 0);
|
|
_scriptSwingSub.ChangeAttribute(0, 0);
|
|
EnemyHelper.Instance.BloodAttribute(0);
|
|
break;
|
|
case 1:// (int)CombatAttributeId.ElementFire:
|
|
_scriptSwing.ChangeAttribute(1, specialAmount);
|
|
_scriptSwingSub.ChangeAttribute(1, specialAmount);
|
|
EnemyHelper.Instance.BloodAttribute(1);
|
|
break;
|
|
case 2:// (int)CombatAttributeId.ElementIce:
|
|
_scriptSwing.ChangeAttribute(2, specialAmount);
|
|
_scriptSwingSub.ChangeAttribute(2, specialAmount);
|
|
EnemyHelper.Instance.BloodAttribute(2);
|
|
break;
|
|
case 3:// (int)CombatAttributeId.ElementLightning:
|
|
_scriptSwing.ChangeAttribute(3, specialAmount);
|
|
_scriptSwingSub.ChangeAttribute(3, specialAmount);
|
|
EnemyHelper.Instance.BloodAttribute(3);
|
|
break;
|
|
case 4://(int)CombatAttributeId.ElementCurse:
|
|
_scriptSwing.ChangeAttribute(4, specialAmount);
|
|
_scriptSwingSub.ChangeAttribute(4, specialAmount);
|
|
EnemyHelper.Instance.BloodAttribute(4);
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void PlayAnimation(int hash)
|
|
{
|
|
_scriptCha.PlayAnimation(hash);
|
|
}
|
|
|
|
private void AddForce(Vector3 force)
|
|
{
|
|
_scriptCha.AddForce(force);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="targetPos"></param>
|
|
public void DoAttack(Vector3 targetPos)
|
|
{
|
|
var transform = this.transform;
|
|
|
|
var attackDirection = targetPos - transform.position;
|
|
attackDirection.y = 0f;
|
|
attackDirection.Normalize();
|
|
|
|
//判断角度
|
|
//attackDot = Vector3.Dot(attackVector, direction);
|
|
//if (magnitude_attackdir > 0.2f)
|
|
//{
|
|
// if (attackDot < 0.5f)
|
|
// {
|
|
// moveState = MoveState.state17;
|
|
// mycollider.enabled = true;
|
|
// return;
|
|
// }
|
|
//}
|
|
//else if (attackDot < -0.2f)
|
|
//{
|
|
// moveState = MoveState.state17;
|
|
// mycollider.enabled = true;
|
|
// return;
|
|
//}
|
|
|
|
//暴击
|
|
|
|
//_speedFactor = 5.2f;
|
|
|
|
//无敌1秒
|
|
if (/*scriptBuff.canDash*/ false && moveState == MoveState.state3_Dash)
|
|
{
|
|
//Spcharge(-20f);
|
|
_attackStep = -1;
|
|
_scriptCha.Invincibility(1f);
|
|
}
|
|
else if (comboTime > 0f)
|
|
{
|
|
_attackStep = (_attackStep + 1) % MAX_STEP;
|
|
}
|
|
//从头
|
|
else
|
|
{
|
|
_attackStep = 0;
|
|
}
|
|
|
|
int extraCritical = 0;
|
|
int extraDamage = 0;
|
|
float extraDamagePercent = 0f;
|
|
|
|
if (_scriptMoves.canThump)
|
|
{
|
|
_attackStep = -2;
|
|
_scriptCha.Invincibility(1f);
|
|
|
|
extraDamage = _scriptMoves.thumpExtraDamage;
|
|
extraDamagePercent = _scriptMoves.thumpExtraDamagePercent;
|
|
|
|
_scriptThump.SetType(_scriptMoves.thumpType);
|
|
}
|
|
|
|
if (_scriptMoves.canCritical)
|
|
{
|
|
extraCritical = 100;
|
|
}
|
|
|
|
transform.rotation = Quaternion.LookRotation(attackDirection);
|
|
|
|
_scriptCha.RndAtk(extraCritical, extraDamage, extraDamagePercent);
|
|
_scriptEffect.FogOn(0);
|
|
//随机声音
|
|
_scriptSound.PlaySoundAttack();
|
|
|
|
//Debug.Log(StringLoggingExtensions.Colored($"AttackOn move_state:{moveState} cur_attack:{weaponAtk}", Color.yellow));
|
|
int weaponAttackStyle = _attackStep;
|
|
if (weaponAttackStyle >= 0)
|
|
weaponAttackStyle += _weaponAttackStyle;
|
|
|
|
switch (weaponAttackStyle)
|
|
{
|
|
//thump
|
|
case -2:
|
|
//_pressDelay = 0f;
|
|
this.attackRising = true;
|
|
moveState = MoveState.state19_dash;
|
|
PlayAnimation(EntityPlayer.Hash_Jump_Attack_AIR);
|
|
AddForce(attackDirection * 50f);
|
|
scriptCamera.ZoomIn(3, 22, 0.2f);
|
|
|
|
ResetStep();
|
|
break;
|
|
//冲刺攻击
|
|
case -1:
|
|
//_pressDelay = 0f;
|
|
this.attackRising = true;
|
|
moveState = MoveState.state19_dash;
|
|
PlayAnimation(EntityPlayer.Hash_Attack_Dash);
|
|
|
|
_ef_swing_ex1.localScale = Vector3.one * 2.4f;
|
|
_ef_swing_ex1.localRotation = Quaternion.Euler(0f, 0f, 180f);
|
|
_ef_swing_ex1.localPosition = Vector3.up * 0.055f;
|
|
_scriptSwingEx1.SwingOn(0.48f, 2, 2, 20, 1, 120);
|
|
|
|
AddForce(attackDirection * 50f);
|
|
scriptCamera.ZoomIn(3, 22, 0.2f);
|
|
|
|
ResetStep();
|
|
break;
|
|
//单刀
|
|
case 0:
|
|
//scriptSound.PlaySoundOneShot(snd_blades[0]);
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_1);
|
|
|
|
_ef_swing1.localRotation = Quaternion.Euler(0f, 0f, 180f);
|
|
_ef_swing1.localPosition = Vector3.up * 0.055f;
|
|
_scriptSwing.SwingOn(0.15f - attackSpeedTime, 2, 2, 20, 1, 0);
|
|
|
|
AddForce(attackDirection * 110f);
|
|
break;
|
|
case 1:
|
|
//scriptSound.PlaySoundOneShot(snd_blades[1]);
|
|
attackRising = true;
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_2);
|
|
|
|
_ef_swing1.localRotation = Quaternion.Euler(0f, 0f, 40f);
|
|
_ef_swing1.localPosition = Vector3.up * 0.12f;
|
|
_scriptSwing.SwingOn(0.15f - attackSpeedTime, 2, 2, 20, 1, 0);
|
|
|
|
AddForce(attackDirection * 110f);
|
|
break;
|
|
case 2:
|
|
//scriptSound.PlaySoundOneShot(snd_blades[2]);
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_3);
|
|
|
|
_ef_swing1.localRotation = Quaternion.Euler(0f, 0f, 330f);
|
|
_ef_swing1.localPosition = Vector3.up * 0.1f;
|
|
_scriptSwing.SwingOn(0.2f - attackSpeedTime, 2, 2, 20, 1, 0);
|
|
|
|
AddForce(attackDirection * 110f);
|
|
break;
|
|
case 3:
|
|
//scriptSound.PlaySoundOneShot(snd_blades[2]);
|
|
moveState = MoveState.state12;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_4);
|
|
|
|
_scriptThrust.SwingOn(0.28f - attackSpeedTime, 4, 1, 20, 1, 100);
|
|
AddForce(attackDirection * 30f);
|
|
break;
|
|
case 4:
|
|
attackRising = true;
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_5);
|
|
|
|
_ef_swing1.localRotation = Quaternion.identity;
|
|
_ef_swing1.localPosition = Vector3.up * 0.055f;
|
|
_scriptSwing.SwingOn(0.21f - attackSpeedTime, 2, 2, 20, 1, 150);
|
|
break;
|
|
// 双剑
|
|
case 10:
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_1);
|
|
|
|
_ef_swing1.localRotation = Quaternion.Euler(0f, 0f, 180f);
|
|
_ef_swing1.localPosition = Vector3.up * 0.06f;
|
|
_scriptSwing.SwingOn(0.15f - attackSpeedTime, 2, 2, 20, 1, 0);
|
|
|
|
_ef_swing2.localRotation = Quaternion.Euler(0f, 0f, -20f);
|
|
_ef_swing2.localPosition = Vector3.up * 0.08f;
|
|
_scriptSwingSub.SwingOn(0.4f - attackSpeedTime, 2, 2, 20, 1, 100);
|
|
AddForce(attackDirection * 120f);
|
|
break;
|
|
case 11:
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_2);
|
|
|
|
_ef_swing1.localRotation = Quaternion.Euler(0f, 0f, 340f);
|
|
_ef_swing1.localPosition = Vector3.up * 0.06f;
|
|
_scriptSwing.SwingOn(0.2f - attackSpeedTime, 2, 2, 20, 1, 0);
|
|
|
|
_ef_swing2.localRotation = Quaternion.Euler(0f, 0f, 10f);
|
|
_ef_swing2.localPosition = Vector3.up * 0.06f;
|
|
_scriptSwingSub.SwingOn(0.4f - attackSpeedTime, 2, 2, 20, 1, 100);
|
|
|
|
AddForce(attackDirection * 120f);
|
|
break;
|
|
case 12:
|
|
attackRising = true;
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_3);
|
|
|
|
_ef_swing1.localRotation = Quaternion.Euler(0f, 0f, 90f);
|
|
_ef_swing1.localPosition = Vector3.up * 0.14f;
|
|
_scriptSwing.SwingOn(0.15f - attackSpeedTime, 2, 2, 20, 1, 140);
|
|
|
|
_ef_swing2.localRotation = Quaternion.Euler(0f, 0f, 90f);
|
|
_ef_swing2.localPosition = Vector3.up * 0.16f;
|
|
_scriptSwingSub.SwingOn(0.31f - attackSpeedTime, 2, 2, 20, 1, 80);
|
|
break;
|
|
case 13:
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_4);
|
|
|
|
_ef_swing1.localRotation = Quaternion.Euler(-20f, 0f, -90f);
|
|
_ef_swing1.localPosition = Vector3.up * 0.06f;
|
|
_scriptSwing.SwingOn(0.11f - attackSpeedTime, 2, 2, 20, 1, 0);
|
|
|
|
AddForce(attackDirection * 150f);
|
|
break;
|
|
case 14:
|
|
attackRising = true;
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_5);
|
|
|
|
_ef_swing1.localRotation = Quaternion.Euler(0f, 0f, 170f);
|
|
_ef_swing1.localPosition = Vector3.up * 0.06f - transform.right * 0.07f;
|
|
_scriptSwing.SwingOn(0.4f - attackSpeedTime, 2, 2, 20, 1, 180);
|
|
|
|
_ef_swing2.localRotation = Quaternion.Euler(0f, 0f, 10f);
|
|
_ef_swing2.localPosition = Vector3.up * 0.055f + transform.right * 0.07f;
|
|
_scriptSwingSub.SwingOn(0.4f - attackSpeedTime, 2, 2, 20, 1, 0);
|
|
break;
|
|
//斧子
|
|
case 20:
|
|
attackRising = true;
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_1);
|
|
|
|
_ef_swing1.localRotation = Quaternion.identity;
|
|
_ef_swing1.localPosition = Vector3.up * 0.06f;
|
|
_scriptSwing.SwingOn(0.15f - attackSpeedTime, 2, 2, 20, 1, 0);
|
|
|
|
AddForce(attackDirection * 160f);
|
|
break;
|
|
case 21:
|
|
attackRising = true;
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_2);
|
|
|
|
_ef_swing1.localRotation = Quaternion.Euler(0f, 0f, -90f);
|
|
_ef_swing1.localPosition = Vector3.up * 0.1f;
|
|
_scriptSwing.SwingOn(0.42f - attackSpeedTime, 2, 2, 20, 1, 0);
|
|
|
|
_scriptSplash.SplashOn(true, 0.18f, 0.5f - attackSpeedTime);
|
|
AddForce(attackDirection * 130f);
|
|
break;
|
|
case 22:
|
|
moveState = MoveState.state12;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_3);
|
|
|
|
_ef_swing1.localRotation = Quaternion.Euler(0f, 0f, 180f);
|
|
_ef_swing1.localPosition = Vector3.up * 0.1f;
|
|
_scriptSwing.SwingOn(0.5f - attackSpeedTime, 2, 2, 20, 1, 90);
|
|
|
|
AddForce(attackDirection * 90f);
|
|
break;
|
|
case 23:
|
|
attackRising = true;
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_4);
|
|
|
|
_ef_swing1.localRotation = Quaternion.Euler(0f, 0f, 160f);
|
|
_ef_swing1.localPosition = Vector3.up * 0.1f;
|
|
_ef_swing1.localScale = Vector3.one * 2.4f;
|
|
_scriptSwing.SwingOn(0.36f - attackSpeedTime, 2, 2, 20, 1, 120);
|
|
//ef_swing_ex1.localRotation = Quaternion.Euler(0f, 0f, 160f);
|
|
//ef_swing_ex1.localScale = Vector3.one * 2.4f;
|
|
//ef_swing_ex1.position = _transform.position + Vector3.up * 0.1f;
|
|
//_scriptSwingEx1.SwingOn(0.36f - attackSpeedTime, 2, 2, 20, 1, 120);
|
|
break;
|
|
case 24:
|
|
attackRising = true;
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_5);
|
|
|
|
_ef_swing1.localRotation = Quaternion.Euler(0f, 0f, -20f);
|
|
_ef_swing1.localPosition = Vector3.up * 0.1f;
|
|
_scriptSwing.SwingOn(0.4f - attackSpeedTime, 2, 2, 20, 1, 200);
|
|
break;
|
|
//
|
|
case 30:
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_1);
|
|
Invoke(nameof(Arrow_shoot), 0.3f - attackSpeedTime);
|
|
AddForce(attackDirection * -30f);
|
|
break;
|
|
case 31:
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_2);
|
|
Invoke(nameof(Arrow_shoot), 0.7f - attackSpeedTime);
|
|
AddForce(attackDirection * -30f);
|
|
break;
|
|
case 32:
|
|
attackRising = true;
|
|
moveState = MoveState.state12;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_3);
|
|
Invoke(nameof(Arrow_shoot), 0.8f - attackSpeedTime);
|
|
AddForce(attackDirection * -30f);
|
|
break;
|
|
case 33:
|
|
attackRising = true;
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_4);
|
|
Invoke(nameof(Arrow_shoot), 0.8f - attackSpeedTime);
|
|
AddForce(attackDirection * -30f);
|
|
break;
|
|
case 34:
|
|
attackRising = true;
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_5);
|
|
Invoke(nameof(Arrow_shoot), 0.8f - attackSpeedTime);
|
|
AddForce(attackDirection * -30f);
|
|
break;
|
|
case 40:
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_1);
|
|
_scriptThrust.SwingOn(0.1f - attackSpeedTime, 4, 1, 20, 1, 30);
|
|
_scriptPunch.PunchShoot(0.3f - attackSpeedTime, 0, _targetEnemy, 0f, 0f, 0.06f, false);
|
|
break;
|
|
case 41:
|
|
attackRising = true;
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_2);
|
|
_scriptPunch.PunchShoot(0.3f - attackSpeedTime, 40, _targetEnemy, -3f * attackSpeedTime * 15f, 0.8f, 0.1f, false);
|
|
break;
|
|
case 42:
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_3);
|
|
_scriptThrust.SwingOn(0.24f - attackSpeedTime, 4, 1, 20, 1, 30);
|
|
_scriptPunch.PunchShoot(0.1f - attackSpeedTime, 0, _targetEnemy, 0f, 0f, 0.06f, false);
|
|
break;
|
|
case 43:
|
|
attackRising = true;
|
|
moveState = MoveState.state12;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_4);
|
|
_scriptPunch.PunchShoot(0.4f - attackSpeedTime, 0, _targetEnemy, 2f * attackSpeedTime * 15f, 0f, 0.15f, true);
|
|
_scriptCha.Invincibility(1.5f - attackSpeedTime);
|
|
break;
|
|
case 44:
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_5);
|
|
_scriptThrust.SwingOn(0.2f - attackSpeedTime, 4, 1, 20, 1, 70);
|
|
_scriptSplash.SplashOn(true, 0.05f, 0.6f - attackSpeedTime);
|
|
AddForce(attackDirection * 120f);
|
|
break;
|
|
|
|
case 50:
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_1);
|
|
Invoke(nameof(Magic_shoot), 0.2f - attackSpeedTime);
|
|
AddForce(attackDirection * 10f);
|
|
break;
|
|
case 51:
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_2);
|
|
Invoke(nameof(Magic_shoot), 0.4f - attackSpeedTime);
|
|
AddForce(attackDirection * 10f);
|
|
break;
|
|
case 52:
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_3);
|
|
Invoke(nameof(Magic_shoot), 0.3f - attackSpeedTime);
|
|
AddForce(attackDirection * 10f);
|
|
break;
|
|
case 53:
|
|
moveState = MoveState.state12;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_4);
|
|
Invoke(nameof(FireSplash), 0.5f - attackSpeedTime);
|
|
AddForce(attackDirection * -60f);
|
|
break;
|
|
case 54:
|
|
moveState = MoveState.attackState11;
|
|
PlayAnimation(EntityPlayer.Hash_Atk_5);
|
|
Invoke(nameof(Magic_shoot), 0.3f - attackSpeedTime);
|
|
AddForce(attackDirection * 80f);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
_scriptCha.OnAttacked(attackDirection, _attackStep);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void CancelAttack()
|
|
{
|
|
switch (_weaponKind)
|
|
{
|
|
case 0:
|
|
_scriptSwing.SwingOff();
|
|
_scriptThrust.SwingOff();
|
|
break;
|
|
case 1:
|
|
_scriptSwing.SwingOff();
|
|
_scriptSwingSub.SwingOff();
|
|
break;
|
|
case 2:
|
|
_scriptSwing.SwingOff();
|
|
_scriptSplash.SplashOff();
|
|
break;
|
|
case 3:
|
|
CancelInvoke(nameof(Arrow_shoot));
|
|
break;
|
|
case 4:
|
|
_scriptThrust.SwingOff();
|
|
_scriptPunch.PunchOff();
|
|
_scriptSplash.SplashOff();
|
|
break;
|
|
case 5:
|
|
_scriptSplash.SplashOff();
|
|
CancelInvoke(nameof(Magic_shoot));
|
|
CancelInvoke(nameof(FireSplash));
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void ResetStep()
|
|
{
|
|
_attackStep = 0;
|
|
}
|
|
|
|
public void ResetCombo()
|
|
{
|
|
comboTime = 0f;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 矛
|
|
/// </summary>
|
|
/// <param name="monpos"></param>
|
|
public void Attack_spear(Vector3 monpos)
|
|
{
|
|
if (moveState == MoveState.state212)
|
|
{
|
|
//_scriptCha._myCollider.enabled = false;
|
|
_scriptCha.RndAtk(0);
|
|
var _attackDirection = monpos - transform.position;
|
|
_attackDirection.y = 0f;
|
|
_attackDirection = Vector3.Normalize(_attackDirection);
|
|
AddForce(_attackDirection * 40f);
|
|
|
|
if (comboTime > 0f)
|
|
{
|
|
_attackStep = (_attackStep + 1) % 2;
|
|
}
|
|
else if (comboTime <= 0f)
|
|
{
|
|
_attackStep = 0;
|
|
}
|
|
int si = Random.Range(0, 5);
|
|
if (si < 2)
|
|
{
|
|
_scriptCha.scriptSound.PlayYell(si);
|
|
}
|
|
|
|
switch (_attackStep)
|
|
{
|
|
case 0:
|
|
moveState = MoveState.state214;
|
|
_scriptCha.PlayAnimation("attack_ride1");
|
|
_ef_swing_ex1.localRotation = Quaternion.Euler(0f, 0f, 160f);
|
|
_ef_swing_ex1.position = transform.position + Vector3.up * 0.17f;
|
|
_ef_swing_ex1.localScale = Vector3.one * 2.8f;
|
|
_scriptSwingEx1.SwingOn(0.18f, 2, 2, 20, 1, 0);
|
|
break;
|
|
case 1:
|
|
moveState = MoveState.state214;
|
|
_scriptCha.PlayAnimation("attack_ride2");
|
|
_ef_swing_ex1.localRotation = Quaternion.Euler(0f, 0f, 20f);
|
|
_ef_swing_ex1.position = transform.position + Vector3.up * 0.17f;
|
|
_ef_swing_ex1.localScale = Vector3.one * 3f;
|
|
_scriptSwingEx1.SwingOn(0.18f, 2, 2, 20, 1, 0);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="monpos"></param>
|
|
public void Attack_arrow(Vector3 monpos)
|
|
{
|
|
if (moveState == MoveState.state203)
|
|
{
|
|
//_scriptCha._myCollider.enabled = false;
|
|
_scriptCha.RndAtk(-1);
|
|
moveState = MoveState.state192;
|
|
var _direction = monpos - transform.position;
|
|
_direction = Vector3.right * _direction.x + Vector3.forward * _direction.z;
|
|
_scriptCha.PlayAnimation("eagle_shoot");
|
|
transform.rotation = Quaternion.LookRotation(_direction);
|
|
var arrowpos = transform.position + Vector3.up * 0.24f + transform.forward * 0.1f;
|
|
|
|
_scriptEffect.ef_arrow_single.SetPositionAndRotation(arrowpos, Quaternion.LookRotation(monpos - arrowpos + Vector3.up * 0.08f));
|
|
_scriptEffect.ef_arrow_single.gameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void Arrow_shoot()
|
|
{
|
|
_scriptEffect.ef_arrow_multy.SetPositionAndRotation(transform.position + Vector3.up * 0.05f, transform.rotation);
|
|
_scriptEffect.ef_arrow_multy.gameObject.SetActive(true);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void Magic_shoot()
|
|
{
|
|
//magicspear.position = _transform.position + Vector3.up * 0.05f;
|
|
//magicspear.rotation = _transform.rotation;
|
|
//magicspear.gameObject.SetActive(true);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void FireSplash()
|
|
{
|
|
//ef_firesplash.gameObject.SetActive(true);
|
|
//ef_firesplash.position = _transform.position + _transform.forward * 0.4f;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Unity
|
|
|
|
// Use this for initialization
|
|
private void Awake()
|
|
{
|
|
_scriptCha = GetComponent<EntityMainPlayer>();
|
|
_scriptEffect = GetComponent<Cha_Effect>();
|
|
_scriptMoves = GetComponent<Cha_Moves>();
|
|
_scriptSound = GetComponent<Cha_Sound>();
|
|
|
|
LoadEffect();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
private void Update()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|