Esempio n. 1
0
    void UpdateItem()
    {
        int nCurMaxGrid = CDataPool.Instance.UserBank_GetBankEndIndex();

        for (int i = 0; i < mActionItems.Count; i++)
        {
            if (nCurMaxGrid < i)
            {
                break;
            }
            ActionButton action = mActionItems[i];
            if (action != null)
            {
                ActionItem actionItem = Interface.Bank.Instance.EnumItem(i);
                if (actionItem.actionItem != null)
                {
                    if (action.CurrActionItem != null && action.CurrActionItem.GetID() == actionItem.actionItem.GetID())
                    {
                        continue;
                    }

                    action.SetActionItemByActionId(actionItem.actionItem.GetID());
                }
                else
                {
                    action.SetActionItemByActionId(-1);
                }
            }
        }
    }
Esempio n. 2
0
    //void Awake()
    //{
    //gameObject.SetActiveRecursively(true);


    //	EZScreenPlacement ScreenPlacement = gameObject.GetComponent<EZScreenPlacement>();
    //    if (ScreenPlacement != null)
    //ScreenPlacement.SetCamera(UISystem.Instance.UiCamrea);
    //		ScreenPlacement.RenderCamera = UISystem.Instance.UiCamrea;

    //     CEventSystem.Instance.RegisterEventHandle(GAME_EVENT_ID.GE_NEW_ITEM, OnEvent);
    //CEventSystem.Instance.RegisterEventHandle(GAME_EVENT_ID.GE_PACKAGE_ITEM_CHANGED, OnEvent);
    //     CEventSystem.Instance.RegisterEventHandle(GAME_EVENT_ID.GE_UNIT_HP,OnEvent);

    //     actionButton.AddInputDelegate(OnActionButtonClicked);

    //     gameObject.SetActiveRecursively(false);
    //  }

    void OnEvent(GAME_EVENT_ID gAME_EVENT_ID, List <string> vParam)
    {
        if (gAME_EVENT_ID == GAME_EVENT_ID.GE_NEW_ITEM)
        {
            int         id         = int.Parse(vParam[0]);
            CActionItem actionItem = CActionSystem.Instance.GetAction_ItemID(id, false);
            if (actionItem == null)
            {
                return;
            }

            actionId = actionItem.GetID();
            actionButton.SetActionItemByActionId(actionItem.GetID());

            CObject_Item item = actionItem.GetImpl() as CObject_Item;
            if (item != null)
            {
                titleText.Text = UIString.Instance.ParserString_Runtime("#{GET_NEW_ITEM}");
                descText.Text  = UIString.Instance.ParserString_Runtime("#{NEW_ITEM_DESC}");
            }
            UIWindowMng.Instance.ShowWindow("NewItemWindow");
        }
        //else if (gAME_EVENT_ID == GAME_EVENT_ID.GE_PACKAGE_ITEM_CHANGED)
        //{
        //CActionItem actionItem = CActionSystem.Instance.GetActionByActionId(actionId);
        //if (actionItem == null)
        // OnClose();
        // }
        else if (gAME_EVENT_ID == GAME_EVENT_ID.GE_UNIT_HP)
        {
            float hp = PlayerMySelf.Instance.GetHPPercent();
            if (hp <= 0.4)
            {
                CObject_Item item = CDataPool.Instance.GetMedicial();
                if (item != null)
                {
                    actionButton.UpdateItem(item.GetID());
                    titleText.Text = "血量剩余40%";
                    descText.Text  = UIString.Instance.ParserString_Runtime("#{NEW_ITEM_DESC}");
                    UIWindowMng.Instance.ShowWindow("NewItemWindow");
                }
            }
            else
            {
                OnClose();
            }
        }
    }
