Created
February 2, 2018 19:38
-
-
Save efarraro/19ebf3c3c33aee24d6384f85a4a944a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System; | |
using System.Runtime.Serialization; | |
[Serializable] | |
public class BaseEffect { | |
[NonSerialized] | |
public Unit AttachedUnit; | |
[NonSerialized] | |
public AbilityData Ability; | |
[NonSerialized] | |
public BaseEffect ParentEffect; // for buff, the effect that created it | |
[NonSerialized] | |
public StoneView View; | |
public int Duration; | |
private bool _isPresentAtStartOfTurn; // indicates if this buff was present at the start of the attached unit's turn | |
public void Attach(AbilityData ability) | |
{ | |
Ability = ability; | |
ability.Effect = this; | |
} | |
public virtual void OnRemoval() { } | |
public string Name | |
{ | |
get { return EffectName(); } | |
} | |
public virtual string EffectName() { return string.Empty; } | |
public virtual void BeforeTurn() | |
{ | |
_isPresentAtStartOfTurn = true; | |
} | |
public virtual void AfterTurn() | |
{ | |
if (_isPresentAtStartOfTurn) | |
{ | |
Duration--; | |
} | |
SyncView(); | |
} | |
public virtual bool IsBuff | |
{ | |
get | |
{ | |
return true; | |
} | |
} | |
public virtual bool CanPlay | |
{ | |
get | |
{ | |
return true; | |
} | |
} | |
public virtual string CantPlayReason | |
{ | |
get | |
{ | |
return string.Empty; | |
} | |
} | |
public void DisableInteraction() | |
{ | |
Ability.View.gameObject.GetComponent<ChoiceView>().IsDisabled = true; | |
} | |
public virtual string SpriteName | |
{ | |
get { return Ability.Sprite; } | |
} | |
public virtual string BuffRepresentation | |
{ | |
get { return Duration + ""; } | |
} | |
// does something immediately when the card is drawn | |
public virtual void OnDrawn() { } | |
public virtual int BonusAttackDamage() { return 0; } | |
public virtual int BonusDamageReduction() { return 0; } | |
public virtual int BlockDamageIfApplicable(int damage) { return damage; } | |
public virtual int ChanceToAvoidAttack() { return 0; } | |
public virtual int BonusSpeed() { return 0; } | |
public virtual void AfterCardDiscarded(AbilityData discardedCard) { } | |
public virtual int CostReduction() { return 0; } | |
public virtual CostType ForceCostType() { return CostType.None; } | |
public virtual void OnAttackTarget(Unit attacker, Unit defender, AbilityData card) { } | |
public virtual void OnAttacked(Unit attacker, Unit defender, AbilityData card) { } | |
public virtual void OnAttachToUnit() { } | |
public virtual void OnAttackDamageDealt(int damage) { } | |
public virtual void OnAttackDamageReceived(int damage) { } | |
public virtual int BonusSpellDamage() { return 0; } | |
public virtual void Apply() { } | |
public virtual void OnHealed() { } | |
public virtual void OnOpponentDrewCard(AbilityData data) { } | |
public virtual void OnCardDrawn(AbilityData data) { } | |
public virtual int BonusStaminaWhenResting | |
{ | |
get | |
{ | |
return 0; | |
} | |
} | |
public virtual DamageType Immunity { | |
get { | |
return DamageType.None; | |
} | |
} | |
public virtual DamageType Vulnerability { | |
get { | |
return DamageType.None; | |
} | |
} | |
// notify the effect that it was applied to a calculation (some buffs may decrease duration on use) | |
public virtual void NotifyApplied() { } | |
public virtual float DamageMultiplier { get { return 0; } } | |
public virtual string CustomDescription() { | |
int level = Ability != null ? Ability.Level : 0; | |
return DescriptionForLevel(level); | |
} | |
public virtual string UpgradeDescription() { return DescriptionForLevel(Ability.Level + 1); } | |
public virtual string DescriptionForLevel(int level) | |
{ | |
if (ParentEffect != null) | |
{ | |
return ParentEffect.DescriptionForLevel(level); | |
} | |
return string.Empty; | |
} | |
public virtual void AfterCardPlayed(AbilityData data) { } | |
public virtual void AfterOpponentCardPlayed(AbilityData data) { } | |
public virtual void Merge(BaseEffect effect) { | |
Duration += effect.Duration; | |
SyncView(); | |
} | |
protected void SyncView() | |
{ | |
if (View != null) | |
{ | |
//View.Sync(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment