Inheritance: PlayMakerCollectionProxy
Example #1
0
    public override void OnInspectorGUI()
    {
        PlayMakerArrayListProxy proxy = (PlayMakerArrayListProxy)target;

        proxy.referenceName = EditorGUILayout.TextField(new GUIContent("Reference", "Unique Reference of this ArrayList. Use it if more than one ArrayList is dropped on this game Object"), proxy.referenceName);


        BuildEventsInspectorGUI();

        // Switch between the two, because we don't need them when they can't be of any help and also would be misleading since changes would not persists
        if (Application.isPlaying)
        {
            BuildPreviewInspectorGUI();
        }
        else
        {
            BuildPreFillInspectorGUI(false);
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(proxy);
                        #if UNITY_5_3_OR_NEWER
            EditorSceneManager.MarkSceneDirty(proxy.gameObject.scene);
                        #endif
        }
    }    // OnInspectorGUI
Example #2
0
        static bool ImportAt(PlayMakerArrayListProxy proxy, string mainPath)
        {
            var paths = Directory.GetFiles(mainPath).Where(x => !x.Contains(".png"));

            if (paths.Count() <= 0)
            {
                return(false);
            }
            else
            {
                var audios = new List <AudioClip>();
                if (proxy.preFillAudioClipList.Count > 0)
                {
                    proxy.preFillAudioClipList.Clear();
                }
                for (var i = 0; i < paths.Count(); i++)
                {
                    audios.Add(AudioImport.LoadAudioFromFile(paths.ToArray()[i], true, true));
                }
                for (var i = 0; i < audios.Count(); i++)
                {
                    proxy.preFillAudioClipList.Add(audios[i]);
                }
                proxy._arrayList = new ArrayList(audios.Count());
                proxy._arrayList.AddRange(proxy.preFillAudioClipList);
                return(true);
            }
        }
Example #3
0
    }    // OnInspectorGUI

    private void BuildEventsInspectorGUI()
    {
        PlayMakerArrayListProxy proxy = (PlayMakerArrayListProxy)target;

        string eventsEnabledString = "";

        if (!proxy.showEvents)
        {
            if (!proxy.enablePlayMakerEvents)
            {
                eventsEnabledString = " (disabled)";
            }
            else
            {
                eventsEnabledString = " (enabled)";
            }
        }

        proxy.showEvents = EditorGUILayout.Foldout(proxy.showEvents, new GUIContent("PLayMaker events" + eventsEnabledString, "Manage PlayMaker events dispatch"));
        if (proxy.showEvents)
        {
            EditorGUI.indentLevel       = 1;
            proxy.enablePlayMakerEvents = EditorGUILayout.Toggle(new GUIContent("Enable Events", "Broadcast events when item is added, set or removed"), proxy.enablePlayMakerEvents);

            if (proxy.enablePlayMakerEvents)
            {
                proxy.addEvent    = EditorGUILayout.TextField(new GUIContent("Add Event", "Sent when an item is added. Event data filled with the item value"), proxy.addEvent);
                proxy.setEvent    = EditorGUILayout.TextField(new GUIContent("Set Event", "Sent when an item is changed. Event data filled with the index value"), proxy.setEvent);
                proxy.removeEvent = EditorGUILayout.TextField(new GUIContent("Remove Event", "Sent when an item is removed. Event data filled with the item value"), proxy.removeEvent);
            }
            EditorGUI.indentLevel = 0;
        }
    }    // BuildEventsInspectorGUI
Example #4
0
 public override void Reset()
 {
     array         = null;
     resultIndexes = null;
     noRepeat      = false;
     indexes.Clear();
 }
		void DoAddPlayMakerArrayList()
		{
			
			GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
		
			PlayMakerArrayListProxy proxy = GetArrayListProxyPointer(go,reference.Value,true);
		 
			
			if (proxy!=null)
			{
				
				Fsm.Event(alreadyExistsEvent);
			}else{
				
				addedComponent = (PlayMakerArrayListProxy)go.AddComponent("PlayMakerArrayListProxy");
	
				if (addedComponent == null)
				{
					LogError("Can't add PlayMakerArrayListProxy");
				}else{
					addedComponent.referenceName = reference.Value;
					
				}
			}
			
			
		}
