441 lines
12 KiB
C#
441 lines
12 KiB
C#
![]() |
// ***********************************************************************
|
|||
|
// Assembly : Game
|
|||
|
// Author : Kimch
|
|||
|
// Created : 2020-09-02
|
|||
|
// Description :
|
|||
|
// Last Modified By :
|
|||
|
// Last Modified On :
|
|||
|
// ***********************************************************************
|
|||
|
// <copyright file= "Stat_IdleAction" company="Kimch"></copyright>
|
|||
|
// <summary></summary>
|
|||
|
// ***********************************************************************
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
namespace G
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 技能
|
|||
|
/// </summary>
|
|||
|
public class Stat_SkillAction : Stat_BaseAction
|
|||
|
{
|
|||
|
protected int m_skillId;
|
|||
|
|
|||
|
protected string m_aniName = string.Empty;
|
|||
|
|
|||
|
protected string m_aniCastName = string.Empty;
|
|||
|
|
|||
|
protected int m_objType;
|
|||
|
|
|||
|
protected bool m_isSkillWarning;
|
|||
|
|
|||
|
protected AudioClip m_sound;
|
|||
|
|
|||
|
protected float m_soundFrame;
|
|||
|
|
|||
|
protected int m_invincible;
|
|||
|
|
|||
|
//protected Config m_curSkillConfig;
|
|||
|
|
|||
|
//public SkillItem m_curSkillItem;
|
|||
|
|
|||
|
protected Vector3 m_touchPos;
|
|||
|
|
|||
|
private RaycastHit m_mouseCastHit;
|
|||
|
|
|||
|
private Ray m_ray;
|
|||
|
|
|||
|
private Collider m_mapCollider;
|
|||
|
|
|||
|
private Transform m_curTargetTransform;
|
|||
|
|
|||
|
private bool m_bRecordInvincible;
|
|||
|
|
|||
|
private bool m_bRecordEnableHurt;
|
|||
|
|
|||
|
protected Vector3 preDir;
|
|||
|
|
|||
|
public Stat_SkillAction(Stat_StateManager statMgr)
|
|||
|
: base(statMgr)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public override bool Enter(Dictionary<string, object> param, bool clearDelegates = false)
|
|||
|
{
|
|||
|
base.Enter(param, clearDelegates);
|
|||
|
if (param == null || param.Count <= 0 || !param.ContainsKey("skill_id"))
|
|||
|
{
|
|||
|
Debug.LogError("param is error");
|
|||
|
return false;
|
|||
|
}
|
|||
|
//if (m_char.m_unitType == enCharacterType.CHAR_TYPE_BUILD && param.ContainsKey("skill_target"))
|
|||
|
//{
|
|||
|
// m_curTargetTransform = ((GameObject)param["skill_target"]).transform;
|
|||
|
//}
|
|||
|
int skillId = (int)param["skill_id"];
|
|||
|
GetSkillInfo(skillId);
|
|||
|
//if (m_char.m_unitType != enCharacterType.CHAR_TYPE_BUILD)
|
|||
|
//{
|
|||
|
// m_curAniLength = m_char.PlayAnimationByName(m_aniName);
|
|||
|
// if (m_curAniLength == -1f)
|
|||
|
// {
|
|||
|
// Debug.LogError("Can not find AniName:" + m_aniName);
|
|||
|
// return false;
|
|||
|
// }
|
|||
|
//}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// m_curAniLength = 0.01f;
|
|||
|
//}
|
|||
|
RecordTaskData();
|
|||
|
StatisticRecord();
|
|||
|
m_bRecordInvincible = m_char.invincible;
|
|||
|
m_bRecordEnableHurt = m_char.EnableHurt;
|
|||
|
SetInvincible(m_invincible);
|
|||
|
SetTimers();
|
|||
|
//if (LevelData.IsPVPMode)
|
|||
|
//{
|
|||
|
// m_touchPos = m_char.touchPos;
|
|||
|
//}
|
|||
|
//else if (LocalInt<LocalData29, ED_29>.instance.GetData(ED_29.InputMode) == 0)
|
|||
|
//{
|
|||
|
// m_touchPos = m_char.SkillDefaultWarningDir(m_skillId);
|
|||
|
//}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// m_touchPos = m_char.transform.position;
|
|||
|
//}
|
|||
|
m_char.isSkilling = true;
|
|||
|
m_isSkillWarning = true;
|
|||
|
//m_char.CurSkillID = m_skillId;
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
public override bool UpdateDelegate()
|
|||
|
{
|
|||
|
//if (m_isSkillWarning && m_char.m_unitType == enCharacterType.CHAR_TYPE_MYPLAYER)
|
|||
|
//{
|
|||
|
// WarningDelegate();
|
|||
|
//}
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
public override bool Exit()
|
|||
|
{
|
|||
|
//if (m_curSkillItem != null)
|
|||
|
//{
|
|||
|
// m_curSkillItem.AddPriority();
|
|||
|
//}
|
|||
|
if (m_char.IsPlayer())
|
|||
|
{
|
|||
|
//DailyTaskDataManager.instance.RecordKillOnce();
|
|||
|
}
|
|||
|
SetInvincible(0);
|
|||
|
m_char.isSkilling = false;
|
|||
|
m_isSkillWarning = false;
|
|||
|
m_char.OnCancelSkill();
|
|||
|
m_char.ResetTargetAfterAtk();
|
|||
|
return base.Exit();
|
|||
|
}
|
|||
|
|
|||
|
public override bool CanTransition(enStat stat)
|
|||
|
{
|
|||
|
if (stat == enStat.STAT_ACTION_DEAD || stat == enStat.STAT_ACTION_CHACKLES)
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
bool result = true;
|
|||
|
if (stat != enStat.STAT_ACTION_GENERAL_CAST && m_char.isSkilling)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
public bool GetSkillInfo(int skillId)
|
|||
|
{
|
|||
|
m_skillId = skillId;
|
|||
|
//m_curSkillItem = m_char.GetSkillBySkillId(skillId);
|
|||
|
//if (m_curSkillItem == null)
|
|||
|
//{
|
|||
|
// Debug.LogError("找不到技能了啊喂 id:" + skillId);
|
|||
|
//}
|
|||
|
//if (!m_char.IsPlayer() && !m_char.IsAttendant())
|
|||
|
//{
|
|||
|
// m_curSkillItem.OnSkill();
|
|||
|
//}
|
|||
|
//int editor_config_id = m_curSkillItem.data.editor_config_id;
|
|||
|
//m_curSkillConfig = Game.skillConfigs.GetConfigByID(editor_config_id);
|
|||
|
//if (m_curSkillConfig == null)
|
|||
|
//{
|
|||
|
// Debug.LogError("Cur Skill Config Is Error SkillId = " + m_skillId);
|
|||
|
// return false;
|
|||
|
//}
|
|||
|
//m_aniName = m_curSkillConfig.m_aniName;
|
|||
|
//m_aniCastName = m_curSkillConfig.m_castAniName;
|
|||
|
//m_objType = m_curSkillConfig.m_objType;
|
|||
|
//m_invincible = m_curSkillItem.data.invincible;
|
|||
|
//if (LevelData.IsPVPMode && m_invincible == 1)
|
|||
|
//{
|
|||
|
// m_invincible = 0;
|
|||
|
//}
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
protected void SetInvincible(int b)
|
|||
|
{
|
|||
|
switch (b)
|
|||
|
{
|
|||
|
case 0:
|
|||
|
m_char.SetColliderEnabled(true);
|
|||
|
m_char.invincible = m_bRecordInvincible;
|
|||
|
m_char.EnableHurt = m_bRecordEnableHurt;
|
|||
|
break;
|
|||
|
case 1:
|
|||
|
m_char.SetColliderEnabled(false);
|
|||
|
m_char.invincible = true;
|
|||
|
break;
|
|||
|
case 2:
|
|||
|
m_char.EnableHurt = false;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected virtual void SetTimers()
|
|||
|
{
|
|||
|
m_statMgr.AddTimer(m_curAniLength, AnimationEnd_CB);
|
|||
|
m_statMgr.AddTimer(0.26f, WarningEnd_CB);
|
|||
|
//for (int i = 0; i < m_curSkillConfig.m_fx.Count; i++)
|
|||
|
//{
|
|||
|
// float frame = m_curSkillConfig.m_fx[i].frame;
|
|||
|
// string name = m_curSkillConfig.m_fx[i].name;
|
|||
|
// if (!(name == string.Empty))
|
|||
|
// {
|
|||
|
// string text = name.Split('.')[0];
|
|||
|
// string[] array = text.Split('/');
|
|||
|
// int num = array.Length;
|
|||
|
// string text2 = array[num - 1];
|
|||
|
// object[] param = new object[2]
|
|||
|
// {
|
|||
|
// i,
|
|||
|
// text2
|
|||
|
// };
|
|||
|
// m_statMgr.AddTimer(frame, PlayEffect_CB, param);
|
|||
|
// }
|
|||
|
//}
|
|||
|
}
|
|||
|
|
|||
|
public new virtual bool WarningDelegate()
|
|||
|
{
|
|||
|
//if (LocalInt<LocalData29, ED_29>.instance.GetData(ED_29.InputMode) == 1)
|
|||
|
//{
|
|||
|
// return HandShank();
|
|||
|
//}
|
|||
|
if (m_mapCollider == null)
|
|||
|
{
|
|||
|
m_mapCollider = GameObject.Find("ground").GetComponent<Collider>();
|
|||
|
}
|
|||
|
if (Input.anyKey)
|
|||
|
{
|
|||
|
//if (LevelData.IsPVPMode)
|
|||
|
//{
|
|||
|
// return true;
|
|||
|
//}
|
|||
|
Vector3 vector = Vector3.zero;
|
|||
|
m_ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|||
|
if (m_mapCollider.Raycast(m_ray, out m_mouseCastHit, 4f) /*&& !UICamera.isOverUI*/)
|
|||
|
{
|
|||
|
m_touchPos = m_mouseCastHit.point;
|
|||
|
vector = m_touchPos - m_char.position;
|
|||
|
vector.Normalize();
|
|||
|
vector.y = 0f;
|
|||
|
float num = 200f;
|
|||
|
//if (MonoInstancePool.getInstance<GuideLocalData>().curGuideModule == 0)
|
|||
|
//{
|
|||
|
// int curGuideModuleStep = MonoInstancePool.getInstance<GuideLocalData>().curGuideModuleStep;
|
|||
|
// if (curGuideModuleStep == 3)
|
|||
|
// {
|
|||
|
// num *= 10f;
|
|||
|
// }
|
|||
|
//}
|
|||
|
m_char.rotation = (Quaternion.Lerp(m_char.rotation, Quaternion.LookRotation(vector), Time.deltaTime * num));
|
|||
|
m_char.SetCurDir(vector);
|
|||
|
}
|
|||
|
//if (m_objType == 1)
|
|||
|
//{
|
|||
|
// float num2 = (float)m_curSkillItem.data.range_R / 100f;
|
|||
|
// Vector3 curPos = m_char.GetCurPos();
|
|||
|
// curPos.y = 0f;
|
|||
|
// float num3 = Vector3.Distance(curPos, m_touchPos);
|
|||
|
// if (num3 > num2)
|
|||
|
// {
|
|||
|
// num3 = num2;
|
|||
|
// m_touchPos = m_char.GetCurPos() + vector * num2;
|
|||
|
// }
|
|||
|
// m_touchPos.y = 0.02f;
|
|||
|
// m_char.m_scriptSkill.UpdateArrowPos(m_curSkillItem.data.range_type, m_touchPos);
|
|||
|
//}
|
|||
|
}
|
|||
|
else if (m_objType == 1)
|
|||
|
{
|
|||
|
//m_char.m_scriptSkill.UpdateArrowPos(m_curSkillItem.data.range_type, m_touchPos);
|
|||
|
}
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
protected bool HandShank()
|
|||
|
{
|
|||
|
if (m_objType == 1)
|
|||
|
{
|
|||
|
Vector3 touchPos = m_touchPos;
|
|||
|
touchPos.y = 0.02f;
|
|||
|
float joyStickPosX = 0;// UIJoyStick.joyStickPosX;
|
|||
|
float joyStickPosY = 0;// UIJoyStick.joyStickPosY;
|
|||
|
touchPos.x += joyStickPosX / 30f;
|
|||
|
touchPos.z += joyStickPosY / 30f;
|
|||
|
float num = 0;// (float)m_curSkillItem.data.range_R / 100f;
|
|||
|
Vector3 curPos = m_char.position;
|
|||
|
curPos.y = 0.02f;
|
|||
|
float num2 = Vector3.Distance(curPos, touchPos);
|
|||
|
if (num2 > num)
|
|||
|
{
|
|||
|
m_char.rotation = (Quaternion.Lerp(m_char.rotation, Quaternion.LookRotation(preDir), Time.deltaTime * 200f));
|
|||
|
m_char.SetCurDir(preDir);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
touchPos.y = 0.02f;
|
|||
|
m_touchPos = touchPos;
|
|||
|
preDir = m_touchPos - m_char.position;
|
|||
|
preDir.Normalize();
|
|||
|
preDir.y = 0f;
|
|||
|
//m_char.m_scriptSkill.UpdateArrowPos(m_curSkillItem.data.range_type, m_touchPos);
|
|||
|
m_char.rotation = (Quaternion.Lerp(m_char.rotation, Quaternion.LookRotation(preDir), Time.deltaTime * 200f));
|
|||
|
m_char.SetCurDir(preDir);
|
|||
|
}
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
protected virtual bool AnimationEnd_CB(object[] param)
|
|||
|
{
|
|||
|
SetInvincible(0);
|
|||
|
m_char.isSkilling = false;
|
|||
|
#pragma warning disable CS0219 // 变量“flag”已被赋值,但从未使用过它的值
|
|||
|
bool flag = false;
|
|||
|
#pragma warning restore CS0219 // 变量“flag”已被赋值,但从未使用过它的值
|
|||
|
//if (m_char.m_unitType != enCharacterType.CHAR_TYPE_BUILD)
|
|||
|
{
|
|||
|
if (m_char.normalAtkEnableMove)
|
|||
|
{
|
|||
|
Dictionary<string, object> dictionary = new Dictionary<string, object>();
|
|||
|
dictionary.Add("speed", 5.5f);
|
|||
|
return SetCurActionState(enStat.STAT_ACTION_MOVE, dictionary);
|
|||
|
}
|
|||
|
return SetCurActionState(enStat.STAT_ACTION_IDLE);
|
|||
|
}
|
|||
|
#pragma warning disable CS0162 // 检测到无法访问的代码
|
|||
|
return true;
|
|||
|
#pragma warning restore CS0162 // 检测到无法访问的代码
|
|||
|
}
|
|||
|
|
|||
|
protected virtual bool Sound_CB(object[] param)
|
|||
|
{
|
|||
|
//m_char.audio.PlayOneShot(m_sound);
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
protected virtual bool WarningEnd_CB(object[] param)
|
|||
|
{
|
|||
|
if (m_skillId == 400104)
|
|||
|
{
|
|||
|
m_char.rotation = (Quaternion.identity);
|
|||
|
m_char.GetComponent<NormalAtkBase>().OnFog(2);
|
|||
|
}
|
|||
|
m_isSkillWarning = false;
|
|||
|
m_char.OnCancelSkill();
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
protected virtual bool PlayEffect_CB(object[] param)
|
|||
|
{
|
|||
|
Vector3 targetPos = m_char.transform.position;
|
|||
|
switch (m_objType)
|
|||
|
{
|
|||
|
case 0:
|
|||
|
targetPos = m_char.transform.position;
|
|||
|
break;
|
|||
|
case 1:
|
|||
|
targetPos = m_touchPos;
|
|||
|
break;
|
|||
|
}
|
|||
|
int num = (int)param[0];
|
|||
|
string fxName = (string)param[1];
|
|||
|
if (num == 0)
|
|||
|
{
|
|||
|
//Transform transform = m_char.m_scriptSkill.PlaySkillMainFx(fxName, m_skillId, targetPos);
|
|||
|
//if (m_skillId == 400105)
|
|||
|
//{
|
|||
|
// transform.position = m_char.GetCurPos() + m_char.transform.forward * 0.2f;
|
|||
|
// transform.rotation = Quaternion.AngleAxis(180f, Vector3.up);
|
|||
|
// CamMove.instance.LookTarget(transform, 28, 0.5f);
|
|||
|
//}
|
|||
|
//if (m_char.m_unitType == enCharacterType.CHAR_TYPE_BUILD && m_curTargetTransform != null)
|
|||
|
//{
|
|||
|
// transform.LookAt(m_curTargetTransform.position);
|
|||
|
//}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//m_char.m_scriptSkill.PlaySkillFx(fxName);
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
private void RecordTaskData()
|
|||
|
{
|
|||
|
if (m_char.IsPlayer())
|
|||
|
{
|
|||
|
//DailyTaskDataManager.instance.killOnceCount = 0;
|
|||
|
//if (m_curSkillItem.data.rageskill_type > 0)
|
|||
|
//{
|
|||
|
// DailyTaskDataManager.instance.DoDailyTask(6, 1);
|
|||
|
//}
|
|||
|
}
|
|||
|
if (m_char.IsGeneral())
|
|||
|
{
|
|||
|
//DailyTaskDataManager.instance.useGeneralSkillInOneGameCount++;
|
|||
|
//DailyTaskDataManager.instance.DoDailyTask(13, 1);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void StatisticRecord()
|
|||
|
{
|
|||
|
//if (m_char.IsPlayer() && !LevelData.IsPVPMode)
|
|||
|
//{
|
|||
|
// if (m_curSkillItem.data.rageskill_type > 0)
|
|||
|
// {
|
|||
|
// DataStatistics.instance.AddRecord("rageSkill", 1);
|
|||
|
// DataStatistics.instance.AddRecord("specificSkill_" + m_skillId, 1);
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// Debug.Log("~~~~~~~~~~casting skill " + m_skillId);
|
|||
|
// DataStatistics.instance.AddRecord("specificSkill_" + m_skillId, 1);
|
|||
|
// DataStatistics.instance.AddRecord("castSkill", 1);
|
|||
|
// }
|
|||
|
//}
|
|||
|
//else if (m_char.IsAttendant() && !LevelData.IsPVPMode)
|
|||
|
//{
|
|||
|
// if (m_skillId == 413102)
|
|||
|
// {
|
|||
|
// DataStatistics.instance.AddRecord("specificSkill_" + 411201, 1);
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// DataStatistics.instance.AddRecord("specificSkill_" + m_skillId, 1);
|
|||
|
// }
|
|||
|
//}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|