Esempio n. 3
0
    /// <summary>
    /// 升档
    /// </summary>
    void UpdateShengDang()
    {
        ClearShengDangContext();
        mIsEnableSD = false;
        if (mSelectedItem != null)
        {
            mSDSelectedAction.SetActionItem(mSelectedItem.GetID());
            string text = mSelectedItem.GetWhiteAttribute(0);
            mSDSelectedAttriDesc.Text = UIString.Instance.ParserString_Runtime(text);
            text = mSelectedItem.GetWhiteAttribute(1);
            if (text == "")
            {
                mSDSelectedAttriDesc2.Hide(true);
            }
            else
            {
                mSDSelectedAttriDesc2.Hide(false);
                mSDSelectedAttriDesc2.Text = UIString.Instance.ParserString_Runtime(text);
            }


            CActionItem actionItem = LifeAbility.Instance.GetEquipUpdatePreView(mSDSelectedAction.CurrActionItem.GetID());
            if (actionItem != null)
            {
                mSDPreviewAction.SetActionItemByActionId(actionItem.GetID());

                CObject_Item previewItem = mSDPreviewAction.CurrActionItem.GetImpl() as CObject_Item;
                if (previewItem != null)
                {
                    text = previewItem.GetWhiteAttribute(0);
                    mSDPreviewAttriDesc.Text = UIString.Instance.ParserString_Runtime(text);
                    text = previewItem.GetWhiteAttribute(1);
                    if (text == "")
                    {
                        mSDPreviewAttriDesc2.Hide(true);
                    }
                    else
                    {
                        mSDPreviewAttriDesc2.Text = UIString.Instance.ParserString_Runtime(text);
                        mSDPreviewAttriDesc2.Hide(false);
                    }
                }
            }

            int nPrescrId = LifeAbility.Instance.GetPrescrID(mSelectedItem.GetIdTable());
            if (nPrescrId == -1)
            {
                NoPrescrHandler(mSelectedItem.GetIdTable());
                mSDOK.controlIsEnabled = false;
                return;
            }
            NoPrescrHandler(-1);
            //材料
            int nCount = LifeAbility.Instance.GetPrescrStuffCount(nPrescrId);
            //int nMaterial = -1;
            for (int i = 1; i < nCount; i++) //第一个材料为当前装备,跳过不显示
            {
                Stuff stuff = LifeAbility.Instance.GetPrescrStuff(i, nPrescrId);
                if (stuff.nID == -1)
                {
                    mSDMaterials[i - 1].SetActionItem(-1);
                    mSDMaterialTexts[i - 1].Text = "";
                    continue;
                }
                bool bCreateNew = true;
                if (mSDMaterials[i - 1].CurrActionItem != null)
                {
                    if (mSDMaterials[i - 1].CurrActionItem.GetIDTable() == stuff.nID)
                    {
                        bCreateNew = false;
                    }
                    else
                    {
                        mSDMaterials[i - 1].CurrActionItem.DestroyImpl();
                    }
                }
                if (bCreateNew)
                {
                    CObject_Item     pItemObj1   = ObjectSystem.Instance.NewItem((uint)stuff.nID);
                    CActionItem_Item actionItem1 = CActionSystem.Instance.GetAction_ItemID(pItemObj1.GetID(), false);

                    mSDMaterials[i - 1].SetActionItemByActionId(actionItem1.GetID());
                }

                int count = CDataPool.Instance.UserBag_CountItemByIDTable(stuff.nID);
                if (count >= stuff.nNum)
                {
                    count       = stuff.nNum;
                    mIsEnableSD = true;
                }
                else
                {
                    mIsEnableSD = false;
                }
                mSDMaterialTexts[i - 1].Text = count + "/" + stuff.nNum;
            }

            mSDOK.controlIsEnabled = mIsEnableSD;
        }
    }