Example #6
0
        void DoAddPlayMakerArrayList()
        {
            GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);

            PlayMakerArrayListProxy proxy = GetArrayListProxyPointer(go, reference.Value, true);


            if (proxy != null)
            {
                Fsm.Event(alreadyExistsEvent);
            }
            else
            {
                addedComponent = (PlayMakerArrayListProxy)go.AddComponent <PlayMakerArrayListProxy>();

                if (addedComponent == null)
                {
                    LogError("Can't add PlayMakerArrayListProxy");
                }
                else
                {
                    addedComponent.referenceName = reference.Value;
                }
            }
        }
        public override void OnEnter()
        {
            GameObject _go = Fsm.GetOwnerDefaultTarget(target);

            //Get all Proxy Components
            PlayMakerArrayListProxy[] proxies = _go.GetComponents <PlayMakerArrayListProxy>();

            if (reference.Value != "" || reference.Value != null)
            {
                //Check if more than one Proxy Component exists on the target
                if (proxies.Length > 0)
                {
                    foreach (PlayMakerArrayListProxy iProxy in proxies)
                    {
                        if (iProxy.referenceName == reference.Value)
                        {
                            proxy = iProxy;
                        }
                        else
                        {
                            // Debug.LogWarning("No Array List with the Reference " + reference.Value + " in " + _go.name + " found!");
                            // Finish();
                        }
                    }
                }
            }
            else
            {
                proxy = _go.GetComponent("" + "PlayMakerArrayListProxy") as PlayMakerArrayListProxy;
            }

            try
            {
                Dictionary <string, object> data;

                if (proxy == null)
                {
                    LogError("ArrayMaker Proxy is null!");
                }

                if (GDEDataManager.Get(ItemName.Value, out data) && proxy != null)
                {
                    List <string> val;
                    data.TryGetStringList(FieldName.Value, out val);

                    proxy.AddRange(val, string.Empty);
                }
                else
                {
                    //LogError(string.Format(GDMConstants.ErrorLoadingValue, "string array", ItemName.Value, FieldName.Value));
                }
            } catch (System.Exception ex)
            {
                UnityEngine.Debug.LogException(ex);
            } finally
            {
                Finish();
            }
        }
 public override void Reset()
 {
     ItemName  = null;
     FieldName = null;
     target    = null;
     reference = null;
     proxy     = null;
 }
Example #9
0
 public override void Enter()
 {
     _proxy = CollectionsActions.GetArrayListProxyPointer(Fsm.GetOwnerDefaultTarget(gameObject), reference.Value, false);
     if (_proxy != null)
     {
         Execute();
     }
 }
Example #10
0
 protected bool SetUpArrayListProxyPointer(GameObject aProxyGO, string nameReference)
 {
     if (aProxyGO == null)
     {
         return(false);
     }
     this.proxy = base.GetArrayListProxyPointer(aProxyGO, nameReference, false);
     return(this.proxy != null);
 }
        protected bool SetUpArrayListProxyPointer(GameObject aProxyGO,string nameReference)
        {
            if (aProxyGO == null){
                    return false;
                }
                 proxy = GetArrayListProxyPointer(aProxyGO,nameReference,false);

                return proxy!=null;
        }
        protected bool SetUpArrayListProxyPointer(PlayMakerArrayListProxy aProxy,string nameReference)
        {
            if (aProxy == null){
                    return false;
                }
                 proxy = GetArrayListProxyPointer(aProxy.gameObject,nameReference,false);

                return proxy!=null;
        }
Example #13
0
 protected bool SetUpArrayListProxyPointer(PlayMakerArrayListProxy aProxy, string nameReference)
 {
     if (aProxy == null)
     {
         return(false);
     }
     this.proxy = base.GetArrayListProxyPointer(aProxy.gameObject, nameReference, false);
     return(this.proxy != null);
 }
Example #14
0
 protected PlayMakerArrayListProxy GetArrayListProxyPointer(GameObject aProxy, string nameReference, bool silent)
 {
     if (aProxy == null)
     {
         if (!silent)
         {
             Debug.LogError("Null Proxy");
         }
         return(null);
     }
     PlayMakerArrayListProxy[] components = aProxy.GetComponents <PlayMakerArrayListProxy>();
     if (components.Length > 1)
     {
         if (nameReference == string.Empty && !silent)
         {
             Debug.LogError("Several ArrayList Proxies coexists on the same GameObject and no reference is given to find the expected ArrayList");
         }
         PlayMakerArrayListProxy[] array = components;
         for (int i = 0; i < array.Length; i++)
         {
             PlayMakerArrayListProxy playMakerArrayListProxy = array[i];
             if (playMakerArrayListProxy.referenceName == nameReference)
             {
                 return(playMakerArrayListProxy);
             }
         }
         if (nameReference != string.Empty)
         {
             if (!silent)
             {
                 this.LogError("ArrayList Proxy not found for reference <" + nameReference + ">");
             }
             return(null);
         }
     }
     else if (components.Length > 0)
     {
         if (nameReference != string.Empty && nameReference != components[0].referenceName)
         {
             if (!silent)
             {
                 Debug.LogError("ArrayList Proxy reference do not match");
             }
             return(null);
         }
         return(components[0]);
     }
     if (!silent)
     {
         this.LogError("ArrayList proxy not found");
     }
     return(null);
 }
Example #15
0
 private void DoDestroyArrayList()
 {
     PlayMakerArrayListProxy[] components = this.proxy.GetComponents <PlayMakerArrayListProxy>();
     PlayMakerArrayListProxy[] array      = components;
     for (int i = 0; i < array.Length; i++)
     {
         PlayMakerArrayListProxy playMakerArrayListProxy = array[i];
         if (playMakerArrayListProxy.referenceName == this.reference.Value)
         {
             UnityEngine.Object.Destroy(playMakerArrayListProxy);
             base.Fsm.Event(this.successEvent);
             return;
         }
     }
     base.Fsm.Event(this.notFoundEvent);
 }
