Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        BattleTouchInput battle_touch_input = BattleTouchInput.Instance;

        if (battle_touch_input.isTouching())
        {
            if (battle_touch_input.isOverrideTouchMode() == false)
            {
                m_HandAreaTouchIndex  = m_HandAreaViewControl.getTouchIndex();
                m_FieldAreaTouchIndex = m_FieldAreaViewControl.getTouchIndex();
            }
            else
            {
                m_HandAreaTouchIndex  = battle_touch_input.getOverrideTouchMode_HandAreaTouchIndex();
                m_FieldAreaTouchIndex = battle_touch_input.getOverrideTouchMode_FieldAreaTouchIndex();
            }

            if (m_HandAreaTouchIndex >= 0)
            {
                // 手札エリアに触れているのでカードがあれば拾う.
                m_BattleCardManager.catchHandAreaCard(m_HandAreaTouchIndex);
            }
        }
        else
        {
            if (battle_touch_input.isWorking())
            {
                if (m_BattleCardManager.isCatchingCardByPlayer())
                {
                    // 手を放したのでカードを置く.
                    m_BattleCardManager.putInHandCard(m_HandAreaTouchIndex, m_FieldAreaTouchIndex);
                }
            }
            else
            {
                // 入力が中断した場合はカードを元の位置に戻す.
                m_BattleCardManager.putInHandCardByTimeOver();
            }

            m_HandAreaTouchIndex  = -1;
            m_FieldAreaTouchIndex = -1;
        }

        if (m_BattleCardManager.m_InHandArea.getCardCount() > 0)
        {
            m_FieldAreaViewControl.setViewSelect(m_FieldAreaTouchIndex);
        }
        else
        {
            m_FieldAreaViewControl.setViewSelect(-1);
        }

        // カードの明暗表示を切り替え
        if (m_BattleCardManager.isUpdateSkillCard(true))
        {
            for (int idx = 0; idx < m_BattleCardManager.m_BattleCards.Length; idx++)
            {
                m_BattleCardManager.m_BattleCards[idx].m_IsOn = m_BattleCardManager.isSkillCard(m_BattleCardManager.m_BattleCards[idx].getElementType());
            }
        }

        // リーチラインの描画更新
        BattleSkillReachInfo reach_info = m_BattleCardManager.getReachInfo();

        if (reach_info != null)
        {
            m_BattleReachLineViewControl.clearLine();
            m_BattleReachLineViewControl.setCameraPosition(battle_touch_input.getCamera().transform.position);
            for (int hand_index = 0; hand_index < m_BattleCardManager.m_HandArea.getCardMaxCount(); hand_index++)
            {
                Vector3    hand_position;
                BattleCard battle_card = m_BattleCardManager.m_HandArea.getCard(hand_index);
                if (battle_card != null)
                {
                    hand_position = m_HandAreaViewControl.getBattleCardTransform(hand_index, HandAreaViewControl.TransformType.HAND_AREA).position;
                }
                else
                {
                    battle_card = m_BattleCardManager.m_InHandArea.getCard(0);
                    if (battle_card == null)
                    {
                        // 場にパネルを置いた瞬間:直前の手の位置に表示
                        hand_position = m_InHandViewControl.getBattleCardTransform(0).position;
                    }
                    else if (battle_card.isChangePhase())
                    {
                        // パネルを手に持った瞬間:手の位置がまだ更新されていないので、手札領域の座標を使用
                        hand_position = m_HandAreaViewControl.getBattleCardTransform(hand_index, HandAreaViewControl.TransformType.HAND_AREA).position;
                    }
                    else
                    {
                        hand_position = m_InHandViewControl.getBattleCardTransform(0).position;
                    }
                }

                for (int field_index = 0; field_index < m_BattleCardManager.m_FieldAreas.getFieldAreaCountMax(); field_index++)
                {
                    MasterDataDefineLabel.ElementType element_type = reach_info.getReachInfo(field_index, hand_index);
                    if (element_type != MasterDataDefineLabel.ElementType.NONE)
                    {
                        Vector3 field_position = m_FieldAreaViewControl.getFieldTransform(field_index).position;
                        m_BattleReachLineViewControl.addLine(hand_position, field_position, element_type);
                    }
                }
            }
        }
        else
        {
            m_BattleReachLineViewControl.clearLine();
        }

        int in_hand_card_count = m_BattleCardManager.m_InHandArea.getCardCount();

        if (in_hand_card_count != m_InHandCardCount)
        {
            if (in_hand_card_count == 1 && m_InHandCardCount == 0)
            {
                //1枚目のカードを手に持った時のSE
                SoundUtil.PlaySE(SEID.SE_BATLE_COST_PLUS_1);
            }
            else if (in_hand_card_count > 1)
            {
                //2枚目以上のカードを手に持った時のSE
                SoundUtil.PlaySE(SEID.SE_BATLE_COST_PLUS_2);

                // エフェクト
                EffectManager.Instance.playEffect(SceneObjReferGameMain.Instance.m_EffectPrefab.m_2DBattleCostPlus, Vector3.zero, Vector3.zero, m_InHandViewControl.getBattleCardTransform(0), null, 5.0f);
            }
            else if (in_hand_card_count == 0)
            {
                bool is_put_field = false;  // 札を場に置いたかどうか
                for (int idx = 0; idx < m_BattleCardManager.m_HandArea.getCardMaxCount(); idx++)
                {
                    if (m_BattleCardManager.m_HandArea.getCard(idx) == null)
                    {
                        // 手札に空きがあるので場に置いたと判断
                        is_put_field = true;
                        break;
                    }
                }

                if (is_put_field)
                {
                    // 場に札を置いた時のSE
                    SoundUtil.PlaySE(SEID.SE_BATLE_COST_PUT);
                }
            }

            m_InHandCardCount = in_hand_card_count;
        }

        // 場・カード関連のエフェクト
        for (int idx = 0; idx < m_BattleCardManager.getEffectInfoCount(); idx++)
        {
            _BattleCardManager.EffectInfo effect_info = m_BattleCardManager.getEffectInfo(idx);

            Transform trans = getEffectPosition(effect_info.m_PositionIndex, effect_info.m_EffectPosition);

            if (trans != null)
            {
                if (SceneObjReferGameMain.Instance != null)
                {
                    GameObject effect_prefab = null;
                    switch (effect_info.m_EffectType)
                    {
                    case _BattleCardManager.EffectInfo.EffectType.CARD_CHANGE:
                        effect_prefab = SceneObjReferGameMain.Instance.m_EffectPrefab.m_HandCardTransform;
                        break;

                    case _BattleCardManager.EffectInfo.EffectType.CARD_DESTROY:
                        effect_prefab = SceneObjReferGameMain.Instance.m_EffectPrefab.m_HandCardDestroy;
                        break;

                    case _BattleCardManager.EffectInfo.EffectType.SKILL_FORMED:
                        effect_prefab = SceneObjReferGameMain.Instance.m_EffectPrefab.m_2DSkill;
                        break;
                    }

                    if (effect_prefab != null)
                    {
                        EffectManager.Instance.playEffect(effect_prefab, Vector3.zero, Vector3.zero, trans, null, 5.0f);
                    }
                }
            }
        }
        m_BattleCardManager.resetEffectInfo();
    }
Ejemplo n.º 2
0
 /// <summary>
 /// リーチ情報をセット
 /// </summary>
 /// <param name="reach_info"></param>
 public void setReachInfo(BattleSkillReachInfo reach_info)
 {
     m_BattleSkillReachInfo = reach_info;
 }