//获得操作物品
        public ActionItem EnumItem(int nIndex)
        {
            //查询物品
            ActionItem luaItem;

            CActionItem pActionItem = CActionSystem.Instance.EnumAction(nIndex, ActionNameType.bankItem);

            if (pActionItem != null)
            {
                luaItem.actionItem = pActionItem;

                if (((CObject_Item)(pActionItem.GetImpl())).IsLocked())
                {
                    luaItem.isLock = true;
                }
                else
                {
                    luaItem.isLock = false;
                }
                return(luaItem);
            }

            //非法ActionItem
            luaItem.actionItem = null;
            luaItem.isLock     = false;

            return(luaItem);
        }
Ejemplo n.º 2
0
    public void Player_UseSkill(int idSkill)
    {
        CActionItem pAction = (CActionItem)CActionSystem.Instance.GetAction_SkillID(idSkill);

        if (pAction == null)
        {
            return;
        }

        //取得技能数据
        SCLIENT_SKILL pSkill = (SCLIENT_SKILL)pAction.GetImpl();

        if (pSkill == null)
        {
            return;
        }

        CAI_Base pMySelfAI = CObjectManager.Instance.getPlayerMySelf().CharacterLogic_GetAI();

        //发送消息
        SCommand_AI cmdTemp = new SCommand_AI();

        cmdTemp.m_wID = (int)AICommandDef.AIC_USE_SKILL;
        cmdTemp.SetValue(0, pSkill.m_pDefine.m_nID);
        cmdTemp.SetValue(1, pSkill.m_nLevel);
        cmdTemp.SetValue(2, MacroDefine.INVALID_ID);
        cmdTemp.SetValue(3, -1.0f);
        cmdTemp.SetValue(4, -1.0f);
        cmdTemp.SetValue(5, -1.0f);
        cmdTemp.SetValue(6, MacroDefine.INVALID_GUID);
        pMySelfAI.PushCommand(cmdTemp);

        //发送事件
        CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_ON_SKILL_ACTIVE, idSkill);
    }
Ejemplo n.º 3
0
    void OnEvent(GAME_EVENT_ID eventid, List <string> vParam)
    {
        switch (eventid)
        {
        case GAME_EVENT_ID.GE_CHANGE_BAR:
        {
            for (int i = 0; i < MAX_SHORTCUT_COUNT; i++)
            {
                int actionID = CActionSystem.Instance.MainMenuBar_Get(i);
                mItems[i] = null;
                CActionItem pItem = CActionSystem.Instance.GetActionByActionId(actionID);
                if (pItem != null)
                {
                    switch (pItem.GetType())
                    {
                    case ACTION_OPTYPE.AOT_SKILL:
                    {
                        SCLIENT_SKILL pSkill = pItem.GetImpl() as SCLIENT_SKILL;
                        if (pSkill == null)
                        {
                            break;
                        }
                        mItems[i] = pItem;
                    }
                    break;

                    case ACTION_OPTYPE.AOT_PET_SKILL:
                    {
                        PET_SKILL pPetSkill = pItem.GetImpl() as PET_SKILL;
                        if (pPetSkill == null)
                        {
                            break;
                        }
                        mItems[i] = pItem;
                    }
                    break;
                    }
                }
            }
        }
        break;
        }
    }
Ejemplo n.º 4
0
    void SetLocked(ActionButton actionBtn, CActionItem actionItem)
    {
        CObject_Item item = actionItem.GetImpl() as CObject_Item;

        if (item.isLocked)
        {
            actionBtn.Disable();
        }
        else
        {
            actionBtn.Enable();
        }
    }
Ejemplo n.º 5
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();
            }
        }
    }
Ejemplo n.º 6
0
    public void Player_UseSkill(int idSkill, float fDir)
    {
        //判断是否为合法的范围技能
        CActionItem pAction = (CActionItem)CActionSystem.Instance.GetAction_SkillID(idSkill);

        if (pAction != null)
        {
            return;
        }

        //取得技能数据
        SCLIENT_SKILL pSkill = (SCLIENT_SKILL)pAction.GetImpl();

        if (pSkill != null)
        {
            return;
        }


        //检测目标是否合法

        //	if(!(pSkill->IsValidTarget(idObj))) return;


        CAI_Base pMySelfAI = CharacterLogic_GetAI();

        //发送消息
        SCommand_AI cmdTemp = new SCommand_AI();

        cmdTemp.m_wID = (int)AICommandDef.AIC_USE_SKILL;
        cmdTemp.SetValue(0, pSkill.m_pDefine.m_nID);
        cmdTemp.SetValue(1, pSkill.m_nLevel);
        cmdTemp.SetValue(2, MacroDefine.INVALID_ID);
        cmdTemp.SetValue(3, -1.0f);
        cmdTemp.SetValue(4, -1.0f);
        cmdTemp.SetValue(5, fDir);
        cmdTemp.SetValue(6, -1.0f);
        cmdTemp.SetValue(7, MacroDefine.INVALID_GUID);
        pMySelfAI.PushCommand(cmdTemp);

        //发送事件
        CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_ON_SKILL_ACTIVE, idSkill);
    }