Example #16
0
        public void ExecuteAction()
        {
            _proxy = GetArrayListProxyPointer(Fsm.GetOwnerDefaultTarget(gameObject), reference.Value, true);

            _isEmpty = _proxy.arrayList.Count == 0;

            isEmpty.Value = _isEmpty;

            if (_isEmpty)
            {
                Fsm.Event(isEmptyEvent);
            }
            else
            {
                Fsm.Event(isNotEmptyEvent);
            }
        }
Example #17
0
 void PlayMakerArrayListProxyGUI(PlayMakerArrayListProxy arrayListProxy)
 {
     if (arrayListProxy.arrayList.Count > 0)
     {
         for (int i = 0; i < arrayListProxy.arrayList.Count; ++i)
         {
             GUILayout.BeginHorizontal();
             GUILayout.Box("[" + i + "]", GUILayout.Width(30.0f));
             GUILayout.Box(arrayListProxy.arrayList[i].ToString());
             GUILayout.EndHorizontal();
         }
     }
     else
     {
         GUILayout.Box("Array is empty");
     }
 }
Example #18
0
        public override void OnEnter()
        {
            PlayMakerArrayListProxy _proxy = GetArrayListProxyPointer(Fsm.GetOwnerDefaultTarget(gameObject), reference.Value, true);

            bool exists = _proxy != null;

            doesExists.Value = exists;
            if (exists)
            {
                Fsm.Event(doesExistsEvent);
            }
            else
            {
                Fsm.Event(doesNotExistsEvent);
            }

            Finish();
        }
Example #19
0
 public override void OnEnter()
 {
     PlayMakerArrayListProxy[] array  = UnityEngine.Object.FindObjectsOfType(typeof(PlayMakerArrayListProxy)) as PlayMakerArrayListProxy[];
     PlayMakerArrayListProxy[] array2 = array;
     for (int i = 0; i < array2.Length; i++)
     {
         PlayMakerArrayListProxy playMakerArrayListProxy = array2[i];
         if (playMakerArrayListProxy.referenceName == this.ArrayListReference.Value)
         {
             this.store.Value = playMakerArrayListProxy.gameObject;
             base.Fsm.Event(this.foundEvent);
             return;
         }
     }
     this.store.Value = null;
     base.Fsm.Event(this.notFoundEvent);
     base.Finish();
 }
        public override void OnEnter()
        {
            if (otherPLayerOnly.Value)
            {
                players = PhotonNetwork.otherPlayers;
            }
            else
            {
                players = PhotonNetwork.playerList;
            }
            //
            GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);

            // -------- Player -----------//
            // get each arrayList reference
            PlayMakerArrayListProxy nameList = GetArrayListProxyPointer(go, NameReference.Value, false);

            /*
             * if (nameList ==null)
             * {
             *      nameList = go.AddComponent<PlayMakerArrayListProxy>();
             *      nameList.referenceName = "Photon Player Name";
             * }
             */

            PlayMakerArrayListProxy idList = GetArrayListProxyPointer(go, IdReference.Value, false);

            /*
             * if (idList ==null)
             * {
             *      idList = go.AddComponent<PlayMakerArrayListProxy>();
             *      idList.referenceName = "Photon Player ID";
             * }
             */

            nameList.arrayList.Clear();
            idList.arrayList.Clear();

            foreach (PhotonPlayer player in players)
            {
                nameList.arrayList.Add(player.NickName);
                idList.arrayList.Add(player.ID);
            }
        }
        public override void OnEnter()
        {
            PlayMakerArrayListProxy _proxy = GetArrayListProxyPointer(Fsm.GetOwnerDefaultTarget(gameObject), reference.Value, true);

            bool _isEmpty = _proxy.arrayList.Count == 0;

            isEmpty.Value = _isEmpty;

            if (_isEmpty)
            {
                Fsm.Event(isEmptyEvent);
            }
            else
            {
                Fsm.Event(isNotEmptyEvent);
            }

            Finish();
        }
Example #22
0
        public void doHashTableValues()
        {
            if (!base.isProxyValid())
            {
                return;
            }
            GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(this.arrayListGameObject);

            if (ownerDefaultTarget == null)
            {
                return;
            }
            PlayMakerArrayListProxy arrayListProxyPointer = base.GetArrayListProxyPointer(ownerDefaultTarget, this.arrayListReference.Value, false);

            if (arrayListProxyPointer != null)
            {
                arrayListProxyPointer.arrayList.AddRange(this.proxy.hashTable.Values);
            }
        }
