public static int IndexOf(ArrayList target, Object value, int startIndex)
    {
        if (startIndex > target.Count)
        {
            throw new ArgumentOutOfRangeException("startIndex", "ArgumentOutOfRange_Index");
        }

        return(PlayMakerUtils_Extensions.IndexOf(target, value, startIndex, target.Count - startIndex));
    }
        public void DoArrayListIndexOf()
        {
            if (!isProxyValid())
            {
                return;
            }

            object item = PlayMakerUtils.GetValueFromFsmVar(Fsm, variable);

            int indexOfResult = -1;

            try{
                if (startIndex.IsNone)
                {
                    UnityEngine.Debug.Log("hello");
                    indexOfResult = PlayMakerUtils_Extensions.IndexOf(proxy.arrayList, item);
                }
                else if (count.IsNone || count.Value == 0)
                {
                    if (startIndex.Value < 0 || startIndex.Value >= proxy.arrayList.Count)
                    {
                        LogError("start index out of range");
                        return;
                    }
                    indexOfResult = PlayMakerUtils_Extensions.IndexOf(proxy.arrayList, item);
                }
                else
                {
                    if (startIndex.Value < 0 || startIndex.Value >= (proxy.arrayList.Count - count.Value))
                    {
                        LogError("start index and count out of range");
                        return;
                    }
                    indexOfResult = PlayMakerUtils_Extensions.IndexOf(proxy.arrayList, item);
                }
            }catch (System.Exception e) {
                Debug.LogError(e.Message);
                Fsm.Event(failureEvent);
                return;
            }


            indexOf.Value = indexOfResult;
            if (indexOfResult == -1)
            {
                Fsm.Event(itemNotFound);
            }
            else
            {
                Fsm.Event(itemFound);
            }
        }
Beispiel #3
0
        public void DoArrayListLastIndex()
        {
            if (!isProxyValid())
            {
                return;
            }

            object item = PlayMakerUtils.GetValueFromFsmVar(Fsm, variable);

            int index = -1;

            try{
                if (startIndex.Value == 0 && count.Value == 0)
                {
                    index = PlayMakerUtils_Extensions.LastIndexOf(proxy.arrayList, item);
                }
                else if (count.Value == 0)
                {
                    if (startIndex.Value < 0 || startIndex.Value >= proxy.arrayList.Count)
                    {
                        Debug.LogError("start index out of range");
                        return;
                    }
                    index = PlayMakerUtils_Extensions.LastIndexOf(proxy.arrayList, item, startIndex.Value);
                }
                else
                {
                    if (startIndex.Value < 0 || startIndex.Value >= (proxy.arrayList.Count - count.Value))
                    {
                        Debug.LogError("start index and count out of range");
                        return;
                    }
                    index = PlayMakerUtils_Extensions.LastIndexOf(proxy.arrayList, item, startIndex.Value, count.Value);
                }
            }catch (System.Exception e) {
                Debug.LogError(e.Message + " on " + Fsm.GameObjectName + "\nFsm: " + Fsm.Name + "\nState: " + Fsm.ActiveStateName);
                Fsm.Event(failureEvent);
                return;
            }

            lastIndexOf.Value = index;
            if (index == -1)
            {
                Fsm.Event(itemNotFound);
            }
            else
            {
                Fsm.Event(itemFound);
            }
        }
 public static int LastIndexOf(ArrayList target, Object value, int startIndex)
 {
     return(PlayMakerUtils_Extensions.LastIndexOf(target, value, startIndex, startIndex + 1));
 }
 public static int LastIndexOf(ArrayList target, Object value)
 {
     return(PlayMakerUtils_Extensions.LastIndexOf(target, value, target.Count - 1, target.Count));
 }