Beispiel #1
0
        public override void OnEnter()
        {
            try{
                if (SetEventProperties.properties == null)
                {
                    throw new System.ArgumentException("no properties");
                }


                for (int i = 0; i < keys.Length; i++)
                {
                    Debug.Log(keys[i].Value);

                    if (SetEventProperties.properties.ContainsKey(keys[i].Value))
                    {
                        Debug.Log("found");
                        PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, datas[i], SetEventProperties.properties[keys[i].Value]);
                    }
                    else
                    {
                        Debug.Log("not found");
                    }
                }
            }catch (Exception e)
            {
                Debug.Log("no properties found " + e);
            }

            Finish();
        }
Beispiel #2
0
        public void GetItemAtIndex()
        {
            if (!isProxyValid())
            {
                return;
            }

            if (result.IsNone)
            {
                Fsm.Event(failureEvent);
                return;
            }

            object element = null;

            try{
                element = proxy.arrayList[atIndex.Value];
            }catch (System.Exception e) {
                Debug.Log(e.Message);
                Fsm.Event(failureEvent);
                return;
            }

            PlayMakerUtils.ApplyValueToFsmVar(Fsm, result, element);
        }
        public void GetRandomItem()
        {
            if (!base.isProxyValid())
            {
                return;
            }
            int    num   = UnityEngine.Random.Range(0, this.proxy.arrayList.Count);
            object value = null;

            try
            {
                value = this.proxy.arrayList[num];
            }
            catch (Exception ex)
            {
                Debug.LogWarning(ex.Message);
                base.Fsm.Event(this.failureEvent);
                return;
            }
            this.randomIndex.Value = num;
            if (!PlayMakerUtils.ApplyValueToFsmVar(base.Fsm, this.randomItem, value))
            {
                Debug.LogWarning("ApplyValueToFsmVar failed");
                base.Fsm.Event(this.failureEvent);
                return;
            }
        }
        public void GetItemAtIncrement()
        {
            if (!isProxyValid())
            {
                return;
            }


            object element = null;

            int targetIndex = baseIndex.Value + increment.Value;

            if (targetIndex >= 0)
            {
                resultIndex.Value = (baseIndex.Value + increment.Value) % proxy.arrayList.Count;
            }
            else
            {
                resultIndex.Value = proxy.arrayList.Count - Mathf.Abs(baseIndex.Value + increment.Value) % proxy.arrayList.Count;
            }


            element = proxy.arrayList[resultIndex.Value];


            PlayMakerUtils.ApplyValueToFsmVar(Fsm, result, element);
        }
        public void GetRandomItem()
        {
            if (!isProxyValid())
            {
                return;
            }

            int index = Random.Range(0, proxy.arrayList.Count);           // IS THIS TRUE? if I do count-1 I never get the last item picked...


            object element = null;

            try{
                element = proxy.arrayList[index];
            }catch (System.Exception e) {
                Debug.LogWarning(e.Message);
                Fsm.Event(failureEvent);
                return;
            }

            randomIndex.Value = index;

            bool ok = PlayMakerUtils.ApplyValueToFsmVar(Fsm, randomItem, element);

            if (!ok)
            {
                Debug.LogWarning("ApplyValueToFsmVar failed");
                Fsm.Event(failureEvent);
                return;
            }
        }
        public override void OnEnter()
        {
            user.Value          = LastUser;
            channel.Value       = LastChannel;
            messagesCount.Value = LastMessages.Length;

            if (!senders.IsNone)
            {
                senders.Values = LastSenders;
            }

            if (!messagesAsString.IsNone)
            {
                messagesAsString.Values = LastMessages.Cast <object> ()
                                          .Select(x => x.ToString())
                                          .ToArray();
            }

            int i = 0;

            foreach (FsmVar _var in messages)
            {
                if (LastMessages.Length > i)
                {
                    PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, LastMessages[i]);
                }
                i++;
            }

            Finish();
        }
        public void GetRandomItem()
        {
            if (!isProxyValid())
            {
                return;
            }

            int index = GetRandomWeightedIndex(_weights);


            object element = null;

            try{
                element = proxy.arrayList[index];
            }catch (System.Exception e) {
                Debug.LogWarning(e.Message);
                Fsm.Event(failureEvent);
                return;
            }

            randomIndex.Value = index;

            bool ok = PlayMakerUtils.ApplyValueToFsmVar(Fsm, randomItem, element);

            if (!ok)
            {
                Debug.LogWarning("ApplyValueToFsmVar failed");
                Fsm.Event(failureEvent);
                return;
            }
        }