Example #23
0
 private void DoAddPlayMakerArrayList()
 {
     GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(this.gameObject);
     PlayMakerArrayListProxy arrayListProxyPointer = base.GetArrayListProxyPointer(ownerDefaultTarget, this.reference.Value, true);
     if (arrayListProxyPointer != null)
     {
         base.Fsm.Event(this.alreadyExistsEvent);
     }
     else
     {
         this.addedComponent = ownerDefaultTarget.AddComponent<PlayMakerArrayListProxy>();
         if (this.addedComponent == null)
         {
             this.LogError("Can't add PlayMakerArrayListProxy");
         }
         else
         {
             this.addedComponent.referenceName = this.reference.Value;
         }
     }
 }
Example #24
0
        private void DoAddPlayMakerArrayList()
        {
            GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(this.gameObject);
            PlayMakerArrayListProxy arrayListProxyPointer = base.GetArrayListProxyPointer(ownerDefaultTarget, this.reference.Value, true);

            if (arrayListProxyPointer != null)
            {
                base.Fsm.Event(this.alreadyExistsEvent);
            }
            else
            {
                this.addedComponent = ownerDefaultTarget.AddComponent <PlayMakerArrayListProxy>();
                if (this.addedComponent == null)
                {
                    base.LogError("Can't add PlayMakerArrayListProxy");
                }
                else
                {
                    this.addedComponent.referenceName = this.reference.Value;
                }
            }
        }
Example #25
0
        public void doHashTableKeys()
        {
            if (!isProxyValid())
            {
                return;
            }

            // now get the arrayList proxy.

            GameObject ArrayListGO = Fsm.GetOwnerDefaultTarget(arrayListGameObject);

            if (ArrayListGO == null)
            {
                return;
            }
            PlayMakerArrayListProxy arrayListproxy = GetArrayListProxyPointer(ArrayListGO, arrayListReference.Value, false);

            if (arrayListproxy != null)
            {
                arrayListproxy.arrayList.AddRange(proxy.hashTable.Keys);
            }
        }
Example #26
0
        public override void OnEnter()
        {
            List <string> allSchemas = GDEHelpers.GDEGetAllDataBy(GDEDataType.Schema).ToStringList();

            if (Fsm.GetOwnerDefaultTarget(gameObject).GetComponent <PlayMakerArrayListProxy>() != null)
            {
                PlayMakerArrayListProxy _proxy = GetArrayListProxyPointer(Fsm.GetOwnerDefaultTarget(gameObject), reference.Value, false);
                _proxy.AddRange(allSchemas, string.Empty);
            }

            if (viaProxyReference != null)
            {
                viaProxyReference.AddRange(allSchemas, string.Empty);
            }

            if (storeAsString != null)
            {
                foreach (string schema in allSchemas)
                {
                    if (schema == (string)allSchemas.ToArray().GetValue(allSchemas.ToArray().Length - 1))
                    {
                        storeAsString.Value = string.Concat(storeAsString.Value + schema);
                    }
                    else
                    {
                        storeAsString.Value = string.Concat(storeAsString.Value + schema + ", ");
                    }
                }

                storeAsString.Value.Remove(storeAsString.Value.Length - 2);
            }

            if (storeAsStringArray != null)
            {
                storeAsStringArray.Values = allSchemas.ToArray();
            }
        }
Example #27
0
        public override void OnEnter()
        {
            List <string> allItems      = new List <string>();
            string        currentSchema = "";

            foreach (KeyValuePair <string, object> pair in GDEDataManager.DataDictionary)
            {
                if (pair.Key.StartsWith(GDMConstants.SchemaPrefix))
                {
                    continue;
                }

                //skip if not in the specified schema
                if (schema.Value != null && schema.Value != "")
                {
                    //get all values of current Item
                    Dictionary <string, object> currentDataSet = pair.Value as Dictionary <string, object>;
                    //get Schema of current Item
                    currentDataSet.TryGetString(GDMConstants.SchemaKey, out currentSchema);
                    //check if current Schema equals specified one
                    if (!(currentSchema == schema.Value))
                    {
                        continue;
                    }
                }
                //add current Item to List
                allItems.Add(pair.Key);
            }

            if (Fsm.GetOwnerDefaultTarget(gameObject).GetComponent <PlayMakerArrayListProxy>() != null)
            {
                PlayMakerArrayListProxy _proxy = GetArrayListProxyPointer(Fsm.GetOwnerDefaultTarget(gameObject), reference.Value, false);
                _proxy.AddRange(allItems, string.Empty);
            }

            if (viaProxyReference != null)
            {
                viaProxyReference.AddRange(allItems, string.Empty);
            }

            if (storeAsString != null)
            {
                foreach (string schema in allItems)
                {
                    if (schema == allItems.ToArray().GetValue(allItems.ToArray().Length - 1).ToString())
                    {
                        storeAsString.Value = string.Concat(storeAsString.Value + schema);
                    }
                    else
                    {
                        storeAsString.Value = string.Concat(storeAsString.Value + schema + ", ");
                    }
                }
            }

            if (storeAsStringArray != null)
            {
                storeAsStringArray.Values = allItems.ToArray();
            }

            Finish();
        }
