1122 lines
38 KiB
C#
1122 lines
38 KiB
C#
|
using System;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
using System.Text;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
using Thousandto.Core.Asset;
|
|||
|
using Thousandto.Core.Framework;
|
|||
|
using Thousandto.Code.Global;
|
|||
|
using Thousandto.Core.Base;
|
|||
|
using Thousandto.Code.Center;
|
|||
|
using Thousandto.Cfg.Data;
|
|||
|
using Thousandto.Plugins.Common;
|
|||
|
using Thousandto.Core.Support;
|
|||
|
|
|||
|
namespace Thousandto.Code.Logic
|
|||
|
{
|
|||
|
//玩家基类
|
|||
|
public class Player : Character
|
|||
|
{
|
|||
|
#region//变量信息
|
|||
|
private FSkinModel _roleSkin = null;
|
|||
|
//玩家属性模块
|
|||
|
protected PlayerPropetry _propMoudlePlayer = null;
|
|||
|
//是否变身
|
|||
|
protected bool _isChangeModel = false;
|
|||
|
//变身模型id
|
|||
|
protected int _changeModeID = 0;
|
|||
|
//变身配置ID
|
|||
|
protected int _changeCfgID = 0;
|
|||
|
//变身配置
|
|||
|
protected DeclareChangeModel _changeModelCfg = null;
|
|||
|
//受击闪烁器
|
|||
|
private HitBlinker _blinker = null;
|
|||
|
//外观信息
|
|||
|
protected IPlayerVisualInfo _visualInfo = null;
|
|||
|
//伴侣名字
|
|||
|
protected string _spouseName = string.Empty;
|
|||
|
//切换武器挂节点倒计时
|
|||
|
private float _brightStateTimer = 0f;
|
|||
|
//切换武器挂节点总时间
|
|||
|
private float _brightMaxTime = 38f * Skill.OneFrameTime;
|
|||
|
//武器状态
|
|||
|
protected PlayerBrightWeaponState _brightState = PlayerBrightWeaponState.Receive;
|
|||
|
//收武器的缩放
|
|||
|
protected Vector3 _receiveWeaponScale = Vector3.one;
|
|||
|
//亮武器的缩放
|
|||
|
protected Vector3 _brightWeaponScale = Vector3.one;
|
|||
|
//当前选择的目标Id
|
|||
|
protected UInt64 _curSelectedTargetId = 0;
|
|||
|
//当前选择是自动还是手动选择的
|
|||
|
private bool _curSelectTargetIsAuto = true;
|
|||
|
//上次播放灵力特效时间
|
|||
|
private float _frontPlayLingLiTime = 0f;
|
|||
|
//是否正在传道
|
|||
|
private bool _isChuanDaoing = false;
|
|||
|
//仙娃唯一ID
|
|||
|
private ulong _marryChildUID = 0;
|
|||
|
//总战斗力
|
|||
|
protected long _fightPower = 0;
|
|||
|
//图片头像id
|
|||
|
protected string _texHeadPicID = string.Empty;
|
|||
|
//上一次的Y轴朝向
|
|||
|
private float _frontYForward = 0f;
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//属性信息
|
|||
|
//属性
|
|||
|
public new PlayerPropetry PropMoudle
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_propMoudlePlayer == null)
|
|||
|
{
|
|||
|
_propMoudlePlayer = base.PropMoudle as PlayerPropetry;
|
|||
|
}
|
|||
|
return _propMoudlePlayer;
|
|||
|
}
|
|||
|
}
|
|||
|
//是否在坐骑上
|
|||
|
public bool IsOnMount
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return Skin.GetSkinPart(FSkinPartCode.Mount).IsValid;
|
|||
|
}
|
|||
|
}
|
|||
|
//是否跟随场景高度旋转
|
|||
|
public bool RotBySceneHeight
|
|||
|
{
|
|||
|
get;
|
|||
|
protected set;
|
|||
|
}
|
|||
|
//是否变身
|
|||
|
public bool IsChangeModel
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _isChangeModel;
|
|||
|
}
|
|||
|
}
|
|||
|
//变身配置ID
|
|||
|
public int ChangeCfgID
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _changeCfgID;
|
|||
|
}
|
|||
|
}
|
|||
|
//变身配置
|
|||
|
public DeclareChangeModel ChangeModelCfg
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _changeModelCfg;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//是否可以被选择
|
|||
|
public override bool CanBeSelect
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
//职业
|
|||
|
public int Occ
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return PropMoudle.Occ;
|
|||
|
}
|
|||
|
}
|
|||
|
//职业
|
|||
|
public int IntOcc
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return PropMoudle.Occ;
|
|||
|
}
|
|||
|
}
|
|||
|
//Skin
|
|||
|
public new FSkinModel Skin
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_roleSkin == null)
|
|||
|
{
|
|||
|
_roleSkin = base.Skin as FSkinModel;
|
|||
|
}
|
|||
|
return _roleSkin;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
base.Skin = value;
|
|||
|
_roleSkin = value;
|
|||
|
}
|
|||
|
}
|
|||
|
//帮会ID
|
|||
|
public virtual ulong GuildID
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return PropMoudle.GuildId;
|
|||
|
}
|
|||
|
}
|
|||
|
//帮会职位ID
|
|||
|
public virtual int GuildRank
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return PropMoudle.GuildRank;
|
|||
|
}
|
|||
|
}
|
|||
|
//帮会名字
|
|||
|
public virtual string GuildName
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return PropMoudle.GuildName;
|
|||
|
}
|
|||
|
}
|
|||
|
//当前境界等级
|
|||
|
public int CurStateLevel
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return PropMoudle.StateLevel;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
if (PropMoudle.StateLevel != value)
|
|||
|
{
|
|||
|
PropMoudle.StateLevel = value;
|
|||
|
_visualInfo.StateLevel = value;
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_HUD_UPDATE_HEADINFO, this);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
//当前识海ID
|
|||
|
public int CurShiHaiID
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return PropMoudle.ShiHaiID;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
if (PropMoudle.ShiHaiID != value)
|
|||
|
{
|
|||
|
PropMoudle.ShiHaiID = value;
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_HUD_UPDATE_HEADINFO, this);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
//当前称号
|
|||
|
public virtual DeclareTitle CurPictureTitle
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return PropMoudle.PictureCfg;
|
|||
|
}
|
|||
|
}
|
|||
|
//外观信息
|
|||
|
public IPlayerVisualInfo VisualInfo
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_visualInfo == null)
|
|||
|
{
|
|||
|
_visualInfo = GameCenter.LuaSystem.Adaptor.CreatePlayerVisualInfo(0);
|
|||
|
}
|
|||
|
return _visualInfo;
|
|||
|
}
|
|||
|
}
|
|||
|
//灵体等级
|
|||
|
public int LingTiDegree
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _visualInfo.LingTiDegree;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
if (_visualInfo.LingTiDegree != value)
|
|||
|
{
|
|||
|
_visualInfo.LingTiDegree = value;
|
|||
|
EquipWithType(FSkinPartCode.Body, _visualInfo.GetLingTiBodyModelID(IntOcc));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
//时装衣服
|
|||
|
public int FashionBodyID
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _visualInfo.FashionBodyID;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
if (_visualInfo.FashionBodyID != value)
|
|||
|
{
|
|||
|
_visualInfo.FashionBodyID = value;
|
|||
|
EquipWithType(FSkinPartCode.Body, _visualInfo.GetFashionBodyModelID(IntOcc));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
//时装武器
|
|||
|
public int FashionWeaponID
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _visualInfo.FashionWeaponID;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
if (_visualInfo.FashionWeaponID != value)
|
|||
|
{
|
|||
|
_visualInfo.FashionWeaponID = value;
|
|||
|
EquipWithType(FSkinPartCode.GodWeaponHead, _visualInfo.GetFashionWeaponModelID(IntOcc));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
//时装光环
|
|||
|
public int FashionHaloID
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _visualInfo.FashionHaloID;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
if (_visualInfo.FashionHaloID != value)
|
|||
|
{
|
|||
|
_visualInfo.FashionHaloID = value;
|
|||
|
EquipWithType(FSkinPartCode.XianjiaHuan, _visualInfo.GetFashionHaloModelID());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
//时装法阵
|
|||
|
public int FashionMatrixID
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _visualInfo.FashionMatrixID;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
if (_visualInfo.FashionMatrixID != value)
|
|||
|
{
|
|||
|
_visualInfo.FashionMatrixID = value;
|
|||
|
EquipWithType(FSkinPartCode.XianjiaZhen, _visualInfo.GetFashionMatrixModelID());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//时装头像
|
|||
|
public int FashionHeadId { get; set; }
|
|||
|
//时装头像框
|
|||
|
public int FashionFrameId { get; set; }
|
|||
|
|
|||
|
//翅膀
|
|||
|
public int WingID
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _visualInfo.WingId;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
if (_visualInfo.WingId != value)
|
|||
|
{
|
|||
|
_visualInfo.WingId = value;
|
|||
|
//EquipWithType(FSkinPartCode.Wing, _visualInfo.WingId);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
//伴侣名字
|
|||
|
public string SpouseName
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _spouseName;
|
|||
|
}
|
|||
|
}
|
|||
|
//战斗状态
|
|||
|
public bool AnimFightState
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _brightState != PlayerBrightWeaponState.Receive;
|
|||
|
}
|
|||
|
}
|
|||
|
//是否有目标
|
|||
|
public bool HasTarget
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_curSelectedTargetId != 0)
|
|||
|
{
|
|||
|
var e = GetCurSelectedTarget();
|
|||
|
if (e != null)
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
_curSelectedTargetId = 0;
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
//当前选择的目标ID
|
|||
|
public UInt64 CurSelectedTargetId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _curSelectedTargetId;
|
|||
|
}
|
|||
|
}
|
|||
|
//当前选择是自动还是手动选择的
|
|||
|
public bool CurSelectTargetIsAuto
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _curSelectTargetIsAuto;
|
|||
|
}
|
|||
|
}
|
|||
|
//灵气百分比
|
|||
|
public float LingLiPercent
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (PropMoudle.LingLi <= 0)
|
|||
|
return 0f;
|
|||
|
return (float)PropMoudle.CurLinLi / (float)PropMoudle.LingLi;
|
|||
|
}
|
|||
|
}
|
|||
|
//是否正在传道
|
|||
|
public bool IsChuanDaoing
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _isChuanDaoing;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
if (_isChuanDaoing != value)
|
|||
|
{
|
|||
|
_isChuanDaoing = value;
|
|||
|
if (_isChuanDaoing)
|
|||
|
{
|
|||
|
if (!IsXState(EntityStateID.ChuanDaoSitDown))
|
|||
|
{
|
|||
|
Action_ChuanDaoSitDown();
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (IsXState(EntityStateID.ChuanDaoSitDown))
|
|||
|
{
|
|||
|
Stop_Action();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//飞剑跟随的trans
|
|||
|
public Transform FlySwordHeightTrans { get; protected set; }
|
|||
|
|
|||
|
//转职等级
|
|||
|
public int ChangeJobLevel
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return PropMoudle.ChangeJobLevel;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
PropMoudle.ChangeJobLevel = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//获取战斗力
|
|||
|
public virtual long FightPower
|
|||
|
{
|
|||
|
get { return _fightPower; }
|
|||
|
set
|
|||
|
{
|
|||
|
if (_fightPower != value)
|
|||
|
{
|
|||
|
_fightPower = value;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
//图片头像id
|
|||
|
public string TexHeadPicID
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _texHeadPicID;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_texHeadPicID = value;
|
|||
|
}
|
|||
|
}
|
|||
|
//是否显示图片头像
|
|||
|
public bool IsShowHeadPic
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
//坐骑动作播放速度
|
|||
|
public float MountAnimSpeed
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//装备处理
|
|||
|
/// <summary>
|
|||
|
/// 检查转换装备ID
|
|||
|
/// </summary>
|
|||
|
/// <param name="type"></param>
|
|||
|
/// <param name="equipId"></param>
|
|||
|
/// <returns></returns>
|
|||
|
protected int CheckEquipID(int type, int equipId)
|
|||
|
{
|
|||
|
switch (type)
|
|||
|
{
|
|||
|
case FSkinPartCode.Body:
|
|||
|
if (Scene != null && Scene.Cfg.SpecialBody.Length > 0)
|
|||
|
{
|
|||
|
equipId = DeclareDataUtils.GetValueWithPrefix((int)Occ, Scene.Cfg.SpecialBody, equipId);
|
|||
|
}
|
|||
|
if (IsChangeModel)
|
|||
|
{
|
|||
|
equipId = _changeModeID;
|
|||
|
}
|
|||
|
else if (FashionBodyID <= 0)
|
|||
|
{
|
|||
|
equipId = _visualInfo.GetLingTiBodyModelID(IntOcc);
|
|||
|
}
|
|||
|
break;
|
|||
|
case FSkinPartCode.GodWeaponHead:
|
|||
|
if (Scene != null && Scene.Cfg.SpecialWeaponHead.Length > 0)
|
|||
|
{
|
|||
|
equipId = DeclareDataUtils.GetValueWithPrefix((int)Occ, Scene.Cfg.SpecialWeaponHead, equipId);
|
|||
|
}
|
|||
|
break;
|
|||
|
case FSkinPartCode.GodWeaponBody:
|
|||
|
case FSkinPartCode.GodWeaponVfx:
|
|||
|
equipId = 0;
|
|||
|
break;
|
|||
|
case FSkinPartCode.Wing:
|
|||
|
if (Scene != null && Scene.Cfg.SpecialWing.Length > 0)
|
|||
|
{
|
|||
|
equipId = DeclareDataUtils.GetValueWithPrefix((int)Occ, Scene.Cfg.SpecialWing, equipId);
|
|||
|
}
|
|||
|
else if (!GameCenter.GameSetting.IsEnabled(GameSettingKeyCode.EnableShowWing) && !IsLocalPlayer())
|
|||
|
{
|
|||
|
Skin.HideSkinPart(FSkinPartCode.Wing);
|
|||
|
}
|
|||
|
break;
|
|||
|
case FSkinPartCode.XianjiaHuan:
|
|||
|
break;
|
|||
|
case FSkinPartCode.XianjiaZhen:
|
|||
|
break;
|
|||
|
}
|
|||
|
return equipId;
|
|||
|
}
|
|||
|
|
|||
|
//切换装备
|
|||
|
public virtual void EquipWithType(int type, int equipId, bool bClearVfx = true)
|
|||
|
{
|
|||
|
equipId = CheckEquipID(type, equipId);
|
|||
|
Skin.SetSkinPartFromCfgID(type, equipId, null, true, null, bClearVfx);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//初始化处理
|
|||
|
protected override bool OnSetupFSMBefore()
|
|||
|
{
|
|||
|
ResetDirection();
|
|||
|
return base.OnSetupFSMBefore();
|
|||
|
}
|
|||
|
//初始化FSM状态
|
|||
|
protected override bool OnSetupFSM()
|
|||
|
{
|
|||
|
Fsm = new EntityFSM(this);
|
|||
|
Fsm.AddState(new PlayerFSM.Idle());
|
|||
|
Fsm.AddState(new PlayerFSM.PathMove());
|
|||
|
Fsm.AddState(new PlayerFSM.DirMove());
|
|||
|
Fsm.AddState(new Dead());
|
|||
|
Fsm.AddState(new Collect());
|
|||
|
Fsm.AddState(new Jump());
|
|||
|
Fsm.AddState(new BeHitBack());
|
|||
|
Fsm.AddState(new BeHitFly());
|
|||
|
Fsm.AddState(new BeHitGrab());
|
|||
|
Fsm.AddState(new FlyUp());
|
|||
|
Fsm.AddState(new FlyDown());
|
|||
|
Fsm.AddState(new FlyTeleport());
|
|||
|
Fsm.AddState(new RollDodge());
|
|||
|
Fsm.AddState(new CrossMapTran());
|
|||
|
Fsm.AddState(new PlayerFSM.SameRide());
|
|||
|
Fsm.AddState(new TaskBarAround());
|
|||
|
Fsm.AddState(new SkillMove());
|
|||
|
Fsm.AddState(new PlayerFSM.SitDown());
|
|||
|
Fsm.AddState(new PlayerFSM.EnterMap());
|
|||
|
Fsm.AddState(new PlayerFSM.ChuanDaoSitDown());
|
|||
|
Fsm.SetDefaultStateId(EntityStateID.Idle);
|
|||
|
Fsm.Init(this);
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
protected override bool OnInitializeAfter(EntityInitInfo baseInfo)
|
|||
|
{
|
|||
|
MountAnimSpeed = 1f;
|
|||
|
var initInfo = baseInfo as PlayerInitInfo;
|
|||
|
_visualInfo = initInfo.VisualInfo;
|
|||
|
_blinker = new HitBlinker();
|
|||
|
return base.OnInitializeAfter(baseInfo);
|
|||
|
}
|
|||
|
|
|||
|
protected override void OnUninitializeBefore()
|
|||
|
{
|
|||
|
//释放飞剑
|
|||
|
UnLoadFlySword();
|
|||
|
//释放仙娃
|
|||
|
UnLoadMarryChild();
|
|||
|
base.OnUninitializeBefore();
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//心跳处理 Update
|
|||
|
protected override void OnUpdate(float elapsedTime)
|
|||
|
{
|
|||
|
_blinker.Update(elapsedTime);
|
|||
|
UpdateBrightState(elapsedTime);
|
|||
|
UpdateTarget();
|
|||
|
if (Skin != null && (Skin.GetSkinPartCfgID(FSkinPartCode.XianjiaZhen) > 0 || Skin.GetSkinPartCfgID(FSkinPartCode.XianjiaHuan) > 0))
|
|||
|
{
|
|||
|
if (Skin.GetSkinPartCfgID(FSkinPartCode.Mount) > 0)
|
|||
|
{
|
|||
|
Skin.HideSkinPart(FSkinPartCode.XianjiaZhen);
|
|||
|
Skin.HideSkinPart(FSkinPartCode.XianjiaHuan);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Skin.ShowSkinPart(FSkinPartCode.XianjiaZhen);
|
|||
|
Skin.ShowSkinPart(FSkinPartCode.XianjiaHuan);
|
|||
|
}
|
|||
|
}
|
|||
|
base.OnUpdate(elapsedTime);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region //重写Entity的方法
|
|||
|
//更新实体的旋转角
|
|||
|
protected override void OnUpdateRotation(float elapsedTime)
|
|||
|
{
|
|||
|
if (Skin == null || Skin.RootGameObject == null)
|
|||
|
return;
|
|||
|
|
|||
|
Vector3 now = Skin.GetForward();
|
|||
|
Vector3 prev = now;
|
|||
|
prev.y = _frontYForward;
|
|||
|
prev = prev.normalized;
|
|||
|
|
|||
|
if (IsOnMount && RotBySceneHeight)
|
|||
|
{
|
|||
|
float checkRadious = 2f;
|
|||
|
var mountPart = Skin.GetSkinPart(FSkinPartCode.Mount);
|
|||
|
if (mountPart != null)
|
|||
|
{
|
|||
|
var radious = mountPart.GetRadious();
|
|||
|
if (radious > 0f)
|
|||
|
{
|
|||
|
checkRadious = radious;
|
|||
|
}
|
|||
|
}
|
|||
|
Vector3 pos1 = Position + now * checkRadious;
|
|||
|
pos1 = GetTerrainPosition(pos1.x, pos1.z);
|
|||
|
Vector3 pos2 = Position - now * checkRadious;
|
|||
|
pos2 = GetTerrainPosition(pos2.x, pos2.z);
|
|||
|
|
|||
|
if (!IsBlocked(pos1) && !IsBlocked(pos2))
|
|||
|
{
|
|||
|
now = (pos1 - pos2).normalized;
|
|||
|
SetPosition(Vector3.Lerp(pos1, pos2, 0.5f));
|
|||
|
Skin.SetForward(Vector3.Slerp(prev, now, 0.5f / checkRadious));
|
|||
|
}
|
|||
|
else if (now != prev || Skin.GetForward().y != 0)
|
|||
|
{
|
|||
|
Skin.SetForward(Vector3.Slerp(prev, now, 0.5f / checkRadious));
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (now != prev || now.y != 0)
|
|||
|
{
|
|||
|
now.y = 0f;
|
|||
|
Skin.SetForward(now);
|
|||
|
}
|
|||
|
}
|
|||
|
_frontYForward = Skin.GetForward().y;
|
|||
|
}
|
|||
|
|
|||
|
public override void OnBeAttackedResponse(Character attacker, HitEffectInfo hitInfo, SkillHitType hitType, MSG_Fight.HitEffectInfo msgInfo)
|
|||
|
{
|
|||
|
if (!GameCenter.GameSetting.IsEnabled(GameSettingKeyCode.TPSkillBlink))
|
|||
|
{
|
|||
|
var setValue = GameCenter.GameSetting.GetSetting(GameSettingKeyCode.HitBlink);
|
|||
|
if (setValue == 2 || (setValue == 1 && attacker.IsLocalPlayer()))
|
|||
|
{
|
|||
|
//开始闪烁
|
|||
|
_blinker.Start(hitInfo.BlinkTime, hitInfo.BlinkPower, hitInfo.BlinkColor, hitInfo.BlinkCurve, Skin);
|
|||
|
}
|
|||
|
}
|
|||
|
if (attacker is Player && PropMoudle.CurLinLi > 0 && (Time.realtimeSinceStartup - _frontPlayLingLiTime) > 0.2f)
|
|||
|
{
|
|||
|
_frontPlayLingLiTime = Time.realtimeSinceStartup;
|
|||
|
var dir = Scene.SceneCamera.transform.position - Position;
|
|||
|
dir.y = 0;
|
|||
|
var vfx = PlayVFX(ModelTypeCode.BodyVFX, 101, SlotUtils.GetSlotName(Slot.Origin), FSkinPartCode.Body, true, 1f, true, false, null, true);
|
|||
|
if (vfx != null)
|
|||
|
{
|
|||
|
vfx.SetForward(dir);
|
|||
|
}
|
|||
|
}
|
|||
|
base.OnBeAttackedResponse(attacker, hitInfo, hitType, msgInfo);
|
|||
|
}
|
|||
|
|
|||
|
//播放闪烁效果
|
|||
|
public void PlayBlinkEffect(float time, float power, Color color, AnimationCurve curve)
|
|||
|
{
|
|||
|
if (curve == null)
|
|||
|
{
|
|||
|
curve = new AnimationCurve();
|
|||
|
curve.AddKey(0, 0);
|
|||
|
curve.AddKey(1, 1);
|
|||
|
}
|
|||
|
_blinker.Start(time, power, color, curve, Skin);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 战斗状态改变
|
|||
|
public void ChangeBrightState(PlayerBrightWeaponState state)
|
|||
|
{
|
|||
|
if (_brightState == state)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
_brightState = state;
|
|||
|
switch (_brightState)
|
|||
|
{
|
|||
|
case PlayerBrightWeaponState.Receive:
|
|||
|
{
|
|||
|
//直接切换挂接点
|
|||
|
var body = Skin.GetSkinPart(FSkinPartCode.Body) as FGameObjectBody;
|
|||
|
if (body != null)
|
|||
|
{
|
|||
|
body.BrightWeapon = false;
|
|||
|
if (IsShowModel)
|
|||
|
{
|
|||
|
//SlotUtils.SetSlotLocalScale(body.RealTransform, SlotNameDefine.LeftWeapon, _receiveWeaponScale);
|
|||
|
SlotUtils.SetSlotLocalScale(body.RealTransform, SlotNameDefine.RightWeapon, _receiveWeaponScale);
|
|||
|
//SlotUtils.SetSlotLocalScale(body.RealTransform, SlotNameDefine.LeftWeaponReceive, _receiveWeaponScale);
|
|||
|
SlotUtils.SetSlotLocalScale(body.RealTransform, SlotNameDefine.RightWeaponReceive, _receiveWeaponScale);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
case PlayerBrightWeaponState.Receiveing:
|
|||
|
{
|
|||
|
//播放收剑剑动作
|
|||
|
if (IsXState(EntityStateID.Idle))
|
|||
|
{
|
|||
|
//没有移动,播放普通收剑动作
|
|||
|
PlayAnim(AnimClipNameDefine.SwordInIdle, AnimationPartType.AllBody, WrapMode.Once);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//正在移动,播放上半身动作
|
|||
|
PlayAnim(AnimClipNameDefine.SwordInRun, AnimationPartType.UpBody, WrapMode.Once);
|
|||
|
}
|
|||
|
_brightStateTimer = _brightMaxTime;
|
|||
|
//直接切换挂接点
|
|||
|
var body = Skin.GetSkinPart(FSkinPartCode.Body) as FGameObjectBody;
|
|||
|
if (body != null)
|
|||
|
{
|
|||
|
if (IsShowModel)
|
|||
|
{
|
|||
|
//SlotUtils.SetSlotLocalScale(body.RealTransform, SlotNameDefine.LeftWeapon, _brightWeaponScale);
|
|||
|
SlotUtils.SetSlotLocalScale(body.RealTransform, SlotNameDefine.RightWeapon, _brightWeaponScale);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
case PlayerBrightWeaponState.Bright:
|
|||
|
{
|
|||
|
_brightStateTimer = _brightMaxTime;
|
|||
|
//直接切换挂接点
|
|||
|
var body = Skin.GetSkinPart(FSkinPartCode.Body) as FGameObjectBody;
|
|||
|
if (body != null)
|
|||
|
{
|
|||
|
body.BrightWeapon = true;
|
|||
|
}
|
|||
|
|
|||
|
if (!this.skillManager.IsSkillUseing() && (IsXState(EntityStateID.Idle) || IsXState(EntityStateID.DirMove) || IsXState(EntityStateID.PathMove)))
|
|||
|
{
|
|||
|
//播放亮剑动作
|
|||
|
if (IsXState(EntityStateID.Idle))
|
|||
|
{
|
|||
|
//没有移动,播放普通亮剑动作
|
|||
|
PlayAnim(AnimClipNameDefine.SwordOutIdle, AnimationPartType.AllBody, WrapMode.Once);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//正在移动,播放上半身动作
|
|||
|
PlayAnim(AnimClipNameDefine.SwordOutRun, AnimationPartType.UpBody, WrapMode.Once);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (body != null && IsShowModel)
|
|||
|
{
|
|||
|
//SlotUtils.SetSlotLocalScale(body.RealTransform, SlotNameDefine.LeftWeapon, _brightWeaponScale);
|
|||
|
SlotUtils.SetSlotLocalScale(body.RealTransform, SlotNameDefine.RightWeapon, _brightWeaponScale);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
public void UpdateBrightState(float dt)
|
|||
|
{
|
|||
|
if (Skin == null || _skillManager == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
switch (_brightState)
|
|||
|
{
|
|||
|
case PlayerBrightWeaponState.Receive:
|
|||
|
{
|
|||
|
//容错处理
|
|||
|
var body = Skin.GetSkinPart(FSkinPartCode.Body) as FGameObjectBody;
|
|||
|
if (body != null && body.BrightWeapon)
|
|||
|
{
|
|||
|
body.BrightWeapon = false;
|
|||
|
}
|
|||
|
|
|||
|
if (FightState || _skillManager.IsSkillUseing())
|
|||
|
{
|
|||
|
//进入到战斗状态,直接切换到亮剑
|
|||
|
ChangeBrightState(PlayerBrightWeaponState.Bright);
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
case PlayerBrightWeaponState.Receiveing:
|
|||
|
{
|
|||
|
if (!(FightState || _skillManager.IsSkillUseing()))
|
|||
|
{
|
|||
|
if (!skillManager.IsSkillUseing())
|
|||
|
{
|
|||
|
_brightStateTimer -= dt;
|
|||
|
|
|||
|
var body = Skin.GetSkinPart(FSkinPartCode.Body) as FGameObjectBody;
|
|||
|
if (body != null)
|
|||
|
{
|
|||
|
if (IsShowModel)
|
|||
|
{
|
|||
|
var sacle = Vector3.Lerp(_receiveWeaponScale, _brightWeaponScale, _brightStateTimer / _brightMaxTime);
|
|||
|
//SlotUtils.SetSlotLocalScale(body.RealTransform, SlotNameDefine.LeftWeapon, sacle);
|
|||
|
SlotUtils.SetSlotLocalScale(body.RealTransform, SlotNameDefine.RightWeapon, sacle);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (_brightStateTimer <= 0f || !(IsXState(EntityStateID.Idle) || IsXState(EntityStateID.PathMove) || IsXState(EntityStateID.DirMove)))
|
|||
|
{
|
|||
|
//切换到收剑状态
|
|||
|
ChangeBrightState(PlayerBrightWeaponState.Receive);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ChangeBrightState(PlayerBrightWeaponState.Bright);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//收剑过程中进入战斗状态,直接切换到亮剑状态
|
|||
|
StopAnim();
|
|||
|
ChangeBrightState(PlayerBrightWeaponState.Bright);
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
case PlayerBrightWeaponState.Bright:
|
|||
|
{
|
|||
|
if (!(FightState || _skillManager.IsSkillUseing()))
|
|||
|
{
|
|||
|
if (IsXState(EntityStateID.Idle) || IsXState(EntityStateID.DirMove) || IsXState(EntityStateID.PathMove))
|
|||
|
{
|
|||
|
if (!skillManager.IsSkillUseing())
|
|||
|
{
|
|||
|
//没有使用技能,切换到收剑过程状态
|
|||
|
ChangeBrightState(PlayerBrightWeaponState.Receiveing);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//正在使用技能,等待技能释放完成
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//状态不允许播放动作,直接切换到收剑
|
|||
|
ChangeBrightState(PlayerBrightWeaponState.Receive);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (!_skillManager.IsSkillUseing() && _brightStateTimer > 0f)
|
|||
|
{
|
|||
|
_brightStateTimer -= dt;
|
|||
|
var body = Skin.GetSkinPart(FSkinPartCode.Body) as FGameObjectBody;
|
|||
|
if (body != null && IsShowModel)
|
|||
|
{
|
|||
|
var sacle = Vector3.Lerp(_brightWeaponScale, _receiveWeaponScale, _brightStateTimer / _brightMaxTime);
|
|||
|
//SlotUtils.SetSlotLocalScale(body.RealTransform, SlotNameDefine.LeftWeapon, sacle);
|
|||
|
SlotUtils.SetSlotLocalScale(body.RealTransform, SlotNameDefine.RightWeapon, sacle);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//容错处理
|
|||
|
var body = Skin.GetSkinPart(FSkinPartCode.Body) as FGameObjectBody;
|
|||
|
if (body != null && !body.BrightWeapon)
|
|||
|
{
|
|||
|
body.BrightWeapon = true;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
public override void OnFightStateChangated(bool state)
|
|||
|
{
|
|||
|
base.OnFightStateChangated(state);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//名字颜色
|
|||
|
public void UpdateNameColor()
|
|||
|
{
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_HUD_UPDATEHUDNAMECOLOR, ID);
|
|||
|
var petList = GameCenter.GameSceneSystem.FindEntityAll<Pet>();
|
|||
|
for (int i = 0; i < petList.Count; ++i)
|
|||
|
{
|
|||
|
if (petList[i].PropMoudle.MasterID == ID)
|
|||
|
{
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_HUD_UPDATEHUDNAMECOLOR, petList[i].ID);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//变身效果处理
|
|||
|
//开始变身
|
|||
|
public void StartChangeModel(DeclareChangeModel cfg)
|
|||
|
{
|
|||
|
if (_isChangeModel)
|
|||
|
return;
|
|||
|
if (cfg == null)
|
|||
|
return;
|
|||
|
|
|||
|
_changeModelCfg = cfg;
|
|||
|
_changeModeID = cfg.ModelId;
|
|||
|
_changeCfgID = cfg.Id;
|
|||
|
_isChangeModel = true;
|
|||
|
Skin.ShowSkinPart(FSkinPartCode.Body, false);
|
|||
|
EquipWithType(FSkinPartCode.Body, _changeModeID, false);
|
|||
|
|
|||
|
Skin.HideSkinPart(FSkinPartCode.Mount);
|
|||
|
Skin.HideSkinPart(FSkinPartCode.GodWeaponHead);
|
|||
|
Skin.HideSkinPart(FSkinPartCode.GodWeaponBody);
|
|||
|
Skin.HideSkinPart(FSkinPartCode.GodWeaponVfx);
|
|||
|
Skin.HideSkinPart(FSkinPartCode.Wing);
|
|||
|
Skin.HideSkinPart(FSkinPartCode.XianjiaHuan);
|
|||
|
Skin.HideSkinPart(FSkinPartCode.XianjiaZhen);
|
|||
|
//变身时取消飞剑
|
|||
|
UnLoadFlySword();
|
|||
|
//变身时去掉仙娃
|
|||
|
UnLoadMarryChild();
|
|||
|
}
|
|||
|
//结束 变身
|
|||
|
public void StopChangeModel()
|
|||
|
{
|
|||
|
if (!_isChangeModel)
|
|||
|
return;
|
|||
|
|
|||
|
_isChangeModel = false;
|
|||
|
_changeModeID = 0;
|
|||
|
_changeCfgID = 0;
|
|||
|
_changeModelCfg = null;
|
|||
|
Skin.ShowSkinPart(FSkinPartCode.Mount);
|
|||
|
Skin.ShowSkinPart(FSkinPartCode.Body);
|
|||
|
Skin.ShowSkinPart(FSkinPartCode.GodWeaponHead);
|
|||
|
Skin.ShowSkinPart(FSkinPartCode.GodWeaponBody);
|
|||
|
Skin.ShowSkinPart(FSkinPartCode.GodWeaponVfx);
|
|||
|
Skin.ShowSkinPart(FSkinPartCode.Wing);
|
|||
|
Skin.ShowSkinPart(FSkinPartCode.XianjiaHuan);
|
|||
|
Skin.ShowSkinPart(FSkinPartCode.XianjiaZhen);
|
|||
|
EquipWithType(FSkinPartCode.Body, VisualInfo.GetBodyModelID(IntOcc), false);
|
|||
|
//重新载入飞剑
|
|||
|
LoadFlySword();
|
|||
|
//重新召唤仙娃
|
|||
|
LoadMarryChild();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//选择目标处理
|
|||
|
//选择目标
|
|||
|
protected virtual void OnSelectTarget(Entity target)
|
|||
|
{
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_PLAYER_TARGET_CHANGED, target);
|
|||
|
if (target != null)
|
|||
|
target.Select();
|
|||
|
}
|
|||
|
|
|||
|
//取消选择目标
|
|||
|
protected virtual void OnDeselectTarget(Entity target)
|
|||
|
{
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_PLAYER_TARGET_CHANGED, null);
|
|||
|
if (target != null)
|
|||
|
target.Deselect();
|
|||
|
}
|
|||
|
|
|||
|
//获取当前目标
|
|||
|
public Character GetCurSelectedTarget()
|
|||
|
{
|
|||
|
if (_curSelectedTargetId == 0 || Scene == null)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
Character target = Scene.Find<Character>(_curSelectedTargetId);
|
|||
|
return target;
|
|||
|
}
|
|||
|
|
|||
|
//设置当前目标,
|
|||
|
//当id==0是表示取消选择目标,id!=0但是没有找到目标的情况下不做任何操作
|
|||
|
public bool SetCurSelectedTargetId(UInt64 id, bool isAuto = true)
|
|||
|
{
|
|||
|
_curSelectTargetIsAuto = isAuto;
|
|||
|
if (id == 0)
|
|||
|
{
|
|||
|
if (_curSelectedTargetId != 0 && Scene != null)
|
|||
|
{
|
|||
|
Character e = Scene.Find<Character>(_curSelectedTargetId);
|
|||
|
_curSelectedTargetId = 0;
|
|||
|
OnDeselectTarget(e);
|
|||
|
}
|
|||
|
_curSelectedTargetId = 0;
|
|||
|
return true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Character newTarget = Scene.Find<Character>(id);
|
|||
|
|
|||
|
//重复选择
|
|||
|
if (id == _curSelectedTargetId || Scene == null)
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
if (newTarget != null && !newTarget.IsDead() && newTarget.CanBeSelect)
|
|||
|
{
|
|||
|
if (_curSelectedTargetId != 0)
|
|||
|
{
|
|||
|
Character oldTarget = Scene.Find<Character>(_curSelectedTargetId);
|
|||
|
_curSelectedTargetId = 0;
|
|||
|
OnDeselectTarget(oldTarget);
|
|||
|
}
|
|||
|
_curSelectedTargetId = id;
|
|||
|
OnSelectTarget(newTarget);
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_PLAYER_TARGET_SELECT, newTarget);
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
public void UpdateTarget()
|
|||
|
{
|
|||
|
//如果当前有选择的目标ID但是查找不到目标对象,丢失目标
|
|||
|
if (_curSelectedTargetId > 0)
|
|||
|
{
|
|||
|
Character target = GetCurSelectedTarget();
|
|||
|
if (target == null || target.IsDead() || !target.CanBeSelect)
|
|||
|
{
|
|||
|
SetCurSelectedTargetId(0);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//飞剑处理
|
|||
|
public void LoadFlySword(bool playShow = false)
|
|||
|
{
|
|||
|
if (!IsChangeModel && PropMoudle.FlySwordCfgID > 0 && PropMoudle.FlySwordUID != ID)
|
|||
|
{
|
|||
|
GameCenter.GameSceneSystem.RefreshFlySword(new FlySwordInitInfo(PropMoudle.FlySwordCfgID, PropMoudle.FlySwordUID, this, PropMoudle.FlySwordSkillId, playShow));
|
|||
|
}
|
|||
|
}
|
|||
|
//释放法宝
|
|||
|
public void UnLoadFlySword()
|
|||
|
{
|
|||
|
if (PropMoudle.FlySwordUID > 0 && PropMoudle.FlySwordUID != ID)
|
|||
|
{
|
|||
|
GameCenter.GameSceneSystem.RemoveRemoteEntity(PropMoudle.FlySwordUID);
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//仙娃处理
|
|||
|
//载入仙娃
|
|||
|
public void LoadMarryChild()
|
|||
|
{
|
|||
|
UnLoadMarryChild();
|
|||
|
var cfg = DeclareMarryChild.Get(PropMoudle.MarryChildID);
|
|||
|
if (cfg != null)
|
|||
|
{
|
|||
|
var initInfo = new MarryChildInitInfo(cfg, this, PropMoudle.MarryChildName);
|
|||
|
_marryChildUID = initInfo.ID;
|
|||
|
GameCenter.GameSceneSystem.RefreshMarryChild(initInfo);
|
|||
|
}
|
|||
|
}
|
|||
|
//释放仙娃
|
|||
|
public void UnLoadMarryChild()
|
|||
|
{
|
|||
|
if (_marryChildUID > 0)
|
|||
|
{
|
|||
|
GameCenter.GameSceneSystem.RemoveRemoteEntity(_marryChildUID);
|
|||
|
_marryChildUID = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//婚姻处理
|
|||
|
public void SetSpouseName(string name)
|
|||
|
{
|
|||
|
_spouseName = name;
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_HUD_UPDATE_HEADINFO, this);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|