public void FixedUpdate()
    {
        for (int index = m_actionList.Count - 1; index >= 0; --index)
        {
            ActorAction action = m_actionList[index];
            if (!action.IsInited)
            {
                action.AnimStartTime = Time.time;
                action.OnEnter();
                action.IsInited = true;
            }
            if (!action.IsEnable)
            {
                RemoveDisableCount(action.GetActionType());
                m_actionList.RemoveAt(index);

                ReleaseObj(action);
                continue;
            }
            if (action.OnUpdate())
            {
                action.OnExit();
                RemoveDisableCount(action.GetActionType());
                action.IsEnable = false;

                m_actionList.RemoveAt(index);
                ReleaseObj(action);
            }
        }
        if (m_actionList.Count == 0)
        {
            AddAction(ActorAction.ENType.enStandAction);
        }
    }
    public ActorAction AddAction(ActorAction.ENType newType)
    {
        if (!IsDisable(newType))
        {
            bool isValidateActionState = false;
            for (int index = m_actionList.Count - 1; index >= 0; --index)
            {
                ActorAction item = m_actionList[index];
                if (!item.IsEnable)
                {
                    continue;
                }
                if (ActorAction.ENRelation.enReplace == CheckRelation(newType, item.GetActionType()))
                {
                    m_actionList.RemoveAt(index);
                    isValidateActionState = true;

                    item.OnInterupt();
                    RemoveDisableCount(item.GetActionType());
                    item.IsEnable = false;
                    ReleaseObj(item);
                }
            }
            ActorAction obj = CreateObj(newType);
            obj.CurrentActor = CurrentActor;
            if (null != CurrentActor.mActorBlendAnim)
            {
                CurrentActor.mActorBlendAnim.CurActionType = newType;
            }
            ActioningObjArray[(int)newType] = obj;
            m_actionList.Add(obj);
            AddDisableCount(obj.GetActionType());
            if (isValidateActionState)
            {
                for (int i = 0; i < ActioningArray.Length; i++)
                {
                    ActioningArray[i]    = 0;
                    ActioningObjArray[i] = null;
                }
                for (int i = 0; i < m_actionList.Count; i++)
                {
                    ActorAction ac = m_actionList[i];
                    ActioningObjArray[(int)ac.GetActionType()] = ac;
                    ActioningArray[(int)ac.GetActionType()]++;
                }
            }
            return(obj);
        }
        else
        {
            string currentActions = CurrentActor.GetType() + ":" + newType.ToString() + " Current Actions:";
            foreach (ActorAction action in m_actionList)
            {
                currentActions += action.GetActionType().ToString() + ", ";
            }
            //Debug.LogWarning("Add action failed:" + newType.ToString()+" actor type:"+CurrentActor.Type.ToString());
            return(null);
        }
    }
    void RefreshWithActions(ActorProp obj)
    {
        if (obj == null)
        {
            return;
        }
        ActorActionControl accontrol = obj.ActorLogicObj.ActionControl;

        if (accontrol != null)
        {
            for (int i = 0; i < accontrol.ActionList.Count; i++)
            {
                ActorAction ac  = accontrol.ActionList[i];
                string      str = ac.GetActionType().ToString();
                m_strs.Add(str);
            }
            return;
        }
        else
        {
            Trap tmpTrap = obj.ActorLogicObj as Trap;
            TrapActionControl trapActionControl = tmpTrap.mActionControl;
            for (int i = 0; i < trapActionControl.ActionList.Count; i++)
            {
                TrapAction ac  = trapActionControl.ActionList[i];
                string     str = ac.GetActionType().ToString();
                m_strs.Add(str);
            }
        }
    }
 private bool Temp_Remove_Action(ActorAction act)
 {
     if (act.GetActionType() == m_curRemoveType_Temp)
     {
         ReleaseObj(act);
         return(true);
     }
     return(false);
 }
 public void RemoveAction(ActorAction action)
 {
     if (action == null)
     {
         return;
     }
     action.OnInterupt();
     RemoveDisableCount(action.GetActionType());
     m_actionList.Remove(action);
     ReleaseObj(action);
 }
Example #6
0
    bool IsNewAction(ActorAction.ENType actionType)
    {
        ActorAction action = mActor.ActionControl.LookupAction(actionType);

        if (null == action)
        {
            return(true);
        }
        uint curRefCount = mActor.mActionRefCountDict[(int)action.GetActionType()];
        //mActor.mActionRefCountDict.TryGetValue(action.GetActionType(), out curRefCount);
        uint lastRefCount = mLastActionRefCountDict[(int)action.GetActionType()];

        mLastActionRefCountDict[(int)action.GetActionType()] = curRefCount;
//         if (mLastActionRefCountDict.TryGetValue(action.GetActionType(), out lastRefCount))
//         {
//             mLastActionRefCountDict[action.GetActionType()] = curRefCount;
//         }
//         else
//         {
//             mLastActionRefCountDict.Add(action.GetActionType(), curRefCount);
//         }
        return(curRefCount != lastRefCount);
    }
    private void ReleaseObj(ActorAction obj)
    {
        obj.Reset();

        m_pool.ReleaseObject(obj.GetActionType(), obj);
    }