/// <summary> /// 攻撃先の戦闘結果のシーケンスを作成 /// </summary> /// <param name="battleResultSet"></param> /// <param name="battleResult"></param> /// <returns></returns> private Sequence CreateToSequence(BattleResultSet battleResultSet, BattleResult battleResult) { RectTransform rectTo = battleResult.ToMonster.GameObject.GetComponent <RectTransform>(); // toのシーケンスの作成 Sequence seqTo = DOTween.Sequence(); // 待機 Tweener stayTo = rectTo.DOMove(rectTo.position, GetShakeStartDuration()); seqTo.Append(stayTo); // シェイクのシーケンス Sequence shakeSeq = DOTween.Sequence(); // モンスターのシェイク shakeSeq.Join(CreateMonsterShakeTween(battleResult, rectTo)); // パネルのシェイク shakeSeq.Join(CreatePanelShakeTween(battleResultSet, battleResult)); seqTo.Append(shakeSeq); return(seqTo); }
/// <summary> /// パネルが左側のモンスターかどうか /// </summary> /// <param name="battleResultSet"></param> /// <param name="monster"></param> /// <returns></returns> private bool IsLeftMonster(BattleResultSet battleResultSet, BattleMapMonster monster) { // 選択されたモンスターと同じなら if (battleResultSet.TargetMonster == monster) { return(true); } return(false); }
/// <summary> /// 戦闘の実行 /// </summary> /// <param name="actionStatus"></param> /// <returns></returns> public BattleResultSet Battle(BattleMapActionStatus actionStatus) { // 順番を作成 List <BattleResult> orderList = orderListCreator.Create(actionStatus); // 戦闘処理 BattleResultSet battleResultSet = Battle(actionStatus, orderList); return(battleResultSet); }
/// <summary> /// カメラを寄せるセンター位置を作成 /// </summary> /// <returns></returns> private Vector3 CreateCenterPosition(BattleResultSet battleResultSet) { Vector3 pos1 = battleResultSet.TargetMonster.GameObject.transform.position; Vector3 pos2 = battleResultSet.OpponentMonster.GameObject.transform.position; Vector3 center = Vector3.Lerp(pos1, pos2, 0.5f); center.z = -10; return(center); }
/// <summary> /// 戦闘 /// </summary> public void Battle() { // エフェクトの残りを削除 particleSystemPrefabHolder.DestroyEffect(); // 戦闘の実行 BattleResultSet battleResultSet = battleProcessor.Battle(holder.BattleMapStatus.BattleMapActionStatus); // 戦闘結果の描画 DrawBattleResultSet(battleResultSet); }
/// <summary> /// 後処理のシーケンスを作成 /// </summary> /// <param name="battleResultSet"></param> /// <returns></returns> public Sequence CreateAfterSequence(BattleResultSet battleResultSet) { Sequence seq = DOTween.Sequence(); // カメラ位置を戻す Transform cameraTransform = bc.cameraController.GetTransform(); seq.Join(CreateCameraMoveTween(cameraTransform, originalCameraPosition)); // ズームを戻す Camera camera = bc.cameraController.GetCamera(); seq.Join(CreateCameraZoomTween(camera, originalCameraFov)); return(seq); }
/// <summary> /// パネルオペレーターを取得 /// </summary> /// <param name="battleResultSet"></param> /// <param name="battleResult"></param> /// <returns></returns> private BattleMapStatusPanelObject GetPanelObject(BattleResultSet battleResultSet, BattleResult battleResult) { // パネルを取得 BattleMapStatusPanelOperator panelOperator = null; if (IsLeftMonster(battleResultSet, battleResult.ToMonster)) { panelOperator = bc.statusGenerator.GetStatusPanelOperator(); } else { panelOperator = bc.statusGenerator.GetStatusPanelOperatorReserve(); } return(panelOperator.GetStatusPanelObject()); }
/// <summary> /// 戦闘処理 /// </summary> /// <param name="actionStatus"></param> /// <param name="orderList"></param> /// <returns></returns> private BattleResultSet Battle(BattleMapActionStatus actionStatus, List <BattleResult> orderList) { BattleResultSet result = new BattleResultSet(); result.TargetMonster = actionStatus.TargetMonster; result.OpponentMonster = actionStatus.OpponentMonster; List <BattleResult> resultList = new List <BattleResult>(); foreach (BattleResult battleResult in orderList) { // TODO: スキルの威力未考慮 // TODO: // 攻撃力 int atk = battleResult.FromMonster.BattleStatus.Atk; // ダメージ int hp = battleResult.ToMonster.BattleStatus.Hp - atk; battleResult.ToDamage = atk; if (hp <= 0) { hp = 0; battleResult.ToDown = true; } // 結果を反映 battleResult.ToMonster.BattleStatus.Hp = hp; resultList.Add(battleResult); // どちらかが倒れていれば終了 if (battleResult.FromDown || battleResult.ToDown) { break; } } result.ResultList = resultList; return(result); }
/// <summary> /// パネルのシーケンスを作成 /// </summary> /// <param name="battleResultSet"></param> /// <param name="battleResult"></param> /// <returns></returns> private Sequence CreatePanelSequence(BattleResultSet battleResultSet, BattleResult battleResult) { // 矢印パネルを作成 if (arrowPanelGameObject == null) { arrowPanelGameObject = bc.statusPrefabHolder.InstantiateArrow(); arrowPanelGameObject.SetActive(false); } RectTransform rect = arrowPanelGameObject.GetComponent <RectTransform>(); Sequence seq = DOTween.Sequence(); float startPosX = -ARROW_ORIGINAL_POS_X; float scaleX = 1; // 矢印の向きが逆の場合 if (IsLeftMonster(battleResultSet, battleResult.FromMonster) == false) { startPosX = -startPosX; scaleX = -1; } // 矢印の移動 Tweener moveArrow = rect.DOAnchorPos(new Vector2(0, ARROW_POS_Y), bc.GetBaseDuration() * 2); moveArrow.SetEase(Ease.OutQuint); seq.Append(moveArrow); seq.OnStart(() => { arrowPanelGameObject.SetActive(true); rect.anchoredPosition = new Vector2(startPosX, ARROW_POS_Y); rect.localScale = new Vector3(scaleX, rect.localScale.y, rect.localScale.z); }); seq.OnComplete(() => { arrowPanelGameObject.SetActive(false); }); return(seq); }
/// <summary> /// パネルのシェイクのTweenを作成 /// </summary> /// <param name="battleResultSet"></param> /// <param name="battleResult"></param> /// <returns></returns> private Sequence CreatePanelShakeTween(BattleResultSet battleResultSet, BattleResult battleResult) { BattleMapStatusPanelObject panelObject = GetPanelObject(battleResultSet, battleResult); RectTransform rectPanel = panelObject.GameObject.GetComponent <RectTransform>(); Sequence seq = DOTween.Sequence(); // パネルのシェイク Tweener shakePanel = rectPanel.DOShakeAnchorPos(bc.GetBaseDuration(), SHAKE_POWER * 40); seq.Append(shakePanel); // HPを減らす int hp = int.Parse(panelObject.HpSubText.text); int damage = battleResult.ToDamage; int restHp = hp - damage; if (restHp < 0) { restHp = 0; } Tween tween = DOTween.To( () => hp, (v) => { hp = v; panelObject.HpSubText.text = "" + v; }, restHp, 1.0f); tween.SetEase(Ease.Linear); seq.Append(tween); return(seq); }
/// <summary> /// 戦闘結果のシーケンスを作成 /// </summary> /// <param name="battleResultSet"></param> /// <param name="battleResult"></param> /// <returns></returns> public Sequence CreateSequence(BattleResultSet battleResultSet, BattleResult battleResult) { Sequence seq = DOTween.Sequence(); // 戦闘元の描画 seq.Join(CreateFromSequence(battleResultSet, battleResult)); // 戦闘先の描画 seq.Join(CreateToSequence(battleResultSet, battleResult)); // パネル seq.Join(CreatePanelSequence(battleResultSet, battleResult)); // どちらかがダウンしていたら if (battleResult.IsDown()) { seq.Append(CreateDownSequence(battleResult)); } return(seq); }
/// <summary> /// 前処理のシーケンスを作成 /// </summary> /// <param name="battleResultSet"></param> /// <param name="battleMapSetting"></param> /// <returns></returns> public Sequence CreatePreSequence(BattleResultSet battleResultSet, BattleMapSetting battleMapSetting) { Sequence seq = DOTween.Sequence(); // カメラ位置 Transform cameraTransform = bc.cameraController.GetTransform(); // 元のカメラ位置を覚えておく this.originalCameraPosition = cameraTransform.position; // 注視視点を作成 Vector3 center = CreateCenterPosition(battleResultSet); center.z = cameraTransform.position.z; // 傾きによってy座標を変化させる center.y = center.y - battleMapSetting.TiltCount * 2; // カメラ位置移動のTweenを追加 seq.Join(CreateCameraMoveTween(cameraTransform, center)); // ズーム Camera camera = bc.cameraController.GetCamera(); // 元のカメラのfovを覚えてくお this.originalCameraFov = camera.fieldOfView; // カメラズームのTweenを追加 seq.Join(CreateCameraZoomTween(camera, CAMERA_ZOOM_FOV)); // パネルの移動 // パネル1 seq.Join(CreatePanelMoveTween(bc.statusGenerator.GetStatusPanelOperator(), new Vector2(-PANEL_POS_X, PANEL_POS_Y))); // パネル2 seq.Join(CreatePanelMoveTween(bc.statusGenerator.GetStatusPanelOperatorReserve(), new Vector2(PANEL_POS_X, PANEL_POS_Y))); return(seq); }
/// <summary> /// 攻撃元の戦闘結果のシーケンスを作成 /// </summary> /// <param name="battleResultSet"></param> /// <param name="battleResult"></param> /// <returns></returns> private Sequence CreateFromSequence(BattleResultSet battleResultSet, BattleResult battleResult) { // Rectの取得 RectTransform rectFrom = battleResult.FromMonster.GameObject.GetComponent <RectTransform>(); RectTransform rectTo = battleResult.ToMonster.GameObject.GetComponent <RectTransform>(); // 移動元のポジションを保持 Vector3 originalFrom = rectFrom.position; // fromのシーケンスの作成 Sequence seqFrom = DOTween.Sequence(); // 待機 Tweener stayFrom = rectFrom.DOMove(rectFrom.position, bc.GetBaseDuration() * 2); // ターンのエフェクトを取得 GameObject turnEffectGo = bc.particleSystemPrefabHolder.Instantiate(EffectType.TURN065, battleResult.FromMonster.GameObject); ParticleSystem turnEffectPs = turnEffectGo.GetComponent <ParticleSystem>(); // エフェクトの位置 turnEffectPs.transform.position = battleResult.FromMonster.GameObject.transform.position; stayFrom.OnStart(() => turnEffectPs.Play()); seqFrom.Append(stayFrom); // ジャンプ Sequence jumpSeq = rectFrom.DOJump(rectTo.position, JUMP_POWER, 1, bc.GetBaseDuration() / 2); jumpSeq.SetEase(Ease.Linear); seqFrom.Append(jumpSeq); // 戻るジャンプ Sequence jumpBackSeq = rectFrom.DOJump(originalFrom, JUMP_POWER, 1, bc.GetBaseDuration() / 2); seqFrom.Append(jumpBackSeq); return(seqFrom); }
/// <summary> /// 戦闘結果の描画 /// </summary> /// <param name="battleResultSet"></param> private void DrawBattleResultSet(BattleResultSet battleResultSet) { BattleSequenceCreator sequenceCreator = new BattleSequenceCreator(this); BattleSequencePrepareCreator sequencePrepareCreator = new BattleSequencePrepareCreator(this); // 前処理 // TODO: コマンドボードを非表示、アニメ化 holder.BattleMapTeams.TeamList[0].CommandBoard.GameObject.SetActive(false); // シーケンスの作成 Sequence baseSeq = DOTween.Sequence(); DOTween.Init(); DOTween.defaultAutoPlay = AutoPlay.None; // 前処理 Sequence preSeq = sequencePrepareCreator.CreatePreSequence(battleResultSet, holder.BattleMapSetting); baseSeq.Append(preSeq); foreach (BattleResult battleResult in battleResultSet.ResultList) { // 戦闘シーケンスの作成 Sequence seq = sequenceCreator.CreateSequence(battleResultSet, battleResult); baseSeq.Append(seq); baseSeq.AppendInterval(GetBaseDuration()); } // 後処理 Sequence afterSeq = sequencePrepareCreator.CreateAfterSequence(battleResultSet); baseSeq.Append(afterSeq); baseSeq.OnComplete(() => actionController.FinishBattle()); baseSeq.Play(); }