405 lines
15 KiB
C#
405 lines
15 KiB
C#
using System.Collections;
|
|
using CodeStage.AntiCheat.ObscuredTypes;
|
|
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
|
|
|
public class PCActor : MyActor
|
|
{
|
|
public Transform[] tfs_weapon; // 0 왼손, 1 오른손
|
|
|
|
float t_RecoverHPTime = 10f, t_RecoverMPTime = 10f, t_autoskill = 0.5f;
|
|
float t_HP = 0f, t_MP = 0f;
|
|
ObscuredFloat[] arr_magicCoolTime = new ObscuredFloat[] { 0f, 0f, 0f, 0f, 0f, 0f };
|
|
ObscuredFloat[] arr_magicMaxCoolTime = new ObscuredFloat[] { 0f, 0f, 0f, 0f, 0f, 0f };
|
|
SkillListTableData[] arr_magicData = new SkillListTableData[6];
|
|
SkillCard[] arr_PCSkillCard;
|
|
public bool IsJoystickMove { get; set; }
|
|
ObscuredFloat m_AvoidCoolTime;
|
|
protected ClassConfigTableData m_ClassData;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
tag = "Player";
|
|
}
|
|
|
|
protected override void Update()
|
|
{
|
|
if (!DSUtil.CheckNull(arr_PCSkillCard) && arr_PCSkillCard.Length > 0)
|
|
{
|
|
for (int i = 0; i < arr_magicCoolTime.Length; i++)
|
|
{
|
|
if (DSUtil.CheckNull(arr_magicData[i]) || arr_magicData[i].e_SkillType == eSkillType.Passive) continue;
|
|
|
|
arr_magicCoolTime[i] -= Time.deltaTime;
|
|
if (arr_magicCoolTime[i] <= 0f) arr_magicCoolTime[i] = 0f;
|
|
arr_magicCoolTime[i].RandomizeCryptoKey();
|
|
|
|
if (!IsEnemy())
|
|
arr_PCSkillCard[i].Set_CoolTime(arr_magicCoolTime[i], arr_magicMaxCoolTime[i], i);
|
|
|
|
if (m_Auto && !IsDead() && !DSUtil.CheckNull(arr_magicData[i]) && arr_magicCoolTime[i] <= 0f && t_autoskill <= 0f && !IsCC() && CurAnim < eAnim.Skill &&
|
|
!DSUtil.CheckNull(m_Target) && Vector3.Distance(Get_position(), m_Target.Get_position()) <= arr_magicData[i].f_SkillRange)
|
|
{
|
|
if (Use_Skill(arr_magicData[i], m_Auto, i))
|
|
{
|
|
arr_magicCoolTime[i] = arr_magicMaxCoolTime[i];
|
|
t_autoskill = Random.Range(2f, 3f);
|
|
}
|
|
}
|
|
}
|
|
t_autoskill -= Time.deltaTime;
|
|
}
|
|
|
|
t_HP += Time.deltaTime;
|
|
if (t_HP >= t_RecoverHPTime)
|
|
{
|
|
t_HP = 0f;
|
|
if (!DSUtil.CheckNull(m_Stat))
|
|
{
|
|
var hpper = (float)(m_Stat.Get_Stat(eStat.HP) / m_Stat.Get_Stat(eStat.MaxHP));
|
|
if (hpper <= m_Stat.Get_Stat(eStat.HeroBuffHP))
|
|
m_Stat.Set_Stat(true, eStat.HP, m_Stat.Get_Stat(eStat.FinalHPRegen) + m_Stat.Get_Stat(eStat.HP_REGEN) * m_Stat.Get_Stat(eStat.HeroBuff_HP_REGEN_Multiplier));
|
|
else
|
|
m_Stat.Set_Stat(true, eStat.HP, m_Stat.Get_Stat(eStat.FinalHPRegen));
|
|
}
|
|
}
|
|
|
|
t_MP += Time.deltaTime;
|
|
if (t_MP >= t_RecoverMPTime + (dic_ccData.ContainsKey(eCC.MPRecoverTime) && dic_ccData[eCC.MPRecoverTime].CCTime > 0 ? dic_ccData[eCC.MPRecoverTime].CCDmg : 0))
|
|
{
|
|
t_MP = 0f;
|
|
if (!DSUtil.CheckNull(m_Stat))
|
|
m_Stat.Set_Stat(true, eStat.MP, m_Stat.Get_Stat(eStat.FinalMPRegen));
|
|
}
|
|
|
|
if (m_AvoidCoolTime > 0f)
|
|
{
|
|
m_AvoidCoolTime -= Time.deltaTime;
|
|
m_AvoidCoolTime.RandomizeCryptoKey();
|
|
if(!DSUtil.CheckNull(NewGameUI.Ins)) NewGameUI.Ins.m_BattleUI.Set_Avoid(m_AvoidCoolTime);
|
|
}
|
|
|
|
Update_Move();
|
|
|
|
if (IsJoystickMove || IsStop || IsDead()) return;
|
|
|
|
base.Update();
|
|
|
|
// 2023. 02. 19. 정인호. 포탈찾는 로직(원래는 스테이지에 있었는데, 마녀의 기억으로 바껴서 이 로직 필요없어짐)
|
|
//if (m_Target == null && m_AutoTarget && MobInfo.Ins.m_PortalMgr != null && MobInfo.Ins.m_PortalMgr.go_portal.activeInHierarchy && m_NavMeshAgent.stoppingDistance > 0f)
|
|
//{
|
|
// Set_AutoBraking(false);
|
|
// Set_Path(MobInfo.Ins.m_PortalMgr.go_portal.transform.position);
|
|
//}
|
|
}
|
|
public override void Set(bool isEnemy, Actor owner, ServerData sdata, int _id, bool _isstop, bool _ui = false)
|
|
{
|
|
if (DSUtil.CheckNull(arr_PCSkillCard) && !DSUtil.CheckNull(NewGameUI.Ins)) arr_PCSkillCard = NewGameUI.Ins.m_BattleUI.skillCards;
|
|
if (!DSUtil.CheckNull(arr_PCSkillCard))
|
|
{ // 스킬 설정
|
|
for (int i = 0; i < arr_PCSkillCard.Length; i++)
|
|
{
|
|
var skillData = table_skilllist.Ins.Get_Data_orNull(sdata.Get_EquipSkillID(i));
|
|
arr_PCSkillCard[i].Set(skillData);
|
|
arr_PCSkillCard[i].Set_CardType(eUICardType.Use);
|
|
|
|
dic_MagicData.Add(i, new UseMagicInfo { m_uiIndex = i, m_SkillTableData = skillData, });
|
|
}
|
|
}
|
|
m_ClassData = table_classconfig.Ins.Get_Data_orNull(_id);
|
|
AddrResourceMgr.Ins.LoadObject<RuntimeAnimatorController>(m_ClassData.s_AnimationController, handle =>
|
|
{
|
|
m_animation.runtimeAnimatorController = handle.Result;
|
|
});
|
|
|
|
if (InGameInfo.Ins.IsGameMode(eGameMode.Lobby))
|
|
transform.localScale = Vector3.one;
|
|
else
|
|
transform.localScale = m_ClassData.f_Scale * Vector3.one;
|
|
|
|
m_NavStopDistance = m_ClassData.f_AttackRange;
|
|
base.Set(isEnemy, owner, sdata, _id, _isstop, _ui);
|
|
Change_Weapon(_ui);
|
|
|
|
isSurviveTime = false;
|
|
if (!_ui)
|
|
{
|
|
ReSet();
|
|
Set_MoveSpeed(true, m_Stat.Get_Stat(eStat.FinalMoveSpeed));
|
|
}
|
|
|
|
f_FindEnemyRange = table_GlobalValue.Ins.Get_Float("f_PC_FindEnemyRange") + (float)m_Stat.Get_Stat(eStat.AttackRange_Up);
|
|
}
|
|
public override void ReSet()
|
|
{
|
|
base.ReSet();
|
|
Set_Stat(true);
|
|
|
|
t_autoskill = Random.Range(2f, 3f);
|
|
m_Auto = m_ServerData.Get_Common(eCommon.Auto) == 1;
|
|
for (int i = 0; i < arr_magicCoolTime.Length; i++)
|
|
arr_magicCoolTime[i] = 0f;
|
|
for (int i = 0; i < arr_magicData.Length; i++)
|
|
arr_magicData[i] = table_skilllist.Ins.Get_Data_orNull(m_ServerData.Get_EquipSkillID(i));
|
|
for (int i = 0; i < arr_magicMaxCoolTime.Length; i++)
|
|
arr_magicMaxCoolTime[i] = arr_magicData[i] != null ? arr_magicData[i].Get_CoolTime(m_Stat.Get_Stat(eStat.COOLTIME_Multiplier)) : 0f;
|
|
|
|
t_HP = t_MP = 0f;
|
|
m_bImmortal = m_bCanDodge = false;
|
|
|
|
if (!m_Enemy)
|
|
{
|
|
MyValue.MyPC = this;
|
|
|
|
//// 카메라 위치 잡기
|
|
//var curStageData = InGameInfo.Ins.Get_CurStageData();
|
|
//var viewcam = LoadMapMgr.Ins.Get_ViewCamera("ViewCamera");
|
|
//var maincam = Camera.main;
|
|
//if (InGameInfo.Ins.IsGameMode(eGameMode.Lobby) && viewcam != null)
|
|
//{
|
|
// InGameTouchInfo.Ins.m_RealCamera.enabled = false;
|
|
// maincam.fieldOfView = viewcam.fieldOfView;
|
|
// maincam.backgroundColor = viewcam.backgroundColor;
|
|
// maincam.transform.position = viewcam.transform.position;
|
|
// maincam.transform.rotation = viewcam.transform.rotation;
|
|
//}
|
|
|
|
#if UNITY_EDITOR
|
|
if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "StatTest" ||
|
|
UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "Settings")
|
|
return;
|
|
#endif
|
|
LoadMapMgr.Ins.Get_PortalPos(MyValue.MyChoiceMapData, Set_Warp);
|
|
}
|
|
else
|
|
LoadMapMgr.Ins.Get_PortalPos(MyValue.MyChoiceMapData, Set_Warp); // TODO 정인호 : PvP 일 경우 적 위치 잡기
|
|
}
|
|
|
|
public override void On_Regen()
|
|
{
|
|
base.On_Regen();
|
|
Del_Target(true);
|
|
Del_Magic();
|
|
Play_Idle();
|
|
ActorInfo.Ins.All_Stop(false);
|
|
m_AttackIndex = m_NextAttackIndex = 0; // 사망 후 공격 인덱스 초기화
|
|
}
|
|
|
|
protected override bool IsAvoidCoolTime() { return m_AvoidCoolTime > 0f; }
|
|
protected override void Set_AvoidCoolTime() { m_AvoidCoolTime = table_GlobalValue.Ins.Get_Int("f_AvoidCoolTime"); }
|
|
public void StartCam()
|
|
{
|
|
Camera.main.fieldOfView = 60f;
|
|
LoadMapMgr.Ins.Get_PortalPos(MyValue.MyChoiceMapData, portalpos =>
|
|
{
|
|
//Vector3 targetPosition = portalpos;
|
|
//Vector3 cameraPosition = portalpos - Vector3.forward; // 현재 카메라의 위치
|
|
|
|
//Vector3 relativePosition = targetPosition - cameraPosition;
|
|
//float rotateAround = Mathf.Atan2(relativePosition.x, relativePosition.z) * Mathf.Rad2Deg;
|
|
|
|
//rotateAround += 180f; // 캐릭터 뒤에서 바라보도록 180도 보정
|
|
|
|
MyValue.m_RealCamera.Set_Target(transform, InGameInfo.Ins.IsGameMode(eGameMode.Lobby) ? 136.5f : 305f);
|
|
});
|
|
}
|
|
public override void Get_Damage(DamageInfo _dinfo)
|
|
{
|
|
//_dinfo.Damage = 1; // 테스트 : 마녀 안 죽게
|
|
base.Get_Damage(_dinfo);
|
|
if (!IsEnemy() && _dinfo.Damage >= Get_MaxHP() * 0.5d && !isSurviveTime)
|
|
StartCoroutine(Co_Survive(5f));
|
|
}
|
|
bool isSurviveTime = false;
|
|
IEnumerator Co_Survive(float _time)
|
|
{
|
|
isSurviveTime = true;
|
|
yield return new WaitForSeconds(_time);
|
|
if (!IsDead()) ServerInfo.Ins.m_ServerData.Add_Item(new ItemData(eItem.Title, 55, 1)); // 칭호 : 지난 세월이 보인
|
|
isSurviveTime = false;
|
|
}
|
|
|
|
public override void Set_RunSmoke(bool _active)
|
|
{
|
|
}
|
|
public override void Set_MagicCoolTime(float _time, int _index)
|
|
{
|
|
arr_magicCoolTime[_index] = _time;
|
|
arr_magicCoolTime[_index].RandomizeCryptoKey();
|
|
}
|
|
public override void Set_SkillCoolTime(bool add, int skillid, float rate)
|
|
{
|
|
for (int i = 0; i < arr_magicData.Length; i++)
|
|
{
|
|
if (arr_magicData[i].n_SkillID == skillid)
|
|
{
|
|
if (add)
|
|
arr_magicCoolTime[i] += arr_magicMaxCoolTime[i] * rate;
|
|
else
|
|
arr_magicCoolTime[i] -= arr_magicMaxCoolTime[i] * rate;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
protected override bool Check_MagicCoolTime(int _index) { return arr_magicCoolTime[_index] <= 0f; }
|
|
|
|
public void Init_UI(Transform _parent)
|
|
{
|
|
DSUtil.Set_Transform_withParent(transform, _parent);
|
|
transform.localEulerAngles = Vector3.up * 180f;
|
|
DSUtil.ChangeLayersRecursively(transform, "UI");
|
|
}
|
|
public override void BossRaidCard_AddDmg(double _dmg)
|
|
{
|
|
}
|
|
public override void BossRaidCard_HP()
|
|
{
|
|
}
|
|
|
|
public void Change_Weapon(bool _ui)
|
|
{
|
|
for (int i = 0; i < tfs_weapon.Length; i++)
|
|
{
|
|
if (tfs_weapon[i].childCount > 0)
|
|
{
|
|
for (int j = 0; j < tfs_weapon[i].childCount; j++)
|
|
Destroy(tfs_weapon[i].GetChild(j).gameObject);
|
|
}
|
|
}
|
|
|
|
if (!_ui)
|
|
{
|
|
var wData = table_equipitemlist.Ins.Get_Data_orNull(m_ServerData.Get_EqiupmentEquip(eItem.WeaponCostume) > 0 ?
|
|
m_ServerData.Get_EqiupmentEquip(eItem.WeaponCostume) : m_ServerData.Get_EqiupmentEquip(eItem.Weapon));
|
|
m_AttackType = DSUtil.CheckNull(wData) ? eAttackType.Physics : wData.e_EquipAttribute;
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
{
|
|
var prefab = i == 0 ? m_ClassData.s_WeaponLHPrefab : m_ClassData.s_WeaponRHPrefab;
|
|
if (!string.IsNullOrEmpty(prefab))
|
|
{
|
|
var fullpath = $"Assets/Res_Addr/Weapon/{prefab}.prefab";
|
|
if (!prefab.Equals("Mace"))
|
|
Make_Weapon(fullpath, tfs_weapon[0], 1, Vector3.zero, Vector3.one);
|
|
else
|
|
Make_Weapon(fullpath, tfs_weapon[1], 0, new Vector3(0.168f, -0.031f, -0.126f), Vector3.one);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var id = m_ServerData.Get_EqiupmentEquip(eItem.WeaponCostume) > 0 ? m_ServerData.Get_EqiupmentEquip(eItem.WeaponCostume) : m_ServerData.Get_EqiupmentEquip(eItem.Weapon);
|
|
Make_Weapon(table_equipitemlist.Ins.Get_Data_orNull(id).s_ItemPrefab_RH, tfs_weapon[1], 0, Vector3.zero, Vector3.one, true);
|
|
}
|
|
}
|
|
|
|
void Make_Weapon(string fullpath, Transform tfparent, int tfsprojectilestartindex,
|
|
Vector3 localpos = default, Vector3 scale = default, bool ui = false)
|
|
{
|
|
AddrResourceMgr.Ins.LoadObject<GameObject>(fullpath, handle =>
|
|
{
|
|
if (handle.IsDone && handle.Status == AsyncOperationStatus.Succeeded)
|
|
{
|
|
var w = DSUtil.Get_Clone(handle.Result);
|
|
AddrResourceMgr.Ins.Set_AddressableReleaseSelf(w);
|
|
DSUtil.Set_Transform_withParent(w.transform, tfparent, localpos, scale);
|
|
if (ui) DSUtil.ChangeLayersRecursively(w.transform, "UI");
|
|
}
|
|
});
|
|
}
|
|
|
|
protected override void Set_Script()
|
|
{
|
|
CameraShake.Ins.VibrateForTime(0.1f);
|
|
}
|
|
|
|
float move_dist = 0f;
|
|
public override void Run_byJoystick(Vector3 _pos)
|
|
{
|
|
if (m_bCanDodge)
|
|
{
|
|
if (!IsDead() && CurAnim != eAnim.Dodge)
|
|
{
|
|
transform.LookAt(transform.position + _pos);
|
|
Play_Dodge();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//if (IsDead() || CurAnim >= eAnim.Skill1 || IsCC())
|
|
if (IsDead() || IsCC() || CurAnim == eAnim.Dodge)
|
|
return;
|
|
Play_RunAnim();
|
|
|
|
Del_Magic();
|
|
Del_Target();
|
|
|
|
transform.LookAt(Get_position() + _pos);
|
|
if (m_NavMeshAgent.isOnNavMesh)
|
|
{
|
|
m_NavMeshAgent.ResetPath();
|
|
m_NavMeshAgent.stoppingDistance = 0f;
|
|
|
|
var before = Get_position();
|
|
m_NavMeshAgent.speed = m_NavSpeed;
|
|
var mov = Get_MoveSpeed() * Time.deltaTime * _pos;
|
|
m_NavMeshAgent.Move(mov);
|
|
var after = Get_position();
|
|
move_dist += Vector3.Distance(before, after);
|
|
if (move_dist >= 1f)
|
|
{
|
|
move_dist -= 1f;
|
|
m_ServerData.Add_TitleCondition(74, 75); // 칭호 : 발로 걷는, 발로 뛰는
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void Set_AutoBraking(bool _active)
|
|
{
|
|
if (IsDead() || IsCC() || CurAnim == eAnim.Dodge) return;
|
|
|
|
if (_active)
|
|
{
|
|
IsStop = false;
|
|
Play_Idle();
|
|
m_NavMeshAgent.stoppingDistance = m_NavStopDistance;
|
|
m_AttackIndex = m_NextAttackIndex = 0;
|
|
m_NavMeshAgent.angularSpeed = 300f;
|
|
}
|
|
else
|
|
{
|
|
IsStop = true;
|
|
Del_Target();
|
|
m_NavMeshAgent.ResetPath();
|
|
m_NavMeshAgent.stoppingDistance = 0f;
|
|
}
|
|
}
|
|
|
|
public bool Check_Path(Vector3 pos)
|
|
{
|
|
if (!IsCC())
|
|
{
|
|
NavMeshPath path = new NavMeshPath();
|
|
if (m_NavMeshAgent.isOnNavMesh && m_NavMeshAgent.CalculatePath(pos, path))
|
|
return path.status == NavMeshPathStatus.PathComplete;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
protected override void Set_Die()
|
|
{
|
|
base.Set_Die();
|
|
ActorInfo.Ins.All_Stop(true);
|
|
NewGameUI.Ins.m_GuideQuestUI.Add_GuideQuest(ePurpose.DieOrQuit);
|
|
}
|
|
|
|
public override void Stop(bool _stop)
|
|
{
|
|
base.Stop(_stop);
|
|
// 투견장 없음
|
|
//if (InGameInfo.Ins.Get_CurStageData().Chapter == 105) IsStop = true;
|
|
}
|
|
} |