123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System;
- using UnityEngine.UI;
- using UnityEngine.AI;
- using Cinemachine;
- using BehaviorDesigner.Runtime;
- using UnityGameFramework.Runtime;
- using Chronos;
- using AdonGameKit;
- using Adon.Game.BO;
- /// <summary>
- /// 角色类
- /// </summary>
- public class Role : RoleBase
- {
- /// <summary>
- /// 动画控制器
- /// </summary>
- public Animator mAnimator = null;
- public Animator mBattleCameraAnim = null;
- public int cameraState = 0;
- public bool cameraLock = false;
- public string playerUID = "";
- /// <summary>
- /// 攻击中
- /// </summary>
- public bool attacking = false;
- /// <summary>
- /// 行为树
- /// </summary>
- public BehaviorTree mBehaviorTree = null;
- /// <summary>
- /// 寻路插件(配合行为树插件使用)
- /// </summary>
- public NavMeshAgent mNavMeshAgent = null;
- /// <summary>
- /// 寻路插件(配合行为树插件使用)
- /// </summary>
- public CharacterController mCharacterController = null;
- /// <summary>
- /// 动作帧事件
- /// </summary>
- public AnimationSkillEvent mSkillEvent = null;
- /// <summary>
- /// 阵营
- /// </summary>
- public E_Camp Camp = E_Camp.None;
- /// <summary>
- /// 移动方向
- /// </summary>
- private Vector3 mMoveDir = Vector3.zero;
- /// <summary>
- /// 蒙皮SkinnedMeshRenderer
- /// </summary>
- private SkinnedMeshRenderer[] mSkinnedMeshRenderers = null;
- /// <summary>
- /// 开火点
- /// </summary>
- public FirePos[] mFirePoss = null;
- /// <summary>
- /// 打击点
- /// </summary>
- public HitPos mHitPos = null;
- /// <summary>
- /// 是否是队长
- /// </summary>
- public bool IsTeamLeader = false;
- /// <summary>
- /// 是否是英雄
- /// </summary>
- public bool IsHero = false;
- /// <summary>
- /// 角色类型
- /// </summary>
- public RoleType roleType;
- /// <summary>
- /// 是否是最后一个点
- /// </summary>
- public bool IsEndPoint = false;
- /// <summary>
- /// 出生区域
- /// </summary>
- public int mLiveArea = -1;
- /// <summary>
- /// 是否无敌
- /// </summary>
- public bool mInvincible = false;
- /// <summary>
- /// 出生坐标
- /// </summary>
- public Vector3 mLivePos;
- public List<int> dropId = null;
- /// <summary>
- /// 活动范围
- /// </summary>
- public float mRadius = 0;
- /// <summary>
- /// 资源名称
- /// </summary>
- public string mResName = "";
- /// <summary>
- /// 能量更新计时器
- /// </summary>
- private float addSPTime = 0;
- private Dictionary<string, GameObject> _buffEffctList;
- public YLBattle.SpawnPoint.BubbleType bubType;
- public string bubStr;
- public bool bubEnable = false;
- public int spawnerID = 0;
- private GameObject mTipArrowObj = null;
- private List<GameObject> mCreateTipArrows = new List<GameObject>();
- /// <summary>
- /// 碰撞
- /// </summary>
- public CapsuleCollider mCollider = null;
- /// <summary>
- ///
- /// 是否是镜像
- /// </summary>
- public bool isMirror = false;
- /// <summary>
- /// 时钟组件
- /// </summary>
- public Timeline time
- {
- get
- {
- return GetComponent<Timeline>();
- }
- }
- /// <summary>
- /// 初始化
- /// </summary>
- /// <param name="date">数据</param>
- /// <param name="camp">阵营</param>
- /// <param name="_isMirror">是否是镜像</param>
- public void Init(YLBattleUnit date, E_Camp camp = E_Camp.Red, bool _isMirror = false)
- {
- base.Init(date);
- selfTransform = transform;
- Camp = camp;
- if (Camp == E_Camp.Red)
- {
- gameObject.layer = LayerMask.NameToLayer("Enemy");
- this.transform.Find("MiniMapFlagEnemy").gameObject.SetActive(false);
- }
- else
- {
- gameObject.layer = LayerMask.NameToLayer("Player");
- this.transform.Find("MiniMapFlagSelf").gameObject.SetActive(false);
- }
- isMirror = _isMirror;
- mBehaviorTree = transform.GetComponent<BehaviorTree>();
- mNavMeshAgent = transform.GetComponent<NavMeshAgent>();
- mCollider = transform.GetComponent<CapsuleCollider>();
- mCharacterController = transform.GetComponent<CharacterController>();
- mSkillEvent = transform.GetComponentInChildren<AnimationSkillEvent>();
- mAnimator = mSkillEvent.transform.GetComponent<Animator>();
- Transform btCA = this.transform.Find("CMStateDrivenCamera");
- if (btCA)
- {
- mBattleCameraAnim = btCA.GetComponent<Animator>();
- }
- mSkinnedMeshRenderers = transform.GetComponentsInChildren<SkinnedMeshRenderer>();
- mFirePoss = transform.GetComponentsInChildren<FirePos>(true);
- mHitPos = transform.GetComponentInChildren<HitPos>(true);
- this._buffEffctList = new Dictionary<string, GameObject>();
- ////// 显示攻击特效
- ////mSkillEvent.mSlowTimeStart = OnSlowTimeStart;
- ////mSkillEvent.mSlowTimeEnd = OnSlowTimeEnd;
- // 英雄
- if (date.mIsHero)
- {
- //GameObject cm = this.gameObject.transform.Find("CMStateDrivenCamera").gameObject;
- //if (cm)
- //{
- // cm.SetActive(false);
- //}
- // 武器换装
- if (this.mData.mHeroVo.equips.ContainsKey("weapon") && this.mData.mHeroVo.equips["weapon"].EquipMo() != null)
- {
- string weaponName = this.mData.mHeroVo.equips["weapon"].EquipMo().res;
- WeaponPos[] weapons = this.transform.GetComponentsInChildren<WeaponPos>(true);
- foreach (var item in weapons)
- {
- if (String.Equals(item.gameObject.name, weaponName, StringComparison.CurrentCultureIgnoreCase))///按刘海的要求,改动一下,刘海要求从typeid适配武器模型,改为从res来适配武器模型。
- // if (item.gameObject.name == weaponName)
- {
- item.gameObject.SetActive(true);
- }
- else
- {
- item.gameObject.SetActive(false);
- }
- }
- }
- }
- }
- public void Update()
- {
- }
- /// <summary>
- /// 设置移动速度
- /// </summary>
- /// <param name="speed"></param>
- public void SetMoveSpeed(float speed)
- {
- if (mBehaviorTree)
- {
- mBehaviorTree.SetVariableValue("moveSpeed", speed);
- }
- }
- public void RefreshYanLing(int pos, HeroGameVo_Yanling yanlingVO)
- {
- if (yanlingVO != null)
- {
- // 骨骼挂载点 挂载言灵装饰预制体
- Transform tsfmHero = transform;
- Transform tsfmPoint;
- YanLingBonePoint[] points = tsfmHero.GetComponentsInChildren<YanLingBonePoint>(true);
- foreach (var item in points)
- {
- if (item._bonePointType != (YanLingBonePoint.BonePoint)pos)
- {
- continue;
- }
- if (yanlingVO.itemuid == 0)
- {
- // item.gameObject.SetActive(false);
- return;
- }
- item.gameObject.SetActive(true);
- int childCount = item.transform.childCount;
- if (childCount > 0)
- {
- var children = new List<GameObject>();
- for (int i = 0; i < childCount; ++i)
- {
- var child = item.transform.GetChild(i).gameObject;
- children.Add(child);
- }
- for (int i = 0; i < childCount; ++i)
- {
- var child = children[i];
- #if UNITY_EDITOR
- UnityEngine.Object.DestroyImmediate(child);
- #else
- UnityEngine. Object.Destroy(child);
- #endif
- }
- }
- string ylRes = yanlingVO.Mo().GetYanlingExt().res;
- ResourceHelper.Instance.LoadAssetBundle(ylRes, (bundle) =>
- {
- if (bundle != null)
- {
- GameObject obj = (GameObject)Instantiate(bundle.LoadAsset(ylRes), item.transform);
- if (obj)
- {
- obj.transform.parent = item.transform;
- obj.transform.localPosition = Vector3.zero;
- }
- }
- });
- }
- }
- }
- public void NetMoveSC(float x, float y, float z)
- {
- this.transform.position.Set(x, y, z);
- }
- public static GameObject FindHideChildGameObject(GameObject parent, string childName)
- {
- if (parent.name == childName)
- {
- return parent;
- }
- if (parent.transform.childCount < 1)
- {
- return null;
- }
- GameObject obj = null;
- for (int i = 0; i < parent.transform.childCount; i++)
- {
- GameObject go = parent.transform.GetChild(i).gameObject;
- obj = FindHideChildGameObject(go, childName);
- if (obj != null)
- {
- break;
- }
- }
- return obj;
- }
- /////// <summary>
- /////// 技能发射事件
- /////// </summary>
- ////private void OnSlowTimeStart()
- ////{
- //// RPGPlayerController.Instance.OnSlowTimeStart(this);
- ////}
- /////// <summary>
- /////// 技能发射事件
- /////// </summary>
- ////private void OnSlowTimeEnd()
- ////{
- //// RPGPlayerController.Instance.OnSlowTimeEnd(this);
- ////}
- /// <summary>
- /// 播放动画
- /// </summary>
- /// <param name="aniName">动作名称</param>
- /// <param name="crossTime">淡入时间</param>
- public void PlayAnimation(string aniName, float crossTime = 0)
- {
- if (mAnimator == null)
- {
- return;
- }
- if (crossTime < 0.01f)
- {
- mAnimator.Play(aniName, 0, 0);
- }
- else
- {
- mAnimator.CrossFade(aniName, crossTime);
- }
- }
- /// <summary>
- /// 某段动画是否播放完成
- /// </summary>
- /// <param name="aniName">动画名称</param>
- /// <param name="playProgress">播放的进度(大于1.0f表示播放完成)</param>
- /// <returns>状态</returns>
- public bool IsPlayAnimationOver(string aniName, float playProgress = 1.0f)
- {
- if (mAnimator == null)
- {
- return true;
- }
- // 获取动画层 0 指Base Layer.
- AnimatorStateInfo stateinfo = mAnimator.GetCurrentAnimatorStateInfo(0);
- if (stateinfo.IsName(aniName))
- {
- if (stateinfo.loop)
- {
- return false;
- }
- else
- {
- if (stateinfo.normalizedTime >= playProgress)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- return true;
- }
- ///// <summary>
- ///// 获取动画时长
- ///// </summary>
- ///// <param name="clip">片段名称</param>
- ///// <returns></returns>
- //public float GetAnimationClipLength(string clip)
- //{
- // if (null == mAnimator || string.IsNullOrEmpty(clip) || null == mAnimator.runtimeAnimatorController)
- // {
- // return 0;
- // }
- // RuntimeAnimatorController ac = mAnimator.runtimeAnimatorController;
- // AnimationClip[] tAnimationClips = ac.animationClips;
- // if (null == tAnimationClips || tAnimationClips.Length <= 0)
- // {
- // return 0;
- // }
- // AnimationClip tAnimationClip;
- // for (int i = 0; i < tAnimationClips.Length; i++)
- // {
- // tAnimationClip = tAnimationClips[i];
- // if (null != tAnimationClip && tAnimationClip.name == clip)
- // {
- // return tAnimationClip.length;
- // }
- // }
- // return 0;
- //}
- /// <summary>
- /// 颜色抖动
- /// </summary>
- public void ShakeColor(bool heroShake = false)
- {
- // 英雄不变色
- if (heroShake == false && mData.mIsHero)
- {
- return;
- }
- BeAttackFlash flash = gameObject.GetComponent<BeAttackFlash>();
- if (flash == null)
- {
- flash = gameObject.AddComponent<BeAttackFlash>();
- }
- flash.Flash();
- }
- /// <summary>
- /// 旋转
- /// </summary>
- /// <param name="dir"></param>
- public void SetRotation(Vector3 dir)
- {
- Quaternion quaDir = Quaternion.LookRotation(dir, Vector3.up);
- Vector3 angle = quaDir.eulerAngles;
- angle.x = 0;
- quaDir.eulerAngles = angle;
- // 方向不同才需转向
- if (quaDir != selfTransform.rotation)
- {
- StartCoroutine(IE_Rotationing(quaDir));
- }
- }
- /// <summary>
- /// 协同旋转
- /// </summary>
- /// <param name="dir">方向</param>
- /// <returns>迭代器</returns>
- private IEnumerator IE_Rotationing(Quaternion quaDir)
- {
- float val = 0;
- while (val < 1.0f)
- {
- val += Time.deltaTime * 5;
- selfTransform.rotation = Quaternion.Lerp(selfTransform.rotation, quaDir, val);
- yield return null;
- }
- }
- private bool bTip = false;
- /// <summary>
- /// 更新血条
- /// </summary>
- /// <param name="val"></param>
- public void UpdateHP(float val, bool isCrit = false)
- {
- //HpbarManager.Instance.CreateHpTip(this, (int)val, isCrit);
- if (!(val > 0 || val < 0))
- {
- return;
- }
- // 队长
- if (IsTeamLeader)
- {
- GameDateManager.Instance.PlayerBehitCount++;
- BattleCanvas.Instance.ShowPlayerHP(mData.HP_Final, mData.MaxHP_Final);
- //HpbarManager.Instance.UpdateHpbar(this, mData.HP_Final / (float)mData.MaxHP_Final, (int)val);
- if (mData.HP_Final / (float)mData.MaxHP_Final < 0.3f)
- {
- ConvertEffect.Instance.PlayEffect(ConvertEffect.convertEffectType.Dying, null);
- }
- else
- {
- ConvertEffect.Instance.PlayEffect(ConvertEffect.convertEffectType.Default, null);
- }
- //BattleCanvas.Instance.ShowPlayerPower(mData.MP_Final, mData.MaxMP_Final);
- }
- // 队员
- else if (mData.mIsHero && IsTeamLeader == false)
- {
- GameDateManager.Instance.PlayerBehitCount++;
- HpbarManager.Instance.UpdateHpbar(this, mData.HP_Final / (float)mData.MaxHP_Final, (int)val);
- }
- // 怪物
- else if (mData.mIsHero == false)
- {
- GameDateManager.Instance.PlayerComboCount++;
- if (BattleCanvas.Instance)
- {
- BattleCanvas.Instance.UpdateComboNumber();
- }
- if (isDie)
- {
- this.mBehaviorTree.SendEvent("DieEvent");
- }
- // 更新已经锁定的目标血条
- if (HeroPlayerController.Instance.m_Hero.TargetRole == this)
- {
- if (isDie)
- {
- BattleCanvas.Instance.HideLockMonsterHP();
- }
- else
- {
- BattleCanvas.Instance.ShowLockMonsterHP(this);
- }
- }
- HpbarManager.Instance.UpdateHpbar(this, mData.HP_Final / (float)mData.MaxHP_Final, (int)val);
- }
- if (val > 0)
- {
- ResourceHelper.Instance.LoadAssetBundle("zhandou_jiaxue_tishi", (AssetBundle bundle) =>
- {
- if (null != bundle)
- {
- GameObject jiaxue = Instantiate(bundle.LoadAsset<GameObject>("zhandou_jiaxue_tishi"));
- jiaxue.transform.parent = this.transform;
- jiaxue.transform.localPosition = Vector3.zero;
- CmptAutoDestory cmpt = jiaxue.AddComponent<CmptAutoDestory>();
- cmpt.LiveTime = 2.0f;
- }
- });
- }
- // 收到伤害颜色渐变
- //if (val < 0)
- //{
- // ShakeColor();
- //}
- }
- /// <summary>
- /// 0 自己 1 父节点
- /// </summary>
- /// <param name="addType"></param>
- /// <param name="effectObj"></param>
- /// <param name="castType"></param>
- /// <param name="skillPos"></param>
- public void AddEffect(int addType, Transform effectObj, X2Battle.EBulletCastPoint castType, BattleDefine.Skill_LaunchPos skillPos = BattleDefine.Skill_LaunchPos.Chest)
- {
- Transform node = null;
- if (castType == X2Battle.EBulletCastPoint.ECAST_POINT_DEFLUAT)
- {
- switch (skillPos)
- {
- case BattleDefine.Skill_LaunchPos.Chest:
- if (mData.mIsHero)
- {
- node = mAnimator.transform.Find("Effect_000/Hit");
- }
- else
- {
- node = mAnimator.transform.Find("Effect_000/Hit");
- }
- break;
- case BattleDefine.Skill_LaunchPos.Head:
- node = mAnimator.transform.Find("Effect_000/Top");
- break;
- case BattleDefine.Skill_LaunchPos.Hand:
- node = mAnimator.transform.Find("Effect_000/Hit");
- break;
- case BattleDefine.Skill_LaunchPos.Foot:
- node = mAnimator.transform.Find("Effect_000/Foot");
- break;
- }
- }
- else
- {
- node = X2Battle.X2BattleManager.Instance.mBulletModel.GetPosBySkillType(this, castType);
- }
- if (node != null)
- {
- effectObj.position = node.position;
- effectObj.rotation = node.rotation;
- if (addType == 0)
- {
- effectObj.SetParent(mAnimator.transform.parent);
- }
- else if (addType == 1)
- {
- effectObj.SetParent(mAnimator.transform.parent.parent);
- }
- }
- }
- public Transform GetPointTrans(BattleDefine.Skill_LaunchPos pointType)
- {
- Transform node = null;
- switch (pointType)
- {
- case BattleDefine.Skill_LaunchPos.Chest:
- if (mData.mIsHero)
- {
- node = mAnimator.transform.Find("Effect_000/Hit");
- }
- else
- {
- node = mAnimator.transform.Find("Effect_000/Hit");
- }
- break;
- case BattleDefine.Skill_LaunchPos.Head:
- node = mAnimator.transform.Find("Effect_000/Top");
- break;
- case BattleDefine.Skill_LaunchPos.Hand:
- node = mAnimator.transform.Find("Effect_000/Hit");
- break;
- case BattleDefine.Skill_LaunchPos.Foot:
- node = mAnimator.transform.Find("Effect_000/Foot");
- break;
- }
- return node;
- }
- public float GetPropertyBase(YLBattle.EBattleProperty perperty)
- {
- return 0;
- }
- public void AdditionBuffEffect(YLBattle.Buff buff)
- {
- return;
- if (this._buffEffctList.ContainsKey(buff.tid.ToString()))
- {
- return;
- }
- string buffPathName = "Battle/buff_" + buff.adapter.Res();
- UnityEngine.Object buffObj = Resources.Load(buffPathName);
- if (buffObj)
- {
- Transform newBuffObj = (GameObject.Instantiate(buffObj) as GameObject).transform;
- newBuffObj.name = buffPathName;
- this._buffEffctList.Add(buff.tid.ToString(), newBuffObj.gameObject);
- sm_buff buffMo = sm_buff.GetMoByID(int.Parse(buff.tid));
- AddEffect(0, newBuffObj, X2Battle.EBulletCastPoint.ECAST_POINT_DEFLUAT, (BattleDefine.Skill_LaunchPos)buffMo.bullet_attack_poi);
- }
- }
- public void RemoveBuffEffect(YLBattle.Buff buff)
- {
- return;
- if (this._buffEffctList.ContainsKey(buff.tid.ToString()))
- {
- GameObject.Destroy(this._buffEffctList[buff.tid.ToString()]);
- this._buffEffctList.Remove(buff.tid.ToString());
- }
- }
- /// <summary>
- /// 执行一次Buff 属性修改
- /// </summary>
- /// <param name="buff"></param>
- /// <param name="property"></param>
- /// <param name="value"></param>
- public void ModifyProperty(YLBattle.Buff buff, YLBattle.EBattleProperty property, int value)
- {
- this.SetPropertyFinal(buff, property, value);
- }
- /// <summary>
- /// 执行一次Buff 属性修改
- /// </summary>
- /// <param name="buff"></param>
- /// <param name="property"></param>
- /// <param name="value"></param>
- public void ModifyProperty(YLBattle.Buff buff, YLBattle.EBattleProperty property, float value)
- {
- this.SetPropertyFinal(buff, property, value);
- }
- public float GetBattleProperty(YLBattle.EBattleProperty property)
- {
- return (float)this.GetPropertyFinal(property);
- }
- public int GetBuffEffectProperty(YLBattle.EBuffEffect property)
- {
- return 0;
- }
- public string ID()
- {
- return this.mData.UID.ToString();
- }
- public float GetProperty(YLBattle.EBattleProperty property)
- {
- float value = 0;
- switch (property)
- {
- case YLBattle.EBattleProperty.YANLI:
- value = mData.YAN;
- break;
- case YLBattle.EBattleProperty.KANGBAOLI:
- value = mData.KBL;
- break;
- case YLBattle.EBattleProperty.ATTACK:
- value = mData.ATK;
- break;
- case YLBattle.EBattleProperty.ATTACKSPEED:
- value = mData.ASP;
- break;
- case YLBattle.EBattleProperty.MOVESPEED:
- value = mData.MSP;
- break;
- case YLBattle.EBattleProperty.COOLTIME:
- value = mData.CLT;
- break;
- case YLBattle.EBattleProperty.ATKRANGE:
- value = mData.ARG;
- break;
- case YLBattle.EBattleProperty.ALARMRANGE:
- value = mData.ORG;
- break;
- case YLBattle.EBattleProperty.CRITICALPROB:
- value = mData.CRT;
- break;
- // 暴击伤害 默认2倍 不做基础属性存储
- case YLBattle.EBattleProperty.CRITICALDAMAGE:
- value = 2;
- break;
- case YLBattle.EBattleProperty.DEFENSE:
- value = mData.DEF;
- break;
- case YLBattle.EBattleProperty.HEIGHT:
- value = 2;
- break;
- case YLBattle.EBattleProperty.HP:
- value = mData.HP;
- break;
- case YLBattle.EBattleProperty.HPMAX:
- value = mData.MaxHP;
- break;
- case YLBattle.EBattleProperty.LEVEL:
- value = mData.LV;
- break;
- case YLBattle.EBattleProperty.MAGICFORCE:
- value = mData.MDF;
- break;
- case YLBattle.EBattleProperty.MAGICSTRENGTH:
- value = mData.ADM;
- break;
- case YLBattle.EBattleProperty.NMAXPOWER:
- value = 10;
- break;
- case YLBattle.EBattleProperty.NPOWER:
- value = 100;
- break;
- case YLBattle.EBattleProperty.POSX:
- value = this.transform.position.x;
- break;
- case YLBattle.EBattleProperty.POSY:
- value = this.transform.position.z;
- break;
- }
- return value;
- }
- public float GetPropertyFinal(YLBattle.EBattleProperty property)
- {
- float value = 0;
- switch (property)
- {
- case YLBattle.EBattleProperty.YANLI:
- value = mData.YAN_Final;
- break;
- case YLBattle.EBattleProperty.KANGBAOLI:
- value = mData.KBL_Final;
- break;
- case YLBattle.EBattleProperty.ATTACK:
- value = mData.ATK_Final;
- break;
- case YLBattle.EBattleProperty.ATTACKSPEED:
- value = mData.ASP_Final;
- break;
- case YLBattle.EBattleProperty.MOVESPEED:
- value = mData.MSP_Final;
- break;
- case YLBattle.EBattleProperty.COOLTIME:
- value = mData.CLT_Final;
- break;
- case YLBattle.EBattleProperty.ATKRANGE:
- value = mData.ARG_Final;
- break;
- case YLBattle.EBattleProperty.ALARMRANGE:
- value = mData.ORG_Final;
- break;
- case YLBattle.EBattleProperty.CRITICALPROB:
- value = mData.CRT_Final;
- break;
- case YLBattle.EBattleProperty.CRITICALDAMAGE:
- value = mData.CRD_Final;
- break;
- case YLBattle.EBattleProperty.DEFENSE:
- value = mData.DEF_Final;
- break;
- case YLBattle.EBattleProperty.HEIGHT:
- value = 2;
- break;
- case YLBattle.EBattleProperty.HP:
- value = mData.HP_Final;
- break;
- case YLBattle.EBattleProperty.HPMAX:
- value = mData.MaxHP_Final;
- break;
- case YLBattle.EBattleProperty.LEVEL:
- value = mData.LV;
- break;
- case YLBattle.EBattleProperty.MAGICFORCE:
- value = mData.MDF_Final;
- break;
- case YLBattle.EBattleProperty.MAGICSTRENGTH:
- value = mData.ADM_Final;
- break;
- case YLBattle.EBattleProperty.NMAXPOWER:
- value = mData.MaxMP_Final;
- break;
- case YLBattle.EBattleProperty.NPOWER:
- value = mData.MP_Final;
- break;
- case YLBattle.EBattleProperty.POSX:
- value = this.transform.position.x;
- break;
- case YLBattle.EBattleProperty.POSY:
- value = this.transform.position.z;
- break;
- }
- return value;
- }
- public void SetPropertyFinal(YLBattle.Buff buff, YLBattle.EBattleProperty property, float value)
- {
- switch (property)
- {
- case YLBattle.EBattleProperty.YANLI:
- mData.YAN_Final = (int)value;
- break;
- case YLBattle.EBattleProperty.KANGBAOLI:
- mData.KBL_Final = value;
- break;
- case YLBattle.EBattleProperty.ATTACK:
- mData.ATK_Final = (int)value;
- break;
- case YLBattle.EBattleProperty.ATTACKSPEED:
- mData.ASP_Final = value;
- // mAnimator.speed = mData.ASP_Final;
- break;
- case YLBattle.EBattleProperty.MOVESPEED:
- mData.MSP_Final = value;
- // SetMoveSpeed(mData.MSP_Final);
- break;
- case YLBattle.EBattleProperty.COOLTIME:
- mData.CLT_Final = value;
- break;
- case YLBattle.EBattleProperty.ATKRANGE:
- mData.ARG_Final = value;
- break;
- case YLBattle.EBattleProperty.ALARMRANGE:
- mData.ORG_Final = value;
- break;
- case YLBattle.EBattleProperty.CRITICALPROB:
- mData.CRT_Final = value;
- break;
- case YLBattle.EBattleProperty.CRITICALDAMAGE:
- mData.CRD_Final = value;
- break;
- case YLBattle.EBattleProperty.DEFENSE:
- mData.DEF_Final = (int)value;
- break;
- case YLBattle.EBattleProperty.HEIGHT:
- value = 2;
- break;
- case YLBattle.EBattleProperty.HP:
- mData.HP_Final = (int)value;
- break;
- case YLBattle.EBattleProperty.HPMAX:
- mData.MaxHP_Final = (int)value;
- break;
- case YLBattle.EBattleProperty.LEVEL:
- break;
- case YLBattle.EBattleProperty.MAGICFORCE:
- mData.MDF_Final = (int)value;
- break;
- case YLBattle.EBattleProperty.MAGICSTRENGTH:
- mData.ADM_Final = (int)value;
- break;
- case YLBattle.EBattleProperty.NMAXPOWER:
- mData.MaxMP_Final = (int)value;
- break;
- case YLBattle.EBattleProperty.NPOWER:
- mData.SetMP((int)value, true);
- break;
- case YLBattle.EBattleProperty.POSX:
- break;
- case YLBattle.EBattleProperty.POSY:
- break;
- }
- }
- public bool GetPropertyBuff(YLBattle.EBuffEffect eff)
- {
- int value = 0;
- switch (eff)
- {
- case YLBattle.EBuffEffect.EBUFF_EFFECT_Shield:
- value = this.mData.BUFF_SHI;
- break;
- case YLBattle.EBuffEffect.EBUFF_EFFECT_Silent:
- value = this.mData.BUFF_SIL;
- break;
- case YLBattle.EBuffEffect.EBUFF_EFFECT_Static:
- value = this.mData.BUFF_STA;
- break;
- case YLBattle.EBuffEffect.EBUFF_EFFECT_Stun:
- value = this.mData.BUFF_STU;
- break;
- case YLBattle.EBuffEffect.EBUFF_EFFECT_BUR:
- value = this.mData.BUFF_BUR;
- break;
- case YLBattle.EBuffEffect.EBUFF_EFFECT_ICE:
- value = this.mData.BUFF_ICE;
- break;
- case YLBattle.EBuffEffect.EBUFF_EFFECT_DIM:
- value = this.mData.BUFF_DIM;
- break;
- }
- return value > 0 ? true : false;
- }
- public void AddPropertyBuff(YLBattle.Buff buff, YLBattle.EBuffEffect eff)
- {
- sm_buff nowbuff = GameConfigData.Ins.GetbuffMo(int.Parse(buff.tid));
- // 创建战报
- Role cRole = buff.caster;
- Role tRole = buff.target;
- WarReport.WarReportInfo info = new WarReport.WarReportInfo();
- WarReport.WarReportUnit ownerUnit = new WarReport.WarReportUnit();
- WarReport.WarReportUnit targetUnit = new WarReport.WarReportUnit();
- ownerUnit.InitData(cRole);
- targetUnit.InitData(tRole);
- info.UnitDataOwner.Add(ownerUnit);
- info.UnitDataTarget.Add(targetUnit);
- switch (eff)
- {
- case YLBattle.EBuffEffect.EBUFF_EFFECT_Shield:
- targetUnit.OriginData.BUFF_SHI = this.mData.BUFF_SHI;
- this.mData.BUFF_SHI += 1;
- targetUnit.NowData.BUFF_SHI = this.mData.BUFF_SHI;
- targetUnit.DiffData.BUFF_SHI = 1;
- break;
- case YLBattle.EBuffEffect.EBUFF_EFFECT_Silent:
- targetUnit.OriginData.BUFF_SIL = this.mData.BUFF_SIL;
- this.mData.BUFF_SIL += 1;
- targetUnit.NowData.BUFF_SIL = this.mData.BUFF_SIL;
- targetUnit.DiffData.BUFF_SIL = 1;
- this.BuffStopAttack();
- break;
- case YLBattle.EBuffEffect.EBUFF_EFFECT_Static:
- targetUnit.OriginData.BUFF_STA = this.mData.BUFF_STA;
- this.mData.BUFF_STA += 1;
- targetUnit.NowData.BUFF_STA = this.mData.BUFF_STA;
- targetUnit.DiffData.BUFF_STA = 1;
- this.BuffStopAnimation();
- this.BuffStopMove();
- this.BuffStopAttack();
- break;
- case YLBattle.EBuffEffect.EBUFF_EFFECT_Stun:
- targetUnit.OriginData.BUFF_SHI = this.mData.BUFF_STU;
- this.mData.BUFF_STU += 1;
- targetUnit.NowData.BUFF_SHI = this.mData.BUFF_SHI;
- targetUnit.DiffData.BUFF_SHI = 1;
- this.BuffStopMove();
- this.BuffStopAttack();
- break;
- }
- //EventComponent eventCmpt = GameEntry.GetComponent<EventComponent>();
- //eventCmpt.FireNow(this, new BattleEventReport(WarReport.EReportType.DeBuffAttach, info));
- }
- public void RemovePropertyBuff(YLBattle.Buff buff, YLBattle.EBuffEffect eff)
- {
- sm_buff nowbuff = GameConfigData.Ins.GetbuffMo(int.Parse(buff.tid));
- // 创建战报
- Role cRole = buff.caster;
- Role tRole = buff.target;
- WarReport.WarReportInfo info = new WarReport.WarReportInfo();
- WarReport.WarReportUnit ownerUnit = new WarReport.WarReportUnit();
- WarReport.WarReportUnit targetUnit = new WarReport.WarReportUnit();
- ownerUnit.InitData(cRole);
- targetUnit.InitData(tRole);
- info.UnitDataOwner.Add(ownerUnit);
- info.UnitDataTarget.Add(targetUnit);
- switch (eff)
- {
- case YLBattle.EBuffEffect.EBUFF_EFFECT_Shield:
- this.mData.BUFF_SHI -= 1;
- targetUnit.NowData.BUFF_SHI = this.mData.BUFF_SHI;
- break;
- case YLBattle.EBuffEffect.EBUFF_EFFECT_Silent:
- this.mData.BUFF_SIL -= 1;
- //if (this.mData.SIL_Final <= 0)
- //{
- // if (this.mData.STU_Final <= 0 && this.mData.STA_Final <= 0)
- // {
- // this.BuffPlayAttack();
- // }
- //}
- targetUnit.NowData.BUFF_SIL = this.mData.BUFF_SIL;
- break;
- case YLBattle.EBuffEffect.EBUFF_EFFECT_Static:
- this.mData.BUFF_STA -= 1;
- //if (this.mData.STA_Final <= 0)
- //{
- // if (this.mData.SIL_Final <= 0 && this.mData.STU_Final <= 0)
- // {
- // this.BuffPlayAnimation();
- // this.BuffPlayAttack();
- // this.BuffPlayMove();
- // }
- // else if (this.mData.SIL_Final <= 0)
- // {
- // this.BuffPlayAnimation();
- // }
- // else if (this.mData.STU_Final <= 0)
- // {
- // this.BuffPlayAnimation();
- // this.BuffPlayMove();
- // }
- //}
- targetUnit.NowData.BUFF_STA = this.mData.BUFF_STA;
- break;
- case YLBattle.EBuffEffect.EBUFF_EFFECT_Stun:
- this.mData.BUFF_STU -= 1;
- //if (this.mData.STU_Final <= 0)
- //{
- // if (this.mData.SIL_Final <= 0 && this.mData.STA_Final <= 0)
- // {
- // this.BuffPlayAttack();
- // this.BuffPlayMove();
- // }
- // else if (this.mData.STA_Final <= 0)
- // {
- // this.BuffPlayMove();
- // }
- //}
- targetUnit.NowData.BUFF_STU = this.mData.BUFF_STU;
- break;
- }
- //EventComponent eventCmpt = GameEntry.GetComponent<EventComponent>();
- //eventCmpt.FireNow(this, new BattleEventReport(WarReport.EReportType.DeBuffCancel, info));
- }
- public int GetLastBuff(string tid, int iid)
- {
- return int.Parse(tid) * 100 + iid;
- }
- public bool IsDead()
- {
- return this.isDie;
- }
- public void BuffStopMove()
- {
- buffCanMove = false;
- }
- public void BuffPlayMove()
- {
- buffCanMove = true;
- }
- public void BuffStopAnimation()
- {
- mAnimator.speed = 0;
- }
- public void BuffPlayAnimation()
- {
- mAnimator.speed = 1;
- }
- public void BuffStopAttack()
- {
- buffCanAttack = false;
- }
- public void BuffPlayAttack()
- {
- buffCanAttack = true;
- }
- public void OnTriggerEnter(Collider other)
- {
- }
- }
|