Project_WL/Assets/Script/Character/PetActor.cs

184 lines
6.8 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;
GameObject go_PetBattleEffect;
IngamePetCard m_IngamePetCard;
SkillListTableData m_SkillData;
float m_SkillCoolTime = 100000f, m_MaxSkillCoolTime;
protected override void Update()
{
if (IsDead()) return;
if (!DSUtil.CheckNull(m_IngamePetCard) && m_SkillCoolTime > 0f)
{
m_SkillCoolTime -= Time.deltaTime;
m_IngamePetCard.Set_CoolTime(m_SkillCoolTime, m_MaxSkillCoolTime, 0);
if (m_SkillCoolTime <= 0f)
Use_Skill(m_SkillData, true, 0);
}
base.Update();
if (!IsStop && (DSUtil.CheckNull(m_Target) || m_Target.IsDead()) && Vector3.Distance(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);
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)
{
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];
Set_MagicCoolTime(0f, 0);
// 투견장 없음
//if (Chapter == 105 && !IsEnemy())
//{
// go_PetBattleEffect = InGameInfo.Ins.Show_Effect(eEffect.PetBattle_My, Get_position(), Vector3.right * 90f);
// go_PetBattleEffect.transform.parent = transform;
// go_PetBattleEffect.transform.position = Get_position();
//}
//else
{
if (go_PetBattleEffect)
{
go_PetBattleEffect.SetActive(false);
go_PetBattleEffect = null;
}
}
}
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()
{
base.On_Regen();
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);
}
}
protected override void Projectile_To_Target(string _proj)
{
ProjectileInfo.Ins.Shoot_Projectile(_proj, this, m_Target, 1f, Get_CenterPositionFoward());
}
protected override void Projectile_To_Target2(string _proj)
{
ProjectileInfo.Ins.Shoot_Projectile(_proj, this, m_Target, 1f, Get_CenterPositionFoward());
}
protected override void Projectile_To_Target3(string _proj)
{
ProjectileInfo.Ins.Shoot_Projectile(_proj, this, m_Target, 1f, Get_CenterPositionFoward());
}
PetActor LinkPet;
public override void Add_ReceiveDmg(double _dmg)
{
base.Add_ReceiveDmg(_dmg);
if (IsBerserkPet())
LinkPet.m_Stat.Set_Stat(false, eStat.HP, _dmg);
}
public void Set_ChangeValue(PetActor _pet)
{
LinkPet = _pet;
m_Damage = _pet.Get_RealDamage();
receiveaccumulateDmg = _pet.Get_ReceiveDmg();
list_IngamePetCard = _pet.list_IngamePetCard;
}
}