public void SetBuff(UnitBuffType buffType) { if (localBuff == UnitBuffType.NONE) { this.localBuff = buffType; } }
static Text TextForBuffType(UnitView view, UnitBuffType type) { switch (type) { case UnitBuffType.Attack: return(view.attack); case UnitBuffType.Defence: return(view.defence); case UnitBuffType.Hp: return(view.hp); default: throw new ArgumentOutOfRangeException("type", type, null); } }
static Cell <int> StatForBuffType(Unit unit, UnitBuffType type) { switch (type) { case UnitBuffType.Attack: return(unit.attack); case UnitBuffType.Defence: return(unit.defence); case UnitBuffType.Hp: return(unit.hp); default: throw new ArgumentOutOfRangeException("type", type, null); } }
public static Color GetColorByBuffType(UnitBuffType t) { switch (t) { case UnitBuffType.INCREASE_FACTORY: return(GetColorByType(UnitType.Mine)); case UnitBuffType.INCREASE_GRASS: return(GetColorByType(UnitType.Grass)); default: return(Color.white); } }
static ICell <int> FinalStat(Unit unit, Equipment eq, UnitBuffType buffType) { // selected unit can be null. if (unit == null) { return(StaticCell <int> .Default()); } var stat = StatForBuffType(unit, buffType); // If equipment does not buff this stat return just stat. if (eq == null || eq.type != buffType) { return(stat); } // If equipment stat match this kind of stat merge those. return(stat.Merge(eq.buff, (s, buff) => s + buff)); }