Example #28
0
 private void Awake()
 {
     this.sceneInfo = Scene.SceneTracker;
     playerScriptSetup.playerTransform = base.transform;
     this.targetFunctions = base.GetComponent <playerTargetFunctions>();
     this.hashName        = Animator.StringToHash(base.transform.root.name);
     PlayMakerFSM[] components = base.transform.GetComponents <PlayMakerFSM>();
     PlayMakerFSM[] array      = components;
     for (int i = 0; i < array.Length; i++)
     {
         PlayMakerFSM playMakerFSM = array[i];
         if (playMakerFSM.FsmName == "rotatePlayerFSM")
         {
             this.pmRotate = playMakerFSM;
         }
         if (playMakerFSM.FsmName == "controlFSM")
         {
             this.pmControl = playMakerFSM;
         }
         if (playMakerFSM.FsmName == "targetManagerFSM")
         {
             this.pmTarget = playMakerFSM;
         }
         if (playMakerFSM.FsmName == "staminaFSM")
         {
             this.pmStamina = playMakerFSM;
         }
         if (playMakerFSM.FsmName == "noiseDetectFSM")
         {
             this.pmNoise = playMakerFSM;
         }
         if (playMakerFSM.FsmName == "damageFSM")
         {
             this.pmDamage = playMakerFSM;
         }
         if (playMakerFSM.FsmName == "tempBlockManagerFSM")
         {
             this.pmBlock = playMakerFSM;
         }
     }
     PlayMakerArrayListProxy[] components2 = base.transform.GetComponents <PlayMakerArrayListProxy>();
     PlayMakerArrayListProxy[] array2      = components2;
     for (int j = 0; j < array2.Length; j++)
     {
         PlayMakerArrayListProxy playMakerArrayListProxy = array2[j];
         if (playMakerArrayListProxy.referenceName == "attackers")
         {
             this.proxyAttackers = playMakerArrayListProxy;
         }
     }
     Transform[] componentsInChildren = base.transform.root.gameObject.GetComponentsInChildren <Transform>();
     Transform[] array3 = componentsInChildren;
     for (int k = 0; k < array3.Length; k++)
     {
         Transform transform = array3[k];
         if (transform.name == "char_Spine")
         {
             this.spine1 = transform;
         }
         if (transform.name == "char_Spine1")
         {
             this.spine2 = transform;
         }
         if (transform.name == "char_Spine2")
         {
             this.spine3 = transform;
         }
         if (transform.name == "MainCamNew")
         {
             this.playerCam = transform;
         }
         if (transform.name == "OVRCameraController")
         {
             this.OvrCam = transform;
         }
         if (transform.name == "LookObject")
         {
             this.camParent = transform;
         }
         if (transform.name == "char_Head1")
         {
             this.headJnt = transform;
         }
         if (transform.name == "player_BASE")
         {
             this.playerBase = transform.gameObject;
         }
         if (transform.name == "lookAtGo")
         {
             this.lookAtTr = transform;
         }
         if (transform.name == "playerHitDetect")
         {
             this.bodyCollisionGo = transform.gameObject;
         }
         if (transform.name == "char_RightHandWeapon")
         {
             this.weaponRight = transform;
         }
         if (transform.name == "char_LeftHand1")
         {
             this.leftHand = transform;
         }
         if (transform.name == "char_LeftArm")
         {
             this.leftArm = transform;
         }
         if (transform.name == "char_RightArm")
         {
             this.rightArm = transform;
         }
         if (transform.name == "char_Neck")
         {
             this.neckJnt = transform;
         }
         if (transform.name == "char_Hips")
         {
             this.hipsJnt = transform;
         }
         if (transform.name == "smallBird_ANIM_landOnFinger")
         {
             this.smallBirdGo = transform.gameObject;
         }
         if (transform.name == "soundDetectGo")
         {
             this.soundDetectGo = transform.gameObject;
         }
         if (transform.name == "enemyBlocker")
         {
             this.enemyBlockerGo = transform.gameObject;
         }
     }
 }
Example #29
0
 public override void Reset()
 {
     resultTypes   = null;
     resultIndexes = null;
 }
