public void OnClickSkillCutin()
    {
#if BUILD_TYPE_DEBUG
        if (m_NewBattleSkillCutin == null)
        {
            GameObject skill_cutin_prefab = Resources.Load <GameObject>("Prefab/BattleScene/NewBattleSkillCutin");
            if (skill_cutin_prefab != null)
            {
                GameObject skill_cutin_object = Instantiate(skill_cutin_prefab);
                if (skill_cutin_object != null)
                {
                    m_NewBattleSkillCutin = skill_cutin_object.GetComponent <NewBattleSkillCutin>();
                    if (m_NewBattleSkillCutin != null)
                    {
                        skill_cutin_object.transform.SetParent(m_DebugPartyOffset.transform.parent, false);
                    }
                    else
                    {
                        Destroy(skill_cutin_object);
                    }
                }
            }
        }

        if (m_NewBattleSkillCutin != null &&
            m_CurrentCharaMaster != null)
        {
            int fix_id        = (int)m_CurrentCharaMaster.fix_id;
            int img_2_offsetX = (int)(m_OffsetXArray[m_Index, (int)CurrentUVTarget] * 1000);
            int img_2_offsetY = (int)(m_OffsetYArray[m_Index, (int)CurrentUVTarget] * 1000);
            int img_2_tiling  = (int)(m_TilingArray[m_Index, (int)CurrentUVTarget] * 1000);
            int size_width    = m_CurrentCharaMaster.size_width;
            int size_height   = m_CurrentCharaMaster.size_height;
            MasterDataDefineLabel.PivotType pivot_type = m_CurrentCharaMaster.pivot;
            int side_offset = m_CurrentCharaMaster.side_offset;
            m_NewBattleSkillCutin.debugSkillCutin(fix_id, img_2_tiling, img_2_offsetX, img_2_offsetY, size_width, size_height, pivot_type, side_offset);
        }
#endif
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (m_CharaIdCurrent != m_CharaIdRequest)
        {
            if (m_CharaIdRequest != 0)
            {
                m_CharaIdCurrent = m_CharaIdRequest;

                bool is_load = false;

                if (m_CharaIdCurrent > 0)
                {
                    // 通常ユニット
                    MasterDataParamChara master_chara = BattleParam.m_MasterDataCache.useCharaParam((uint)m_CharaIdCurrent);
                    if (master_chara != null)
                    {
                        float uv_off_x = master_chara.img_2_offsetX * 0.001f;
                        float uv_off_y = master_chara.img_2_offsetY * 0.001f;
                        float uv_size  = master_chara.img_2_tiling * 0.001f;
                        uv_size         *= 0.5f;
                        m_FaceCenterUv.x = uv_off_x + uv_size;
                        m_FaceCenterUv.y = uv_off_y + uv_size;
                        m_FaceUvSize     = uv_size * 0.5f * 1.2f;

                        m_CharaScaleAdjust = 1.0f;
                        if (m_ImageType == ImageType.CUTIN_DISP || m_ImageType == ImageType.CUTIN_DISP2)
                        {
                            // スキルカットインの時はキャラ表示サイズの大小の差を緩和(小さいものも大きめに表示)
                            m_CharaScaleAdjust = 1.0f + (640.0f - master_chara.size_width) * (0.5f / 640.0f);
                        }

                        m_EnemyDispMeshSize.x = master_chara.size_width * m_CharaScaleAdjust / m_MeterPerDot;
                        m_EnemyDispMeshSize.y = master_chara.size_height * m_CharaScaleAdjust / m_MeterPerDot;
                        if (m_ImageType != ImageType.FACE)
                        {
                            m_PivotType = master_chara.pivot;
                        }
                        else
                        {
                            m_PivotType = MasterDataDefineLabel.PivotType.NONE;
                        }
                        m_CharaWidth = master_chara.side_offset * 2.0f / m_MeterPerDot;
                        m_CharaTall  = master_chara.size_height / m_MeterPerDot; // 表示基準位置から上方向の高さ
                        if (m_PivotType == MasterDataDefineLabel.PivotType.CENTER)
                        {
                            if (m_CharaWidth >= 4.9f)
                            {
                                m_CharaTall *= 0.8f;
                            }
                            m_CharaTall *= 0.5f;
                        }

                        is_load = true;
                    }
                    else
                    {
                        m_MainSprite      = null;
                        m_TextureMask     = null;
                        m_TextureSize     = Vector2.zero;
                        m_Mesh            = null;
                        m_State           = ImageState.ERROR_IMAGE;
                        m_IsChangeTexture = true;
                    }
                }
                else
                {
                    // 主人公
                    m_FaceCenterUv.x = 0.5f;
                    m_FaceCenterUv.y = 0.5f;
                    m_FaceUvSize     = 0.1f;

                    m_EnemyDispMeshSize.x = 5.0f * 1.6f;
                    m_EnemyDispMeshSize.y = 5.0f * 1.6f;
                    m_PivotType           = MasterDataDefineLabel.PivotType.NONE;
                    m_CharaWidth          = m_EnemyDispMeshSize.x;

                    is_load = true;
                }

                if (is_load)
                {
                    // テクスチャロード
                    m_State = ImageState.LOADING;
                    if (BattleUnitTextureCache.HasInstance)
                    {
                        BattleUnitTextureCache.Instance.loadTexture(m_CharaIdCurrent, false);
                    }
                    else
                    {
                        AssetBundler.Create().
                        SetAsUnitTexture((uint)m_CharaIdCurrent,
                                         (o) =>
                        {
                            Texture2D texture = o.GetTexture2D(TextureWrapMode.Clamp);
                            m_MainSprite      = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), Vector2.one * 0.5f, 128, 0, SpriteMeshType.FullRect);
                            m_TextureMask     = null;
                            if (m_MainSprite != null)
                            {
                                m_State           = ImageState.READY_IMAGE;
                                m_IsChangeTexture = true;

                                calcSpriteAdjustment();
                            }
                            else
                            {
                                m_State           = ImageState.ERROR_IMAGE;
                                m_IsChangeTexture = true;
                            }
                        },
                                         (s) =>
                        {
                            m_State = ImageState.ERROR_IMAGE;
                        }
                                         ).Load();
                    }
                }
                else
                {
                    m_State           = ImageState.ERROR_IMAGE;
                    m_IsChangeTexture = true;
                }
            }
            else
            {
                clearCharaID();
            }
        }

        if (m_State == ImageState.LOADING &&
            BattleUnitTextureCache.HasInstance
            )
        {
            BattleUnitTextureCache.Status tex_status = BattleUnitTextureCache.Instance.getStatus(m_CharaIdCurrent);
            if (tex_status == BattleUnitTextureCache.Status.READY)
            {
                m_MainSprite      = BattleUnitTextureCache.Instance.getSprite(m_CharaIdCurrent);
                m_TextureMask     = BattleUnitTextureCache.Instance.getTexture(m_CharaIdCurrent, true);
                m_State           = ImageState.READY_IMAGE;
                m_IsChangeTexture = true;

                calcSpriteAdjustment();
            }
            else
            if (tex_status != BattleUnitTextureCache.Status.LOADING)
            {
                m_MainSprite      = null;
                m_TextureMask     = null;
                m_State           = ImageState.ERROR_IMAGE;
                m_IsChangeTexture = true;
            }
        }

        if (m_IsChangeTexture)
        {
            switch (m_CompnentType)
            {
            case CompnentType.SPRITE_RENDERER:
            {
                m_SpriteRenderer.sprite = m_MainSprite;

                if (m_MainSprite != null)
                {
                    if (m_TextureMask == null)
                    {
                        m_SpriteRenderer.material = m_OriginalMaterial;
                    }
                    else
                    {
                        m_SpriteRenderer.material = m_AlphaMaskMaterial;
                        m_SpriteRenderer.material.SetTexture("_AlphaTex", m_TextureMask);
                    }
                    transform.localPosition = m_SpriteOffsetPosition;
                    transform.localScale    = new Vector3(m_SpriteScale, m_SpriteScale, m_SpriteScale);

                    m_SpriteRenderer.enabled = true;
                }
                else
                {
                    m_SpriteRenderer.enabled = false;
                }
            }
            break;

            case CompnentType.MESH_RENDERER:
                break;

            case CompnentType.UI_IMAGE:
            {
                m_ImageComponent.sprite = m_MainSprite;
                if (m_MainSprite != null)
                {
                    m_ImageComponent.SetNativeSize();

                    if (m_TextureMask == null)
                    {
                        m_ImageComponent.material = m_OriginalMaterial;
                    }
                    else
                    {
                        m_ImageComponent.material = m_AlphaMaskMaterial;
                        m_ImageComponent.material.SetTexture("_AlphaTex", m_TextureMask);
                    }
                    transform.localPosition = m_SpriteOffsetPosition;
                    transform.localScale    = new Vector3(m_SpriteScale, m_SpriteScale, m_SpriteScale);

                    m_ImageComponent.enabled = true;
                }
                else
                {
                    m_ImageComponent.enabled = false;
                }
            }
            break;
            }
        }

        if (m_IsChangeColor || m_IsChangeTexture)
        {
            switch (m_CompnentType)
            {
            case CompnentType.SPRITE_RENDERER:
            {
                m_IsChangeColor        = false;
                m_SpriteRenderer.color = m_Color;
            }
            break;

            case CompnentType.MESH_RENDERER:
            {
                m_IsChangeColor = false;
                m_MeshRenderer.material.color = m_Color;
            }
            break;

            case CompnentType.UI_IMAGE:
            {
                m_IsChangeColor        = false;
                m_ImageComponent.color = m_Color;
            }
            break;
            }
        }

        m_IsChanged       = m_IsChangeTexture;
        m_IsChangeTexture = false;
    }
