OneShotOneKill/Assets/Script/InGame/Actor/PCActor.cs

127 lines
4.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PCActor : Actor
{
public Image i_actor;
public EffectBase eff_Shield;
public GameObject go_lowhp;
Dictionary<eActorStatus, string> dic_statusImageKey = new Dictionary<eActorStatus, string>
{
{ eActorStatus.Idle, "" }, { eActorStatus.Hit, "" },
};
protected override void Awake()
{
base.Awake();
eff_Shield.Off();
}
public override void Set(int identity, ActorTableDataBase actordata, HUD_HPShield hUD_HPShield, ServerData sdata = null)
{
base.Set(identity, actordata, hUD_HPShield, sdata);
IngameUIManager.Ins.m_SpecificityList.Set(list_Specificity);
go_lowhp.SetActive(false);
dic_statusImageKey[eActorStatus.Idle] = m_TableData.Get_ImagePath();
dic_statusImageKey[eActorStatus.Hit] = m_TableData.Get_ImagePath(eActorStatus.Hit);
Load_Image(i_actor, dic_statusImageKey[eActorStatus.Hit], () =>
{
Load_Image(i_actor, dic_statusImageKey[eActorStatus.Idle], () =>
{
i_actor.SetNativeSize();
isSetImage = true;
if (IsRole(eRole.Mob)) Set_HUD(true);
});
});
}
public override void Heal(eHealType healType, float ratio)
{
base.Heal(healType, ratio);
Check_LowHP();
}
public override void Heal(eHealType healType, int heal)
{
base.Heal(healType, heal);
Check_LowHP();
}
protected override void OnEvent_GetDmg(ProjectileData pdData)
{
base.OnEvent_GetDmg(pdData);
Check_LowHP();
//if (co_Hit != null) { StopCoroutine(co_Hit); co_Hit = null; }
//co_Hit = StartCoroutine(Co_Anim(eActorStatus.Hit));
}
public override void OnEvent_Kill(Actor deadactor)
{
base.OnEvent_Kill(deadactor);
if (dic_Card.ContainsKey(eCardType.G2_ActivateInvincibleShieldOnKill))
{
eff_Shield.Set_OffTime(dic_Card[eCardType.G2_ActivateInvincibleShieldOnKill].m_Data.Get_FloatValue3());
}
}
public override bool IsShield() { return eff_Shield.isActiveAndEnabled; }
public override Vector3 Get_World_Position(eEffectPivot pivot = eEffectPivot.Center) { return base.Get_World_Position(pivot); }
protected override float Get_ProjectileSpeed() { return table_GlobalValue.Ins.Get_Float("PC_ProjectileSpeed"); }
void Check_LowHP()
{
var hp = m_StatInfo.Get_TotalStat(eStat.HP);
var maxhp = m_StatInfo.Get_TotalStat(eStat.MaxHP);
var cal = hp / maxhp;
if (cal < 0.3)
{
if (!go_lowhp.activeInHierarchy)
{
go_lowhp.SetActive(true);
i_actor.sprite = m_Handle[dic_statusImageKey[eActorStatus.Hit]].Result as Sprite;
}
}
else if (go_lowhp.activeInHierarchy)
{
go_lowhp.SetActive(false);
i_actor.sprite = m_Handle[dic_statusImageKey[eActorStatus.Idle]].Result as Sprite;
}
}
#region
protected override void Play_Attack()
{
if (!IsDead())
{
if (m_Target == null || m_Target.IsDead() || isCantSetTarget())
Find_Target();
base.Play_Attack();
m_anim.Play("PC_Attack");
}
}
protected override void Play_Hit()
{
base.Play_Hit();
if (IsDead() || ActorStatus == eActorStatus.Attack) return;
ActorStatus = eActorStatus.Hit;
m_anim.Stop();
m_anim.Play("PC_Hit");
}
protected override void Play_Evasion()
{
base.Play_Evasion();
if (IsDead() || ActorStatus == eActorStatus.Attack) return;
ActorStatus = eActorStatus.Evasion;
m_anim.Stop();
m_anim.Play("PC_Evasion");
}
IEnumerator Co_Anim(eActorStatus status)
{
i_actor.sprite = m_Handle[dic_statusImageKey[status]].Result as Sprite;
yield return new WaitForSeconds(1.0f);
i_actor.sprite = m_Handle[dic_statusImageKey[eActorStatus.Idle]].Result as Sprite;
}
#endregion
}