public bool EnoughLevel(Action predicate = null) { var result = false; own.GetModule <LevelModule> (x => { result = x.level >= level; }); if (result && predicate != null) { predicate.Invoke(); } return(result); }
public static void Calculate(float bonusDamage, Race attacker, Race[] targets) { var stat = attacker.GetModule <StatModule> (); foreach (var target in targets) { var targetStat = target.GetModule <StatModule> (); var isHit = AccuracyCalculator.IsHit(stat.attackRating, targetStat.attackRating); isHit = !isHit?AccuracyCalculator.MakeSureHit(attacker) : isHit; if (isHit) { var isCritHit = AccuracyCalculator.IsCriticalHit(attacker, stat.criticalRating); isCritHit = !isCritHit?AccuracyCalculator.MakeSureCritical(attacker) : isCritHit; // optional Damage var outputDamage = AttackPowerCalculator.TakeDamage(bonusDamage, targetStat.magicResist, isCritHit); AccuracyCalculator.HandleCriticalDamage(ref outputDamage, attacker, target); AttackPowerCalculator.HandleDamage(ref outputDamage, attacker, target); target.GetModule <HealthPowerModule> (x => x.SubtractHp(outputDamage)); } else { var isCritHit = AccuracyCalculator.IsCriticalHit(attacker, stat.criticalRating); var damage = AttackPowerCalculator.TakeDamage(bonusDamage, targetStat.physicalDefend, isCritHit); Affect.GetSubAffects <IMissingHandler>(target, handler => handler.HandleMissing(damage, attacker)); } } }
public static void RemoveAffect <T>(Race who) where T : Affect { var affectModule = who.GetModule <AffectModule> (); affectModule.GetAffects <T> (x => Destroy(x.gameObject)); affectModule.RefreshAffect(); }
public static void RemoveAffect(Race who, Affect affect) { var affectModule = who.GetModule <AffectModule> (); Destroy(affect.gameObject); affectModule.RefreshAffect(); }
public override void Buy(Race who, float price = 0f, int quantity = 0) { BuyAndUseImmediately <SwordItem> (who, new Race[] { who }, price, a => { AlternateInStoreState(); who.GetModule <GearModule> (x => { if (x.weapon != null) { x.weapon.Disuse(); } }); a.title = title; a.brief = brief; a.gearType = gearType; a.upgradePrice = this.price; who.GetModule <GearModule>(x => x.weapon = a); }); }
public static T[] GetSubAffects <T>(Race who, Action <T> predicate = null) { T[] result = new T[0]; who.GetModule <AffectModule> ((a) => { result = a.GetSubAffects <T>(predicate); }); return(result); }
public static void ExtraAttackableAffect(Race own, Race target) { own.GetModule <AffectModule>(am => { am.GetSubAffects <IAttackableAffect>(a => { a.AssignAttackableAffect(target); }); }); }
public static bool MakeSureCritical(Race own) { var result = false; own.GetModule <AffectModule> (am => { result = am.HasSubAffect <ICritical>(); }); return(result); }
public void SubtractGold(Race who, float price = 0f, int quantity = 0) { var p = price <= 0f ? this.price : price; var q = quantity <= 0 ? this.quantity : quantity; who.GetModule <GoldModule> ((g) => { g.SubtractGold(p * q); }); }
bool TryToConnect() { return(NetworkHelper.instance.TryToConnect(() => { if (!_character.IsNull() && !_countdownModule.IsNull() && !_refereeModule.IsNull()) { return true; } _character = Race.GetLocalCharacter(); if (_character.IsNull()) { return false; } _countdownModule = _character.GetModule <CountdownNetworkModule>(); _refereeModule = _character.GetModule <RefereeModule>(); return false; })); }
bool TryToConnect() { return(NetworkHelper.instance.TryToConnect(() => { if (!_character.IsNull() && !_goldModule.IsNull() && !_energyModule.IsNull()) { return true; } _character = Race.GetLocalCharacter(); if (_character.IsNull()) { return false; } _goldModule = _character.GetModule <GoldModule>(); _energyModule = _character.GetModule <EnergyModule>(); return false; })); }
bool TryToConnect() { return(NetworkHelper.instance.TryToConnect(() => { if (!_character.IsNull() && !_levelModule.IsNull() && !_hpModule.IsNull() && !_energyModule.IsNull()) { return true; } _character = Race.GetOpponentCharacter(); if (_character.IsNull()) { return false; } _levelModule = _character.GetModule <LevelModule>(); _hpModule = _character.GetModule <HealthPowerModule>(); _energyModule = _character.GetModule <EnergyModule>(); return false; })); }
public override void Pick(Race who, int quantity) { var skillModule = who.GetModule <SkillModule> (); if (skillModule.evolvedSkillPoint <= 0) { return; } who.GetModule <SkillModule> (x => x.Add <SwordmanD1Skill> (quantity, t => { t.icon = icon; t.title = title; t.brief = brief; t.cooldown = cooldown; t.level = learnedLevel; t.gainPoint = gainPoint; })); --skillModule.evolvedSkillPoint; enabled = false; }
public static void HandleAccuracy(ref float accuracy, Race own, Race target) { var _ = float.MinValue; own.GetModule <AffectModule>(am => { am.GetSubAffects <IAccurate>(a => { _ = Mathf.Max(_, a.HandleAccuracy(target)); }); }); accuracy = Mathf.Max(_, accuracy); }
public static bool HasAffect <T>(Race who, Action <T> predicate = null) where T : Affect { var affectModule = who.GetModule <AffectModule> (); var result = affectModule != null && affectModule.HasAffect <T> (); if (result && predicate != null) { GetAffects <T>(who, predicate); } return(result); }
public static void HandleResistance(ref float extraResistance, Race own, Race target) { var _ = float.MinValue; own.GetModule <AffectModule>(am => { am.GetSubAffects <IResistant>(a => { _ = Mathf.Max(_, a.HandleResistance(target)); }); }); extraResistance = Mathf.Max(_, extraResistance); }
public void Buy <T>(Race who, float price = 0f, int quantity = 0, Action <T> predicate = null, Action postBuying = null) where T : Item { EnoughGold(who, price, quantity, () => { who.GetModule <BagModule>(i => i.Add <T>(quantity, predicate)); SubtractGold(who, price, quantity); if (postBuying != null) { postBuying.Invoke(); } }); }
public static void HandleCriticalDamage(ref float damage, Race own, Race target) { var _ = float.MinValue; var d = damage; own.GetModule <AffectModule> (am => { am.GetSubAffects <ICriticalHandler>(c => { _ = Mathf.Max(_, c.HandleCriticalDamage(d, target)); }); }); damage = Mathf.Max(_, damage); }
public float HandleDamage(float damage, Race target) { var result = 0f; target.GetModule <AffectModule> (x => { if (x.HasSubAffect <INegativeAffect>()) { result = damage + damage * 1.5f; } }); return(result); }
public static void AssignDamage(ref float attackDamage, Race own) { var _ = float.MinValue; own.GetModule <AffectModule>(am => { am.GetSubAffects <IAssignableDamage>(a => { _ = Mathf.Max(_, a.AssignDamage()); }); }); attackDamage = Mathf.Max(_, attackDamage); }
public override void Pick(Race who, int quantity) { who.GetModule <SkillModule> (x => x.Add <SwordmanA1Skill> (quantity, t => { t.icon = icon; t.title = title; t.brief = brief; t.gainPoint = gainPoint; t.level = learnedLevel; t.cooldown = cooldown; t.energy = reducedEnergy; t.effectType = effectType; })); }
public static BoughtItem[] GetFor(Race who) { var result = new BoughtItem[0]; who.GetModule <LevelModule>(lv => { var level = lv.level; if (Mathf.Clamp(level, 1, 6) == level) { result = GetTreasuresInTier(Tier1()); return; } else if (Mathf.Clamp(level, 7, 9) == level) { var p = Probability.Initialize(new float[] { 80f, 20f }); var i = Probability.GetValueInProbability(p); if (i == 0) { result = GetTreasuresInTier(Tier1()); return; } if (i == 1) { result = GetTreasuresInTier(Tier2()); return; } } else { var p = Probability.Initialize(new float[] { 40f, 40f, 20f }); var i = Probability.GetValueInProbability(p); if (i == 0) { result = GetTreasuresInTier(Tier1()); return; } if (i == 1) { result = GetTreasuresInTier(Tier2()); return; } if (i == 2) { result = GetTreasuresInTier(Tier3()); return; } } }); return(result); }
public bool EnoughGold(Race who, float price = 0f, int quantity = 1, Action predicate = null) { var enough = false; var p = price < 0f ? this.price : price; var q = quantity < 0 ? this.quantity : quantity; who.GetModule <GoldModule> ((g) => { enough = g.gold >= p * q; }); if (enough && predicate != null) { predicate.Invoke(); } return(enough); }
bool TryToConnect() { return(NetworkHelper.instance.TryToConnect(() => { if (_character != null && _statModule != null) { return true; } _character = Race.GetLocalCharacter(); if (_character == null) { return false; } _statModule = _character.GetModule <StatModule> (); return false; })); }
bool TryToConnect() { return(NetworkHelper.instance.TryToConnect(() => { if (_character != null && _levelModule != null) { return true; } _character = Race.GetOpponentCharacter(); if (_character == null) { return false; } _levelModule = _character.GetModule <LevelModule>(); return false; })); }
bool TryToConnect() { return(NetworkHelper.instance.TryToConnect(() => { if (_character != null && _energyModule != null) { return true; } isInit = false; _character = Race.GetOpponentCharacter(); if (_character == null) { return false; } _energyModule = _character.GetModule <EnergyModule>(); return false; })); }
bool TryToConnect() { return(NetworkHelper.instance.TryToConnect(() => { if (_character != null && _hpModule != null) { return true; } isInit = false; _character = Race.GetLocalCharacter(); if (_character == null) { return false; } _hpModule = _character.GetModule <HealthPowerModule>(); return false; })); }
public static bool IsDodgeable(Race own, Race target) { var _ = 0f; target.GetModule <AffectModule>(am => { am.GetSubAffects <IDodgeableChance>(a => { _ = Mathf.Min(_, a.dodgeChance); }); }); var percents = new float[] { _, 100f - _ }; // init accuracy values var accuracies = new bool[] { true, false }; var arr = Probability.Initialize(accuracies, percents); var index = Random.Range(0, arr.Length - 1); return(arr [index]); }
void Update() { if (!NetworkHelper.instance.TryToConnect(() => { if (_character != null && _skillModule != null) { return(true); } _character = Race.GetLocalCharacter(); if (_character == null) { return(false); } _skillModule = _character.GetModule <SkillModule>(); return(false); })) { return; } }
public override void Pick(Race who, int quantity) { var skillModule = who.GetModule <SkillModule> (); if (skillModule.evolvedSkillPoint <= 0) { return; } BuyAndUseImmediately <SwordmanB1Skill> (who, new Race[] { who }, 0f, t => { t.icon = icon; t.title = title; t.brief = brief; t.cooldown = cooldown; t.level = learnedLevel; t.gainPoint = gainPoint; t.energy = reducedEnergy; }); --skillModule.evolvedSkillPoint; enabled = false; }