Beispiel #8
0
        public void GetItemAtIndex()
        {
            if (!isProxyValid())
            {
                return;
            }

            if (result.IsNone)
            {
                return;
            }

            object element = null;

            currentIndex.Value = nextItemIndex;

            try{
                element = proxy.arrayList[nextItemIndex];
            }catch (System.Exception e) {
                Debug.Log(e.Message + "" + Fsm.GameObjectName + "\nFsm: " + Fsm.Name + "\nState: " + Fsm.ActiveStateName);
                Fsm.Event(failureEvent);
                return;
            }

            PlayMakerUtils.ApplyValueToFsmVar(Fsm, result, element);
        }
Beispiel #9
0
        public override void OnEnter()
        {
            foreach (FsmVar _fsmVar in variables)
            {
                PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _fsmVar, null);
            }

            Finish();
        }
Beispiel #10
0
 public void Get()
 {
     if (!base.isProxyValid())
     {
         return;
     }
     if (!this.proxy.hashTable.ContainsKey(this.key.Value))
     {
         base.Fsm.Event(this.KeyNotFoundEvent);
         return;
     }
     PlayMakerUtils.ApplyValueToFsmVar(base.Fsm, this.result, this.proxy.hashTable[this.key.Value]);
     base.Fsm.Event(this.KeyFoundEvent);
 }
Beispiel #11
0
 public void Get()
 {
     if (!base.isProxyValid())
     {
         return;
     }
     for (int i = 0; i < this.keys.Length; i++)
     {
         if (this.proxy.hashTable.ContainsKey(this.keys[i].Value))
         {
             PlayMakerUtils.ApplyValueToFsmVar(base.Fsm, this.results[i], this.proxy.hashTable[this.keys[i].Value]);
         }
     }
 }
        bool getRoomProperties()
        {
            Room _room     = PhotonNetwork.CurrentRoom;
            bool _isInRoom = _room != null;

            isInRoom.Value = _isInRoom;

            if (_isInRoom)
            {
                if (isInRoomEvent != null)
                {
                    Fsm.Event(isInRoomEvent);
                }
            }
            else
            {
                if (isNotInRoomEvent != null)
                {
                    Fsm.Event(isNotInRoomEvent);
                }
                return(false);
            }

            // we get the room properties
            RoomName.Value       = _room.Name;
            maxPlayers.Value     = _room.MaxPlayers;
            open.Value           = _room.IsOpen;
            visible.Value        = _room.IsVisible;
            playerCount.Value    = _room.PlayerCount;
            autoCleanUp.Value    = _room.AutoCleanUp;
            expectedUsers.Values = _room.ExpectedUsers;

            // get the custom properties
            int i = 0;

            foreach (FsmString key in customPropertyKeys)
            {
                if (_room.CustomProperties.ContainsKey(key.Value))
                {
                    PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, customPropertiesValues[i], _room.CustomProperties[key.Value]);
                }
                else
                {
                    return(false);
                }
                i++;
            }

            return(true);
        }
Beispiel #13
0
        public void Get()
        {
            if (!isProxyValid())
            {
                return;
            }

            for (int i = 0; i < keys.Length; i++)
            {
                if (proxy.hashTable.ContainsKey(keys[i].Value))
                {
                    PlayMakerUtils.ApplyValueToFsmVar(Fsm, results[i], proxy.hashTable[keys[i].Value]);
                }
            }
        }
