Пример #1
0
    public override void OnPropBeginUsing()
    {
        if (m_isOver)
        {
            // 主角动作
            ((MapHeroNode)MapNodeManager.Instance.GetHeroNode()).Operate();

            // 重置状态
            GetComponent <Image>().sprite = m_savedSprite;
            m_isOver = false;
            Inventory.Instance.RemoveProp(PropId);
            m_uiBtn.SetActive(false);

            // 执行动作
            PropAction action = PropData.GetData <PropAction>("reset_action");
            if (action.Action != null)
            {
                action.Action();
            }
            // 还原 旋转动画
            if (PropId == 205)
            {
                transform.rotation = Quaternion.Euler(0, 0, -45);
            }
            if (PropId == 207)
            {
                transform.rotation = Quaternion.Euler(0, 0, 0);
            }
            if (PropId == 205)
            {
                SetGreenLight();
            }

            // 道具重置完后的文字
            string tips = PropData.GetData <string>("reset_comment");
            if (tips != default(string))
            {
                UICommentory.Instance.SetTips(tips);
            }

            return;
        }

        base.OnPropBeginUsing();

        // 使用 旋转动画
        if (PropId == 205)
        {
            // 旋转一定角度开启
            float rotation = 0f;
            transform.DORotate(new Vector3(0, 0, rotation), 0.5f);
            SetGreenLight();
        }
        if (PropId == 207)
        {
            // 旋转一定角度开启
            float rotation = -71f;
            transform.DORotate(new Vector3(0, 0, rotation), 0.5f);
        }
    }
Пример #2
0
    public virtual void OnPropEndUsing()
    {
        // 使用完后图标的替换
        string usedIconPath = PropData.GetData <string>("used_icon");

        if (usedIconPath != default(string))
        {
            Texture2D tex = Resources.Load(usedIconPath) as Texture2D;
            Sprite    spr = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
            GetComponent <Image>().sprite = spr;
        }

        // 使用完后所关联物体图标的替换
        string associateIconPath = PropData.GetData <string>("associated_obj_used_icon");

        if (AssociatedObj && associateIconPath != default(string))
        {
            Texture2D tex = Resources.Load(associateIconPath) as Texture2D;
            Sprite    spr = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
            AssociatedObj.GetComponent <Image>().sprite = spr;
        }

        // 执行动作
        PropAction action = PropData.GetData <PropAction>("used_action");

        if (action.Action != null)
        {
            action.Action();
        }

        // 道具使用完后的文字
        string tips = PropData.GetData <string>("used_comment");

        if (tips != default(string))
        {
            UICommentory.Instance.SetTips(tips);
        }

        m_isUsing = false;
    }