private void OnTrigger()
    {
        //try get target
        var param = m_ActionPlayer.GetActionParam();

        if (null != param && null != param.Object && param.Object is FuncContext)
        {
            FuncContext context = param.Object as FuncContext;
            if (!context.ContainsKey(FuncContext.ContextKey.LimitId) ||
                !context.ContainsKey(FuncContext.ContextKey.FunctionId))
            {
                return;
            }

            int          limitId = (int)(context.Get(FuncContext.ContextKey.LimitId));
            int          funcId  = (int)(context.Get(FuncContext.ContextKey.LimitId));
            HandleTarget target  = null;
            Ilife        user    = context.Get(FuncContext.ContextKey.User) as Ilife;
            if (context.ContainsKey(FuncContext.ContextKey.Target))
            {
                //locked skill
                target = HandleTarget.GetHandleTarget(user, context.Get(FuncContext.ContextKey.Target) as Ilife);
            }
            else
            {
                //target is null,unlocked skill
                int targetId = (int)(context.Get(FuncContext.ContextKey.TargetId));
                target = TargetMethods.GetTargetList(user, targetId, null);
            }

            //exec attack
            if (LimitMethods.HandleLimitExec(target, limitId, null))
            {
                FuncMethods.HandleFuncExec(target, funcId, null);
            }
        }
    }
Exemplo n.º 2
0
    public virtual bool ExecNode()
    {
        HandleTarget target = TargetMethods.GetTargetList(this, m_NodeData.TargetMethodId, null);

        if (target.GetTarget(EFuncTarget.EFT_Target).Count == 0)
        {
            if (m_CurrentTargetList.Count == 0)
            {
                // no target ,not trigger
                return(true);
            }
            else
            {
                foreach (Ilife elem in m_CurrentTargetList)
                {
                    //离开
                    Debuger.Log("trigger exit " + elem.GetInstanceId());
                    HandleTarget tmpTarget = HandleTarget.GetHandleTarget(this, elem);
                    if (LimitMethods.HandleLimitExec(tmpTarget, m_NodeData.ExitLimitMethodId, null))
                    {
                        FuncMethods.HandleFuncExec(tmpTarget, m_NodeData.ExitFuncMethodId, null);
                    }
                }
                m_CurrentTargetList.Clear();
            }
            return(true);
        }

        List <Ilife> targetList = target.GetTarget(EFuncTarget.EFT_Target);

        for (int i = 0; i < targetList.Count; ++i)
        {
            if (m_NodeData.IsTick)
            {
                //进入
                Debuger.Log("trigger enter " + targetList[i].GetInstanceId());
                HandleTarget tmpTarget = HandleTarget.GetHandleTarget(this, targetList[i]);
                if (LimitMethods.HandleLimitExec(tmpTarget, m_NodeData.EnterLimitMethodId, null))
                {
                    FuncMethods.HandleFuncExec(tmpTarget, m_NodeData.EnterFuncMethodId, null);
                }
            }

            if (!m_CurrentTargetList.Contains(targetList[i]))
            {
                if (!m_NodeData.IsTick)
                {
                    //进入
                    Debuger.Log("trigger enter " + targetList[i].GetInstanceId());
                    HandleTarget tmpTarget = HandleTarget.GetHandleTarget(this, targetList[i]);
                    if (LimitMethods.HandleLimitExec(tmpTarget, m_NodeData.EnterLimitMethodId, null))
                    {
                        FuncMethods.HandleFuncExec(tmpTarget, m_NodeData.EnterFuncMethodId, null);
                    }
                }
            }
            else
            {
                m_CurrentTargetList.Remove(targetList[i]);
            }
        }

        foreach (Ilife elem in m_CurrentTargetList)
        {
            HandleTarget tmpTarget = HandleTarget.GetHandleTarget(this, elem);
            if (LimitMethods.HandleLimitExec(tmpTarget, m_NodeData.ExitLimitMethodId, null))
            {
                //离开
                Debuger.Log("trigger exit " + elem.GetInstanceId());
                FuncMethods.HandleFuncExec(tmpTarget, m_NodeData.ExitFuncMethodId, null);
            }
        }
        ResetCurrentTargetList(targetList);

        //collection target instance

        return(true);
    }