Beispiel #14
0
        public void Get()
        {
            if (!isProxyValid())
            {
                return;
            }

            if (!proxy.hashTable.ContainsKey(key.Value))
            {
                Fsm.Event(KeyNotFoundEvent);
                return;
            }

            PlayMakerUtils.ApplyValueToFsmVar(Fsm, result, proxy.hashTable[key.Value]);

            Fsm.Event(KeyFoundEvent);
        }
Beispiel #15
0
    public static void StoreNodeProperties(Fsm fsm, XmlNode node, FsmXmlProperty[] properties)
    {
        int prop_i = 0;

        foreach (FsmXmlProperty prop in properties)
        {
            string _property = DataMakerXmlActions.GetNodeProperty(node, prop.property.Value);

            PlayMakerUtils.ApplyValueToFsmVar(
                fsm,
                prop.variable,
                PlayMakerUtils.ParseValueFromString(_property, prop.variable.Type)
                );

            prop_i++;
        }
    }
Beispiel #16
0
        bool getLastMessagePlayerProperties()
        {
            // get the photon proxy for Photon RPC access
            GameObject go = GameObject.Find("PlayMaker Photon Proxy");

            if (go == null)
            {
                return(false);
            }

            // get the proxy component
            PlayMakerPhotonProxy _proxy = go.GetComponent <PlayMakerPhotonProxy>();

            if (_proxy == null)
            {
                return(false);
            }

            Player _player = _proxy.lastMessagePhotonPlayer;

            if (_player == null)
            {
                return(false);
            }

            name.Value           = _player.NickName;
            ID.Value             = _player.ActorNumber;
            isLocal.Value        = _player.IsLocal;
            isMasterClient.Value = _player.IsMasterClient;

            // get the custom properties
            int i = 0;

            foreach (FsmString key in customPropertyKeys)
            {
                if (!_player.CustomProperties.ContainsKey(key.Value))
                {
                    return(false);
                }
                PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, customPropertiesValues[i], _player.CustomProperties[key.Value]);
                i++;
            }

            return(true);
        }
        void DoGetRandom()
        {
            int index = Random.Range(0, _keys.Count);

            object element = null;

            try{
                element = proxy.hashTable[_keys[index]];
            }catch (System.Exception e) {
                Debug.LogError(e.Message);
                Fsm.Event(failureEvent);
                return;
            }

            key.Value = (string)_keys[index];

            PlayMakerUtils.ApplyValueToFsmVar(Fsm, result, element);
        }
        public override void OnEnter()
        {
            for (int i = 0; i < keys.Length; i++)
            {
                if (keys[i].IsNone)
                {
                    continue;
                }

                int keyHash = StringUtils.GetHashCode(keys[i].Value);

                if (PlayMakerEventData.ContainsKey(keyHash))
                {
                    PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, datas[i], PlayMakerEventData.GetValue(keyHash));
                }
            }

            Finish();
        }
Beispiel #19
0
        public void GetItemAtIndex()
        {
            if (!base.isProxyValid())
            {
                return;
            }
            object value = null;

            try
            {
                value = this.proxy.arrayList[this.nextItemIndex];
            }
            catch (Exception ex)
            {
                Debug.LogError(ex.Message);
                base.Fsm.Event(this.failureEvent);
                return;
            }
            PlayMakerUtils.ApplyValueToFsmVar(base.Fsm, this.result, value);
        }
Beispiel #20
0
        public void GetItemAtIndex()
        {
            if (!isProxyValid())
            {
                return;
            }

            currentIndex.Value = countBase - nextItemIndex;

            object element = null;

            try{
                element = proxy.arrayList[currentIndex.Value];
            }catch (System.Exception e) {
                Debug.LogError(e.Message);
                Fsm.Event(failureEvent);
                return;
            }

            PlayMakerUtils.ApplyValueToFsmVar(Fsm, result, element);
        }
        public void GetItemAtIndex()
        {
            if (!isProxyValid())
            {
                return;
            }


            object element = null;

            try{
                element = proxy.hashTable[_keys[nextItemIndex]];
            }catch (System.Exception e) {
                Debug.LogError(e.Message);
                Fsm.Event(failureEvent);
                return;
            }

            key.Value = (string)_keys[nextItemIndex];

            PlayMakerUtils.ApplyValueToFsmVar(Fsm, result, element);
        }
