private TrapAction.ENRelation CheckRelation(TrapAction.ENType newAction, TrapAction.ENType oldAction)
    {
        if (newAction == oldAction)
        {
            return(TrapAction.ENRelation.enUnable);
        }
        if (oldAction == TrapAction.ENType.enAttackAction)
        {
            switch (newAction)
            {
            case TrapAction.ENType.enContinueDamageAction:
                return(TrapAction.ENRelation.enReplace);

            default:
                return(TrapAction.ENRelation.enUnable);
            }
        }
        if (oldAction == TrapAction.ENType.enStandAction)
        {
            switch (newAction)
            {
            case TrapAction.ENType.enAttackAction:
                return(TrapAction.ENRelation.enReplace);

            default:
                return(TrapAction.ENRelation.enReplace);
            }
        }
        return(TrapAction.ENRelation.enUnable);
        //return (TrapAction.ENRelation)GameTable.trapActionRelationTableAsset.Lookup((int)newAction, (int)oldAction);
    }
    private TrapAction CreateObj(TrapAction.ENType newType)
    {
        LinkedList <TrapAction> outList;

        if (m_pool.TryGetValue(newType, out outList))
        {
            if (outList.Count > 0)
            {
                TrapAction obj = outList.Last.Value as TrapAction;
                outList.RemoveLast();
                return(obj);
            }
        }
        switch (newType)
        {
        case TrapAction.ENType.enAttackAction:
            return(new TrapAttackAction());

//                break;	//站立
        case TrapAction.ENType.enBackAction:
            return(new TrapBackAction());

//                break;
        case TrapAction.ENType.enStandAction:
            return(new TrapStandAction());
//                break;
        }

        throw new Exception("Miss Action Create for" + newType.ToString());
    }
    public TrapAction AddAction(TrapAction.ENType newType)
    {
        if (!IsDisable(newType))
        {
            bool isValidateActionState = false;
            for (int index = m_actionList.Count - 1; index >= 0; --index)
            {
                TrapAction item = m_actionList[index];
                if (!item.IsEnable)
                {
                    continue;
                }
                if (TrapAction.ENRelation.enReplace == CheckRelation(newType, item.GetActionType()))
                {
                    m_actionList.RemoveAt(index);
                    isValidateActionState = true;

                    item.OnInterupt(newType);
                    RemoveDisableCount(item.GetActionType());
                    item.IsEnable = false;
                    ReleaseObj(item);
                }
            }
            TrapAction obj = CreateObj(newType);
            obj.CurrentActor = CurrentActor;

            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++)
                {
                    TrapAction 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 (TrapAction action in m_actionList)
            {
                currentActions += action.GetActionType().ToString() + ", ";
            }
            //Debug.LogWarning("Add action failed:" + newType.ToString()+" actor type:"+CurrentActor.Type.ToString());
            return(null);
        }
    }
 public void AddDisableCount(TrapAction.ENType type)
 {
     ActioningArray[(int)type]++;
     for (int index = 0; index < m_disableCount.Length; ++index)
     {
         if (TrapAction.ENRelation.enUnable == CheckRelation((TrapAction.ENType)index, type))
         {
             ++m_disableCount[index];
         }
     }
 }
 public void RemoveAction(TrapAction.ENType type)
 {
     foreach (var action in m_actionList)
     {
         if (action.GetActionType() == type)
         {
             action.OnExit();
             RemoveDisableCount(type);
         }
     }
     m_actionList.RemoveAll(action => action.GetActionType() == type);
     ActioningObjArray[(int)type] = null;
     ActioningArray[(int)type]    = 0;
 }
Exemple #6
0
    bool IsNewAction(TrapAction.ENType actionType)
    {
        TrapAction action = mActor.mActionControl.LookupAction(actionType);

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

        mLastActionRefCountDict[(int)action.GetActionType()] = curRefCount;
        return(curRefCount != lastRefCount);
    }
 private void RemoveDisableCount(TrapAction.ENType type)
 {
     ActioningObjArray[(int)type] = null;
     ActioningArray[(int)type]--;
     if (ActioningArray[(int)type] < 0)
     {
         ActioningArray[(int)type] = 0;
     }
     for (int index = 0; index < m_disableCount.Length; ++index)
     {
         if (TrapAction.ENRelation.enUnable == CheckRelation((TrapAction.ENType)index, type))
         {
             --m_disableCount[index];
         }
     }
 }
 public override void OnInterupt(TrapAction.ENType newType)
 {
     CurrentActor.MainAnim.Stop();
     OnExit();
 }
 public virtual void OnInterupt(TrapAction.ENType newType)
 {
 }
 public bool IsDisable(TrapAction.ENType type)
 {
     return(m_disableCount[(int)type] > 0);
 }
 public TrapAction LookupAction(TrapAction.ENType type)
 {
     return(ActioningObjArray[(int)type]);
     //return m_actionList.Find(action => action.GetActionType() == type);
 }
 public bool IsActionRunning(TrapAction.ENType acType)
 {
     return(ActioningArray[(int)acType] > 0);
 }
 public override void OnInterupt(TrapAction.ENType newType)
 {
 }