private static IList<WarMagicData> CreateAbnormalConditionMagic(MagicData magic, bool isChipEffect, IAbnormalCondition cond, TargetType targetType) { var name = magic.Name; var description = magic.Description; var cores = magic.Cores; var magicDatas = new List<WarMagicData>(cores.Length); foreach (var core in cores) { // 行為の範囲や対象を設定する IScope scope; if (core.Area != 0) scope = new DefaultScope(core.Range, core.Area, targetType); else scope = new WholeScope(targetType); // 画面効果を設定する var screenEffect = CreateScreenEffect(magic, isChipEffect); // 消費MPの設定 var consumption = new MPCost(core.MPCost); // 行為の設定 var action = new GiveAbnormalConditionAction(scope, consumption, screenEffect, cond); // 魔法データを作成する var magicData = new WarMagicData(name, description, action, core.MPCost, core.Area, core.Range); magicDatas.Add(magicData); } return magicDatas; }
public GiveAbnormalConditionAction(IScope scope, ICost cost, IScreenEffect screenEffect, IAbnormalCondition cond) { _scope = scope; _cost = cost; _screenEffect = screenEffect; _cond = cond; }
public bool AddingConditonTable(Situation situation, WarUnit unit, IAbnormalCondition oldCond) { Contract.Requires(oldCond.GetType() == GetType()); var cond = (AttackCountChangeCondition)oldCond; var newCount = cond._changeAttackCount + _changeAttackCount; // 変化量が0ならば削除、そうでなければ値を更新 if (newCount == 0) unit.Conditions.Remove(ID, situation); else cond._changeAttackCount = _changeAttackCount; return false; }
/// <summary> /// ユニットに状態異常が追加される直前に呼び出される。 /// </summary> /// <param name="situation"></param> /// <param name="unit"></param> /// <param name="oldCond"></param> public bool AddingConditonTable(Situation situation, WarUnit unit, IAbnormalCondition oldCond) { Contract.Requires(oldCond.GetType() == GetType()); var cond = (StatusChangeCondition)oldCond; // 効果がお互いに反対であった場合は状態異常を消す if (_changeStatusValue * cond._changeStatusValue < 0) { unit.Conditions.Remove(ID, situation); } // そうでない場合は、効果が大きいほうで上書きする else if (Math.Abs(_changeStatusValue) > Math.Abs(cond._changeStatusValue)) { cond._changeStatusValue = _changeStatusValue; } return false; }
/// <summary> /// ユニットに状態異常が追加される直前に呼び出される。 /// </summary> /// <param name="situation"></param> /// <param name="unit"></param> public bool AddingConditonTable(Situation situation, WarUnit unit, IAbnormalCondition oldCond) { return false; }
public bool TryGet(string id, out IAbnormalCondition cond) { return _conditions.TryGetValue(id, out cond); }
/// <summary> /// 新たな状態異常を追加する /// </summary> /// <param name="cond"></param> /// <param name="situation"></param> public void Add(IAbnormalCondition cond, Situation situation) { IAbnormalCondition existingCond; if (!_conditions.TryGetValue(cond.ID, out existingCond) || cond.AddingConditonTable(situation, _unit, existingCond)) { _conditions[cond.ID] = cond; cond.AddedConditonTable(situation, _unit); } }