コード例 #1
0
    /// <summary>
    /// 处理-瞄准使用道具的目标
    /// </summary>
    public void HandlerForUseItemSightTarget()
    {
        if (!isActiveAndEnabled)
        {
            return;
        }
        //获取道具栏上的物品
        UserDataBean userData  = GameDataHandler.Instance.manager.GetUserData();
        ItemsBean    itemsData = userData.GetItemsFromShortcut();

        ItemsHandler.Instance.UseItemForSightTarget(itemsData);
    }
コード例 #2
0
    /// <summary>
    /// 丢弃处理
    /// </summary>
    /// <param name="callback"></param>
    public void HandleForDrop(CallbackContext callback)
    {
        //获取道具栏上的物品
        UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();
        ItemsBean    itemData = userData.GetItemsFromShortcut();

        //丢出道具
        Player  player      = GameHandler.Instance.manager.player;
        Vector3 randomFroce = new Vector3(UnityEngine.Random.Range(-0.5f, 0.5f), UnityEngine.Random.Range(0f, 0.5f), UnityEngine.Random.Range(-0.5f, 0.5f));

        ItemsHandler.Instance.CreateItemCptDrop(itemData.itemId, 1, itemData.meta, player.transform.position + Vector3.up, ItemDropStateEnum.DropNoPick, player.transform.forward + randomFroce);

        //扣除道具
        userData.AddItems(itemData, -1);
        //刷新UI
        UIHandler.Instance.RefreshUI();
    }
コード例 #3
0
    public void HandleForUse(CallbackContext callback, ItemUseTypeEnum useType, bool isUserItem = true)
    {
        if (!isActiveAndEnabled)
        {
            return;
        }
        if (UGUIUtil.IsPointerUI())
        {
            return;
        }
        this.isUseItem = isUserItem;
        timeForUseItem = 0;
        //获取道具栏上的物品
        UserDataBean userData  = GameDataHandler.Instance.manager.GetUserData();
        ItemsBean    itemsData = userData.GetItemsFromShortcut();
        Player       player    = GameHandler.Instance.manager.player;

        ItemsHandler.Instance.UseItem(player.gameObject, itemsData, useType);
    }
コード例 #4
0
    /// <summary>
    /// 初始化状态栏
    /// </summary>
    public void InitShortcuts()
    {
        UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();

        for (int i = 0; i < listShortcut.Count; i++)
        {
            listShortcut[i].SetData(UIViewItemContainer.ContainerType.Shortcuts, userData.GetItemsFromShortcut(i), i);
        }

        for (int i = 0; i < listShortcut.Count; i++)
        {
            UIViewItemContainer uiViewItem = listShortcut[i];
            if (uiViewItem.viewIndex == userData.indexForShortcuts)
            {
                //如果选中的是当前状态栏
                uiViewItem.SetSelectState(true);
            }
            else
            {
                //如果未选中当前状态栏
                uiViewItem.SetSelectState(false);
            }
        }
    }