/// <summary> /// キャラクターの死亡による離脱処理をおこないます /// </summary> /// <param name="character"> 死亡したキャラクター </param> public void deadCharacter(IBattleable character) { if (!isBattleing) { throw new InvalidOperationException("battle isn't started"); } if (character is Enemy) { this.expSum += ((Enemy)character).getGiveExp(); } removeBalFromJoinedCharacter(character); character.death(); if (isContinuingBattle()) { finishBattle(); } else { var keys = joinedManager.Keys; foreach (long id in keys) { IBattleTaskManager taskManager = joinedManager [id]; taskManager.deleteTaskFromTarget(character); } } }
/// <summary> /// 単体を目標とした初期設定 /// </summary> /// <param name="target">担当するキャラクター</param> /// <param name="manager">元のBattleTaskManager</param> public void setState(IBattleable target, PlayerBattleTaskManager manager) { this.targets.Clear(); this.targets.Add(target); this.manager = manager; targetName.text = target.getName(); }
/// <summary> /// 与えられたAffectSkillが、その使用者によって対象に使用できるかを判定します /// </summary> /// <returns><c>true</c>, 使用可能, <c>false</c> 使用不可</returns> /// <param name="actioner">スキル使用者</param> /// <param name="targets">スキル対象</param> /// <param name="skill">使用するスキル AffectSkillである必要があります</param> public static bool canUseAffectSkill(IBattleable actioner, List <IBattleable> targets, IActiveSkill skill) { if (!isAffectSkill(skill)) { throw new ArgumentException("gave skill isn't an affectSkill"); } //スキル使用者のMPが足りるか if (actioner.getMp() < skill.getCost()) { return(false); } //スキル使用対象はちゃんと存在するか if (targets.Count <= 0) { return(false); } //スキル使用対象まで射程が届くか int actionerPos = (int)BattleManager.getInstance().searchCharacter(actioner); int targetPos = (int)BattleManager.getInstance().searchCharacter(targets[0]); int distance = (actionerPos < targetPos) ? targetPos - actionerPos : actionerPos - targetPos; if (distance > searchRange(skill, actioner)) { return(false); } //以上が満たされればtrue return(true); }
public BattleResult(IBattleable attacker, IBattleable defender, List <AttackResult> battleLog) { _round = 0; Attacker = attacker; Defender = defender; BattleLog = battleLog.Count != 0 ? battleLog : new List <AttackResult>(); }
private void reaction() { IBattleable attacker = prosessingPair.Key; AttackSkill useSkill = prosessingPair.Value; choseReaction = ai.decideReaction(attacker, useSkill); }
/// <summary> /// 指定された範囲内の危険度を計算します /// Rawでないのとの違いは、指定範囲外の危険度を考慮しない点です /// </summary> /// <returns>エリア危険レベルのDictionary</returns> /// <param name="bal">起点となるキャラクター</param> /// <param name="range">検索範囲</param> public Dictionary <FieldPosition, int> getRawAreaDangerLevelTableInRange(IBattleable bal, int range) { Dictionary <FieldPosition, int> dangerLevelTable = new Dictionary <FieldPosition, int>(); FieldPosition nowPos = searchCharacter(bal); int minIndex = restructionPositionValue(nowPos, -range); int maxIndex = restructionPositionValue(nowPos, range); int minAreaLevel = 0; for (int i = minIndex; i < minIndex; i++) { dangerLevelTable.Add((FieldPosition)i, 0); } //レンジ内の危険度計算 for (int i = minIndex; i < minIndex; i++) { int areaLevel = getAreaDangerLevel(bal.getFaction(), (FieldPosition)i); if (areaLevel < minAreaLevel) { minAreaLevel = areaLevel; } dangerLevelTable[(FieldPosition)i] += areaLevel; } var keys = new Dictionary <FieldPosition, int>(dangerLevelTable).Keys; foreach (FieldPosition pos in keys) { dangerLevelTable[pos] -= minAreaLevel; } return(dangerLevelTable); }
/// <summary> /// ターゲットラインを対象の間に引きます /// </summary> /// <param name="user">スキル使用者</param> /// <param name="targets">スキル対象者のリスト</param> private void drawTargetingLine(IBattleable user, List <IBattleable> targets, string lineName, bool isFriendly) { GameObject targetingLinePrefab = (GameObject)Resources.Load("Prefabs/TargetLine"); GameObject attackerModel = user.getContainer().getModel(); List <GameObject> addedLines = new List <GameObject>(); foreach (IBattleable target in targets) { GameObject targetingLine = Instantiate(targetingLinePrefab); TargetLine line = targetingLine.GetComponent <TargetLine>(); GameObject targetModel = target.getContainer().getModel(); line.setState(attackerModel, targetModel, lineName, isFriendly); addedLines.Add(targetingLine); } if (targetLines.ContainsKey(user)) { targetLines[user].AddRange(addedLines); } else { targetLines.Add(user, addedLines); } }
/// <summary> /// 対象を指定された量移動させます /// </summary> /// <param name="bal">移動させるキャラクター</param> /// <param name="moveness">移動させる量</param> public void moveCommand(IBattleable bal, int moveness) { if (!isBattleing) { throw new InvalidOperationException("battle isn't started"); } field.deleteCharacterPos(bal); //引数に渡されたIBattleableキャラの位置を検索 FieldPosition nowPos = searchCharacter(bal); //値が適切か判断 if (Enum.GetNames(typeof(FieldPosition)).Length < (int)(nowPos + moveness)) { throw new ArgumentException("invalid moveness"); } int movePosValue = restructionPositionValue(nowPos, moveness); FieldPosition movePos = (FieldPosition)movePosValue; //移動処理 joinedCharacter [nowPos].Remove(bal); joinedCharacter [movePos].Add(bal); bal.syncronizePositioin(field.getObjectPosition(movePos, bal)); }
void Direct(IBattleable attacker, IBattleable defencer) { attacker.Attack(); var damagePoint = DamagePointCalc(attacker, defencer); defencer.BeDamaged(damagePoint); }
public Battle(IRandom randomDice, IBattleable attacker, IBattleable defender) { _round = 0; _attacker = attacker; _defender = defender; _randomDice = randomDice; _log = new List <AttackResult>(); }
/// <summary> /// 回復処理を行います /// </summary> /// <param name="actioner"> 回復を行うIBattleableキャラクター </param> /// <param name="targets"> 対象のリスト </param> private void heal(IBattleable actioner, List <IBattleable> targets) { foreach (IBattleable target in targets) { int healVal = actioner.getHeal(USE_ABILITY); target.healed(healVal, ATTRIBUTE); } }
private void ResolveAttackPhase(IBattleable a, IBattleable b) { ResolveAttack(a, b); if (b.IsAlive()) { ResolveAttack(b, a); } }
/// <summary> /// スキルのターゲットラインを削除します /// </summary> private void deleteTargetingLine(IBattleable user) { if (targetLines.ContainsKey(user)) { Destroy(targetLines[user][0]); targetLines[user].Remove(targetLines[user][0]); } }
public int DamagePointCalc(IBattleable attacker, IBattleable defencer) { int iryoku = 50; float ransu = DamageRatioGenerator(); var damagePoint = ((attacker.level * 2 / 5 + 2) * (iryoku * attacker.attackPoint / defencer.defencePoint) / 50 + 2) * ransu; return((int)damagePoint); }
/// <summary> /// 移動量の最大値を取得します /// </summary> /// <returns> スキルの移動量 </returns> public int getMove(IBattleable actioner) { int moveBonus = 0; int abilityVal = actioner.getAbilityContainsBonus(USE_ABILITY); moveBonus += abilityVal / 3 + 1; return(MOVE + moveBonus); }
/// <summary> /// 攻撃力を取得します /// </summary> /// <returns> 攻撃力 </returns> public int getAtk(IBattleable actioner) { int dammage = atk + actioner.getAtk(getAttackSkillAttribute(), getUseAbility(actioner), DEPEND_ATK); if (actioner is Enemy) { ((Enemy)actioner).progressAboutAttack(dammage); } return(dammage); }
/// <summary> /// 射程を取得します /// </summary> /// <returns> 射程 </returns> /// <param name="actioner"> 射程を算出したいIBattleableキャラクター </param> public int getRange(IBattleable actioner) { int bonus = 0; if (DEPEND_RANGE) { bonus += actioner.getCharacterRange(); } return(this.RANGE + bonus); }
public float getDelay(IBattleable actioner) { float bonus = 0; if (DEPEND_DELAY) { bonus += actioner.getCharacterDelay(); } return(this.delay + bonus); }
/// <summary> /// IDからActiveSkillSetを取得します /// </summary> /// <returns>指定されたActiveSkillSet</returns> /// <param name="id">取得したいActiveSkillSetのリスト</param> /// <param name="user">使用者</param> public ActiveSkillSet getActiveSkillSetFromId(int id, IBattleable user) { foreach (ActiveSkillSetBuilder builder in dataTable) { if (builder.getId() == id) { return(builder.build(user)); } } throw new ArgumentException("invlit id"); }
/// <summary> /// AIをidから取得します /// </summary> /// <returns>オーダーされたAI</returns> /// <param name="id">取得したいAIのID</param> /// <param name="user">AIを設定したいIBattleableオブジェクト</param> /// <param name="activeSkills">userのActiveSkillSet.</param> /// <param name="reactionSkills">userのReactionSkillSet.</param> public IEnemyAI getAiFromId(int id, IBattleable user, ActiveSkillSet activeSkills, ReactionSkillSet reactionSkills) { foreach (IEnemyAIBuilder builder in summarizingAI) { if (builder.getId() == id) { return(builder.build(user, activeSkills, reactionSkills)); } } throw new ArgumentException("invalid aiId"); }
/// <summary> /// 判定に使う能力値を取得します /// </summary> /// <returns> 判定に使う能力値 使用者依存ならNONEを返します </returns> public BattleAbility getUseAbility(IBattleable actoiner) { if (DEPEND_ABILITY) { return(actoiner.getCharacterAttackMethod()); } else { return(this.USE_ABILITY); } }
public void action(IBattleable actioner, BattleTask task) { if (ActiveSkillSupporter.canUseAffectSkill(actioner, task.getTargets(), this)) { return; } observer.used(); setBounsToCharacter(task.getTargets()); actioner.minusMp(cost); }
public void action(IBattleable actioner, BattleTask task) { //MPが足りないと終わり if (actioner.getMp() < this.COST) { return; } move(actioner, task.getMove()); actioner.minusMp(this.COST); }
/// <summary> /// 渡されたIActiveSkillからmoveを検出します /// </summary> /// <returns> 検出したmove</returns> /// <param name="skill"> 検索したいIActiveSkill </param> public static int searchMove(IActiveSkill skill, IBattleable actoiner) { if (skill.getActiveSkillType() == ActiveSkillType.MOVE) { MoveSkill moveSkill = (MoveSkill)skill; return(moveSkill.getMove(actoiner)); } else { throw new ArgumentException("invalid skill " + skill); } }
public void action(IBattleable actioner, BattleTask task) { if (!ActiveSkillSupporter.canUseAffectSkill(actioner, task.getTargets(), this)) { return; } attack(actioner, task.getTargets()); actioner.minusMp(this.cost); observer.used(); }
/// <summary> /// 渡されたキャラクターをバトルから削除します /// </summary> /// <param name="bal">削除するキャラクター</param> private void removeBalFromJoinedCharacter(IBattleable bal) { if (!isBattleing) { throw new InvalidOperationException("battle isn't started"); } FieldPosition pos = searchCharacter(bal); joinedCharacter [pos].Remove(bal); joinedManager[bal.getUniqueId()].finished(); joinedManager.Remove(bal.getUniqueId()); }
/// <summary> /// ダメージを与えられます /// </summary> private void dammage() { IBattleable attacker = prosessingPair.Key; AttackSkill useSkill = prosessingPair.Value; int atk = useSkill.getAtk(attacker); int hit = useSkill.getHit(attacker); choseReaction.reaction(user, atk, hit, useSkill.getAttackSkillAttribute()); waitingReactionActiveSkills.Remove(prosessingPair); updateProsessingPair(); choseReaction = ReactionSkillMasterManager.getInstance().getReactionSkillFromId(2); }
/// <summary> /// 攻撃を行います /// </summary> /// <param name="bal"> 攻撃を行うIBattleableキャラクター </param> /// <param name="targets"> 攻撃の対象のリスト </param> private void attack(IBattleable bal, List <IBattleable> targets) { if (targets.Count <= 0) { throw new InvalidOperationException("invlid battleTask operation"); } foreach (IBattleable target in targets) { //対象のリアクション IBattleTaskManager targetManager = BattleManager.getInstance().getTaskManager(target.getUniqueId()); targetManager.offerReaction(bal, this); } }
/// <summary> /// BattleTaskを生成します /// </summary> /// <returns>生成したタスク</returns> private BattleTask creatTask() { if (!isReady) { throw new InvalidOperationException("manager hasn't readied yet"); } IActiveSkill skill = ai.decideSkill(); if (ActiveSkillSupporter.isAffectSkill(skill)) { Extent extent = ActiveSkillSupporter.searchExtent(skill); BattleTask returnTask; //効果範囲に応じてタスクを生成 switch (extent) { case Extent.SINGLE: IBattleable target = ai.decideSingleTarget(skill); List <IBattleable> singleTargetList = new List <IBattleable>() { target }; returnTask = new BattleTask(user.getUniqueId(), skill, singleTargetList, battletaskIdCount); break; case Extent.AREA: FieldPosition pos = ai.decideAreaTarget(skill); returnTask = new BattleTask(user.getUniqueId(), skill, pos, battletaskIdCount); break; case Extent.ALL: List <IBattleable> allTargetList = BattleManager.getInstance().getJoinedBattleCharacter(); returnTask = new BattleTask(user.getUniqueId(), skill, allTargetList, battletaskIdCount); break; default: throw new NotSupportedException("unkonwn extent"); } battletaskIdCount++; return(returnTask); } else if (skill.getActiveSkillType() == ActiveSkillType.MOVE) { MoveSkill moveSkill = (MoveSkill)skill; int move = ai.decideMove(moveSkill); BattleTask returnTask = new BattleTask(user.getUniqueId(), skill, move, battletaskIdCount); battletaskIdCount++; return(returnTask); } throw new InvalidOperationException("unknown skillType"); }
public void offerReaction(IBattleable attacker, AttackSkill skill) { KeyValuePair <IBattleable, AttackSkill> pair = new KeyValuePair <IBattleable, AttackSkill>(attacker, skill); waitingDecideReactionSkills.Add(pair); List <IBattleable> drawLineTarget = new List <IBattleable>() { player }; drawTargetingLine(attacker, drawLineTarget, skill.getName(), skill.isFriendly()); updateProsessingPair(); }