コード例 #1
0
ファイル: UITutorial.cs プロジェクト: 1010MMR/Portfolio
    public override void OpenUI(TutorialInfo info, UITutorialCloseCB completeCB = null)
    {
        m_curTutorialInfo      = info;
        m_uiTutorialCompleteCB = completeCB;

        SetActive(true);

        m_uiAnchor.side = info.attachAnchorType;

        m_objTransform.gameObject.SetActive(true);
        m_objTransform.localPosition = GetPosition(info.highlightPos);

        m_targetSprite.width  = GetSizeValue((int)info.highlighSize.x);
        m_targetSprite.height = GetSizeValue((int)info.highlighSize.y);

        switch (info.TriggerType)
        {
        case TUTORIAL_TRIGGER_TYPE.TYPE_TOUCH_VIEW:
            m_targetSprite.GetComponent <Collider>().enabled = true;
            m_targetEventListener.onTutorialClick            = OnTouchViewClick;
            break;

        case TUTORIAL_TRIGGER_TYPE.TYPE_TOUCH_CALLBACK:
            m_targetSprite.GetComponent <Collider>().enabled = true;
            m_targetEventListener.onTutorialClick            = OnTouchCallbackClick;
            break;

        default:
            m_targetSprite.GetComponent <Collider>().enabled = false;
            m_targetEventListener.onTutorialClick            = null;
            break;
        }

        OnOffSprite(true);
    }
コード例 #2
0
ファイル: SoundMng.cs プロジェクト: jhj000213/ThieFour
 public void SetLineLenght()
 {
     _LineLenght            = float.Parse(_LineLenghtLabel.text);
     _LineLenghtBar.width   = (int)_LineLenght;
     _LineLenghtBar_2.width = (int)_LineLenght;
     _LineLenghtBar.GetComponent <BoxCollider>().size   = new Vector3(_LineLenght, 50, 0);
     _LineLenghtBar.GetComponent <BoxCollider>().center = new Vector3(_LineLenght / 2, 0, 0);
 }
コード例 #3
0
    IEnumerator OnAlpha(float time)
    {
        yield return(new WaitForSeconds(time));

        _OnAlpha = true;
        _OptionBg_UI.GetComponent <Animator>().SetTrigger("onalpha");
    }
コード例 #4
0
    private IEnumerator FadeAll(NewImageEffect effect, Action callback, bool includeBack, bool includeDiabox)
    {
        Dictionary <int, float> originAlpha = new Dictionary <int, float>();

        foreach (int i in GetDepthNum())
        {
            UI2DSprite ui = GetSpriteByDepth(i);
            originAlpha[i] = ui.alpha;
        }
        if (includeBack)
        {
            originAlpha[-1] = bgSprite.alpha;
        }
        if (includeDiabox)
        {
            duiManager.Close(effect.time, () => { });
            //originAlpha[-2] = duiManager.mainContainer.GetComponent<UIWidget>().alpha;
            //duiManager.clickContainer.SetActive(false);
        }
        float t     = 0;
        float final = effect.state.spriteAlpha;

        while (t < 1)
        {
            t = Mathf.MoveTowards(t, 1, 1 / effect.time * Time.deltaTime);
            if (includeDiabox)
            {
                //float origin = originAlpha[-2];
                //float alpha = origin + t * (final - origin);

                //duiManager.mainContainer.GetComponent<UIWidget>().alpha = alpha;
            }
            foreach (int i in GetDepthNum())
            {
                UI2DSprite ui     = GetSpriteByDepth(i);
                float      origin = originAlpha[i];
                float      alpha  = origin + t * (final - origin);
                ui.GetComponent <UIRect>().alpha = alpha;
            }
            if (includeBack)
            {
                float origin = originAlpha[-1];
                float alpha  = origin + t * (final - origin);
                bgSprite.GetComponent <UIRect>().alpha = alpha;
            }
            yield return(null);
        }
        //删除
        foreach (int i in GetDepthNum())
        {
            RemoveSpriteByDepth(i);
        }
        if (includeBack)
        {
            bgSprite.sprite2D = null;
        }
        //if (includeDiabox)duiManager.mainContainer.SetActive(false);
        callback();
    }
コード例 #5
0
    public void OpenPicAt(int x)
    {
        int index = (pageNum - 1) * 15 + x;

        //查看图片以ID作为索引
        largepic.GetComponent <UI2DSprite>().sprite2D = Resources.Load <Sprite>(cgInfoTable[index]);
        StartCoroutine(FadeIn(large));
    }
