1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690 |
- using Adon.Game.Data;
- using Adon.Game.Data.StructData;
- using Adon.Game.BO;
- using Adon.Game.Helper;
- using Chronos;
- using Cinemachine;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Playables;
- using WarReport;
- using BehaviorDesigner.Runtime;
- using X2Battle;
- namespace AdonGameKit
- {
- /// <summary>
- /// 英雄基础类
- /// </summary>
- public class BaseHero : BaseCharacterAdon
- {
- #region readonly
- /// <summary>
- /// 前速度字符
- /// </summary>
- readonly int m_HashForwardSpeed = Animator.StringToHash("ForwardSpeed");
- /// <summary>
- /// 近战攻击字符
- /// </summary>
- readonly int m_HashMeleeAttack = Animator.StringToHash("MeleeAttack");
- /// <summary>
- /// 冲刺攻击字符
- /// </summary>
- readonly int m_HashDashAttack = Animator.StringToHash("DashAttack");
- /// <summary>
- /// 后退闪避字符
- /// </summary>
- readonly int m_HashDodge = Animator.StringToHash("Dodge");
- /// <summary>
- /// 前冲闪避字符
- /// </summary>
- readonly int m_HashRush = Animator.StringToHash("Rush");
- /// <summary>
- /// 技能字符
- /// </summary>
- readonly int m_HashSkill = Animator.StringToHash("Skill");
- readonly int m_HashIdle = Animator.StringToHash("Idle");
- #endregion
- GameObject _targetMonster;
- /// <summary>
- /// 目标怪
- /// </summary>
- public GameObject m_targetMonster;
- /// <summary>
- /// 技能碰撞器
- /// </summary>
- public Collider m_SkillCol;
- /// <summary>
- /// 是否僵直中
- /// </summary>
- private bool isStiff;
- /// <summary>
- /// 根时钟
- /// </summary>
- private Clock m_clockRoot;
- /// <summary>
- /// 玩家时钟
- /// </summary>
- public Clock m_clockPlayer;
- /// <summary>
- /// 敌人时钟
- /// </summary>
- private Clock m_clockEnemy;
- /// <summary>
- /// 僵直时间
- /// </summary>
- private float stiffTime;
- /// <summary>
- /// 是否被击
- /// </summary>
- private bool isAttacked;
- /// <summary>
- /// 是否治疗
- /// </summary>
- private bool isCuring;
- /// <summary>
- /// 损伤材质闪光强度
- /// </summary>
- private float m_damageFlashScale;
- /// <summary>
- /// 损伤材质闪光强度
- /// </summary>
- private float m_CuringFlashScale;
- /// <summary>
- /// 是否看向目标
- /// </summary>
- private bool isHeadlook;
- private bool isExtermeTimeZone;//是否进入极限闪避时区
- private float m_ExtermeZoneTimer;//极限闪避时区计时
- private bool isExtermeDodge;//是否进入极限闪避
- private float m_ExtermeDodgeTimer;//极限闪避计时
- /// <summary>
- /// 镜头效果组件
- /// </summary>
- public PlayableDirector m_PlayableDirector;
- public HeroBlur m_HeroBlur;//残影组件
- /// <summary>
- /// 检测的攻击范围
- /// </summary>
- public float m_AutoAttackRange = 18;
- /// <summary>
- /// 近战攻击视野
- /// </summary>
- public float m_AttackSight = 3;
- /// <summary>
- /// 攻击角度
- /// </summary>
- public float m_AttackAngle = 160;
- //private GameObject m_targetMonster;
- /// <summary>
- /// 推力方向
- /// </summary>
- public Vector3 m_ForceDirection;
- /// <summary>
- /// 是否切换角色
- /// </summary>
- private bool IsSwitchRoles;
- /// <summary>
- /// 无敌
- /// </summary>
- private bool isGod;
- /// <summary>
- /// 无敌时间
- /// </summary>
- private float m_GodTime;
- private float detectTime;
- private bool isStun;
- /// <summary>
- /// 网络同步间隔
- /// </summary>
- public float netUpdateTime = 0.1f;
- public float curUpdateTime = 0;
- /// <summary>
- /// 言灵挂件
- /// </summary>
- public Dictionary<string, BaseYLPartAdon> m_YLParts = new Dictionary<string, BaseYLPartAdon>();
- Dictionary<int, int> buffnum = new Dictionary<int, int>();//buff计数
- protected static readonly int hashHit = Animator.StringToHash("Hit");//打击
- protected static readonly int hashHitAngle = Animator.StringToHash("HitAngle");//受击方向
- protected static readonly int hashHitDown = Animator.StringToHash("HitDown");//击倒
- protected static readonly int hashDie = Animator.StringToHash("Die");//死亡
- protected static readonly int hashDieDown = Animator.StringToHash("DieDown");//击飞死亡
- protected static readonly int hashStun = Animator.StringToHash("Stun");//眩晕
- protected static readonly int hashWin = Animator.StringToHash("Win");//胜利
- private Transform attackRangeTran = null;
- /// <summary>
- /// 时间器刚体
- /// </summary>
- private RigidbodyTimeline3D m_Rigidbody
- {
- get { return time.rigidbody; }
- }
- /// <summary>
- /// 时间寻路组件
- /// </summary>
- public NavMeshAgentTimeline m_navMeshAgent
- {
- get { return time.navMeshAgent; }
- }
- /// <summary>
- /// 头部言灵
- /// </summary>
- BaseYLPartAdon _Head_YL;
- BaseYLPartAdon _Shoulder_YL;
- BaseYLPartAdon _Foot_YL;
- /// <summary>
- /// 头部言灵
- /// </summary>
- public BaseYLPartAdon m_Head_YL
- {
- get
- {
- if (_Head_YL == null)
- {
- Transform head_YL = X2BattleManager.Instance.mBulletModel.GetCmptRootByType(this, YanLingBonePoint.BonePoint.head);
- ///获取言灵脚本
- _Head_YL = head_YL.GetComponent<BaseYLPartAdon>();
- _Head_YL.m_Hero = this;
- }
- return _Head_YL;
- }
- }
- /// <summary>
- /// 肩部言灵
- /// </summary>
- public BaseYLPartAdon m_Shoulder_YL
- {
- get
- {
- if (_Shoulder_YL == null)
- {
- Transform Shoulder_YL = X2BattleManager.Instance.mBulletModel.GetCmptRootByType(this, YanLingBonePoint.BonePoint.shoulder);
- ///获取言灵脚本
- _Shoulder_YL = Shoulder_YL.GetComponent<BaseYLPartAdon>();
- _Shoulder_YL.m_Hero = this;
- }
- return _Shoulder_YL;
- }
- }
- /// <summary>
- /// 脚部言灵
- /// </summary>
- public BaseYLPartAdon m_Foot_YL
- {
- get
- {
- if (_Foot_YL == null)
- {
- Transform foot_YL = X2BattleManager.Instance.mBulletModel.GetCmptRootByType(this, YanLingBonePoint.BonePoint.foot);
- ///获取言灵脚本
- _Foot_YL = foot_YL.GetComponent<BaseYLPartAdon>();
- _Foot_YL.m_Hero = this;
- }
- return _Foot_YL;
- }
- }
- protected override void Awake()
- {
- base.Awake();
- m_CameraManagerAdon = gameObject.AddComponent<CameraManagerAdon>();//添加相机管理
- m_CameraManagerAdon.m_Hero = this.transform;
- m_HeroBlur = gameObject.AddComponent<HeroBlur>();//添加残影脚本
- m_HeroBlur.enabled = false;
- m_fbx.gameObject.GetComponent<FBXEvent>().SetOwner(this.gameObject);
- mCM_ThirdPerson = transform.Find("CMStateDrivenCamera/CM_ThirdPerson").GetComponent<CinemachineFreeLook>();
- attackRangeTran = transform.Find("AttackRange");
- m_CameraManagerAdon.m_Timeline_CM_Respawn.gameObject.SetActive(false);
- }
- void Start()
- {
- m_clockRoot = Timekeeper.instance.Clock("Root");
- m_clockPlayer = Timekeeper.instance.Clock("Player");
- m_clockEnemy = Timekeeper.instance.Clock("Enemy");
- //m_fbx.gameObject.SetActive(true);
- ////开始场景漫游相机
- //CameraManager.Instance.PlaySceneTour();
- }
- private void OnEnable()
- {
- if (IsSwitchRoles)
- {
- BattleCanvas.Instance.userYanlingSkill = BattleUseYanlingSkill;//注册言灵技委托。
- BattleCanvas.Instance.cancelyanlingSkill = BattleCancelyanlingSkill;//注册言灵技委托。
- m_fbx.gameObject.SetActive(true);
- m_CameraManagerAdon.SwitchToCM_TopDown();
- SetAnimatorStatusIdle();
- }
- else
- {
- //m_fbx.gameObject.SetActive(false);
- Invoke("showFBX", 0.5f);//延迟显示角色
- }
- }
- void Update()
- {
- if (m_bStopTime)//时间暂停
- {
- if (m_stopTime <= Time.realtimeSinceStartup - lastUpdateTime)
- {
- Time.timeScale = 1;
- m_bStopTime = false;
- }
- }
- if (isGod)
- {
- //m_CapsuleCollider.enabled = false;
- if (m_GodTime <= 0)
- {
- m_GodTime = 0;
- isGod = false;
- //m_CapsuleCollider.enabled = true; ;
- }
- m_GodTime -= time.deltaTime;
- }
- ///检测可锁定的攻击目标
- detectTime += time.deltaTime;
- if (detectTime >= 0.1f)
- {
- detectTime = 0;
- PlayerHelperAdon.GetNearEnemyDistance(this, m_AutoAttackRange, out _targetMonster);
- if (_targetMonster == null)
- {
- if (m_targetMonster != null)
- {
- m_targetMonster.GetComponent<BaseMonsterAdon>().ReleaseLock();
- m_targetMonster = null;
- }
- return;
- }
- if (m_targetMonster != _targetMonster)
- {
- if (m_targetMonster != null)
- {
- m_targetMonster.GetComponent<BaseMonsterAdon>().ReleaseLock();
- ReleaseTarget();
- }
- if (_targetMonster != null)
- {
- _targetMonster.GetComponent<BaseMonsterAdon>().Lock();
- }
- m_targetMonster = _targetMonster;
- TargetRole = _targetMonster.GetComponent<BaseMonsterAdon>();
- }
- // BOSS 通过服务器刷新血量
- if (GameDateManager.Instance.GateVO != null && int.Parse(GameDateManager.Instance.GateVO.Mo.battleType) != (int)BattleDefine.EBattleSceneType.EBattleType_WorldBoss)
- {
- BattleCanvas.Instance.ShowLockMonsterHP(TargetRole);
- }
- }
- //残影测试
- if (Input.GetKeyDown(KeyCode.Q))
- {
- m_HeroBlur.enabled = false;
- m_HeroBlur.enabled = true;
- }
- // 网络同步
- curUpdateTime += Time.deltaTime;
- if (curUpdateTime > netUpdateTime)
- {
- curUpdateTime = curUpdateTime - netUpdateTime;
- }
- else
- {
- return;
- }
- //if (this.mData.UID == HeroPlayerController.Instance.m_Hero.mData.UID)
- if (GameDateManager.Instance.isMultiRoom && playerUID == UserProxy.Instance.player.uid)
- {
- float x = this.transform.position.x;
- float y = this.transform.position.y;
- float z = this.transform.position.z;
- MultiBattleProxy.Instance.SendPostion(x, y, z);
- }
- }
- void showFBX()
- {
- m_fbx.gameObject.SetActive(true);
- m_CameraManagerAdon.m_Timeline_CM_Respawn.gameObject.SetActive(true);
- //CameraManager.Instance.StopSceneTour();//停止场景漫游
- //判断是否为角色切换,如果是角色切换则不播放出生动作和出生特写镜头
- if (IsSwitchRoles)
- {
- m_CameraManagerAdon.SwitchToCM_TopDown();
- SetAnimatorStatusIdle();
- }
- else
- {
- m_CameraManagerAdon.m_Timeline_CM_Respawn.gameObject.SetActive(true);
- }
- }
- /// <summary>
- /// 设置是否切换角色
- /// </summary>
- /// <param name="isSwitchRoles"></param>
- public void SetIsSwitchRoles(bool isSwitchRoles)
- {
- IsSwitchRoles = isSwitchRoles;
- m_fbx.gameObject.SetActive(true);
- if (IsSwitchRoles)
- {
- BattleCanvas.Instance.userYanlingSkill = BattleUseYanlingSkill;//注册言灵技委托。
- BattleCanvas.Instance.cancelyanlingSkill = BattleCancelyanlingSkill;//注册言灵技委托。
- }
- }
- void FixedUpdate()
- {
- if (isStiff)//僵直
- {
- if (stiffTime > 0)
- {
- stiffTime -= Time.deltaTime;
- }
- else
- {
- stiffTime = 0;
- m_clockRoot.localTimeScale = 1;
- //m_clockPlayer.localTimeScale = 1;
- //m_clockEnemy.localTimeScale = 1;
- //m_Hero.m_Animator.speed = 1;
- isStiff = false;
- }
- }
- //受击闪光效果
- if (isAttacked)
- {
- m_damageFlashScale -= time.deltaTime * 10;
- if (m_damageFlashScale <= 0)
- {
- m_damageFlash.gameObject.SetActive(false);
- m_damageFlashScale = 0;
- isAttacked = false;
- }
- for (int l = 0; l < m_damageFlashMaterial.Length; l++)
- {
- m_damageFlashMaterial[l].SetFloat("_Scale", m_damageFlashScale);
- }
- }
- //治愈闪光效果
- if (isCuring)
- {
- m_CuringFlashScale -= time.deltaTime * 2;
- if (m_CuringFlashScale <= 0)
- {
- m_CuringFlashs.gameObject.SetActive(false);
- m_CuringFlashScale = 0;
- isCuring = false;
- }
- for (int l = 0; l < m_CuringFlashMaterial.Length; l++)
- {
- m_CuringFlashMaterial[l].SetFloat("_Scale", m_CuringFlashScale);
- }
- }
- //看向目标
- if (m_PerfectLookAtAdon != null)
- {
- if (isHeadlook == true)//如果看向目标
- {
- m_PerfectLookAtAdon.m_Weight += 0.03f;//权重增加
- }
- else
- {
- m_PerfectLookAtAdon.m_Weight -= 0.03f;//权重递减
- }
- if (m_PerfectLookAtAdon.m_Weight > 1)
- {
- m_PerfectLookAtAdon.m_Weight = 1;//限制权重不能大于1
- }
- else if (m_PerfectLookAtAdon.m_Weight < 0)
- {
- m_PerfectLookAtAdon.m_Weight = 0;//限制权重不能小于0
- }
- }
- if (isExtermeTimeZone)//进入极限闪避时区
- {
- m_ExtermeZoneTimer -= Time.deltaTime;//递减极限闪避时区
- if (m_ExtermeZoneTimer <= 0)
- {
- m_ExtermeZoneTimer = 0;
- isExtermeTimeZone = false;
- }
- }
- if (isExtermeDodge)//成功极限闪避
- {
- m_ExtermeDodgeTimer -= Time.deltaTime;//递减极限闪避时区
- if (m_ExtermeDodgeTimer <= 0)
- {
- m_ExtermeDodgeTimer = 0;
- isExtermeDodge = false;
- FreedExterme();
- }
- }
- }
- #region ============================================ MSG ======================================================
- /// <summary>
- /// 攻击消息
- /// </summary>
- /// <param name="baseData"></param>
- public void OnMsg_Attack(Attack_MsgData data)
- {
- SetAnimatorStatusAttack(data);
- }
- public void SetAnimatorStatusAttack(Attack_MsgData data)
- {
- m_Rigidbody.velocity = Vector3.zero;//刚体推力设置为0
- m_Animator.SetBool(m_HashMeleeAttack, true);//触发近战攻击动作
- data.dir.Normalize();
- transform.rotation = Quaternion.LookRotation(data.dir);//看向方向
- if (m_targetMonster)
- {
- LockingTarget();//锁定目标
- }
- // 网络同步
- if (GameDateManager.Instance.isMultiRoom && playerUID == UserProxy.Instance.player.uid)
- {
- string msgData = CommonManager.Serialize<Attack_MsgData>(data);
- MultiBattleProxy.Instance.SendStatus("SetBool", msgData);
- }
- }
- /// <summary>
- /// 冲刺攻击
- /// </summary>
- /// <param name="b"></param>
- public void SetAnimatorStatusDash(Rush_MsgData data)
- {
- m_Rigidbody.velocity = Vector3.zero;//刚体推力设置为0
- data.dir.Normalize();
- transform.localRotation = Quaternion.LookRotation(data.dir);//看向方向
- if (m_targetMonster)
- {
- LockingTarget();//锁定目标
- }
- m_Animator.SetTrigger(m_HashDashAttack);//触发冲刺攻击动作
- }
- /// <summary>
- /// 闪避后退
- /// </summary>
- /// <param name="b"></param>
- public void SetAnimatorStatusDodge()
- {
- bDodge = true;
- m_Animator.SetTrigger(m_HashDodge);
- // 网络同步
- if (GameDateManager.Instance.isMultiRoom && playerUID == UserProxy.Instance.player.uid)
- {
- MultiBattleProxy.Instance.SendStatus("Dodge", m_HashDodge.ToString());
- }
- }
- /// <summary>
- /// 闪避前进
- /// </summary>
- /// <param name="b"></param>
- public void SetAnimatorStatusRush()
- {
- bDodge = true;
- m_Animator.SetTrigger(m_HashRush);
- // 网络同步
- if (GameDateManager.Instance.isMultiRoom && playerUID == UserProxy.Instance.player.uid)
- {
- MultiBattleProxy.Instance.SendStatus("Rush", m_HashDodge.ToString());
- }
- }
- /// <summary>
- /// 施放必杀
- /// </summary>
- public void SetAnimatorStatusSkill()
- {
- // m_Animator.SetTrigger(m_HashSkill);
- // 释放必杀 放入场景
- GameObject bishaEffObj = m_Animator.transform.Find("Effect_000/Attacks/skill/skill_101005").gameObject;
- GameObject newEffObj = (GameObject)Instantiate(bishaEffObj, bishaEffObj.transform.parent);
- newEffObj.SetActive(true);
- newEffObj.transform.parent = null;
- FBXEvent fe = newEffObj.GetComponent<FBXEvent>();
- fe.SetOwner(this.gameObject);
- // 网络同步
- if (GameDateManager.Instance.isMultiRoom && playerUID == UserProxy.Instance.player.uid)
- {
- MultiBattleProxy.Instance.SendStatus("Skill", m_HashSkill.ToString());
- }
- }
- /// <summary>
- /// 等待
- /// </summary>
- public void SetAnimatorStatusIdle()
- {
- m_Animator.SetTrigger(m_HashIdle);
- // 网络同步
- if (GameDateManager.Instance.isMultiRoom && playerUID == UserProxy.Instance.player.uid)
- {
- MultiBattleProxy.Instance.SendStatus("Idle", m_HashIdle.ToString());
- }
- }
- /// <summary>
- /// 冲刺攻击消息
- /// </summary>
- /// <param name="data"></param>
- public void OnMsg_DashAttack(Rush_MsgData data)
- {
- SetAnimatorStatusDash(data);
- // 网络同步
- if (GameDateManager.Instance.isMultiRoom && playerUID == UserProxy.Instance.player.uid)
- {
- string msgData = CommonManager.Serialize<Rush_MsgData>(data);
- MultiBattleProxy.Instance.SendStatus("DashAttack", m_HashDashAttack.ToString());
- }
- }
- /// <summary>
- /// 闪避消息
- /// </summary>
- /// <param name="data"></param>
- public void OnMsg_Dodge(Dodge_MsgData data)
- {
- isGod = true;
- m_GodTime = 0.5f;
- ////if (m_CurState != eState.Idle)
- {
- SetAnimatorStatusRush();//触发前冲闪避
- }
- ////else
- ////{
- //// SetAnimatorStatusDodge();//触发后退闪避动作
- ////}
- data.dir.Normalize();
- //if (isExtermeTimeZone)//极限闪避
- //{
- // SetExtermeDodgeTimer(10);
- //}
- }
- public void OnMsg_Bisha(Dodge_MsgData data)
- {
- SetAnimatorStatusSkill();
- }
- /// <summary>
- /// 技能消息
- /// </summary>
- /// <param name="data"></param>
- public void OnMsg_Skill(Skill_MsgData data)
- {
- m_Rigidbody.velocity = Vector3.zero;//刚体推力设置为0
- SetAnimatorStatusSkill();
- data.dir.Normalize();
- transform.rotation = Quaternion.LookRotation(data.dir);//看向方向
- if (m_targetMonster)
- {
- LockingTarget();//锁定目标
- }
- m_CurState = eState.Skill;
- }
- /// <summary>
- /// 受击消息接收
- /// </summary>
- /// <param name="baseData"></param>
- public override void OnMsg_Attacked(Attacked_MsgData data)
- {
- Debug.Log("英雄受击消息");
- //m_targetMonster = data.sender;
- m_ForceDirection = data.forceDirection;
- //计算怪角度偏移
- float HitAngle = PlayerHelperAdon.Angle_360(transform.forward, m_ForceDirection);
- HpbarManager.Instance.CreateHpTip(this, data.dmg, data.isCR, data.weakness);//血条及数字显示
- if (data.resultHp <= 0)//死亡
- {
- if (data.attackedEffType == EnumDefine.AttackedEffT.DWN)//击倒击飞
- {
- SetCameraShake(transform.position, 2f, 0.1f, 0.3f);//震屏
- m_Animator.SetTrigger(hashDieDown);//播放击飞死亡动作
- //转向玩家
- transform.LookAt(data.sender.transform);
- }
- else
- {
- m_Animator.SetTrigger(hashDie);//播放死亡动作
- SetCameraShake(transform.position, 0.8f, 0.1f, 0.2f);//震屏
- }
- // 英雄死亡
- HeroDie();
- }
- else
- {
- if (data.dmg < 0)
- {
- if (data.attackedEffType == EnumDefine.AttackedEffT.DWN)//击倒击飞
- {
- SetCameraShake(transform.position, 2f, 0.1f, 0.3f);//震屏
- m_Animator.SetTrigger(hashHitDown);//播放击倒动作
- transform.LookAt(data.sender.transform);
- }
- else if (data.attackedEffType == EnumDefine.AttackedEffT.NOR)
- {
- SetCameraShake(transform.position, 0.8f, 0.1f, 0.2f);//震屏
- }
- else
- {
- m_Animator.SetTrigger(hashHit);//播放受击动作
- m_Animator.SetFloat(hashHitAngle, HitAngle);//根据受击方向播受击动作
- SetCameraShake(transform.position, 0.8f, 0.1f, 0.2f);//震屏
- }
- }
- }
- //实例化克隆被击光效
- if (data.AttackedEff != null)
- {
- GameObject effobj = Instantiate(data.AttackedEff);
- if (!effobj.GetComponent<DestroyObjectDelayed>()) effobj.gameObject.AddComponent<DestroyObjectDelayed>();//添加延迟销毁脚本
- effobj.transform.position = m_HitObj.position;
- if (m_targetMonster != null)
- {
- effobj.transform.rotation = m_targetMonster.transform.rotation;
- }
- effobj.SetActive(true);
- }
- if (data.SkillId == "711002" || data.SkillId == "708003" || data.dmg > 0)
- {
- //m_damageFlash.gameObject.SetActive(true);//受击高亮材质显示
- //m_damageFlashScale = 5;
- //for (int l = 0; l < m_damageFlashMaterial.Length; l++)
- //{
- // m_damageFlashMaterial[l].SetFloat("_Scale", m_damageFlashScale);
- //}
- m_freezeFlashs.gameObject.SetActive(true);
- //m_freezeFlashPower = 5;
- for (int l = 0; l < m_freezeFlashMaterial.Length; l++)
- {
- m_freezeFlashMaterial[l].SetFloat("_Power", 0.6f);
- }
- }
- else
- {
- m_damageFlash.gameObject.SetActive(true);//受击高亮材质显示
- m_damageFlashScale = 5;
- for (int l = 0; l < m_damageFlashMaterial.Length; l++)
- {
- m_damageFlashMaterial[l].SetFloat("_Scale", m_damageFlashScale);
- }
- }
- isAttacked = true;
- isGod = true;
- m_GodTime = 0.5f;
- }
- /// <summary>
- /// 英雄死亡
- /// </summary>
- private void HeroDie()
- {
- // 延迟删除角色
- RoleManager.Instance.DeleteRole(this, 2.0f);
- GameDateManager.Instance.PlayerDeathNumber++;
- HeroPlayerController.Instance.m_Hero.TargetRole = null;
- // 队长死亡
- if (IsTeamLeader)
- {
- GameDateManager.Instance.PlayerDeathNumber++;
- // 切换下一位队长
- RoleManager.Instance.NextTeamLeader(transform.position, (suc) =>
- {
- if (suc == false)
- {
- if (YLBattle.GameBattleManager.Instance().battleType == BattleDefine.EBattleSceneType.EBattleType_Arena)
- {
- RoleManager.Instance.ChallengeResult(false);
- }
- else
- {
- // 切换队长失败,游戏结束
- PanelHelper.Instance.ShowPanel("YL_BattleFailWindow", null, null);
- }
- }
- });
- }
- }
- /// <summary>
- /// 治愈消息接收
- /// </summary>
- /// <param name="baseData"></param>
- public void OnMsg_Curing(Attacked_MsgData data)
- {
- Debug.Log("英雄治愈消息");
- //m_targetMonster = data.sender;
- m_ForceDirection = data.forceDirection;
- //计算怪角度偏移
- float HitAngle = PlayerHelperAdon.Angle_360(transform.forward, m_ForceDirection);
- HpbarManager.Instance.CreateHpTip(this, data.dmg, data.isCR, data.weakness);//血条及数字显示
- //实例化克隆被击光效
- if (data.AttackedEff != null)
- {
- GameObject effobj = Instantiate(data.AttackedEff);
- if (!effobj.GetComponent<DestroyObjectDelayed>()) effobj.gameObject.AddComponent<DestroyObjectDelayed>();//添加延迟销毁脚本
- effobj.transform.position = m_HitObj.position;
- effobj.transform.rotation = this.transform.rotation;
- effobj.SetActive(true);
- }
- m_CuringFlashs.gameObject.SetActive(true);//治愈高亮材质显示
- m_CuringFlashScale = 5;
- for (int l = 0; l < m_CuringFlashMaterial.Length; l++)
- {
- m_CuringFlashMaterial[l].SetFloat("_Scale", m_CuringFlashScale);
- }
- isCuring = true;
- }
- ///// <summary>
- ///// 战士普通打击
- ///// </summary>
- ///// <param name="attackIdx"></param>
- ///// <param name="enemy"></param>
- //public void OnMsgAttackHit(WarReportInfo report)
- //{
- // WarReportUnit enemyData = report.UnitDataTarget[0];
- // BaseMonsterAdon enemy = RoleManager.Instance.GetRole(enemyData.UnitId) as BaseMonsterAdon;
- // //m_targetMonster = enemy.gameObject;
- // //僵直一下
- // //m_clockRoot.localTimeScale = 0.01f;
- // //特效时钟暂停
- // stiffTime += 0.05f;
- // if (stiffTime > 0.3f)
- // {
- // stiffTime = 0.3f;
- // }
- // isStiff = true;
- // Attacked_MsgData data = new Attacked_MsgData();//受击消息数据
- // data.sender = this.gameObject;
- // Vector3 force = enemy.transform.position - transform.position;//推力方向
- // force.Normalize();
- // if (m_CurAttackIdx == 5)
- // {
- // data.attackedEffType = EnumDefine.AttackedEffT.DWN;
- // data.forceDirection = force;//推力方向
- // //发送震屏
- // //SetCameraShake(transform.position, 2, 0.1f, 0.3f);
- // }
- // else if (m_CurAttackIdx == 0)
- // {
- // data.attackedEffType = EnumDefine.AttackedEffT.SLD;
- // data.forceDirection = force;//推力方向
- // //发送震屏
- // //SetCameraShake(transform.position, 2f, 0.1f, 0.3f);
- // }
- // else
- // {
- // data.attackedEffType = EnumDefine.AttackedEffT.SLD;
- // data.forceDirection = force;//推力方向
- // //发送震屏
- // //SetCameraShake(transform.position, 0.8f, 0.1f, 0.2f);
- // }
- // //计算怪剩余血量
- // data.resultHp = enemyData.NowData.HP_Final;
- // data.dmg = enemyData.DiffData.HP_Final;
- // data.isCR = enemyData.NowData.IS_CRT;//是否暴击
- // data.AttackedEff = m_FxManagerAdon.m_AttackedEff[m_CurAttackIdx].gameObject;//被击特效
- // enemy.OnMsg_Attacked(data);
- // if (data.resultHp <= 0)//目标死亡
- // {
- // //释放目标
- // ReleaseTarget();
- // }
- //}
- ///// <summary>
- ///// 言灵技能打击
- ///// </summary>
- ///// <param name="attackIdx"></param>
- ///// <param name="enemy"></param>
- //public void OnMsgYanlingSkill(WarReportInfo report)
- //{
- // //string OwnerId;//发送者id
- // //string TargetId;//目标者id
- // //string SkillId;//技能id
- // //int resultHP;//剩余血量
- // //int dmg;//单次伤害值
- // //bool isCR;//是否暴击
- // //bool isBuff;//是否为buff
- // //int buffType;//buff类型
- // //bool isDOG;//是否闪避
- // WarReportUnit enemyData = report.UnitDataTarget[0];
- // BaseMonsterAdon enemy = RoleManager.Instance.GetRole(enemyData.UnitId) as BaseMonsterAdon;
- // Attacked_MsgData data = new Attacked_MsgData();//受击消息数据
- // data.sender = this.gameObject;
- // Vector3 force = enemy.transform.position - transform.position;//推力方向
- // force.Normalize();
- // //判断技能id
- // if (m_CurAttackIdx == 5)
- // {
- // data.attackedEffType = EnumDefine.AttackedEffT.DWN;
- // data.forceDirection = force;//推力方向
- // //发送震屏
- // //SetCameraShake(transform.position, 2, 0.1f, 0.3f);
- // }
- // else if (m_CurAttackIdx == 0)
- // {
- // data.attackedEffType = EnumDefine.AttackedEffT.SLD;
- // data.forceDirection = force;//推力方向
- // //发送震屏
- // //SetCameraShake(transform.position, 2f, 0.1f, 0.3f);
- // }
- // else
- // {
- // data.attackedEffType = EnumDefine.AttackedEffT.SLD;
- // data.forceDirection = force;//推力方向
- // //发送震屏
- // //SetCameraShake(transform.position, 0.8f, 0.1f, 0.2f);
- // }
- // //计算怪剩余血量
- // data.resultHp = enemyData.NowData.HP_Final;
- // data.dmg = enemyData.DiffData.HP_Final;
- // data.isCR = enemyData.NowData.IS_CRT;//是否暴击
- // data.AttackedEff = m_FxManagerAdon.m_AttackedEff[m_CurAttackIdx].gameObject;//被击特效
- // enemy.OnMsg_Attacked(data);
- // if (data.resultHp <= 0)//目标死亡
- // {
- // //释放目标
- // ReleaseTarget();
- // }
- //}
- ///// <summary>
- ///// Debuff打击发动
- ///// </summary>
- ///// <param name="attackIdx"></param>
- ///// <param name="enemy"></param>
- //public void OnMsgDebuff(WarReportInfo report)
- //{
- // Attacked_MsgData data = new Attacked_MsgData();//受击消息数据
- // data.buffType = report.BuffDataInfo.mo.buffType;
- // data.valueMove = report.BuffDataInfo.mo.moveSpeed;
- // data.dmg = (int)report.BuffDataInfo.mo.damage;
- // data.sender = this.gameObject;
- // ///根据触发的技能id获取触发的言灵挂件
- // ///获取挂件技能的被动技
- // //data.AttackedEff = m_FxManagerAdon.m_AttackedEff[m_CurAttackIdx].gameObject;//被击特效
- // WarReportUnit enemyData = report.UnitDataTarget[0];
- // BaseMonsterAdon enemy = RoleManager.Instance.GetRole(enemyData.UnitId) as BaseMonsterAdon;
- // enemy.OnMsgDebuff(data);
- // if (data.resultHp <= 0)//目标死亡
- // {
- // //释放目标
- // ReleaseTarget();
- // }
- //}
- public Attacked_MsgData m_Attacked_MsgData;
- public BaseCharacterAdon m_Enemy;
- //----------------------新战报方法
- /// <summary>
- /// 新战士普通打击
- /// </summary>
- /// <param name="attackIdx"></param>
- /// <param name="enemy"></param>
- public void OnMsgAttackHitNew(ReportDataAdon report)
- {
- m_Enemy = null;
- if (report.targetUnitType == EBattleUnitType.Hero)
- {
- m_Enemy = RoleManager.Instance.GetRole(report.TargetId) as BaseHero;
- }
- else
- {
- m_Enemy = RoleManager.Instance.GetRole(report.TargetId) as BaseMonsterAdon;
- }
- //BaseMonsterAdon enemy = RoleManager.Instance.GetRole(report.TargetId) as BaseMonsterAdon;
- m_Attacked_MsgData = new Attacked_MsgData();//受击消息数据
- m_Attacked_MsgData.sender = this.gameObject;
- Vector3 force = m_Enemy.transform.position - transform.position;//推力方向
- m_Attacked_MsgData.HitAngle = 180;
- force.Normalize();
- if (m_CurAttackIdx == 5)
- {
- m_Attacked_MsgData.attackedEffType = EnumDefine.AttackedEffT.DWN;
- m_Attacked_MsgData.forceDirection = force;//推力方向
- }
- else if (m_CurAttackIdx == 0)//冲刺攻击
- {
- m_Attacked_MsgData.attackedEffType = EnumDefine.AttackedEffT.SLD;
- m_Attacked_MsgData.forceDirection = force;//推力方向
- }
- else
- {
- m_Attacked_MsgData.attackedEffType = EnumDefine.AttackedEffT.SLD;
- m_Attacked_MsgData.forceDirection = force;//推力方向
- //发送震屏
- //SetCameraShake(transform.position, 0.8f, 0.1f, 0.2f);
- }
- //计算怪剩余血量
- m_Attacked_MsgData.resultHp = report.resultHP;
- m_Attacked_MsgData.dmg = report.dmg;
- m_Attacked_MsgData.isCR = report.isCR;//是否暴击
- m_Attacked_MsgData.weakness = report.weakness;
- m_Attacked_MsgData.AttackedEff = m_FxManagerAdon.m_AttackedEff[m_CurAttackIdx].gameObject;//被击特效
- if (m_Attacked_MsgData.resultHp <= 0)//目标死亡
- {
- //释放目标
- ReleaseTarget();
- }
- OnMsgAttackHitNewExpand(report);
- m_Enemy.OnMsg_Attacked(m_Attacked_MsgData);
- }
- /// <summary>
- /// 新战士普通打击拓展
- /// </summary>
- /// <param name="report"></param>
- public virtual void OnMsgAttackHitNewExpand(ReportDataAdon report)
- {
- }
- float m_stopTime;
- bool m_bStopTime;
- float lastUpdateTime;
- public void HITStop(float stopTime)
- {
- m_stopTime = stopTime;
- m_bStopTime = true;
- lastUpdateTime = Time.realtimeSinceStartup;
- Time.timeScale = 0;
- }
- /// <summary>
- /// 言灵技能打击
- /// </summary>
- /// <param name="attackIdx"></param>
- /// <param name="enemy"></param>
- public void OnMsgYanlingSkillNew(ReportDataAdon report)
- {
- Debug.Log("新言灵技战报触发");
- Role target = RoleManager.Instance.GetRole(report.TargetId);
- Attacked_MsgData data = new Attacked_MsgData();//受击消息数据
- data.sender = this.gameObject;
- Vector3 force = target.transform.position - transform.position;//推力方向
- force.Normalize();
- data.resultHp = report.resultHP;
- data.dmg = report.dmg;
- data.isCR = report.isCR;//是否暴击
- data.weakness = report.weakness;
- //获取言灵挂件被击特效
- //BaseYLPartAdon YLPart = report.YLPart.GetComponent<BaseYLPartAdon>();
- //data.AttackedEff = YLPart.m_FxManagerAdon.m_AttackedEff[m_CurAttackIdx].gameObject;//被击特效
- data.SkillId = report.SkillId;
- //判断技能id
- if (data.SkillId == "6010201" || data.SkillId == "6010301")
- {
- data.attackedEffType = EnumDefine.AttackedEffT.STF;
- data.forceDirection = Vector3.zero;//推力方向
- }
- else if (data.SkillId == "6010302")//星云吸力
- {
- data.attackedEffType = EnumDefine.AttackedEffT.INHALE;
- data.forceDirection = Vector3.zero;//推力方向
- }
- else
- {
- data.attackedEffType = EnumDefine.AttackedEffT.SLD;
- data.forceDirection = force;//推力方向
- }
- if (data.resultHp <= 0)//目标死亡
- {
- //释放目标
- ReleaseTarget();
- }
- if (report.targetUnitType == EBattleUnitType.Hero)
- {
- BaseHero hero = target as BaseHero;
- hero.OnMsg_Curing(data);//治愈
- }
- else
- {
- BaseMonsterAdon enemy = target as BaseMonsterAdon;
- enemy.OnMsg_Attacked(data);
- }
- }
- /// <summary>
- /// Debuff打击发动
- /// </summary>
- /// <param name="attackIdx"></param>
- /// <param name="enemy"></param>
- public void FireMsgDebuffNew(ReportDataAdon report)
- {
- Debug.Log("新Debuff战报触发");
- Attacked_MsgData data = new Attacked_MsgData();//受击消息数据
- data.buffType = report.buffType;
- //data.valueMove = report.BuffDataInfo.mo.moveSpeed;
- data.dmg = report.dmg;
- data.resultHp = report.resultHP;
- data.sender = this.gameObject;
- data.buffResStr = report.buffData.mo.res;
- data.buffPoi = report.buffData.mo.bullet_attack_poi;
- ///根据触发的技能id获取触发的言灵挂件
- ///获取挂件技能的被动光效
- //获取挂件技能的死亡光效
- //BaseYLPartAdon part = GetYLPart(report.SkillId);
- //if(part != null)
- //{
- // data.AttackedEff = part.GetAttackedEff().gameObject;
- // data.DieEff = part.GetDieEff().gameObject;
- //}
- BaseMonsterAdon enemy = RoleManager.Instance.GetRole(report.TargetId) as BaseMonsterAdon;
- if (enemy != null)
- {
- enemy.OnMsgDebuff(data);
- }
- BaseHero play = RoleManager.Instance.GetRole(report.TargetId) as BaseHero;
- if (play != null)
- {
- play.OnMsgDebuff(data);
- }
- if (data.resultHp <= 0)//目标死亡
- {
- //释放目标
- ReleaseTarget();
- //根据技能id获取挂件
- //获取挂件的死亡特效
- //赋值死亡特效
- }
- }
- /// <summary>
- /// 执行debuff
- /// </summary>
- /// <param name="report"></param>
- public void OnMsgDebuff(Attacked_MsgData data)
- {
- int damage;
- //debuff计数
- if (buffnum.ContainsKey(data.buffType))
- {
- int num = buffnum[data.buffType];
- num++;
- buffnum[data.buffType] = num;
- }
- else
- {
- buffnum[data.buffType] = 1;
- }
- //1眩晕 2静止 3护盾 4沉默 5麻痹 6灼烧 7冰冻 8黯
- switch (data.buffType)
- {
- case 1:
- //眩晕,播放眩晕动作,显示眩晕光效,禁用玩家控制
- m_FxManagerAdon.m_DizzEff.gameObject.SetActive(true);
- HeroPlayerController.Instance.SetInputBlocked(true);//禁用控制
- HeroPlayerController.Instance.SetAutoMoveDirection(Vector2.zero);
- isStun = true;
- m_Animator.SetBool(hashStun, true);
- break;
- case 5:
- damage = data.dmg;
- ///执行debuff
- ///麻痹
- SetLocalClockTimeScale(0.1f);
- HpbarManager.Instance.CreateHpTip(this, -damage, false, 1.0f);//血条及数字显示
- break;
- case 6:
- damage = data.dmg;
- ///灼烧
- HpbarManager.Instance.CreateHpTip(this, -damage, false, 1.0f);//血条及数字显示
- break;
- case 7:
- damage = data.dmg;
- ///执行debuff
- ///缓速
- ///冻结效果
- SetLocalClockTimeScale(0.3f);
- //开启冻结网格材质
- m_freezeFlashs.gameObject.SetActive(true);
- //m_freezeFlashPower = 5;
- for (int l = 0; l < m_freezeFlashMaterial.Length; l++)
- {
- m_freezeFlashMaterial[l].SetFloat("_Power", 0.6f);
- }
- HpbarManager.Instance.CreateHpTip(this, -damage, false, 1.0f);//血条及数字显示
- break;
- case 8:
- damage = data.dmg;
- ///中毒
- HpbarManager.Instance.CreateHpTip(this, -damage, false, 1.0f);//血条及数字显示
- break;
- }
- if (data.resultHp <= 0)//死亡
- {
- m_Animator.SetTrigger(hashDie);
- // 英雄死亡
- HeroDie();
- }
- }
- /// <summary>
- /// 关闭debuff
- /// </summary>
- /// <param name="report"></param>
- public void OffMsgDebuff(ReportDataAdon reportData)
- {
- //debuff计数减
- if (buffnum.ContainsKey(reportData.buffType))
- {
- int num = buffnum[reportData.buffType];
- num--;
- buffnum[reportData.buffType] = num;
- if (buffnum[reportData.buffType] > 0) return;
- }
- //1眩晕 2静止 3护盾 4沉默 5麻痹 6灼烧 7冰冻 8黯
- switch (reportData.buffType)
- {
- case 1:
- //眩晕,播放眩晕动作,显示眩晕光效,禁用玩家控制
- m_FxManagerAdon.m_DizzEff.gameObject.SetActive(false);
- HeroPlayerController.Instance.SetInputBlocked(false);//禁用控制
- isStun = false;
- m_Animator.SetBool(hashStun, false);
- break;
- case 5:
- SetLocalClockTimeScale(1);
- break;
- case 7:
- SetLocalClockTimeScale(1);
- for (int l = 0; l < m_freezeFlashMaterial.Length; l++)
- {
- m_freezeFlashMaterial[l].SetFloat("_Power", 2.5f);
- }
- m_freezeFlashs.gameObject.SetActive(false);
- break;
- }
- }
- #endregion
- //#endregion
- /// <summary>
- /// 锁定目标
- /// </summary>
- void LockingTarget()
- {
- if (m_targetMonster)
- {
- BaseMonsterAdon targetM = m_targetMonster.GetComponent<BaseMonsterAdon>();
- if (targetM == null || targetM.m_HitObj == null)
- {
- return;
- }
- //Debug.Log("锁定目标");
- if (m_targetMonster.GetComponent<BaseMonsterAdon>().m_CurState == eState.Die) return;
- //m_CameraManagerAdon.SetLockTarget(targetMonster);//相机添加锁定目标
- GameObject lookTarget = targetM.m_HitObj.gameObject;
- m_PerfectLookAtAdon.m_TargetObject = lookTarget;//甚至看向对目标对象
- isHeadlook = true;
- }
- }
- void ReleaseTarget()
- {
- //m_CameraManagerAdon.ReleaseTarget();//相机释放锁定目标
- m_PerfectLookAtAdon.m_TargetObject = null;
- isHeadlook = false;
- //ObjectManagerAdon.RemoveMonster(targetMonster.GetComponent<BaseCharacterAdon>().Name, targetMonster);
- //m_targetMonster = null;
- }
- /// <summary>
- /// 设置可极限闪避时区
- /// </summary>
- /// <param name="_time">可极限闪避的倒计时</param>
- public void SetExtermeTimeZone(float _time)
- {
- m_ExtermeZoneTimer = _time;
- isExtermeTimeZone = true;
- }
- /// <summary>
- /// 设置极限闪避计时
- /// </summary>
- /// <param name="_time">可极限闪避的倒计时</param>
- public void SetExtermeDodgeTimer(float _time)
- {
- m_ExtermeDodgeTimer = _time;
- isExtermeDodge = true;
- //全部慢放
- m_clockEnemy.localTimeScale = 0.1f;
- m_clockPlayer.localTimeScale = 0.1f;
- m_CameraManagerAdon.PlyeExterme();
- }
- /// <summary>
- /// 释放极限闪避效果
- /// </summary>
- private void FreedExterme()
- {
- m_clockEnemy.localTimeScale = 1;
- m_CameraManagerAdon.StopExterme();
- }
- /// <summary>
- /// 设置无敌免伤
- /// </summary>
- /// <param name="godTime">免伤时间</param>
- public void SetGod(float godTime)
- {
- isGod = true;
- m_GodTime = godTime;
- }
- /// <summary>
- /// 发动言灵技
- /// </summary>
- /// <param name="num"></param>
- public void BattleUseYanlingSkill(string id, X2Battle.EBulletCastPoint point)
- {
- if (isStun == true) return;
- ///播放言灵挂件攻击动作
- if (point == EBulletCastPoint.ECAST_POINT_HEAD)
- {
- m_Head_YL.m_CurUseSkill = id;
- m_Head_YL.OnFire();
- _Head_YL.M_YLType = point;
- m_YLParts[id] = m_Head_YL;
- }
- else if (point == EBulletCastPoint.ECAST_POINT_SHOULDER)
- {
- m_Shoulder_YL.m_CurUseSkill = id;
- m_Shoulder_YL.OnFire();
- m_Shoulder_YL.M_YLType = point;
- m_YLParts[id] = m_Shoulder_YL;
- }
- else if (point == EBulletCastPoint.ECAST_POINT_FOOT)
- {
- m_Foot_YL.m_CurUseSkill = id;
- m_Foot_YL.OnFire();
- m_Foot_YL.M_YLType = point;
- m_YLParts[id] = m_Foot_YL;
- }
- LockingTarget();
- }
- /// <summary>
- /// 取消言灵技
- /// </summary>
- /// <param name="num"></param>
- public void BattleCancelyanlingSkill(string id, X2Battle.EBulletCastPoint point)
- {
- Debug.Log(id);
- ///播放言灵挂件攻击动作
- if (point == EBulletCastPoint.ECAST_POINT_HEAD)
- {
- //m_Head_YL.m_CurUseSkill = "";
- m_Head_YL.OffFire();
- }
- else if (point == EBulletCastPoint.ECAST_POINT_SHOULDER)
- {
- //m_Shoulder_YL.m_CurUseSkill = "";
- m_Shoulder_YL.OffFire();
- //m_Foot_YL.OnFire();//测试
- }
- else if (point == EBulletCastPoint.ECAST_POINT_FOOT)
- {
- //m_Foot_YL.m_CurUseSkill = "";
- m_Foot_YL.OffFire();
- }
- //LockingTarget();
- }
- /// <summary>
- /// 获取言灵部件
- /// </summary>
- /// <param name="skillId"></param>
- /// <returns></returns>
- public BaseYLPartAdon GetYLPart(string skillId)
- {
- if (m_YLParts.Count > 0 && m_YLParts.ContainsKey(skillId))
- {
- return m_YLParts[skillId];
- }
- return null;
- }
- /// <summary>
- /// 播放胜利
- /// </summary>
- public void PlayWinning()
- {
- m_Animator.SetTrigger(hashWin);
- m_CameraManagerAdon.SwitchToCM_Win();
- m_CurState = eState.Win;
- }
- /// <summary>
- /// 是否可伤害
- /// </summary>
- /// <returns></returns>
- public bool IsHurt()
- {
- if (isGod || m_CurState == eState.Die || m_CurState == eState.Win)
- {
- return false;
- }
- return true;
- }
- float attackNum = 1;
- bool bDodge = false;
- //---------------------------FBXEvent------------------------------------
- /// <summary>
- /// 攻击移动开始
- /// </summary>
- public void OnAttackMoveStart(float num)
- {
- attackNum = num;
- //更改为寻路方式冲刺
- if (m_CurState == eState.DashAttack)
- {
- m_navMeshAgent.component.destination = m_targetMonster.transform.position;
- m_navMeshAgent.component.speed = 10;
- }
- else
- {
- //HeroPlayerController.Instance.moveController.SetMoveOff();//关闭控制器移动
- // 闪避
- if (bDodge)
- {
- bDodge = false;
- // 推力
- Vector3 velocity = transform.forward * attackNum;
- m_Rigidbody.velocity = velocity;
- }
- }
- }
- /// <summary>
- /// 显示攻击范围
- /// </summary>
- public void ShowAttackRange()
- {
- // 推力
- if (m_CurState != eState.Skill && m_Rigidbody.velocity.magnitude == 0)
- {
- Vector3 velocity = transform.forward.normalized * attackNum;
- m_Rigidbody.velocity = velocity;
- }
- if (attackRangeTran)
- {
- //attackRangeTran.localScale = Vector3.one * (m_WeaponCol as SphereCollider).radius * 2;
- attackRangeTran.localScale = Vector3.one * 5;
- attackRangeTran.gameObject.SetActive(true);
- if (IsInvoking("HideAttackRange"))
- {
- CancelInvoke("HideAttackRange");
- }
- Invoke("HideAttackRange", 1.0f);
- }
- }
- /// <summary>
- /// 隐藏攻击范围
- /// </summary>
- public void HideAttackRange()
- {
- CancelInvoke("ShowAttackRange");
- if (attackRangeTran)
- {
- attackRangeTran.gameObject.SetActive(false);
- }
- }
- /// <summary>
- /// 击飞移动开始
- /// </summary>
- public void OnDownMoveStart(float num)
- {
- //HeroPlayerController.Instance.moveController.SetMoveOff();//关闭控制器移动
- Vector3 velocity = m_ForceDirection * num;
- m_Rigidbody.velocity = velocity;
- }
- /// <summary>
- /// 击飞移动结束
- /// </summary>
- public void OnDownMoveEnd()
- {
- HeroPlayerController.Instance.moveController.SetMoveOn();//开启控制器移动
- m_Rigidbody.velocity = Vector3.zero;
- }
- public void OnAttackMoveEnd()
- {
- HeroPlayerController.Instance.moveController.SetMoveOn();//开启控制器移动
- m_Rigidbody.velocity = Vector3.zero;
- m_navMeshAgent.component.ResetPath();
- m_navMeshAgent.component.speed = 5;
- }
- /// <summary>
- /// 普通攻击触发
- /// </summary>
- /// <param name="skillId">技能id</param>
- /// <param name="attackId">子连击id</param>
- public virtual void OnAttackOn(string attackId)
- {
- // 检测是否有怪物
- Collider[] colliders = Physics.OverlapSphere(transform.position, 2.5f, 1 << LayerMask.NameToLayer("Enemy"));
- bool showAttackRange = true;
- for (int i = 0; i < colliders.Length; i++)
- {
- // 筛选符合攻击范围的玩家
- Vector3 v3Dir = colliders[i].transform.position - transform.position;
- v3Dir.Normalize();
- float angle = Vector3.Angle(transform.forward, v3Dir);
- if (angle <= 70)
- {
- showAttackRange = false;
- break;
- }
- }
- if (showAttackRange)
- {
- ShowAttackRange();
- }
- List<string> list = new List<string>(attackId.Split(','));
- m_SkillId = int.Parse(list[0]);
- if (list.Count > 1)
- {
- m_CurAttackIdx = int.Parse(list[1]);
- }
- else
- {
- m_CurAttackIdx = 1;
- }
- if (m_SkillId == 1)
- {
- m_WeaponCol.transform.localEulerAngles = Vector3.zero;
- m_WeaponCol.enabled = true;
- }
- else if (m_SkillId == 2)
- {
- m_SkillCol.transform.localEulerAngles = Vector3.zero;
- m_SkillCol.enabled = true;
- }
- }
- /// <summary>
- /// 普通攻击结束
- /// </summary>
- public void OnAttackOff()
- {
- if (m_WeaponCol) m_WeaponCol.enabled = false;//关闭武器碰撞
- if (m_SkillCol) m_SkillCol.enabled = false;//关闭技能碰撞
- }
- /// <summary>
- /// 受击移动开始
- /// </summary>
- public void OnHitMoveStart(float force)
- {
- Vector3 velocity = m_ForceDirection * force;
- m_Rigidbody.velocity = velocity;
- }
- /// <summary>
- /// 受击移动结束
- /// </summary>
- public void OnHitMoveEnd()
- {
- m_Rigidbody.velocity = Vector3.zero;
- }
- /// <summary>
- /// 释放残影
- /// </summary>
- public void OnHeroBlur()
- {
- m_HeroBlur.enabled = false;
- m_HeroBlur.enabled = true;
- }
- /// <summary>
- /// 武器技能触发事件
- /// </summary>
- /// <param name="collision"></param>
- void OnTriggerEnter(Collider collision)
- {
- if (collision.gameObject.layer == LayerMask.NameToLayer("Obstacle"))//层
- {
- Debug.Log("碰撞陷阱");
- m_CapsuleCollider.isTrigger = false;
- }
- }
- #if UNITY_EDITOR
- /// <summary>
- /// 绘制打击配置
- /// </summary>
- private void OnDrawGizmosSelected()
- {
- Vector3 forward = transform.forward;
- UnityEditor.Handles.color = new Color(1.0f, 0.0f, 0.0f, 0.1f);
- Vector3 rotatedForward = Quaternion.Euler(0, -m_AttackAngle * 0.5f, 0) * transform.forward;
- UnityEditor.Handles.DrawSolidArc(transform.position, Vector3.up, rotatedForward, m_AttackAngle, m_AttackSight);
- UnityEditor.Handles.color = new Color(0.0f, 1.0f, 0.0f, 0.1f);
- UnityEditor.Handles.DrawSolidArc(transform.position, transform.up, forward, 360, m_AutoAttackRange);
- }
- #endif
- }
- }
|