Example #30
0
    }    // BuildEventsInspectorGUI

    private void BuildPreviewInspectorGUI()
    {
        PlayMakerArrayListProxy proxy = (PlayMakerArrayListProxy)target;

        if (proxy.arrayList == null)
        {
            return;
        }

        int count = proxy.arrayList.Count;

        BuildPreviewInspectorHeaderGUI(count);


        if (!proxy.showContent)
        {
            return;
        }

        if (proxy.arrayList != null)
        {
            int start = proxy.contentPreviewStartIndex;
            int last  = Mathf.Min(count, proxy.contentPreviewStartIndex + proxy.contentPreviewMaxRows);

            string label;
            for (int i = start; i < last; i++)
            {
                label = "Item " + i;
                EditorGUILayout.BeginHorizontal();

                if (proxy.arrayList[i] != null)
                {
                    if (proxy.arrayList[i].GetType() == typeof(bool))
                    {
                        proxy.arrayList[i] = (bool)EditorGUILayout.Toggle(label, (bool)proxy.arrayList[i]);
                    }
                    else if (proxy.arrayList[i].GetType() == typeof(Color))
                    {
                        proxy.arrayList[i] = (Color)EditorGUILayout.ColorField(label, (Color)proxy.arrayList[i]);
                    }
                    else if (proxy.arrayList[i].GetType() == typeof(float))
                    {
                        proxy.arrayList[i] = (float)EditorGUILayout.FloatField(label, (float)proxy.arrayList[i]);
                    }
                    else if (proxy.arrayList[i].GetType() == typeof(GameObject))
                    {
                        proxy.arrayList[i] = (GameObject)EditorGUILayout.ObjectField(label, (GameObject)proxy.arrayList[i], typeof(GameObject), true);
                    }
                    else if (proxy.arrayList[i].GetType() == typeof(int))
                    {
                        proxy.arrayList[i] = (int)EditorGUILayout.IntField(label, (int)proxy.arrayList[i]);
                    }
                    else if (proxy.arrayList[i].GetType() == typeof(Material))
                    {
                        proxy.arrayList[i] = (Material)EditorGUILayout.ObjectField(label, (Material)proxy.arrayList[i], typeof(Material), false);
                    }
                    else if (proxy.arrayList[i].GetType() == typeof(Object))
                    {
                        proxy.arrayList[i] = (Object)EditorGUILayout.ObjectField(label, (Object)proxy.arrayList[i], typeof(Object), true);
                    }
                    else if (proxy.arrayList[i].GetType() == typeof(Quaternion))
                    {
                        Quaternion q    = (Quaternion)proxy.arrayList[i];
                        Vector4    quat = new Vector4(q[0], q[1], q[2], q[3]);
                        quat = EditorGUILayout.Vector4Field(label, quat);
                        q[0] = quat[0];
                        q[1] = quat[1];
                        q[2] = quat[2];
                        q[3] = quat[3];
                        proxy.arrayList[i] = q;
                    }
                    else if (proxy.arrayList[i].GetType() == typeof(Rect))
                    {
                        proxy.arrayList[i] = (Rect)EditorGUILayout.RectField(label, (Rect)proxy.arrayList[i]);
                    }
                    else if (proxy.arrayList[i].GetType() == typeof(string))
                    {
                        proxy.arrayList[i] = (string)EditorGUILayout.TextField(label, (string)proxy.arrayList[i]);
                    }
                    else if (proxy.arrayList[i].GetType() == typeof(Texture2D))
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(15);
                        GUILayout.Label(label);
                        GUILayout.FlexibleSpace();
                        if (proxy.TextureElementSmall)
                        {
                            proxy.arrayList[i] = (Texture2D)EditorGUILayout.ObjectField((Texture2D)proxy.arrayList[i], typeof(Texture2D), false);
                        }
                        else
                        {
                            proxy.arrayList[i] = (Texture2D)EditorGUILayout.ObjectField("", (Texture2D)proxy.arrayList[i], typeof(Texture2D), false);
                        }
                        GUILayout.Space(5);
                        GUILayout.EndHorizontal();
                    }
                    else if (proxy.arrayList[i].GetType() == typeof(Vector2))
                    {
                        proxy.arrayList[i] = (Vector2)EditorGUILayout.Vector2Field(label, (Vector2)proxy.arrayList[i]);
                    }
                    else if (proxy.arrayList[i].GetType() == typeof(Vector3))
                    {
                        proxy.arrayList[i] = (Vector3)EditorGUILayout.Vector3Field(label, (Vector3)proxy.arrayList[i]);
                    }
                    else if (proxy.arrayList[i].GetType() == typeof(AudioClip))
                    {
                        proxy.arrayList[i] = (AudioClip)EditorGUILayout.ObjectField(label, (AudioClip)proxy.arrayList[i], typeof(AudioClip), true);
                    }
                    else if (proxy.arrayList[i].GetType() == typeof(Sprite))
                    {
                        proxy.arrayList[i] = (Sprite)EditorGUILayout.ObjectField(label, (Sprite)proxy.arrayList[i], typeof(Sprite), true);
                    }
                    else
                    {
                        //(FsmBool)proxy.arrayList[i].Value = (bool)EditorGUILayout.Toggle(label, (FsmBool)proxy.arrayList[i].Value);
                        // OUPS
                        Debug.Log(proxy.arrayList[i].GetType());
                        //EditorGUILayout.TextField(label, (string)proxy.arrayList[i]);
                    }
                }
                else
                {
                    EditorGUILayout.LabelField(label, "-- NULL --");
                }
                EditorGUILayout.EndHorizontal();
                if (Application.isPlaying && GUI.changed)
                {
                    proxy.InspectorEdit(i);
                }
            }
        }
        else
        {
            EditorGUILayout.LabelField("-- Empty --", "");
        }

        if (proxy.liveUpdate)
        {
            Repaint();
        }
    }