Exemplo n.º 3
0
    /// <summary>
    /// デバッグ用スキルカットイン再生
    /// </summary>
    /// <param name="chara_fix_id"></param>
    /// <param name="img_2_tiling"></param>
    /// <param name="img_2_offsetX"></param>
    /// <param name="img_2_offsetY"></param>
    public void debugSkillCutin(int chara_fix_id, int img_2_tiling, int img_2_offsetX, int img_2_offsetY, int size_width, int size_height, MasterDataDefineLabel.PivotType pivot, int side_offset)
    {
        MasterDataParamChara base_chara_master = MasterFinder <MasterDataParamChara> .Instance.Find(chara_fix_id);

        if (base_chara_master != null)
        {
            // ダミーのキャラマスターを生成(面倒なのでスキルカットインで使うところだけ設定)
            MasterDataParamChara dummy_chara_master = new MasterDataParamChara();
            dummy_chara_master.fix_id        = base_chara_master.fix_id;
            dummy_chara_master.element       = base_chara_master.element;
            dummy_chara_master.skill_active0 = base_chara_master.skill_active0;
            dummy_chara_master.img_2_tiling  = img_2_tiling;
            dummy_chara_master.img_2_offsetX = img_2_offsetX;
            dummy_chara_master.img_2_offsetY = img_2_offsetY;
            dummy_chara_master.size_width    = size_width;
            dummy_chara_master.size_height   = size_height;
            dummy_chara_master.pivot         = pivot;
            dummy_chara_master.side_offset   = side_offset;

            // ダミーのキャラマスターをバトルのキャッシュに登録
            BattleParam.m_MasterDataCache.clearCachePlayerAll();
            BattleParam.m_MasterDataCache.addCharaParam(dummy_chara_master);

            // ダミーのキャラデータを生成(バトルのキャッシュを使用して生成される)
            CharaOnce chara_once = new CharaOnce();
            bool      is_success = chara_once.CharaSetupFromID((uint)chara_fix_id, 1);
            if (is_success)
            {
                string skill_name = "スキル名";
                MasterDataDefineLabel.ElementType element_type = base_chara_master.element;

                MasterDataSkillActive skill_master = MasterFinder <MasterDataSkillActive> .Instance.Find((int)chara_once.m_CharaMasterDataParam.skill_active0);

                if (skill_master != null)
                {
                    skill_name   = skill_master.name;
                    element_type = skill_master.skill_element;
                }

                // ダミーのパーティを生成
                CharaOnce[] party_members = new CharaOnce[5];
                party_members[0]          = chara_once;
                BattleParam.m_PlayerParty = new CharaParty();
                BattleParam.m_PlayerParty.PartySetup(party_members, true);

                // カットインを開始
                clearSkill();
                addSkill(GlobalDefine.PartyCharaIndex.LEADER, skill_name, ESKILLTYPE.eACTIVE, element_type, 0);
                startCutin(false, false, false);
            }
        }
    }