/// <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; }
public void Unmask(BattleMapMonster monster) { BattleMapTile centerTile = holder.BattleMap.BattleMapTiles[monster.X, monster.Y]; // 視界のタイルセットを取得 List <BattleMapTile> set = MapUtils.GetRangeTileList(centerTile, monster.BattleStatus.View); BattleMapTileMaskGroup maskGroup = holder.BattleMap.BattleMapTileMaskGroup[monster.GetTeamIndex()]; foreach (BattleMapTile bmt in set) { // マスクを取得 BattleMapTileMask mask = maskGroup.BattleMapTileMask[bmt.X, bmt.Y]; // すでにマスク解除されているならなにもしない if (mask.Mask == false) { continue; } mask.Mask = false; mask.GameObject.SetActive(false); mask.GameObjectShadow.SetActive(false); // オブジェクトが存在しない場合 // オブジェクトを描画 BattleMapObjectSet bmoSet = holder.BattleMap.BattleMapObjectSets[bmt.X, bmt.Y]; if (bmoSet == null) { mapObjectGenerator.DecoreteMapTile(bmt); } } }
/// <summary> /// タイル間の座標をキューに追加 /// </summary> /// <param name="queue"></param> /// <param name="monster"></param> /// <param name="bmt1"></param> /// <param name="bmt2"></param> private void EnqueuePosition(Queue <Vector2> queue, BattleMapMonster monster, BattleMapTile bmt1, BattleMapTile bmt2) { float tmpX = bmt2.GameObject.transform.position.x - bmt1.GameObject.transform.position.x; float diffX = tmpX / (float)MOVE_COUNT_PER_TILE; float tmpY = bmt2.GameObject.transform.position.y - bmt1.GameObject.transform.position.y; float diffY = tmpY / (float)MOVE_COUNT_PER_TILE; BattleMapMonsterPositionCalculator calculator = new BattleMapMonsterPositionCalculator(); for (int i = 0; i < MOVE_COUNT_PER_TILE - 1; i++) { float x = bmt1.GameObject.transform.position.x + (diffX * (i + 1)); float y = bmt1.GameObject.transform.position.y + (diffY * (i + 1)); Vector2 pos = calculator.CalculateMonsterPosition(monster, x, y); queue.Enqueue(pos); } // 最後は目的地 Vector2 lastPos = calculator.CalculateMonsterPosition(monster, bmt2); queue.Enqueue(lastPos); }
/// <summary> /// 相手を選択 /// </summary> /// <param name="monster"></param> private void SelectOpponent(BattleMapMonster monster) { BattleMapActionStatus actionStatus = holder.BattleMapStatus.BattleMapActionStatus; MonsterSkill skill = actionStatus.SelectedSkill; // ステータスを移動 statusGenerator.ShowStatus( actionStatus.TargetMonster, BattleMapStatusPanelType.SKILL1, BattleMapStatusPanelPositionType.ON_RESERVE); statusGenerator.SetSkill(skill); // 相手のステータスを表示 statusGenerator.ShowStatusReserve(monster, BattleMapStatusPanelType.SKILL1); // 距離を計算 BattleMapTile from = holder.BattleMap.GetByMonster(actionStatus.TargetMonster); BattleMapTile to = holder.BattleMap.GetByMonster(monster); int range = MapUtils.GetRange(from, to); // カウンタースキルを取得 MonsterSkill counterSkill = monster.GetCounterSkill(range); statusGenerator.SetSkillReserve(counterSkill); // ステータスの更新 actionStatus.BattleMapActionStatusType = BattleMapActionStatusType.CONFIRM_OPPONENT_SELECT; actionStatus.OpponentMonster = monster; actionStatus.CounterSkill = counterSkill; }
private void JumpDamageText() { BattleMapMonster monster = holder.BattleMapMonsters.MonsterList[0]; GameObject go = particleSystemPrefabHolder.InstantiateDamageText(monster.GameObject, 123); DOTween.Init(); DOTween.defaultAutoPlay = AutoPlay.None; RectTransform monsterRect = monster.GameObject.GetComponent <RectTransform>(); RectTransform rect = go.GetComponent <RectTransform>(); Sequence seq = DOTween.Sequence(); Tween jumpTween = rect.DOJumpAnchorPos(rect.anchoredPosition, 0.1f, 1, 0.2f); // jumpTween.SetDelay(1.0f); jumpTween.SetEase(Ease.Linear); seq.Append(jumpTween); Tween stayTween = monsterRect.DOMove(monsterRect.position, 2.0f); seq.Append(stayTween); seq.Play(); }
/// <summary> /// ダウンのシーケンスを作成 /// </summary> /// <param name="monster"></param> /// <returns></returns> private Sequence CreateDownSequence(BattleMapMonster monster) { Sequence seq = DOTween.Sequence(); // 点滅 SpriteRenderer sr = monster.GameObject.GetComponent <SpriteRenderer>(); Blinker blinker = new Blinker(sr); Tween tween = DOTween.To(() => blinker.Blink, (x) => blinker.Blink = x, 4, bc.GetBaseDuration() * 2); tween.SetEase(Ease.Linear); // エフェクト GameObject effectGo = bc.particleSystemPrefabHolder.Instantiate(EffectType.EXTINCT044, monster.GameObject); ParticleSystem effectPs = effectGo.GetComponent <ParticleSystem>(); // エフェクトの位置 effectPs.transform.position = monster.GameObject.transform.position; tween.OnComplete(() => { effectPs.Play(); bc.monsterGenerator.DownMonster(monster); }); seq.Append(tween); return(seq); }
/// <summary> /// マーカーを強調表示 /// </summary> /// <param name="monster"></param> public void HighlightMarker(BattleMapMonster monster) { // マーカーを回転させる BattleMapIcon icon = holder.BattleMapIcons.GetSingle(BattleMapIconType.MONSTER_MAKER, monster.X, monster.Y); icon.BattleMapIconStatusType = BattleMapIconStatusType.HIGHLIGHT; }
/// <summary> /// スキルリストの設定 /// </summary> /// <param name="monster"></param> private void SetSkillList(BattleMapMonster monster) { List <MonsterSkill> skillList = monster.GetAvailableSkillList(); int skillCount = skillList.Count; if (SKILL_BUTTON_VIEW_COUNT < skillCount) { skillCount = SKILL_BUTTON_VIEW_COUNT; } // 全体 RectTransform panelRect = skillSelectObject.GameObject.GetComponent <RectTransform>(); panelRect.sizeDelta = new Vector2(panelRect.sizeDelta.x, GetPanelHeight(skillCount)); // 本体の位置 float posY = PANEL_POSY_MARGIN + (panelRect.sizeDelta.y / 2); panelRect.anchoredPosition = new Vector2(PANEL_POSX, posY); // スクロールビュー RectTransform scrollViewRect = skillSelectObject.ScrollViewGameObject.GetComponent <RectTransform>(); scrollViewRect.sizeDelta = new Vector2(scrollViewRect.sizeDelta.x, skillCount * SKILL_BUTTON_HEIGHT); scrollViewRect.anchoredPosition = new Vector2(scrollViewRect.anchoredPosition.x, -(scrollViewRect.sizeDelta.y / 2 + SCROLL_VIEW_Y_MARGIN)); // 概要の初期化 skillSelectObject.OverviewText.text = ""; // スキルボタンの設定 SetSkillButtonList(monster, skillList); }
/// <summary> /// スキルボタンの設定 /// </summary> /// <param name="monster"></param> /// <param name="skillList"></param> private void SetSkillButtonList(BattleMapMonster monster, List <MonsterSkill> skillList) { // ボタンの追加 List <GameObject> buttonList = new List <GameObject>(); foreach (MonsterSkill skill in skillList) { GameObject skillGo = skillSelectPrefabHolder.InstantiateSkillSelectButton(skillSelectObject.ContentGameObject); buttonList.Add(skillGo); // イベントの追加 skillGo.GetComponent <Button>().onClick.AddListener(() => actionController.SelectSkill(skill)); // ボタンのラベルの表示 Transform[] childTransformList = skillGo.GetComponentsInChildren <Transform>(); foreach (Transform ts in childTransformList) { GameObject go = ts.gameObject; // テキスト if (go.name == "textNodeSkillSelect") { go.GetComponent <Text>().text = skill.Name; } } } skillSelectObject.SkillButtonGameObjectList = buttonList; }
private Vector3 CreateCenterPosition() { BattleMapMonster fromMonster = holder.BattleMapMonsters.MonsterList[0]; BattleMapTile from = holder.BattleMap.GetByMonster(fromMonster); BattleMapMonster toMonster = holder.BattleMapMonsters.MonsterList[1]; BattleMapTile to = holder.BattleMap.GetByMonster(toMonster); Vector3 pos1 = fromMonster.GameObject.transform.position; Vector3 pos2 = toMonster.GameObject.transform.position; Vector3 center = Vector3.Lerp(pos1, pos2, 0.5f); center.z = -10; // ズーム Camera camera = cameraController.GetCamera(); Vector3 screenPoint = camera.WorldToScreenPoint(center); Debug.Log("center:" + center); Debug.Log("spoint:" + screenPoint); return(center); }
/// <summary> /// モンスターのマーカーを設定 /// </summary> /// <param name="battleMapMonster"></param> public void InstallMonsterMarker(BattleMapMonster battleMapMonster) { BattleMapTile bmt = holder.BattleMap.BattleMapTiles[battleMapMonster.X, battleMapMonster.Y]; GameObject iconGo = prefabHolder.InstantiateCircle(battleMapMonster.Team.TeamColor); InstallIcon(bmt, BattleMapIconType.MONSTER_MAKER, iconGo); }
/// <summary> /// スキル選択画面を表示する /// </summary> /// <param name="monster"></param> public void ShowSkillSelect(BattleMapMonster monster) { SetActive(true); // TODO: スキルがない場合 // スキルリストの設定 SetSkillList(monster); }
/// <summary> /// ステータスを表示する /// </summary> /// <param name="monster"></param> /// <param name="panelType"></param> public void ShowStatus( BattleMapMonster monster, BattleMapStatusPanelType panelType, BattleMapStatusPanelPositionType positionType = BattleMapStatusPanelPositionType.NORMAL) { Initialize(); ShowStatus(panelOperator, monster, panelType, positionType); }
/// <summary> /// パスリストの処理 /// </summary> /// <param name="bmt"></param> /// <param name="movableTileList"></param> /// <param name="pathList"></param> /// <param name="currentPath"></param> /// <param name="moveCount"></param> private void ProcessPathList( BattleMapTile targetTile, List <BattleMapTile> movableTileList, List <string> pathList, string currentPath, int moveCount) { // 終点なら終了 BattleMapTile startTile = holder.BattleMapStatus.BattleMapMoveStatus.StartMapTile; if (targetTile == startTile) { currentPath += targetTile.X + "," + targetTile.Y + "-" + moveCount; pathList.Add(currentPath); return; } // 移動可能かどうか if (movableTileList.Contains(targetTile) == false) { return; } // 該当タイルに別モンスターがいたら侵入不可 BattleMapMonster monster = holder.BattleMapStatus.BattleMapMoveStatus.TargetMonster; BattleMapMonster anotherMonster = holder.BattleMapMonsters.GetMonster(targetTile.X, targetTile.Y); if (anotherMonster != null && monster != anotherMonster) { return; } // 移動コストを取得 MapTileType tileType = targetTile.MapTileType; int cost = monster.BattleStatus.BattleMapMonsterMoveCost.GetMoveCost(tileType); // 侵入不可の場合 if (cost < 0) { return; } // タイルのコストごとに移動力を減少 moveCount = moveCount - cost; // 移動力がなくなったら終了 if (moveCount <= 0) { return; } // パスに追加 currentPath += targetTile.X + "," + targetTile.Y + "_"; // タイルごとの処理 foreach (BattleMapTile jointTile in targetTile.JointInfo.GetJointTileList()) { ProcessPathList(jointTile, movableTileList, pathList, currentPath, moveCount); } }
/// <summary> /// モンスターのマーカーを除去 /// </summary> /// <param name="battleMapMonster"></param> public void UninstallMonsterMarker(BattleMapMonster battleMapMonster) { // マーカーを削除 BattleMapIcons icons = holder.BattleMapIcons; BattleMapIcon icon = icons.GetSingle(BattleMapIconType.MONSTER_MAKER, battleMapMonster.X, battleMapMonster.Y); Destroy(icon.GameObject); icons.Remove(icon); }
/// <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="skill"></param> /// <param name="monster"></param> private void DrawRange(MonsterSkill skill, BattleMapMonster monster) { BattleMapTile bmt = holder.BattleMap.GetByMonster(monster); // 範囲の取得 List <BattleMapTile> list = MapUtils.GetRangeTileList(bmt, skill.Range); // 描画 MapUtils.DrawRangeTile(new HashSet <BattleMapTile>(list), iconGenerator.InstallFrameAque); }
/// <summary> /// 顔の色を差し替え /// </summary> /// <param name="monster"></param> private void SetFaceColorImage(BattleMapMonster monster) { // スプライトを取得 Sprite sprite = GetFaceColorImageSprite(monster.Team.TeamColor); // スプライトを差し替え GameObject go = spObject.FaceColorImage; Image img = go.GetComponent <Image>(); img.sprite = sprite; }
/// <summary> /// 顔を差し替え /// </summary> /// <param name="monster"></param> private void SetFaceImage(BattleMapMonster monster) { // スプライトを取得 Sprite sprite = GetFaceImageSprite(monster.BattleStatus.MonsterType); // テクスチャを差し替え GameObject go = spObject.FaceImage; Image img = go.GetComponent <Image>(); img.sprite = sprite; }
/// <summary> /// モンスターの除去 /// </summary> /// <param name="monster"></param> public void DownMonster(BattleMapMonster monster) { // マーカーを除去 mapIconGenerator.UninstallMonsterMarker(monster); // リストから削除 holder.BattleMapMonsters.DownMonster(monster); // GameObjectを破棄 Destroy(monster.GameObject); }
/// <summary> /// 選択ステータスを設定 /// </summary> /// <param name="startTile"></param> /// <param name="monster"></param> /// <param name="movableTileList"></param> private void SetSelectedStatus(BattleMapTile startTile, BattleMapMonster monster, List <BattleMapTile> movableTileList) { // ステータスを設定 BattleMapMoveStatus moveStatus = new BattleMapMoveStatus(); moveStatus.BattleMapMoveStatusType = BattleMapMoveStatusType.SELECTED; moveStatus.TargetMonster = monster; moveStatus.MapTileMovableList = movableTileList; moveStatus.StartMapTile = startTile; holder.BattleMapStatus.BattleMapMoveStatus = moveStatus; }
/// <summary> /// スキルのハイライト /// </summary> /// <param name="monster"></param> /// <param name="skill"></param> public void SetSkillHighlight(BattleMapMonster monster, MonsterSkill skill) { // いったん全部ハイライトを解除 skillSelectObject.SkillButtonGameObjectList.ForEach( skillGo => skillGo.GetComponent <Animator>().SetBool("Highlight", false)); // 対象をハイライト skillSelectObject.GetSkillButtonGameObject(skill).GetComponent <Animator>().SetBool("Highlight", true); // オーバービューを設定 skillSelectObject.OverviewText.text = skill.Overview; }
/// <summary> /// モンスターのGameObjectをリセットする /// </summary> /// <param name="monster"></param> public void ResetMonsterGameObject(BattleMapMonster monster) { Destroy(monster.GameObject); BattleMapTile bmt = holder.BattleMap.GetByMonster(monster); GameObject newGo = GetMonsterGameObject(bmt, monster.BattleStatus.MonsterType); monster.GameObject = newGo; // 位置の調整 ConditionMonsterPosition(bmt, monster); }
/// <summary> /// ステータスを表示する /// </summary> /// <param name="monster"></param> /// <param name="panelType"></param> private void ShowStatus( BattleMapStatusPanelOperator panelOperator, BattleMapMonster monster, BattleMapStatusPanelType panelType, BattleMapStatusPanelPositionType positionType = BattleMapStatusPanelPositionType.NORMAL) { panelOperator.ShowStatus(monster, panelType, positionType); // アイコンを削除 mapIconGenerator.UninstallSelectionMarker(); // アイコンの表示 mapIconGenerator.InstallSelectionMarker(monster); }
/// <summary> /// 相手のステータスを表示する /// </summary> /// <param name="monster"></param> /// <param name="panelType"></param> public void ShowStatusReserve( BattleMapMonster monster, BattleMapStatusPanelType panelType) { Initialize(); panelOperatorReserve.ShowStatus(monster, panelType, BattleMapStatusPanelPositionType.NORMAL); // 相手のアイコンを削除 holder.RemoveIcons(BattleMapIconType.MOVE_ORANGE_LARGE); // 相手のアイコンの表示 mapIconGenerator.InstallMoveOrangeLarge(holder.BattleMap.GetByMonster(monster)); }
/// <summary> /// 移動のキャンセル /// </summary> public void CancelMove() { BattleMapMoveStatus moveStatus = holder.BattleMapStatus.BattleMapMoveStatus; BattleMapMonster monster = moveStatus.TargetMonster; // 回転を止める iconController.UnHighlightMarker(monster); // 枠とパスを削除 ClearFlameAndPath(); // ステータスを削除 holder.BattleMapStatus.BattleMapMoveStatus = null; }
/// <summary> /// モードごとに設定 /// </summary> /// <param name="panelType"></param> /// <param name="monster"></param> /// <param name="panelPositionType"></param> private void SetPanelMode( BattleMapMonster monster, BattleMapStatusPanelType panelType, BattleMapStatusPanelPositionType panelPositionType) { float panelHeight = PANEL_HEIGHT; if (panelType == BattleMapStatusPanelType.NORMAL) { spObject.PaperGameObject.SetActive(true); spObject.PaperSubGameObject.SetActive(false); spObject.SkillButton.SetActive(false); spObject.CancelButton.SetActive(false); panelHeight = PANEL_HEIGHT; } else if (panelType == BattleMapStatusPanelType.SKILL1) { spObject.PaperGameObject.SetActive(false); spObject.PaperSubGameObject.SetActive(true); spObject.SkillButton.SetActive(true); spObject.CancelButton.SetActive(true); panelHeight = PANEL_HEIGHT_SKILL; } RectTransform goRect = spObject.GameObject.GetComponent <RectTransform>(); goRect.anchorMin = new Vector2(0, 0); goRect.anchorMax = new Vector2(0, 0); // 本体の高さ goRect.sizeDelta = new Vector2(goRect.sizeDelta.x, panelHeight); // 本体の位置 float posY = PANEL_POSY_MARGIN + (goRect.sizeDelta.y / 2); // スキル表示ありの場合 if (panelPositionType == BattleMapStatusPanelPositionType.ON_SKILL_PANEL) { posY += BattleMapSkillSelectOperator.GetPanelHeight(monster.GetAvailableSkillList().Count); } // 控えありの場合 else if (panelPositionType == BattleMapStatusPanelPositionType.ON_RESERVE) { posY += goRect.sizeDelta.y + PANEL_POSY_RESERVE_MARGIN; } goRect.anchoredPosition = new Vector2(PANEL_POSX, posY); }
public BattleMapMonsterMover( BattleStageHolder holder, BattleMapMoveProcessor moveProcessor, MapIconGenerator mapIconGenerator, BattleMapMonsterGenerator monsterGenerator) { this.holder = holder; this.moveProcessor = moveProcessor; this.mapIconGenerator = mapIconGenerator; this.monsterGenerator = monsterGenerator; this.monster = holder.BattleMapStatus.BattleMapMoveStatus.TargetMonster; this.movePositionQueue = CreateMovePositionQueue(); }
/// <summary> /// 移動チェック /// </summary> /// <param name="monster"></param> /// <param name="targetTile"></param> /// <param name="moveCount"></param> /// <param name="movableTileSet"></param> private void CheckMove( BattleMapMonster monster, BattleMapTile targetTile, int moveCount, HashSet <BattleMapTile> movableTileSet) { // 該当タイルに別モンスターがいたら侵入不可 BattleMapMonster anotherMonster = holder.BattleMapMonsters.GetMonster(targetTile.X, targetTile.Y); if (anotherMonster != null && monster != anotherMonster) { return; } // マスクしてあったら侵入不可 BattleMapTileMaskGroup group = holder.BattleMap.BattleMapTileMaskGroup[monster.GetTeamIndex()]; BattleMapTileMask mask = group.BattleMapTileMask[targetTile.X, targetTile.Y]; if (mask.Mask) { return; } // 移動コストを取得 MapTileType tileType = targetTile.MapTileType; int cost = monster.BattleStatus.BattleMapMonsterMoveCost.GetMoveCost(tileType); // 侵入不可の場合 if (cost < 0) { return; } // このタイルを移動可能に追加 movableTileSet.Add(targetTile); // タイルのコストごとに移動力を減少 moveCount = moveCount - cost; // 移動力がなくなったら終了 if (moveCount <= 0) { return; } // タイルごとの処理 foreach (BattleMapTile jointTile in targetTile.JointInfo.GetJointTileList()) { CheckMove(monster, jointTile, moveCount, movableTileSet); } }
/// <summary> /// 一つ動かす /// </summary> public void Step() { BattleMapMonster monster = holder.BattleMapStatus.BattleMapMoveStatus.TargetMonster; // キューから取得 Vector2 pos = movePositionQueue.Dequeue(); // 移動 monster.GameObject.transform.position = pos; // なくなったら終了処理 if (isFinished()) { FinishMove(); } }