Beispiel #22
0
		public void GetItemAtIndex(){
			
			
			if (! isProxyValid())
				return;
		
	
			object element = null;
			
			try{
				element = proxy.hashTable[_keys[nextItemIndex]];
			}catch(System.Exception e){
				Debug.Log(e.Message +""+ Fsm.GameObjectName + "\nFsm: " + Fsm.Name + "\nState: " + Fsm.ActiveStateName); 
				Fsm.Event(failureEvent);
				return;
			}
			
			key.Value = (string)_keys[nextItemIndex];
			
			PlayMakerUtils.ApplyValueToFsmVar(Fsm,result,element);

		}
        void DoFindMaximumValue()
        {
            if (!isProxyValid())
            {
                return;
            }

            VariableType _targetType = maximumValue.Type;

            if (!supportedTypes.Contains(maximumValue.Type))
            {
                return;
            }

            float max = float.NegativeInfinity;

            int maxIndex = 0;

            int index = 0;

            foreach (object _obj in proxy.arrayList)
            {
                try{
                    float _val = PlayMakerUtils.GetFloatFromObject(_obj, _targetType, true);
                    if (max < _val)
                    {
                        max      = _val;
                        maxIndex = index;
                    }
                }finally{ }

                index++;
            }


            maximumValueIndex.Value = maxIndex;

            PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, maximumValue, proxy.arrayList[maxIndex]);
        }
Beispiel #24
0
        public override void OnEnter()
        {
            if (!status.IsNone)
            {
                status.Value = (Enum)Enum.ToObject(status.EnumType, LastStatus);
            }
            if (!statusAsInt.IsNone)
            {
                statusAsInt.Value = LastStatus;
            }

            if (!gotMessage.IsNone)
            {
                gotMessage.Value = LastGotMessage;
            }

            if (!message.IsNone)
            {
                if (message.Type == VariableType.Array)
                {
                    object[] _lastMessages = (object[])LastMessage;
                    if (_lastMessages != null)
                    {
                        PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, message, _lastMessages);
                    }
                }
                else
                {
                    message.SetValue(LastMessage);
                }
            }

            if (gotMessageEvent != null && LastGotMessage)
            {
                this.Fsm.Event(gotMessageEvent);
            }

            Finish();
        }
