//------------------------------------------------------------------------ /*! * @brief 初期化処理 */ //------------------------------------------------------------------------ protected override void Start() { base.Start(); if (SceneModeContinuousBattle.Instance != null) { MasterDataQuest2 master = MasterDataUtil.GetQuest2ParamFromID(SceneModeContinuousBattle.Instance.m_QuestMissionID); if (master != null) { if (m_InGameMenuQuest2 != null) { m_QuestName = master.quest_name; } if (master.enable_autoplay != MasterDataDefineLabel.BoolType.ENABLE) { // オートプレイ禁止でなければ、オートプレイボタンの初期状態を設定(出撃画面での設定値を反映) LocalSaveOption cOption = LocalSaveManager.Instance.LoadFuncOption(); bool is_auto_play = (cOption.m_OptionAutoPlayEnable == (int)LocalSaveDefine.OptionAutoPlayEnable.ON); if (is_auto_play) { BattleParam.setAutoPlayState(BattleParam.AutoPlayState.ON); } else { BattleParam.setAutoPlayState(BattleParam.AutoPlayState.OFF); } } else { // オートプレイ禁止 BattleParam.setAutoPlayState(BattleParam.AutoPlayState.NONE); } } } }
public void OnAutoPlayButton() { if (BattleParam.IsTutorial()) { return; // チュートリアル中は押せなくする } switch (BattleParam.getAutoPlayState()) { case BattleParam.AutoPlayState.OFF: SoundUtil.PlaySE(SEID.SE_MENU_OK); BattleParam.setAutoPlayState(BattleParam.AutoPlayState.ON); break; case BattleParam.AutoPlayState.ON: SoundUtil.PlaySE(SEID.SE_MENU_OK); BattleParam.setAutoPlayState(BattleParam.AutoPlayState.OFF); break; } }
/// <summary> /// /// </summary> /// <param name="is_active"></param> /// <param name="ai"></param> /// <param name="is_debug_stop_mode">ユーザーが画面タッチしたらオートモードを解除するかどうか</param> public void startAutoPlay(AI ai = null, bool is_debug_stop_mode = false) { m_IsPlaying = true; m_IsDebugStopMode = is_debug_stop_mode; if (m_IsDebugStopMode) { BattleParam.setAutoPlayState(BattleParam.AutoPlayState.ON); } if (ai != null) { m_AI = ai; } else { m_AI = new AI_Default(); } m_AI.startAutoPlay(); m_Timer = 0.0f; m_AutoPlayPhase = AutoPlayPhase.START_WAIT; }
public void update(float delta_time) { if (m_IsPlaying) { if (m_IsDebugStopMode) { bool mouse_button = Input.GetMouseButton(0); if (mouse_button) { BattleParam.setAutoPlayState(BattleParam.AutoPlayState.CANCEL); m_IsPlaying = false; m_AutoPlayPhase = AutoPlayPhase.NOT_INPUT_PHASE; return; } } BattleParam.BattlePhase battle_phase = BattleParam.getBattlePhase(); if (battle_phase == BattleParam.BattlePhase.INPUT || battle_phase == BattleParam.BattlePhase.INPUT_HANDLING ) { if (m_IsFullField) { return; } Vector2 hand_pos = new Vector2(2.0f, 5.0f); //画面外の見えない位置に初期化 bool is_touching = false; switch (m_AutoPlayPhase) { case AutoPlayPhase.NOT_INPUT_PHASE: { // オートプレイの停止判定 if (m_AI.isStopAutoPlay()) { BattleParam.setAutoPlayState(BattleParam.AutoPlayState.CANCEL); m_IsPlaying = false; m_AutoPlayPhase = AutoPlayPhase.NOT_INPUT_PHASE; m_IsFullField = false; return; } // プレイヤーフェイズに戻ってきたときにここに来る. m_Timer = 1.0f; m_AutoPlayPhase = AutoPlayPhase.START_WAIT; } break; case AutoPlayPhase.START_WAIT: { m_Timer -= delta_time; if (m_Timer <= 0.0f) { m_PanelInfo = new AI.PanelInfo(); m_PanelInfo.m_HandElements = new MasterDataDefineLabel.ElementType[m_BattleCardManager.m_HandArea.getCardMaxCount()]; m_PanelInfo.m_NextElements = new MasterDataDefineLabel.ElementType[m_BattleCardManager.m_NextArea.getCardMaxCount()]; m_PanelInfo.m_FieldElements = new AI.CostInfo[m_BattleCardManager.m_FieldAreas.getFieldAreaCountMax()]; for (int field_idx = 0; field_idx < m_PanelInfo.m_FieldElements.Length; field_idx++) { m_PanelInfo.m_FieldElements[field_idx] = new AI.CostInfo(m_BattleCardManager.m_FieldAreas.getFieldArea(field_idx).getCardMaxCount()); } m_PanelInfo.m_FieldCosts = new int[m_PanelInfo.m_FieldElements.Length]; m_PanelInfo.m_IsBoosts = new bool[m_PanelInfo.m_FieldElements.Length]; // 思考ルーチン初期化 m_AI.initThink(_updatePanelInfo()); // リミブレスキルをチェック GlobalDefine.PartyCharaIndex limit_break_skill_caster = m_AI.getLimitBreakSkillCaster(); if (BattleParam.IsEnableLBS(limit_break_skill_caster) == false) { limit_break_skill_caster = GlobalDefine.PartyCharaIndex.ERROR; } if (limit_break_skill_caster >= GlobalDefine.PartyCharaIndex.LEADER && limit_break_skill_caster <= GlobalDefine.PartyCharaIndex.FRIEND ) { // リミブレスキル発動 BattleParam.RequestLBS(limit_break_skill_caster); m_AutoPlayPhase = AutoPlayPhase.NOT_INPUT_PHASE; m_IsFullField = false; } else { // パネル操作開始 m_PanelPutTimer = 0.0f; m_PanelPutCountGoal = m_AI.getPanelPutCount(); m_PanelPutCountCurrent = 0; float count_down_time = BattleSceneManager.Instance.PRIVATE_FIELD.calcCountDownTime(); if (count_down_time < COUNT_DOWN_TIME) { count_down_time = COUNT_DOWN_TIME; } m_PanelPutInterval = count_down_time / m_PanelPutCountGoal * (1.0f + 1.0f / m_PanelPutCountGoal); m_AutoPlayPhase = AutoPlayPhase.CARD_GET; } } } break; case AutoPlayPhase.CARD_GET: { m_PanelPutTimer += delta_time; float card_get_time = m_PanelPutCountCurrent * m_PanelPutInterval; // カードを掴む時刻 if (m_PanelPutTimer >= card_get_time) { if (m_BattleCardManager != null) { if (m_BattleCardManager.m_FieldAreas.getFieldArea(0).isFull() && m_BattleCardManager.m_FieldAreas.getFieldArea(1).isFull() && m_BattleCardManager.m_FieldAreas.getFieldArea(2).isFull() && m_BattleCardManager.m_FieldAreas.getFieldArea(3).isFull() && m_BattleCardManager.m_FieldAreas.getFieldArea(4).isFull() ) { BattleSceneManager.Instance.PRIVATE_FIELD.skipCountDown(); m_IsFullField = true; m_AutoPlayPhase = AutoPlayPhase.NOT_INPUT_PHASE; return; } } // カウントダウンスキップ判定 if (m_AI.isSkipCountDown()) { BattleSceneManager.Instance.PRIVATE_FIELD.skipCountDown(); m_AutoPlayPhase = AutoPlayPhase.NOT_INPUT_PHASE; m_IsFullField = false; return; } // 思考ルーチン呼び出し int hand_index = 0; int field_index = 0; m_AI.execThink(ref hand_index, ref field_index, _updatePanelInfo()); m_StartPosition = new Vector2(hand_index, 1.0f - 0.3f); m_GoalPosition = new Vector2(field_index, 0.0f - 0.5f); hand_pos = m_StartPosition; is_touching = true; float card_put_time = (m_PanelPutCountCurrent + 1) * m_PanelPutInterval - CARD_PUT_TIME; // カードを置く時刻 m_Duration = card_put_time - m_PanelPutTimer; m_Duration = Mathf.Max(m_Duration, 0.0f); m_Duration = Mathf.Min(m_Duration, CARD_MOVE_TIME_MAX); m_Timer = 0.0f; m_AutoPlayPhase = AutoPlayPhase.CARD_MOVE; } } break; case AutoPlayPhase.CARD_MOVE: { m_PanelPutTimer += delta_time; m_Timer += delta_time; if (m_Timer < m_Duration) { float t = m_Timer / m_Duration; Vector2 vec = m_GoalPosition - m_StartPosition; vec.x *= t * t; // 横方向は動き始めをゆっくりにする(2枚以上を掴まないようにするため) vec.y *= t; hand_pos = m_StartPosition + vec; is_touching = true; } else { hand_pos = m_GoalPosition; is_touching = true; m_AutoPlayPhase = AutoPlayPhase.CARD_PUT; } } break; case AutoPlayPhase.CARD_PUT: // タッチしていないフレームが最低1フレームはあるようにするための処理 { m_PanelPutTimer += delta_time; m_PanelPutCountCurrent++; hand_pos = m_GoalPosition; is_touching = false; m_AutoPlayPhase = AutoPlayPhase.CARD_GET; } break; } BattleSceneManager.Instance.setOverrideTouchMode(BattleSceneManager.Instance.getCardFieldScreenPos(hand_pos.x, hand_pos.y), is_touching); } else { m_AutoPlayPhase = AutoPlayPhase.NOT_INPUT_PHASE; m_IsFullField = false; } } else { m_AutoPlayPhase = AutoPlayPhase.NOT_INPUT_PHASE; m_IsFullField = false; } }
//---------------------------------------------------------------------------- /*! * @brief Unity固有処理:更新処理 ※定期処理 */ //---------------------------------------------------------------------------- void Update() { if (m_WaitTime > 0) { m_WaitTime -= Time.deltaTime; if (m_WaitTime <= 0) { m_WaitTime = 0; Total_hands_active = false; } } if (m_PartyAilmentIndex >= 0) { Timer_active = false; Timer_minus_active = false; Skill_Invalid_active = false; bool change_index = false; if (m_PartyAilmentTurn[m_PartyAilmentIndex] > 0) { m_PartyAilmentTime -= Time.deltaTime; if (m_PartyAilmentTime <= 0) { m_PartyAilmentTime += PARTY_AILMENT_TIME; change_index = true; } } else { change_index = true; } if (change_index == true) { int index = m_PartyAilmentIndex; do { ++index; if (index >= (int)PartyAilmentType.Max) { index = 0; } if (m_PartyAilmentTurn[index] > 0) { break; } } while (index != m_PartyAilmentIndex); if (m_PartyAilmentIndex != index) { m_PartyAilmentIndex = index; } else { if (m_PartyAilmentTurn[(int)m_PartyAilmentIndex] <= 0) { m_PartyAilmentIndex = -1; } } } switch ((PartyAilmentType)m_PartyAilmentIndex) { case PartyAilmentType.TimePlus: { Timer_active = true; Timer_count = m_PartyAilmentTurn[m_PartyAilmentIndex].ToString("00"); } break; case PartyAilmentType.TimeMinus: { Timer_minus_active = true; Timer_minus_count = m_PartyAilmentTurn[m_PartyAilmentIndex].ToString("00"); } break; case PartyAilmentType.HandChance: { Skill_Invalid_active = true; Skill_Invalid_count = m_PartyAilmentTurn[m_PartyAilmentIndex].ToString("00"); } break; default: break; } } // オートプレイボタンの表示を更新 { BattleParam.AutoPlayState auto_play_state = BattleParam.getAutoPlayState(); if (auto_play_state == BattleParam.AutoPlayState.CANCEL) { if (m_AutoPlayButtonCancelTimer <= 0.0f) { m_AutoPlayButtonCancelTimer = 0.5f; } else { m_AutoPlayButtonCancelTimer -= Time.deltaTime; if (m_AutoPlayButtonCancelTimer <= 0.0f) { m_AutoPlayButtonCancelTimer = 0.0f; BattleParam.setAutoPlayState(BattleParam.AutoPlayState.OFF); auto_play_state = BattleParam.AutoPlayState.OFF; } } } if (auto_play_state != m_AutoPlayButtonState) { m_AutoPlayButtonState = auto_play_state; switch (m_AutoPlayButtonState) { case BattleParam.AutoPlayState.ON: IsActiveAutoPlayOnButton = true; IsActiveAutoPlayOffButton = true; IsActiveAutoPlayNgButton = false; if (m_AutoButtonOnAnimation.isPlaying == false) { m_AutoButtonOnAnimation.Play(); } break; case BattleParam.AutoPlayState.OFF: IsActiveAutoPlayOnButton = false; IsActiveAutoPlayOffButton = true; IsActiveAutoPlayNgButton = false; if (m_AutoButtonOnAnimation.isPlaying) { m_AutoButtonOnAnimation.Stop(); } break; default: IsActiveAutoPlayOnButton = false; IsActiveAutoPlayOffButton = false; IsActiveAutoPlayNgButton = true; break; } } } }