/// <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); } } }