/// <summary> /// 戦闘の終了 /// </summary> public void FinishBattle() { BattleMapActionStatus actionStatus = holder.BattleMapStatus.BattleMapActionStatus; // 強調表示の終了 // TODO: Down後の場合は処理しない、ダウン後かどうかの判定方法? if (holder.BattleMapMonsters.MonsterList.Contains(actionStatus.TargetMonster)) { iconController.UnHighlightMarker(actionStatus.TargetMonster); } // ステータスを消す statusGenerator.HideStatus(); statusGenerator.HideStatusReserve(); // TODO: ボードの表示、いずれアニメーション化 holder.BattleMapTeams.TeamList[0].CommandBoard.GameObject.SetActive(true); // コマンドを減らす BattleMapCommand command = holder.GetCurrentCommand(); command.Count = command.Count - 1; // ボードの更新 commandController.UpdateActionBoard(); holder.BattleMapStatus.BattleMapActionStatus = null; }
/// <summary> /// 移動の終了 /// </summary> private void FinishMove() { BattleMapMonster monster = holder.BattleMapStatus.BattleMapMoveStatus.TargetMonster; // マーカーを削除 mapIconGenerator.UninstallMonsterMarker(monster); // モンスターを移動 BattleMapTile endTile = holder.BattleMapStatus.BattleMapMoveStatus.GetEndMapTile(); monster.X = endTile.X; monster.Y = endTile.Y; // モンスターのリセット // 傾き、移動で位置がずれるため monsterGenerator.ResetMonsterGameObject(monster); // sortingOrderを再設定 monsterGenerator.SetMonsterSortingOrder(monster); // マーカーを作り直す mapIconGenerator.InstallMonsterMarker(monster); // 移動パスの削除 moveProcessor.ClearFlameAndPath(); // ステータスの削除 holder.BattleMapStatus.BattleMapMoveStatus = null; // 現在のチームの選択されているコマンド BattleMapCommand command = holder.GetCurrentCommand(); command.Count = command.Count - 1; }
/// <summary> /// コマンドの追加 /// </summary> public void AddCommand() { string text = dropdownAddCommand.captionText.text; BattleMapCommandType commandType = BattleMapCommandType.MOVE; if (text == "Move") { commandType = BattleMapCommandType.MOVE; } else if (text == "Action") { commandType = BattleMapCommandType.ACTION; } else if (text == "Summon") { commandType = BattleMapCommandType.SUMMON; } // ボード BattleMapCommandBoard commandBoard = holder.GetCurrentTeam().CommandBoard; // コマンドを作成 BattleMapCommand command = CreateBattleMapCommand(commandBoard.GameObject, commandType, UnityEngine.Random.Range(2, 5)); commandBoard.CommandList.Add(command); // ボードの更新 commandController.DrawActionBoard(); }
/// <summary> /// 強制終了 /// </summary> private void ForcedFinish() { // 回数を0にする BattleMapCommand command = holder.GetCurrentCommand(); command.Count = 0; // ボードの更新 UpdateActionBoard(); Debug.Log("強制終了!"); }
/// <summary> /// コマンド状態を設定 /// </summary> /// <param name="commandId"></param> private void SetCommandStatus(string commandId) { // いったんリセット ResetCommandStatus(); BattleMapCommandBoard commandBoard = holder.GetCurrentTeam().CommandBoard; BattleMapCommand command = commandBoard.GetCommandById(commandId); command.Selected = true; // ステータスを設定しておく holder.BattleMapStatus.SetStatusTypeByCommandType(command.CommandType); holder.BattleMapStatus.SelectedCommandId = commandId; }
/// <summary> /// アクションボードの更新 /// </summary> public void UpdateActionBoard() { BattleMapCommandBoard commandBoard = holder.GetCurrentTeam().CommandBoard; BattleMapCommand finishCommand = null; // カウントが0を除去 foreach (BattleMapCommand command in commandBoard.CommandList) { if (command.Count == 0) { finishCommand = command; } } // カウントゼロ処理 if (finishCommand != null) { // TODO: プレイヤーの行動回数を減らす // GameObjectの破棄 Destroy(finishCommand.ButtonGameObject); Destroy(finishCommand.TextGameObject); // コマンドボードから除去 commandBoard.CommandList.Remove(finishCommand); // ステータスをリセット ResetCommandStatus(); // ボードの再描画 DrawActionBoard(); } // カウントゼロ処理をしていないならテキストのみ更新 else { string commandId = holder.BattleMapStatus.SelectedCommandId; if (commandId != null) { BattleMapCommand bmc = commandBoard.GetCommandById(commandId); GameObject textGo = bmc.TextGameObject; Text text = textGo.GetComponent <Text>(); text.text = bmc.Count + "/" + bmc.MaxCount; } } }
/// <summary> /// ボタンの拡張 /// </summary> /// <param name="commandId"></param> public void ExpandButton(string commandId) { BattleMapCommandBoard commandBoard = holder.GetCurrentTeam().CommandBoard; BattleMapCommand command = commandBoard.GetCommandById(commandId); bool exist = false; foreach (BattleMapCommand bmc in commandBoard.CommandList) { GameObject buttonGo = bmc.ButtonGameObject; RectTransform rect = buttonGo.GetComponent <RectTransform>(); float move = (rect.sizeDelta.x * COMMAND_BUTTON_MAG - rect.sizeDelta.x) / 2; // 一致するものはサイズを大きくする if (command == bmc) { rect.sizeDelta = new Vector2(rect.sizeDelta.x * COMMAND_BUTTON_MAG, rect.sizeDelta.y * COMMAND_BUTTON_MAG); rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, rect.anchoredPosition.y + move - COMMAND_BUTTON_Y_ADD); // 文字位置も移動 RectTransform textRect = bmc.TextGameObject.GetComponent <RectTransform>(); textRect.anchoredPosition = new Vector2( textRect.anchoredPosition.x + COMMAND_TEXT_MOVE_X, textRect.anchoredPosition.y + COMMAND_TEXT_MOVE_Y); // 色も変更 Text text = bmc.TextGameObject.GetComponent <Text>(); text.color = COMMAND_TEXT_HIGHLIGHT_COLOR; // テキストも変更 text.text = bmc.Count + "/" + bmc.MaxCount; exist = true; } // 一致しない場合は移動 else { // 存在前は左 if (exist == false) { move = -move; } rect.anchoredPosition = new Vector2(rect.anchoredPosition.x + move, rect.anchoredPosition.y); } } }
/// <summary> /// コマンドを作成 /// </summary> /// <param name="boardGo"></param> /// <param name="commandType"></param> /// <param name="maxCount"></param> /// <returns></returns> private BattleMapCommand CreateBattleMapCommand(GameObject boardGo, BattleMapCommandType commandType, int maxCount) { // ゲームオブジェクトの作成 BattleMapCommand command = new BattleMapCommand(commandType, maxCount); command.ButtonGameObject = commandPrefabHolder.InstantiateCommandButton(boardGo, command.CommandType); command.TextGameObject = commandPrefabHolder.InstantiateCommandCountText(command.ButtonGameObject); // テキスト command.TextGameObject.GetComponent <Text>().text = "" + command.MaxCount; // ボタンにイベント追加 Button button = command.ButtonGameObject.GetComponent <Button>(); button.onClick.AddListener(() => commandController.PushCommandButton(command.Id)); return(command); }
/// <summary> /// ボタンの描画 /// </summary> /// <param name="commandBoard"></param> private void DrawActionButton(BattleMapCommandBoard commandBoard) { int buttonCount = commandBoard.CommandList.Count; for (int i = 0; i < commandBoard.CommandList.Count; i++) { BattleMapCommand command = commandBoard.CommandList[i]; GameObject buttonGo = command.ButtonGameObject; RectTransform buttonRect = buttonGo.GetComponent <RectTransform>(); // 位置 float buttonX = (BattleMapCommandPrefabHolder.BUTTON_ACTION_WIDTH * (buttonCount - i - 1)) + (BattleMapCommandPrefabHolder.BUTTON_ACTION_WIDTH / 2) + BattleMapCommandPrefabHolder.FRAME_MARGIN_WIDTH; buttonRect.anchoredPosition = new Vector2(-buttonX, buttonRect.anchoredPosition.y); } }