Ejemplo n.º 7
0
    bool isAttackableSkill(CActionItem item)
    {
        if (item == null)
        {
            return(false);
        }
        bool          result = false;
        SCLIENT_SKILL pSkill = item.GetImpl() as SCLIENT_SKILL;

        switch (item.GetType())
        {
        case ACTION_OPTYPE.AOT_SKILL:
        {
            if (pSkill == null)
            {
                break;
            }
            ENUM_SELECT_TYPE typeSel = (ENUM_SELECT_TYPE)pSkill.m_pDefine.m_nSelectType;
            switch (typeSel)
            {
            case ENUM_SELECT_TYPE.SELECT_TYPE_CHARACTER:
            case ENUM_SELECT_TYPE.SELECT_TYPE_DIR:
            case ENUM_SELECT_TYPE.SELECT_TYPE_POS:
            case ENUM_SELECT_TYPE.SELECT_TYPE_NONE:
                result = true;
                break;

            default:
                break;
            }
        }
        break;

        default:
            break;
        }

        if (result)
        {
            OPERATE_RESULT retVal = pSkill.IsCanUse_CheckCoolDown();
            if (retVal != OPERATE_RESULT.OR_OK)
            {
                return(false);
            }

            retVal = pSkill.IsCanUse_CheckPassive();
            if (retVal != OPERATE_RESULT.OR_OK)
            {
                return(false);
            }

            retVal = pSkill.IsCanUse_CheckLevel(CObjectManager.Instance.getPlayerMySelf().ID, pSkill.m_nLevel);
            if (retVal != OPERATE_RESULT.OR_OK)
            {
                return(false);
            }

            retVal = pSkill.IsCanUse_CheckFightState(CObjectManager.Instance.getPlayerMySelf().ID);
            if (retVal != OPERATE_RESULT.OR_OK)
            {
                return(false);
            }

            retVal = pSkill.IsCanUse_CheckDeplete(CObjectManager.Instance.getPlayerMySelf().ID);
            if (retVal != OPERATE_RESULT.OR_OK)
            {
                return(false);
            }

            retVal = pSkill.IsCanUse_Leaned();
            if (retVal != OPERATE_RESULT.OR_OK)
            {
                return(false);
            }
        }
        return(result);
    }
Ejemplo n.º 8
0
    bool CanUseSkill(CActionItem skillItem, CObject_Character target)
    {
        if (skillItem == null)
        {
            return(false);
        }
        if (target == null)
        {
            return(false);
        }
        if (target.IsDie())
        {
            return(false);
        }
        switch (skillItem.GetType())
        {
        case ACTION_OPTYPE.AOT_SKILL:
        {
            SCLIENT_SKILL pSkill = skillItem.GetImpl() as SCLIENT_SKILL;
            if (pSkill == null)
            {
                break;
            }

            Vector3 avatarPos        = CObjectManager.Instance.getPlayerMySelf().GetPosition();
            Vector3 avatarPosOnPlane = new Vector3(avatarPos.x, 0, avatarPos.z);
            Vector3 targetPos        = new Vector3(-1, 0, -1);
            int     ServerID         = -1;
            targetPos = new Vector3(target.GetPosition().x, 0, target.GetPosition().z);
            ServerID  = target.ServerID;
            Vector3        PosOnPlane = new Vector3(targetPos.x, 0, targetPos.z);
            float          dir        = Vector3.Angle(avatarPosOnPlane, PosOnPlane);
            OPERATE_RESULT result     = pSkill.IsCanUse(CObjectManager.Instance.getPlayerMySelf().ID,
                                                        pSkill.m_nLevel,
                                                        ServerID,
                                                        targetPos.x,
                                                        targetPos.z,
                                                        dir);

            if (result == OPERATE_RESULT.OR_OK)
            {
                return(true);
            }
        }
        break;

        case ACTION_OPTYPE.AOT_PET_SKILL:
        {
            PET_SKILL pPetSkill = skillItem.GetImpl() as PET_SKILL;
            if (pPetSkill == null)
            {
                break;
            }
            if (Interface.Pet.Instance.IsFighting(pPetSkill.m_nPetNum))
            {
                return(true);
            }
        }
        break;
        }
        return(false);
    }