Esempio n. 4
0
    void UpdateSkill()
    {
        if (!gameObject.active)
        {
            return;
        }

        ResetUI();

        if (tabMode == TAB_MODE.TAB_SELFXINFA)
        {
            int           num         = CActionSystem.Instance.GetSkillActionNum();
            int           nXinfaIndex = -1;
            IUIListObject listItem    = null;
            for (int i = 0; i < num; i++)
            {
                CActionItem_Skill skill = CActionSystem.Instance.EnumAction(i, ActionNameType.Skill) as CActionItem_Skill;
                if (skill != null && (skill.GetXinfaID() >= SCLIENT_SKILLCLASS.XINFATYPE_JINGJIEBEGIN && skill.GetXinfaID() < SCLIENT_SKILLCLASS.XINFATYPE_SKILLBENGIN))
                {
                    nXinfaIndex++;
                    int nOffset = nXinfaIndex % 3;
                    if (nOffset == 0)
                    {
                        listItem = list.CreateItem(itemPrefab);
                        listItem.gameObject.name = "XinfaListItem" + nXinfaIndex;
                        for (int j = 0; j < 3; j++)
                        {
                            listItem.gameObject.transform.FindChild("Item" + j).gameObject.SetActiveRecursively(false);
                        }
                    }
                    GameObject item = listItem.gameObject.transform.FindChild("Item" + nOffset).gameObject;
                    item.SetActiveRecursively(true);
                    ActionButton skillAction = item.GetComponentInChildren <ActionButton>();
                    if (skillAction != null)
                    {
                        skillAction.SetActionItemByActionId(skill.GetID());
                        skillAction.DisableDrag();
                        skillAction.EnableDoAction = false;
                    }
                    UIButton bg = item.transform.FindChild("Bg").gameObject.GetComponent <UIButton>();
                    if (bg != null)
                    {
                        bg.SetInputDelegate(handlerInput);
                    }

                    SpriteText txt = item.transform.FindChild("NameLabel").gameObject.GetComponent <SpriteText>();
                    if (txt != null)
                    {
                        txt.Text = skill.GetName() + "\n" + "等级:" + skill.GetSkillLevel();
                    }

                    UIButton levelBtn = item.transform.FindChild("LevelUp").gameObject.GetComponent <UIButton>();
                    if (levelBtn != null)
                    {
                        levelBtn.SetInputDelegate(levelUpInputDelegate);
                        //LogManager.LogWarning("Set Delegate : " + levelBtn.gameObject.name);
                    }


                    SCLIENT_SKILLCLASS skillClass = CObjectManager.Instance.getPlayerMySelf().GetCharacterData().Get_SkillClass(skill.GetXinfaID());
                    //升级可操作
                    string error;
                    if (!CDataPool.Instance.isCanSkillLevelUp(skillClass.m_pDefine.nID, skillClass.m_nLevel + 1, out error))
                    {
                        item.transform.FindChild("LevelUp").gameObject.GetComponent <UIButton>().controlIsEnabled = false;
                        //toolText[showIndex] = UIString.Instance.ParserString_Runtime(error);
                    }
                    else
                    {
                        item.transform.FindChild("LevelUp").gameObject.GetComponent <UIButton>().controlIsEnabled = true;
                        //toolText[showIndex] = null;
                    }
                }
            }
        }
        else if (tabMode == TAB_MODE.TAB_PETXINFA)
        {
            //int num = CActionSystem.Instance.GetSkillActionNum();
            ////LogManager.LogWarning("Skill count = " + num);
            //int showIndex = 0;
            //for (int i = 0; i < num; i++)
            //{
            //    CActionItem_Skill skill = CActionSystem.Instance.EnumAction(i, ActionNameType.Skill) as CActionItem_Skill;


            //    if (showIndex >= buttons.Count) break;

            //    //超过51不属于普通技能
            //    if (skill != null && (skill.GetXinfaID() == -1 && skill.GetIDTable() < 51))
            //    {
            //        // LogManager.LogWarning("Xinfa = " + skill.GetXinfaID() + "skill = " + skill.GetDefineID() + "index=" + i);
            //        //这里可能有问题
            //        items[showIndex].SetActiveRecursively(true);

            //        buttons[showIndex].UpdateItemFromAction(skill);
            //        buttons[showIndex].EnableDrag();
            //        buttons[showIndex].EnableDoAction = true;

            //        //update text
            //        txtNames[showIndex].Text = skill.GetName();
            //        txtLevels[showIndex].Text = "等级:" + skill.GetSkillLevel();

            //        levelUpBtns[showIndex].gameObject.SetActiveRecursively(false);

            //        showIndex++;
            //    }
            //}
        }
        if (list.UnviewableArea > 0)
        {
            list.slider.Hide(false);
        }
        else
        {
            list.slider.Hide(true);
        }
    }