383 lines
13 KiB
C#
383 lines
13 KiB
C#
|
using Thousandto.Code.Center;
|
|||
|
using Thousandto.Core.Asset;
|
|||
|
|
|||
|
using Thousandto.Core.RootSystem;
|
|||
|
using Thousandto.Core.Base;
|
|||
|
using Thousandto.Plugins.Common;
|
|||
|
using Thousandto.Plugins.Common.UniScene;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
using System.Text;
|
|||
|
using UnityEngine;
|
|||
|
using Thousandto.Cfg.Data;
|
|||
|
using Thousandto.Core.PostEffect;
|
|||
|
using Thousandto.Code.Global;
|
|||
|
using Thousandto.Core.Support;
|
|||
|
|
|||
|
namespace Thousandto.Code.Logic
|
|||
|
{
|
|||
|
//主角外的其他玩家
|
|||
|
public class RemotePlayer : Player
|
|||
|
{
|
|||
|
//战斗状态timer
|
|||
|
private float _fightStateTimer = 0;
|
|||
|
//是否显示血条
|
|||
|
private bool _isShowLife = false;
|
|||
|
//是否被选择
|
|||
|
private bool _isBeSelect = false;
|
|||
|
//玩家属性模块
|
|||
|
private RemotePlayerProperty _propMoudleEx = null;
|
|||
|
//载入法宝倒计时帧数
|
|||
|
private int _loadFaBaoFrame = -1;
|
|||
|
|
|||
|
public new RemotePlayerProperty PropMoudle
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_propMoudleEx == null)
|
|||
|
{
|
|||
|
_propMoudleEx = base.PropMoudle as RemotePlayerProperty;
|
|||
|
}
|
|||
|
return _propMoudleEx;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//是否显示选中框
|
|||
|
public override bool CanShowSelectUI
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//是否显示血条
|
|||
|
public bool IsShowLife
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _isShowLife || _isBeSelect;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
if (_isShowLife != value)
|
|||
|
{
|
|||
|
_isShowLife = value;
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_UPDATEPLAYERHPSHOW_STATE, this);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public override bool IsShowModel
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _isShowModel;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_isShowModel = value;
|
|||
|
if ((_isShowModel && !GameCenter.MapLogicSwitch.HideOtherPlayer) != Skin.IsActive())
|
|||
|
{
|
|||
|
Skin.SetActive((_isShowModel && !GameCenter.MapLogicSwitch.HideOtherPlayer));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//如果角色被隐藏,不切换装备
|
|||
|
public override void EquipWithType(int type, int equipId, bool bClearVfx = true)
|
|||
|
{
|
|||
|
equipId = CheckEquipID(type, equipId);
|
|||
|
Skin.SetSkinPartFromCfgID(type, equipId, null, true, null, bClearVfx);
|
|||
|
}
|
|||
|
|
|||
|
#region//初始化处理
|
|||
|
//通过baseInfo,加载Skin
|
|||
|
protected override FSkinBase OnSetupSkin()
|
|||
|
{
|
|||
|
FSkinModel skin = GameCenter.LuaSystem.Adaptor.CreateFSkinModel(FSkinTypeCode.Player);
|
|||
|
skin.SetLayer(LayerUtils.RemotePlayer);
|
|||
|
skin.SetActiveChangedCallBack(OnActiveChanged);
|
|||
|
skin.SetOnSkinPartChangedHandler((x, y) =>
|
|||
|
{
|
|||
|
if (y == FSkinPartCode.Mount)
|
|||
|
{
|
|||
|
if (IsXState(EntityStateID.Idle) || IsXState(EntityStateID.DirMove) || IsXState(EntityStateID.PathMove))
|
|||
|
{
|
|||
|
x.StopAnim();
|
|||
|
}
|
|||
|
|
|||
|
var cfgId = Skin.GetSkinPartCfgID(FSkinPartCode.Mount);
|
|||
|
var cfg = DeclareHuaxingHorse.Get(cfgId);
|
|||
|
if (cfg != null)
|
|||
|
{
|
|||
|
RotBySceneHeight = cfg.RotBySceneHeight != 0;
|
|||
|
MountAnimSpeed = cfg.AnimSpeed / 100f;
|
|||
|
MountAnimSpeed /= 2;//fix yy
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
RotBySceneHeight = true;
|
|||
|
//MountAnimSpeed = 1f;
|
|||
|
MountAnimSpeed = 0.5f;
|
|||
|
}
|
|||
|
var mPart = x.GetSkinPart(FSkinPartCode.Mount);
|
|||
|
if (cfgId > 0 && mPart != null)
|
|||
|
{
|
|||
|
var radious = mPart.GetRadious();
|
|||
|
if (radious > 0)
|
|||
|
{
|
|||
|
SetRotationSpeed(FGameObjectRotater.CN_ROTATE_SPEED_DEFAULT * radious);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
SetRotationSpeed();
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
SetRotationSpeed();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (y == FSkinPartCode.GodWeaponHead)
|
|||
|
{
|
|||
|
var weaponModelID = Skin.GetSkinPartCfgID(FSkinPartCode.GodWeaponHead);
|
|||
|
var scaleCfg = DeclareWeaponScale.Get(weaponModelID);
|
|||
|
if (scaleCfg != null)
|
|||
|
{
|
|||
|
_receiveWeaponScale = new Vector3(scaleCfg.ReceiveScale / 100f, scaleCfg.ReceiveScale / 100f, scaleCfg.ReceiveScale / 100f);
|
|||
|
_brightWeaponScale = new Vector3(scaleCfg.BrightScale / 100f, scaleCfg.BrightScale / 100f, scaleCfg.BrightScale / 100f);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (y == FSkinPartCode.Body)
|
|||
|
{
|
|||
|
//重新挂载buff特效
|
|||
|
GameCenter.BuffSystem.ReAddAllBuffVfx(this);
|
|||
|
var body = Skin.GetSkinPart(FSkinPartCode.Body);
|
|||
|
if (body != null)
|
|||
|
{
|
|||
|
FlySwordHeightTrans = body.FindTransform(SlotNameDefine.RightWeaponReceive);
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
return skin;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
//通过外部数据初始化
|
|||
|
protected override bool OnInitializeAfter(EntityInitInfo baseInfo)
|
|||
|
{
|
|||
|
base.OnInitializeAfter(baseInfo);
|
|||
|
var initInfo = baseInfo as RemotePlayerInitInfo;
|
|||
|
SyncInfo(initInfo);
|
|||
|
|
|||
|
if (Scene.Cfg.ShowPlayerHud != 0)
|
|||
|
{
|
|||
|
_isShowLife = Scene.Cfg.ShowPlayerHp != 0;
|
|||
|
ShowHUD();
|
|||
|
}
|
|||
|
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
//数据信息同步
|
|||
|
public void SyncInfo(RemotePlayerInitInfo initInfo)
|
|||
|
{
|
|||
|
_propMoudle = _propMoudlePlayer = _propMoudleEx = new RemotePlayerProperty(this);
|
|||
|
|
|||
|
_propMoudleEx.Name = initInfo.Name;
|
|||
|
_propMoudleEx.Occ = initInfo.Occ;
|
|||
|
_propMoudleEx.Level = (uint)initInfo.Level;
|
|||
|
_propMoudleEx.CurHP = (ulong)initInfo.CurHp;
|
|||
|
_propMoudleEx.CurLinLi = (ulong)initInfo.CurLingLi;
|
|||
|
|
|||
|
_propMoudleEx.GuildId = initInfo.Guild;
|
|||
|
_propMoudleEx.GuildRank = initInfo.GuildRank;
|
|||
|
_propMoudleEx.GuildName = initInfo.GuildName;
|
|||
|
_propMoudleEx.PictureCfg = DeclareTitle.Get(initInfo.CurTitle);
|
|||
|
_propMoudleEx.SceneCampID = initInfo.Camp;
|
|||
|
_propMoudleEx.StateLevel = initInfo.StateLevel;
|
|||
|
_propMoudleEx.ShiHaiID = initInfo.ShiHaiID;
|
|||
|
_propMoudleEx.ServerID = initInfo.ServerID;
|
|||
|
|
|||
|
_propMoudleEx.SetBattleProp(AllBattleProp.MaxHP, (long)initInfo.MaxHp);
|
|||
|
_propMoudleEx.SetBattleProp(AllBattleProp.MoveSpeed, initInfo.MoveSpeedFinal);
|
|||
|
_propMoudleEx.SetBattleProp(AllBattleProp.AttackSpeed, initInfo.AttackSpeedFinal);
|
|||
|
_propMoudleEx.FaBaoCfgID = initInfo.FaBaoCfgID;
|
|||
|
_propMoudleEx.FaBaoUID = initInfo.FaBaoUID;
|
|||
|
_propMoudleEx.FaBaoSprite1ID = initInfo.FaBaoSprite1ID;
|
|||
|
_propMoudleEx.FaBaoSprite2ID = initInfo.FaBaoSprite2ID;
|
|||
|
_propMoudleEx.FaBaoSprite3ID = initInfo.FaBaoSprite3ID;
|
|||
|
_propMoudleEx.FlySwordCfgID = initInfo.FlySwordCfgID;
|
|||
|
_propMoudleEx.FlySwordUID = initInfo.FlySwordUID;
|
|||
|
_propMoudleEx.MarryChildID = initInfo.MarryChildID;
|
|||
|
_propMoudleEx.MarryChildName = initInfo.MarryChildName;
|
|||
|
_fightPower = initInfo.FightPower;
|
|||
|
FashionHeadId = initInfo.FashionHeadId;
|
|||
|
FashionFrameId = initInfo.FashionFrameId;
|
|||
|
TexHeadPicID = initInfo.TexHeadPicID;
|
|||
|
IsShowHeadPic = initInfo.IsShowHeadPic;
|
|||
|
|
|||
|
_visualInfo = initInfo.VisualInfo;
|
|||
|
|
|||
|
GameCenter.BuffSystem.ReAddAllBuffSpecial(this);
|
|||
|
if (!IsChangeModel)
|
|||
|
{
|
|||
|
GameCenter.LuaSystem.Adaptor.RefreshPlayerModel(this, VisualInfo);
|
|||
|
EquipWithType(FSkinPartCode.Mount, initInfo.Mount);
|
|||
|
|
|||
|
}
|
|||
|
IsShowModel = GameObjectLimit.IsCanShow(this);
|
|||
|
|
|||
|
InitStartPose(initInfo.X, initInfo.Z, ref initInfo.PosList);
|
|||
|
SetDirection2d(initInfo.Dir, false, true);
|
|||
|
|
|||
|
//设置状态
|
|||
|
_stateManager.SetStateData(initInfo.State);
|
|||
|
|
|||
|
if (initInfo.IsCollecting)
|
|||
|
{
|
|||
|
Action_Collect(0);
|
|||
|
}
|
|||
|
|
|||
|
//是否已经死亡
|
|||
|
if (initInfo.IsDead)
|
|||
|
{
|
|||
|
DeadDetail = new CharacterDeadInfo();
|
|||
|
DeadDetail.DeadTime = 0f;
|
|||
|
Fsm.TransTo(EntityStateID.Dead);
|
|||
|
}
|
|||
|
RayCastToGroundXOZ(new Vector2(initInfo.X, initInfo.Z));
|
|||
|
_spouseName = initInfo.SpouseName;
|
|||
|
if (IsShowHUD)
|
|||
|
{
|
|||
|
//如果头顶已经展示了,刷新下头顶
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_HUD_UPDATE_HEADINFO, this);
|
|||
|
}
|
|||
|
|
|||
|
//是否正在打坐
|
|||
|
if (initInfo.IsSitting)
|
|||
|
{
|
|||
|
Action_SitDown(true);
|
|||
|
}
|
|||
|
//5帧后召唤法宝
|
|||
|
_loadFaBaoFrame = 5;
|
|||
|
}
|
|||
|
|
|||
|
protected override void OnUninitializeBefore()
|
|||
|
{
|
|||
|
HideHUD();
|
|||
|
base.OnUninitializeBefore();
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//是否被选择的处理
|
|||
|
|
|||
|
//选择
|
|||
|
protected override void OnSelect()
|
|||
|
{
|
|||
|
var vfxId = 931;
|
|||
|
if (CombatUtil.CanAttackTarget(Scene.GetLocalPlayer(), this, false))
|
|||
|
{
|
|||
|
vfxId = 920;
|
|||
|
}
|
|||
|
Skin.SetSkinPart(FSkinPartCode.SelectedVfx, ModelTypeCode.OtherVFX, vfxId, false, null, null, null, SlotNameDefine.Origin);
|
|||
|
//设置选择圈的大小
|
|||
|
Skin.GetSkinPart(FSkinPartCode.SelectedVfx).SetLocalScale(new Vector3(PropMoudle.LogicBodyRadius / BodyScale, 1, PropMoudle.LogicBodyRadius / BodyScale));
|
|||
|
|
|||
|
_isBeSelect = true;
|
|||
|
if (Scene.Cfg.ShowPlayerHud != 0)
|
|||
|
{
|
|||
|
if (!_isShowLife)
|
|||
|
{
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_UPDATEPLAYERHPSHOW_STATE, this);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//取消选择
|
|||
|
protected override void OnDeselect()
|
|||
|
{
|
|||
|
Skin.RemoveSkinPart(FSkinPartCode.SelectedVfx);
|
|||
|
|
|||
|
_isBeSelect = false;
|
|||
|
if (Scene.Cfg.ShowPlayerHud != 0)
|
|||
|
{
|
|||
|
if (!_isShowLife)
|
|||
|
{
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_UPDATEPLAYERHPSHOW_STATE, this);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 战斗状态
|
|||
|
public override void OnFightStateChangated(bool state)
|
|||
|
{
|
|||
|
if (state)
|
|||
|
{
|
|||
|
_fightStateTimer = 5f;
|
|||
|
}
|
|||
|
base.OnFightStateChangated(state);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
#region 受击处理
|
|||
|
public override void OnBeAttackedResponse(Character attacker, HitEffectInfo hitInfo, SkillHitType hitType, MSG_Fight.HitEffectInfo msgInfo)
|
|||
|
{
|
|||
|
FightState = true;
|
|||
|
if (hitType != SkillHitType.None)
|
|||
|
{
|
|||
|
EquipWithType(FSkinPartCode.Mount, 0);
|
|||
|
}
|
|||
|
|
|||
|
//只有主角或者主角宠物攻击的玩家才会显示血条
|
|||
|
if (attacker != null && (attacker.IsLocalPlayer() || attacker.IsLocalPet()))
|
|||
|
{
|
|||
|
if (Scene.Cfg.ShowPlayerHud != 0)
|
|||
|
{
|
|||
|
IsShowLife = true;
|
|||
|
}
|
|||
|
}
|
|||
|
base.OnBeAttackedResponse(attacker, hitInfo, hitType, msgInfo);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 心跳
|
|||
|
protected override void OnUpdate(float elapsedTime)
|
|||
|
{
|
|||
|
if (FightState)
|
|||
|
{
|
|||
|
_fightStateTimer -= elapsedTime;
|
|||
|
if (_fightStateTimer <= 0f)
|
|||
|
{
|
|||
|
FightState = false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (_loadFaBaoFrame > 0)
|
|||
|
{
|
|||
|
--_loadFaBaoFrame;
|
|||
|
if (_loadFaBaoFrame <= 0)
|
|||
|
{
|
|||
|
//召唤飞剑
|
|||
|
LoadFlySword();
|
|||
|
//召唤仙娃
|
|||
|
LoadMarryChild();
|
|||
|
_loadFaBaoFrame = -1;
|
|||
|
}
|
|||
|
}
|
|||
|
base.OnUpdate(elapsedTime);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|