Project_WL/Assets/Script/Util/MyClass.cs

273 lines
9.5 KiB
C#

using CodeStage.AntiCheat.ObscuredTypes;
using System;
using System.Collections.Generic;
using UnityEngine;
public class ObjectPool<T> where T : new()
{
private Stack<T> pool = new Stack<T>();
public T Get()
{
return pool.Count > 0 ? pool.Pop() : new T();
}
public void Release(T obj)
{
pool.Push(obj);
}
}
[Serializable] public class TableDataBase
{
public int ID;
public virtual string Get_Name() { return "no name"; }
public virtual float Get_Value(int lv, float balance, float defaultval, float perlv, bool abandon = false)
{
if (lv <= 0) return 0f;
float val;
if (Mathf.Approximately(0f, balance))
val = lv * perlv;
else
val = Mathf.Pow(lv * perlv, balance * Mathf.Sqrt(lv));
val *= 0.0001f;
val += defaultval;
if (abandon) val = Mathf.Floor(val); // 소수점 이하 모두 버림
return val;
}
}
public class StatTableDataBase : TableDataBase
{
public eStat Stat;
public ObscuredDouble BaseValue, ValuePerLv;
public ObscuredInt MaxLv, CostBase, CostIncrease;
public string Icon;
public double Get_Cost(int lv)
{
return CostBase + CostIncrease * lv;
}
}
public class StatInfo
{
public int Index;
public eStat Stat;
public ObscuredFloat Value, PerLvValue;
public float Get_StatValue(int _lv)
{
if (_lv <= 0) return 0f;
switch (Stat)
{
case eStat.AttackCoolTime:
//case eStat.FairySeek:
{
var val = Value - (PerLvValue * (_lv - 1));
if (val < 0.05f) val = 0.05f;
return val;
}
default:
return Value + (PerLvValue * (_lv - 1));
}
}
}
public class SpecailStatInfo
{
public eStat Stat;
public ObscuredFloat Value;
}
public class EquipmentTableBase : TableDataBase
{
public eItem ItemType;
public eItemGrade Grade;
public ObscuredInt Star, Gamble, Stone;
public string Prefab, Icon, Name, Desc;
public float Scale, UIScale;
public List<StatInfo> list_stat = new List<StatInfo>();
public eEffect Skill;
public void Set_Star(GameObject[] gos_star, UIGrid Grid_Star)
{
DSUtil.InActivateGameObjects(gos_star);
for (int i = 0; i < Star; i++)
gos_star[i].SetActive(true);
Grid_Star.repositionNow = true;
}
public float Get_StatValue(eStat stat, int lv) { return list_stat.Find(f => f.Stat == stat).Get_StatValue(lv); }
}
public class RandomStatTableDataBase : TableDataBase
{
public List<ObscuredULong> StatRange1, StatRange2, StatRange3, StatRange4, StatRange5, StatRange6;
public List<int> Drawlots; // StatRange 별 뽑기 개수
public int Get_StatRange(float _v)
{
if (StatRange1.Find(f => f == _v) > 0f) return 1;
else if (StatRange2.Find(f => f == _v) > 0f) return 2;
else if (StatRange3.Find(f => f == _v) > 0f) return 3;
else if (StatRange4.Find(f => f == _v) > 0f) return 4;
else if (StatRange5.Find(f => f == _v) > 0f) return 5;
return 6;
}
}
public class DamageInfo
{
public Actor Beater;
ObscuredDouble _BaseDmg, _Damage, _PiercingDmg;
public double BaseDmg { get { return _BaseDmg; } set { _BaseDmg = value; _BaseDmg.RandomizeCryptoKey(); } }
public double NoCriDmg;
public double Damage { get { return _Damage; } set { _Damage = value; _Damage.RandomizeCryptoKey(); } }
public double PiercingDmg { get { return _PiercingDmg; } set { _PiercingDmg = value; _PiercingDmg.RandomizeCryptoKey(); } }
public eCC CC;
public eStat Critical = eStat.None;
public string TextColor;
public bool IsDeadByThisDamage, bExtraDmg;
public ProjectileData Beater_pd;
public Action<double> act_returnLastDmg;
public Action<Actor> act_AfterFreezing;
public Action<eStat> act_CriAfterHit;
public float Get_AddValue(eAddExtraType addExtraType)
{
var pd = Beater_pd;
if (!DSUtil.CheckNull(pd))
switch (addExtraType)
{
case eAddExtraType.AddCri_byTonado:
if (pd.IsSkill() && pd.m_SkillListTableData.e_Skill == eEffect.Skill_Tornado)
return pd.CC_AddVal1;
break;
case eAddExtraType.AddCriDmg_byTonado:
if (pd.IsSkill() && pd.m_SkillListTableData.e_Skill == eEffect.Skill_Tornado)
return pd.CC_AddVal2;
break;
case eAddExtraType.AddCRI_Piercing_Multiplier_byTonado:
if (pd.IsSkill() && pd.m_SkillListTableData.e_Skill == eEffect.Skill_Tornado)
return pd.CC_AddDmg;
break;
case eAddExtraType.AddCri_byFireBall:
if (pd.IsSkill() && pd.m_SkillListTableData.e_Skill == eEffect.Skill_Fireball &&
!DSUtil.CheckNull(pd.target) && pd.target.Get_CCData(eCC.Burn).CCTime > 0f)
return pd.CC_AddVal1;
break;
case eAddExtraType.Add_Piercing_Multiplier_bySpiriBless:
if (pd.IsSkill() && pd.m_SkillListTableData.e_Skill == eEffect.Skill_SpiritBless)
return pd.CC_AddVal1;
break;
}
return 0f;
}
public void Cal_Cri(eAttackType attackType, ActorStatInfo statinfo, bool forceCri = false)
{
Critical = eStat.None;
if (attackType == eAttackType.Magic)
{
var addcri = Get_AddValue(eAddExtraType.AddCri_byFireBall);
Critical = forceCri || DSUtil.RandomTrue((float)statinfo.Get_Stat(eStat.M_CRI) + addcri) ? eStat.M_CRI : eStat.None;
if (Critical == eStat.M_CRI)
{
Damage += NoCriDmg * statinfo.Get_Stat(eStat.M_CRI_DMG_Multiplier);
TextColor = DSUtil.Format("{0}<color=#ff00ff> ", Critical);
}
}
else
{
var addcri = Get_AddValue(eAddExtraType.AddCri_byTonado) + Get_AddValue(eAddExtraType.AddCri_byFireBall) +
Beater.Get_CCData(eCC.Cri_Up).CCDmg;
Critical = forceCri || DSUtil.RandomTrue((float)statinfo.Get_Stat(eStat.CRI) + addcri) ? eStat.CRI : eStat.None;
if (Critical == eStat.CRI)
{
var addcridmg = Get_AddValue(eAddExtraType.AddCriDmg_byTonado);
var addcripiercingdmg = Get_AddValue(eAddExtraType.AddCRI_Piercing_Multiplier_byTonado);
Damage += NoCriDmg * (statinfo.Get_Stat(eStat.CRI_DMG_Multiplier) + addcridmg);
TextColor = DSUtil.Format("{0}<color=#ffff00> ", Critical);
PiercingDmg += BaseDmg * (statinfo.Get_Stat(eStat.CRI_Piercing_Multiplier) + addcripiercingdmg);
}
}
if (Critical == eStat.None) TextColor = "";
}
public void Set_Extra(eSkillExtraType extraType)
{
Beater_pd.e_SkillExtraType = extraType;
Beater_pd.m_skillTypeConfigTable = table_skilltypeconfig.Ins.Get_Data_orNull(extraType);
}
public DamageInfo Copy()
{
var dinfo = new DamageInfo
{
Beater = this.Beater, // 참조형이므로 같은 인스턴스를 가리킴 (참조 복사)
Damage = this.Damage, // ObscuredDouble가 struct일 경우 값 복사
PiercingDmg = this.PiercingDmg, // 동일
CC = this.CC, // enum은 값 복사
Critical = this.Critical, // enum은 값 복사
TextColor = this.TextColor, // string은 참조형 (Immutable), 복사 필요 없음
IsDeadByThisDamage = this.IsDeadByThisDamage,
Beater_pd = this.Beater_pd, // 참조형 복사
act_returnLastDmg = act_returnLastDmg,
};
return dinfo;
}
}
public class CCData
{
public bool TimeUpdate;
public ObscuredInt _CCVal;
//ObscuredDouble _CCTime, _CCDelay, _CCDmg, _CCReduceTime;
public void Init()
{
CCVal = 0;
CCTime = CCDelay = CCDmg = CCReduceTime = 0d;
CC1Sec = 0f;
}
public int CCVal { get { return _CCVal; } set { _CCVal = value; _CCVal.RandomizeCryptoKey(); } }
public double CCTime;// { get { return _CCTime; } set { _CCTime = value; _CCTime.RandomizeCryptoKey(); } }
public double CCDelay;// { get { return _CCDelay; } set { _CCDelay = value; _CCDelay.RandomizeCryptoKey(); } }
public double CCDmg;// { get { return _CCDmg; } set { _CCDmg = value; _CCDmg.RandomizeCryptoKey(); } }
public double CCReduceTime;// { get { return _CCReduceTime; } set { _CCReduceTime = value; _CCReduceTime.RandomizeCryptoKey(); } }
public float CC1Sec;
}
public class CountLevelData
{
public ObscuredInt Count, Lv;
public CountLevelData(string _data)
{
var split = _data.Split('|');
Count = int.Parse(split[0]); Count.RandomizeCryptoKey();
Lv = int.Parse(split[1]); Lv.RandomizeCryptoKey();
}
}
public class MobDropItems { public ObscuredDouble Gold, Exp, Stone, Potion, PartyStone, AvatarStone, Gem, DropEvent; }
public class ShieldInfo { public GameObject go; public double rate; }
public class UseMagicInfo { public SkillListTableData m_SkillTableData; public int m_uiIndex; }
public class ItemSimpleData
{
ObscuredInt _itemid;
ObscuredDouble _amount;
public int itemid
{
get { return _itemid; }
set { _itemid = value; _itemid.RandomizeCryptoKey(); }
}
public double amount
{
get { return _amount; }
set { _amount = value; _amount.RandomizeCryptoKey(); }
}
}