Project_WL/Assets/Script/Character/PC/SummonActor.cs

102 lines
3.0 KiB
C#

using CodeStage.AntiCheat.ObscuredTypes;
using UnityEngine;
using UnityEngine.SceneManagement;
public enum eSummon { Golem, Worm }
public class SummonActor : MyActor
{
public eSummon SummonType;
float LifeTime, MaxLifeTime;
ObscuredInt projctile_amount = 1;
public void Set(bool isEnemy, Actor owner, float _time, float _attackrate, float _hprate, int projctileamount)
{
gameObject.SetActive(true);
OwnerActor = owner;
isFollowOwner = DeadStatus = false;
projctile_amount = projctileamount; projctile_amount.RandomizeCryptoKey();
m_Auto = true;
MaxLifeTime = LifeTime = _time;
m_Enemy = owner.IsEnemy();
m_ServerData = owner.Get_ServerData();
Set_Stat(true);
m_Stat.Set_Stat(true, eStat.BaseDmg, m_Stat.Get_Stat(eStat.BaseDmg) * _attackrate);
m_Stat.Set_Stat(true, eStat.HP, m_Stat.Get_Stat(eStat.HP) * _hprate);
m_NavMeshAgent.speed = owner.Get_MoveSpeed();
Play_Idle();
Set_Warp(owner.Get_position() + Vector3.forward);
f_FindEnemyRange = table_GlobalValue.Ins.Get_Float("f_Pet_FindEnemyRange");
switch (SummonType)
{
case eSummon.Golem:
m_NavStopDistance = 1.5f;
InGameInfo.Ins.Show_Effect("Effect_Summoning_Golem", transform.position);
transform.localScale = Vector3.one * 3.0f;
break;
default:
m_NavStopDistance = 3.5f;
InGameInfo.Ins.Show_Effect("Effect_Summoning", transform.position);
transform.localScale = Vector3.one * 1.5f;
break;
}
Set(isEnemy, owner, owner.Get_ServerData(), 0, true);
Get_HUDUI().Set_HPSlider(this);
Set_Coroutine(() =>
{
IsStop = false;
Set_Target();
}, 1f);
}
protected override void Update()
{
base.Update();
#if UNITY_EDITOR
if (SceneManager.GetActiveScene().name == "StatTest")
{
return;
}
#endif
if (IsDead()) return;
if (LifeTime > 0f)
{
LifeTime -= Time.deltaTime;
Get_HUDUI().Set(this, LifeTime / MaxLifeTime);
}
if (LifeTime <= 0f || DSUtil.CheckNull(OwnerActor))
{
End_Summon();
return;
}
if (!IsStop && (!isTarget || m_Target.IsDead()) && !DSUtil.WithInDistance(OwnerActor.Get_position(), Get_position(), 2f))
{ // 마녀 따라다니기
Follow_PC();
}
else if (CurAnim == eAnim.Run && m_NavMeshAgent.velocity == Vector3.zero)
Play_Idle();
if (CurAnim == eAnim.Attack && !isPlaying())
Play_Idle();
}
void End_Summon()
{
DeadStatus = true;
Set_Die();
}
protected override void After_Die()
{
base.After_Die();
Off();
InGameInfo.Ins.Show_Effect(SummonType == eSummon.Golem ? "Effect_Summoning_Golem" : "Effect_Summoning", transform.position);
}
}