protected bool Equals(MagicClass other) { var thisProps = this.AllProperties; var otherProps = other.AllProperties; return(thisProps.SequenceEqual(otherProps)); }
public HealingSpell(int minHeal, int maxHeal, MagicClass magicClass) { this.minHeal = minHeal; this.maxHeal = maxHeal; this.magicClass = magicClass; }
public DamageSpell(int minDmg, int maxDmg, MagicClass magicClass) { this.minDmg = minDmg; this.maxDmg = maxDmg; this.magicClass = magicClass; }
static void Main(string[] args) { WriteLine("Assembly metadata:"); Assembly assembly = Assembly.GetEntryAssembly(); WriteLine($" Full name: {assembly.FullName}"); WriteLine($" Location: {assembly.Location}"); var attributes = assembly.GetCustomAttributes(); WriteLine($" Attributes:"); foreach (Attribute a in attributes) { WriteLine($" {a.GetType()}"); } var version = assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>(); WriteLine($" Version: {version.InformationalVersion}"); var company = assembly.GetCustomAttribute <AssemblyCompanyAttribute>(); WriteLine($" Company: {company.Company}"); WriteLine($"Types:"); Type[] types = assembly.GetTypes(); foreach (Type type in types) { WriteLine($" Name: {type.FullName}"); MemberInfo[] members = type.GetMembers(); foreach (MemberInfo member in members) { WriteLine($" {member.MemberType}: {member.Name} ({member.DeclaringType.Name})"); var coders = member.GetCustomAttributes <CoderAttribute>().OrderByDescending(c => c.LastModified); foreach (CoderAttribute coder in coders) { WriteLine($" Modified by {coder.Coder} on {coder.LastModified.ToShortDateString()}"); } } } // Get the constructor and create an instance of MagicClass var mc = new MagicClass(); var mc2 = new MagicClass2(); string tipo = "MagicClass3"; Type magicType = Type.GetType(tipo); ConstructorInfo magicConstructor = magicType.GetConstructor(Type.EmptyTypes); object magicClassObject = magicConstructor.Invoke(new object[] {}); // Get the ItsMagic method and invoke with a parameter value of 100 MethodInfo magicMethod = magicType.GetMethod("ItsMagic"); object magicValue = magicMethod.Invoke(magicClassObject, new object[] { 100 }); Console.WriteLine("MethodInfo.Invoke() Example\n"); Console.WriteLine($"MagicClass.ItsMagic() returned : {magicValue}"); }
[SerializeField] public List <MagicClass> magicResources; /// public float MakeMagicWithConsumables() /// { List <ConsumableRate> priority = consumablesNeed.OrderBy(x => x.significanceRate).ToList(); Dictionary <ConsumableData, int> inStock = GetConsumablesInStockCount(); magicResources = new List <MagicClass>(); foreach (ConsumableRate conNeed in priority) { MagicClass m = new MagicClass(); m.Resource = conNeed.Resource; if (inStock.ContainsKey(conNeed.Resource)) { if (inStock[conNeed.Resource] >= conNeed.amountRate) { m.spended = conNeed.amountRate; m.remain = inStock[conNeed.Resource] - conNeed.amountRate; } else { m.spended = inStock[conNeed.Resource]; m.penaltyAmount = conNeed.amountRate - inStock[conNeed.Resource]; } } else { m.penaltyAmount = conNeed.amountRate; } magicResources.Add(m); } foreach (var item in inStock) { var r = magicResources.SingleOrDefault(x => x.Resource == item.Key); if (r == null) { MagicClass m = new MagicClass(); m.Resource = item.Key; m.remain = item.Value; magicResources.Add(m); } } // priority.Sort((x, y) => x.significanceRate.CompareTo(y.significanceRate)); foreach (MagicClass mc in magicResources) { foreach (MagicClass mc2 in magicResources) { if (mc != mc2 && mc.penaltyAmount > 0) { ConverterParameter p = mc.Resource.convertingParameters.Parameters.FirstOrDefault(x => x.from == mc2.Resource.convertingParameters); if (p != null && mc2.remain >= p.withCoefficient) { // Debug.Log("found "+mc2.Resource.Name+" for "+mc.Resource.Name+" with coeff = "+p.withCoefficient); int resAmount = mc2.remain / p.withCoefficient; if (resAmount > mc.penaltyAmount) { resAmount = mc.penaltyAmount; } mc2.remain -= resAmount * p.withCoefficient; mc2.spended += resAmount * p.withCoefficient; mc.penaltyAmount -= resAmount; if (mc.penaltyAmount < 0) { mc.penaltyAmount = 0; } } } } } float penalty = 0; foreach (ConsumableRate conNeed in priority) { MagicClass m = magicResources.SingleOrDefault(x => x.Resource == conNeed.Resource); penalty += m.penaltyAmount * conNeed.significanceRate; } ci.AnalyzeConsumablesShortage(penalty); Debug.Log("consumables raw penalty = " + (penalty / GetAffilatedConsumablesNeed())); return(penalty / GetAffilatedConsumablesNeed()); }