159 lines
5.9 KiB
C#
159 lines
5.9 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PetActor : MyActor
|
|
{
|
|
List<IngamePetCard> list_IngamePetCard = new List<IngamePetCard> { null, null }; // 스테이지, 투견장
|
|
protected PetListTableData m_PetTableData;
|
|
IngamePetCard m_IngamePetCard;
|
|
bool isIngamePetCard;
|
|
|
|
SkillListTableData m_SkillData;
|
|
float m_SkillCoolTime = 100000f, m_MaxSkillCoolTime;
|
|
|
|
protected override void Update()
|
|
{
|
|
if (IsDead()) return;
|
|
|
|
if (isIngamePetCard)
|
|
{
|
|
if (m_SkillCoolTime > 0f)
|
|
{
|
|
m_SkillCoolTime -= Time.deltaTime;
|
|
if (m_SkillCoolTime < 0f)
|
|
m_SkillCoolTime = 0f;
|
|
|
|
m_IngamePetCard.Set_CoolTime(m_SkillCoolTime, m_MaxSkillCoolTime, 0);
|
|
}
|
|
|
|
if (m_SkillCoolTime <= 0f)
|
|
Use_Skill(m_SkillData, true, 0);
|
|
}
|
|
|
|
base.Update();
|
|
if (!IsStop && (!isTarget || m_Target.IsDead()) && !DSUtil.WithInDistance(OwnerActor.Get_position(), Get_position(), 2))
|
|
{ // 마녀 따라다니기
|
|
Follow_PC();
|
|
}
|
|
else if (CurAnim == eAnim.Run && m_NavMeshAgent.velocity == Vector3.zero)
|
|
Play_Idle();
|
|
|
|
if (CurAnim == eAnim.Attack && !isPlaying())
|
|
Play_Idle();
|
|
}
|
|
|
|
protected override bool Check_MagicCoolTime(int _index) { return true; }
|
|
public override void Set_MagicCoolTime(float _time, int _index)
|
|
{
|
|
var cooldown = m_Stat.Get_Stat(eStat.COOLTIME_Multiplier) + m_Stat.Get_Stat(eStat.Pet_CoolTime);
|
|
m_MaxSkillCoolTime = m_SkillCoolTime = m_SkillData.Get_CoolTime(cooldown);
|
|
if (isIngamePetCard) m_IngamePetCard.Set_CoolTime(m_SkillCoolTime, m_MaxSkillCoolTime, 0);
|
|
}
|
|
public override void Set_SkillCoolTime(bool add, int skillid, float rate)
|
|
{
|
|
m_SkillCoolTime -= m_MaxSkillCoolTime * rate;
|
|
}
|
|
|
|
public override void Set(bool isEnemy, Actor owner, ServerData sdata, int _id, bool _isstop, bool _ui = false)
|
|
{
|
|
isFollowOwner = false;
|
|
Del_Target();
|
|
OwnerActor = owner;
|
|
m_Role = eRole.Pet;
|
|
//var Chapter = InGameInfo.Ins.Get_CurStageData().Chapter;
|
|
//m_AutoTarget = Chapter < 101 || sdata.Get_Common(eCommon.AutoTarget) == 1;
|
|
m_Auto = true;
|
|
f_FindEnemyRange = table_GlobalValue.Ins.Get_Float("f_Pet_FindEnemyRange");
|
|
base.Set(isEnemy, owner, sdata, _id, _isstop);
|
|
m_PetTableData = table_petlist.Ins.Get_Data_orNull(_id);
|
|
m_AttackType = m_PetTableData.e_AttackType;
|
|
m_SkillData = table_skilllist.Ins.Get_Data_orNull(m_PetTableData.n_PetActiveSkill);
|
|
dic_MagicData.Add(0, new UseMagicInfo { m_SkillTableData = m_SkillData, });
|
|
ReSet();
|
|
if (IsRole(eRole.Pet))
|
|
{
|
|
m_IngamePetCard = NewGameUI.Ins.arr_PetCard[0];
|
|
isIngamePetCard = m_IngamePetCard;
|
|
}
|
|
Set_MagicCoolTime(0f, 0);
|
|
}
|
|
public override void Set_Card(int index, int chapter)
|
|
{
|
|
base.Set_Card(index, chapter);
|
|
if (!IsEnemy() && InGameInfo.Ins.IsGameMode(eGameMode.Stage)) list_IngamePetCard[0] = NewGameUI.Ins.arr_PetCard[index];
|
|
//if (chapter == 105)
|
|
//{
|
|
// if (IsEnemy()) list_IngamePetCard[1] = GameUI.Ins.IngameUI.m_PetBattleUI.enemyPetCards[index];
|
|
// else list_IngamePetCard[1] = GameUI.Ins.IngameUI.m_PetBattleUI.myPetCards[index];
|
|
//}
|
|
for (int i = 0; i < list_IngamePetCard.Count; i++)
|
|
{
|
|
if (list_IngamePetCard[i] != null)
|
|
list_IngamePetCard[i].Set(m_PetTableData);
|
|
}
|
|
}
|
|
public IngamePetCard Get_PetCard() { return list_IngamePetCard[0]; }
|
|
public override void ReSet()
|
|
{
|
|
if (DSUtil.CheckNull(m_ServerData)) return; // 광폭화 펫인데 아직 정보가 없음
|
|
|
|
base.ReSet();
|
|
//var curStageData = InGameInfo.Ins.Get_CurStageData();
|
|
|
|
Set_Stat(true);
|
|
m_NavSpeed = m_NavMeshAgent.speed = m_PetTableData.f_PetMoveSPD;
|
|
m_NavStopDistance = m_NavMeshAgent.stoppingDistance = m_PetTableData.f_AttackRange;
|
|
|
|
var selectskill = InGameInfo.Ins.Get_SelectSkills();
|
|
if (selectskill != null)
|
|
foreach (var item in selectskill)
|
|
Set_Stat_SelectSkill(table_selectskill.Ins.Get_Data(item.Key));
|
|
|
|
if (!m_Enemy) LoadMapMgr.Ins.Get_PortalPos(MyValue.MyChoiceMapData, Set_Warp);
|
|
else LoadMapMgr.Ins.Get_PortalPos(MyValue.MyChoiceMapData, Set_Warp); // TODO 정인호 : 적인 경우 적의 펫 위치 잡기
|
|
|
|
Play_Idle();
|
|
}
|
|
public override void Set_Stat(bool init)
|
|
{
|
|
if (DSUtil.CheckNull(m_Stat))
|
|
m_Stat = MyValue.MakeorGet_ActorStatInfo(m_Role, Get_ServerData(), m_PetTableData, "0", m_PetTableData.n_PetID);
|
|
else
|
|
m_Stat.Reset();
|
|
}
|
|
|
|
public override void On_Regen(bool reincarnation = false, float healrate = 1f)
|
|
{
|
|
base.On_Regen(reincarnation, healrate);
|
|
Del_Target();
|
|
Play_Idle();
|
|
}
|
|
|
|
public override void Heal(float _rate, bool showhealeffect = true)
|
|
{
|
|
base.Heal(_rate, showhealeffect);
|
|
if (!IsDead())
|
|
for (int i = 0; i < list_IngamePetCard.Count; i++)
|
|
{
|
|
if (list_IngamePetCard[i] != null)
|
|
list_IngamePetCard[i].Set_HPGage((float)(Get_HP() / Get_MaxHP()));
|
|
}
|
|
}
|
|
|
|
public override void Get_Damage(DamageInfo _dinfo)
|
|
{
|
|
base.Get_Damage(_dinfo);
|
|
var hpRate = (float)(Get_HP() / Get_MaxHP());
|
|
for (int i = 0; i < list_IngamePetCard.Count; i++)
|
|
{
|
|
if (list_IngamePetCard[i] != null)
|
|
list_IngamePetCard[i].Set_HPGage(hpRate);
|
|
}
|
|
}
|
|
|
|
public override void Projectile(AnimationEvent s)
|
|
{
|
|
var lifeTime = table_effectlist.Ins.Get_Data(m_PetTableData.s_PetAttackPrefab).f_ProjectileLifeTime;
|
|
Shoot_Projectile(m_PetTableData.s_PetAttackPrefab, s.floatParameter, lifeTime, Get_CenterPositionFoward());
|
|
}
|
|
} |