コード例 #6
0
    private IEnumerator FadeAll(NewImageEffect effect, Action callback, bool includeBack, bool includeDiabox)
    {
        float t      = 0;
        float origin = 1 - effect.state.spriteAlpha;
        float final  = effect.state.spriteAlpha;

        if (includeDiabox)
        {
            dUiManager.clickContainer.SetActive(false);
        }
        while (t < 1)
        {
            t = Mathf.MoveTowards(t, 1, 1 / effect.time * Time.fixedDeltaTime);
            float alpha = origin + t * (final - origin);
            foreach (int i in GetDepthNum())
            {
                UI2DSprite ui = GetSpriteByDepth(i);
                ui.GetComponent <UIRect>().alpha = alpha;
            }
            if (includeBack)
            {
                bgSprite.alpha = alpha;
            }
            if (includeDiabox)
            {
                dUiManager.mainContainer.GetComponent <UIWidget>().alpha = alpha;
            }
            yield return(null);
        }
        //删除
        foreach (int i in GetDepthNum())
        {
            RemoveSpriteByDepth(i);
        }
        if (includeBack)
        {
            bgSprite.sprite2D = null;
        }
        if (includeDiabox)
        {
            dUiManager.mainContainer.SetActive(false);
        }
        callback();
    }
コード例 #7
0
    //GetCurCharInfo를 OnEnable에서 호출해주기때문에 start에서 아래 정보들을 가져오면 너무 늦어서 널이 뜸.
    void Awake()
    {
        m_charTween = m_charSpr.GetComponent <TweenPosition>();
        m_menuBtns  = m_menuBtnObj.GetComponentsInChildren <UIButton>();
        var results = m_menuObj.GetComponentsInChildren <ILobbyMenu>();

        m_menu = new ILobbyMenu[results.Length];

        for (int i = 0; i < m_menu.Length; i++)
        {
            m_menu[i] = results[i];
            m_menu[i].CloseUI();
        }

        for (int i = 0; i < m_menuBtns.Length; i++)
        {
            EventDelegate del = new EventDelegate(this, "OpenMenu");
            del.parameters[0] = Util.MakeParameter(m_menuBtns[i], typeof(UIButton));
            m_menuBtns[i].onClick.Add(del);
        }
    }
コード例 #8
0
    static void SetBG(Transform target, GameObject prefabInstance)
    {
        if (target == null)
        {
            return;
        }
        //set bg
        UI2DSprite bg     = target.GetComponent <UI2DSprite>();
        Sprite     tempSp = (Sprite)AssetDatabase.LoadAssetAtPath("Assets/ArtResources/allArtRes_optimize_/Common/CommonBg/Common_Bg_Top.png", typeof(Sprite));

        bg.sprite2D = tempSp;

        bg.type = UIBasicSprite.Type.Sliced;
        //x z
        //y w
        bg.border = new Vector4(1000f, 0f, 200f, 0);

        UIWidget tempWidget = bg.GetComponent <UIWidget>();

        tempWidget.pivot  = UIWidget.Pivot.Top;
        tempWidget.depth  = 0;
        tempWidget.width  = 1280;
        tempWidget.height = 62;
        bg.ResetAnchors();

        bg.leftAnchor = new UIRect.AnchorPoint()
        {
            target   = prefabInstance.transform,
            absolute = 0,
        };

        bg.rightAnchor = new UIRect.AnchorPoint()
        {
            target   = prefabInstance.transform,
            relative = 1.0f,
            absolute = 0,
        };

        bg.transform.localPosition = Vector3.zero;
    }
コード例 #9
0
    static void ReturnBtn(Transform target, GameObject prefabInstance, Transform bgTrans)
    {
        if (target == null)
        {
            return;
        }
        if (bgTrans == null)
        {
            return;
        }
        //set bg
        UI2DSprite bg     = target.GetComponent <UI2DSprite>();
        Sprite     tempSp = (Sprite)AssetDatabase.LoadAssetAtPath("Assets/ArtResources/allArtRes_optimize_/Common/CommonButton/Common_Btn_Back.png", typeof(Sprite));

        bg.sprite2D = tempSp;

        bg.type = UIBasicSprite.Type.Simple;
        //x z
        //y w
        //bg.border = new Vector4(1000f, 200f, 0, 0);

        UIWidget tempWidget = bg.GetComponent <UIWidget>();

        tempWidget.pivot  = UIWidget.Pivot.Center;
        tempWidget.depth  = 1;
        tempWidget.width  = 138;
        tempWidget.height = 60;

        bg.leftAnchor = new UIRect.AnchorPoint()
        {
            target   = bgTrans,
            absolute = 0,
        };

        bg.rightAnchor = new UIRect.AnchorPoint()
        {
            target   = bgTrans,
            absolute = 138,
        };
        bg.bottomAnchor = new UIRect.AnchorPoint()
        {
            target   = bgTrans,
            relative = 0f,
            absolute = 3,
        };
        bg.topAnchor = new UIRect.AnchorPoint()
        {
            target   = bgTrans,
            relative = 1f,
            absolute = 1,
        };

        BoxCollider2D box = target.GetComponent <BoxCollider2D>();

        if (box == null)
        {
            Debug.LogError(prefabInstance.name + " has no box");
            return;
        }

        box.offset = Vector2.zero;
        box.size   = new Vector2(138, 62);
    }