Beispiel #25
0
        bool getOwnerProperties()
        {
            if (_networkView == null)
            {
                return(false);
            }

            Player _player = _networkView.Owner;

            if (_player == null)
            {
                return(false);
            }

            nickname.Value       = _player.NickName;
            userID.Value         = _player.UserId;
            actorNumber.Value    = _player.ActorNumber;
            isLocal.Value        = _player.IsLocal;
            isMasterClient.Value = _player.IsMasterClient;

            // get the custom properties
            int i = 0;

            foreach (FsmString key in customPropertyKeys)
            {
                if (_player.CustomProperties.ContainsKey(key.Value))
                {
                    PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, customPropertiesValues[i], _player.CustomProperties[key.Value]);
                }
                else
                {
                    return(false);
                }
                i++;
            }

            return(true);
        }
        public void GetItemAtIndex()
        {
            if (itemName.IsNone)
            {
                return;
            }

            object element = null;

            currentIndex.Value = nextItemIndex;

            try
            {
                element = (string)gdeData[nextItemIndex];
            } catch (System.Exception e)
            {
                Debug.LogError(e.Message);
                Fsm.Event(failureEvent);
                return;
            }

            PlayMakerUtils.ApplyValueToFsmVar(Fsm, itemName, element);
        }
        bool getLastMessagePlayerProperties()
        {
            if (PlayMakerPhotonProxy.Instance == null)
            {
                Debug.LogError("PlayMakerPhotonProxy is missing in the scene");
                return(false);
            }

            Player _player = PlayMakerPhotonProxy.Instance.lastMessagePhotonPlayer;

            if (_player == null)
            {
                return(false);
            }

            nickName.Value       = _player.NickName;
            actorNumber.Value    = _player.ActorNumber;
            userId.Value         = _player.UserId;
            isLocal.Value        = _player.IsLocal;
            isMasterClient.Value = _player.IsMasterClient;

            // get the custom properties
            int i = 0;

            foreach (FsmString key in customPropertyKeys)
            {
                if (!_player.CustomProperties.ContainsKey(key.Value))
                {
                    return(false);
                }
                PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, customPropertiesValues[i], _player.CustomProperties[key.Value]);
                i++;
            }

            return(true);
        }
        void DoGetSpanTimeInfo()
        {
            TimeSpan span = new TimeSpan();

            if (timeSpanCreate == TimeSpanCreate.TryParse)
            {
                /*bool _success = */ TimeSpan.TryParse(timeSpan.Value, out span);
            }
            else if (timeSpanCreate == TimeSpanCreate.FromSeconds)
            {
                span = TimeSpan.FromSeconds(Convert.ToDouble(timeSpan.Value));
            }


            int i = 0;

            foreach (TimeSpanProperties _prop in properties)
            {
                FsmVar _var = values[i];

                switch (_prop)
                {
                case TimeSpanProperties.Milliseconds:
                    PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.Milliseconds);
                    break;

                case TimeSpanProperties.TotalMilliseconds:
                    PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.TotalMilliseconds);
                    break;

                case TimeSpanProperties.Seconds:
                    PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.Seconds);
                    break;

                case TimeSpanProperties.TotalSeconds:
                    PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.TotalSeconds);
                    break;

                case TimeSpanProperties.Hours:
                    PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.Hours);
                    break;

                case TimeSpanProperties.TotalHours:
                    PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.TotalHours);
                    break;

                case TimeSpanProperties.Minutes:
                    PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.Minutes);
                    break;

                case TimeSpanProperties.totalMinutes:
                    PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.TotalMinutes);
                    break;

                case TimeSpanProperties.Days:
                    PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.Days);
                    break;

                case TimeSpanProperties.TotalDays:
                    PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, span.TotalDays);
                    break;

                default:
                    PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, _var, 0);
                    break;
                }

                i++;
            }
        }
Beispiel #29
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();
        }
Beispiel #30
0
        public override void OnEnter()
        {
            //check if we are in a room or not
            //if (PhotonNetwoek.is)
            if (!PhotonNetwork.insideLobby)
            {
                Fsm.Event(notInLobbyEvent);
                Finish();
                return;
            }

            if (nextRoomIndex == 0)
            {
                rooms = PhotonNetwork.GetRoomList();
            }

            if (rooms.Length == 0)
            {
                nextRoomIndex = 0;
                Fsm.Event(noRoomsEvent);
                Fsm.Event(finishedEvent);
                Finish();
                return;
            }

            if (nextRoomIndex >= rooms.Length)
            {
                nextRoomIndex = 0;
                Fsm.Event(finishedEvent);
                Finish();
                return;
            }

            _room = rooms[nextRoomIndex];

            // we get the room properties
            RoomName.Value    = _room.Name;
            maxPlayers.Value  = _room.MaxPlayers;
            open.Value        = _room.IsOpen;
            visible.Value     = _room.IsVisible;
            playerCount.Value = _room.PlayerCount;



            // get the custom properties
            int i = 0;

            foreach (FsmString key in customPropertyKeys)
            {
                if (_room.CustomProperties.ContainsKey(key.Value))
                {
                    PlayMakerUtils.ApplyValueToFsmVar(this.Fsm, customPropertiesValues[i], _room.CustomProperties[key.Value]);
                }
                i++;
            }


            nextRoomIndex++;

            Fsm.Event(loopEvent);

            Finish();
        }