Example #31
0
        public void SetItemAtIndex()
        {
            if (!UpdateCache(Fsm.GetOwnerDefaultTarget(gameObject)))
            {
                Debug.Log("ArrayListTable not found for " + PlayMakerUtils.LogFullPathToAction(this));
                Fsm.Event(failureEvent);
                return;
            }

            ArrayListTable _at = this.cachedComponent as ArrayListTable;

            int index = 0;

            string _error = string.Empty;

            try{
                if (UseColumnHeader)
                {
                    if (_at.HeaderProxy == null)
                    {
                        _error = "Header Proxy not defined";

                        throw new UnityException(_error + " for " + PlayMakerUtils.LogFullPathToAction(this));
                    }

                    index = _at.HeaderProxy.arrayList.IndexOf(atColumn.Value);

                    if (index < 0 || (index + 1) > _at.ColumnData.Length)
                    {
                        _error = "Header Column index out of range";
                        throw new UnityException(_error + " for " + PlayMakerUtils.LogFullPathToAction(this));
                    }
                }
                else
                {
                    index = atColumnIndex.Value;

                    if (index < 0 || (index + 1) > _at.ColumnData.Length)
                    {
                        _error = "Column index out of range";
                        throw new UnityException(_error + " for " + PlayMakerUtils.LogFullPathToAction(this));
                    }
                }

                if (atRowIndex.Value < 0 || (atRowIndex.Value + 1) > _at.ColumnData[atColumnIndex.Value].arrayList.Count)
                {
                    _error = "Row index out of range";
                    throw new UnityException(_error + " for " + PlayMakerUtils.LogFullPathToAction(this));
                }

                PlayMakerArrayListProxy _column = _at.ColumnData[index];
                if (_column == null)
                {
                    _error = "Column index not found";
                    throw new UnityException(_error + " for " + PlayMakerUtils.LogFullPathToAction(this));
                }

                _column._arrayList[atRowIndex.Value] = PlayMakerUtils.GetValueFromFsmVar(this.Fsm, value);
            }catch (System.Exception e) {
                Debug.Log(e.Message);
                Fsm.EventData.StringData = _error;
                Fsm.Event(failureEvent);
                return;
            }
        }
Example #32
0
        public ItemHook()
        {
            Toggle = ToggleActive;

            IgnoreRule rule = Rules.instance.IgnoreRules.Find(f => f.ObjectName == this.gameObject.name);

            if (rule != null)
            {
                Toggle = ToggleActiveOldMethod;

                if (rule.TotalIgnore)
                {
                    Destroy(this);
                    return;
                }
            }

            // Use the old method, if for some reason item cannot be disabled.
            if (this.gameObject.name.EqualsAny("fish trap(itemx)", "bucket(itemx)", "pike(itemx)", "envelope(xxxxx)", "lottery ticket(xxxxx)"))
            {
                Toggle = ToggleActiveOldMethod;
            }

            // Add self to the MinorObjects.objectHooks list
            Items.instance.Add(this);

            // Get object's components
            rb = GetComponent <Rigidbody>();
            PlayMakerFSM playMakerFSM = GetComponent <PlayMakerFSM>();

            renderer = GetComponent <Renderer>();

            // From PlayMakerFSM, find states that contain one of the names that relate to destroying object,
            // and inject RemoveSelf void.
            if (playMakerFSM != null)
            {
                foreach (var st in playMakerFSM.FsmStates)
                {
                    switch (st.Name)
                    {
                    case "Destroy self":
                        FsmHook.FsmInject(this.gameObject, "Destroy self", RemoveSelf);
                        break;

                    case "Destroy":
                        FsmHook.FsmInject(this.gameObject, "Destroy", RemoveSelf);
                        break;

                    case "Destroy 2":
                        FsmHook.FsmInject(this.gameObject, "Destroy 2", RemoveSelf);
                        break;
                    }
                }
            }

            // If the item is a shopping bag, hook the RemoveSelf to "Is garbage" FsmState
            if (gameObject.name.Contains("shopping bag"))
            {
                FsmHook.FsmInject(this.gameObject, "Is garbage", RemoveSelf);

                // Destroys empty shopping bags appearing at the back of the yard.
                PlayMakerArrayListProxy list = gameObject.GetComponent <PlayMakerArrayListProxy>();
                if (list.arrayList.Count == 0)
                {
                    Items.instance.Remove(this);
                    Destroy(this.gameObject);
                }
            }

            // If the item is beer case, hook the DestroyBeerBottles void uppon removing a bottle.
            if (gameObject.name.StartsWith("beer case"))
            {
                FsmHook.FsmInject(this.gameObject, "Remove bottle", DestroyBeerBottles);
                FsmHook.FsmInject(this.gameObject, "Remove bottle", HookBottles);
            }

            // If ignore, disable renderer
            if (rule != null)
            {
                renderer = null;
            }

            position = transform.position;

            // Fixes a bug which would prevent player from putting on the helmet, after taking it off.
            if (this.gameObject.name == "helmet(itemx)")
            {
                return;
            }

            if (this.gameObject.name.EqualsAny("floor jack(itemx)", "car jack(itemx)"))
            {
                floorJackTriggerY = gameObject.transform.Find("Trigger").gameObject.GetComponent <PlayMakerFSM>().FsmVariables.GetFsmFloat("Y");
            }

            // We're preventing the execution of State 1 and Load,
            // because these two reset the variables of the item
            // (such as position, state or rotation).
            FsmFixes();

            // HACK: For some reason the trigger that's supposed to fix tire job not working doesn't really work on game load,
            // toggle DontDisable to true, if tire is close to repair shop cash register.
            if (this.gameObject.name.StartsWith("wheel_") && Vector3.Distance(gameObject.transform.position, GameObject.Find("REPAIRSHOP").transform.Find("LOD/Store/ShopCashRegister").position) < 5)
            {
                DontDisable = true;
            }

            if (gameObject.name.Equals("empty plastic can(itemx)"))
            {
                if (Vector3.Distance(position, WorldManager.instance.GetCanTrigger().position) < 2)
                {
                    position = WorldManager.instance.GetLostSpawner().position;
                    return;
                }
            }
        }
Example #33
0
    public void OnEnable()
    {
        PlayMakerArrayListProxy proxy = (PlayMakerArrayListProxy)target;

        proxy.cleanPrefilledLists();
    }
Example #34
0
        public override void OnEnter()
        {
            if (string.IsNullOrEmpty(jsonString.Value))
            {
                LogWarning("json raw string is empty");
                Fsm.Event(failureEvent);
                Finish();
                return;
            }

            Hashtable jsonHash;



            try {
                jsonHash = (Hashtable)JSON.JsonDecode(jsonString.Value);
                if (jsonHash == null)
                {
                    LogWarning("json content is null");
                    return;
                }
            } catch (System.Exception e) {
                LogError("Json parsing error " + e.Message);
                Fsm.Event(failureEvent);
                Finish();
                return;
            }

            if (jsonHash == null)
            {
                LogError("Json parsing failed ");
                Fsm.Event(failureEvent);
                Finish();
                return;
            }


            int i = 0;

            foreach (FsmString _key in keys)
            {
                object _val = jsonHash[_key.Value];

                if (_val != null)
                {
                    //Debug.Log(_val.GetType().Name);

                    if (_val.GetType() == typeof(Hashtable))
                    {
                        if (values[i].Type == VariableType.GameObject)
                        {
                            // we put it into a hashtable with a proper reference to it;

                            PlayMakerHashTableProxy _proxy = GetHashTableProxyPointer(values[i].gameObjectValue, _key.Value, true);
                            if (_proxy != null)
                            {
                                Hashtable _table = (Hashtable)_val;
                                foreach (DictionaryEntry _entry in _table)
                                {
                                    if (_entry.Value.GetType() == typeof(Hashtable) || _entry.Value.GetType() == typeof(ArrayList))
                                    {
                                        _proxy.hashTable[_entry.Key] = JSON.JsonEncode(_entry.Value);
                                    }
                                    else
                                    {
                                        _proxy.hashTable[_entry.Key] = _entry.Value;
                                    }
                                }
                            }
                        }
                        else if (values[i].Type == VariableType.String)
                        {
                            PlayMakerUtils.ApplyValueToFsmVar(Fsm, values[i], JSON.JsonEncode(_val));
                        }
                    }
                    else if (_val.GetType() == typeof(ArrayList))
                    {
                        if (values[i].Type == VariableType.GameObject)
                        {
                            // we put it into a arraylist with a proper reference to it;

                            PlayMakerArrayListProxy _proxy = GetArrayListProxyPointer(values[i].gameObjectValue, "", true);
                            if (_proxy != null)
                            {
                                //	Debug.Log("We are in");
                                ArrayList _list = (ArrayList)_val;
                                foreach (object _entry in _list)
                                {
                                    //	Debug.Log(_entry);
                                    if (_entry.GetType() == typeof(Hashtable) || _entry.GetType() == typeof(ArrayList))
                                    {
                                        _proxy.arrayList.Add(JSON.JsonEncode(_entry));
                                    }
                                    else
                                    {
                                        _proxy.arrayList.Add(_entry);
                                    }
                                }
                            }
                        }
                        else if (values[i].Type == VariableType.String)
                        {
                            PlayMakerUtils.ApplyValueToFsmVar(Fsm, values[i], JSON.JsonEncode(_val));
                        }
                    }


                    else
                    {
                        PlayMakerUtils.ApplyValueToFsmVar(Fsm, values[i], _val);
                    }
                }

                i++;
            }

            Fsm.Event(successEvent);
            Finish();
        }