protected void SubscribeToMailingList(string email)
        {
            string result = "";

            using (var client = new WebClient())
            {
                client.Headers[HttpRequestHeader.ContentType] = "application/json";
                result = client.UploadString(signupNewsletterApiUrl + "?email_address=" + email, "POST");
            }

            if (result.Contains("\"status\":\"subscribed\""))
            {
                subscribedWithEmail = email;
                DevdogLogger.Log("Successfully subscribed to mailing list :)");

                Repaint();
            }
            else
            {
                DevdogLogger.Log("Whoops something went wrong while subscribing");
                DevdogLogger.Log(result);
            }

            GetImages();
        }
        protected virtual void Kill()
        {
            if (isDead)
            {
                return;
            }

            isDead = true;
            DevdogLogger.Log("You killed it!");
            if (_onKilled != null)
            {
                _onKilled.OnKilled();
            }

            if (_agent.isOnNavMesh)
            {
#if UNITY_2017_1_OR_NEWER
                _agent.isStopped = true;
#else
                _agent.Stop();
#endif
            }

            StartCoroutine(SinkIntoGround());
        }
Example #3
0
        public bool CompleteAndGiveRewards(bool forceComplete = false)
        {
            if (CanComplete() == false && forceComplete == false)
            {
                return(false);
            }

            // Even when forcing the quest CAN NOT be completed if the user can't get his/her rewards.
            if (CanGiveRewards() == false)
            {
                return(false);
            }

            repeatedTimes++;

            CompleteCompletableTasks(forceComplete);
            GiveRewards();

            status = repeatedTimes < maxRepeatTimes ? QuestStatus.InActive : QuestStatus.Completed;
            DevdogLogger.Log("Completed quest/achievement with ID: " + ID + " and gave rewards. Repeated quest #" + repeatedTimes + " times. Quest status is: " + status);

            NotifyTasksQuestCompleted();

            return(true);
        }
Example #4
0
        protected virtual void OnGUI()
        {
            searchQuery = EditorStyles.SearchBar(searchQuery, this, isSearching);

            foreach (var kvp in lookups)
            {
                if (isSearching)
                {
                    if (kvp.Value.Any(o => o.Name.ToLower().Contains(searchQuery.ToLower())) == false)
                    {
                        continue;
                    }
                }
                else
                {
                    GUI.color = Color.cyan;

                    if (GUILayout.Button(kvp.Key, expandedKeys.Contains(kvp.Key) ? normalButtonStyle : selectedButtonStyle))
                    {
                        if (expandedKeys.Contains(kvp.Key))
                        {
                            expandedKeys.Remove(kvp.Key);
                        }
                        else
                        {
                            expandedKeys.Add(kvp.Key);
                        }
                    }
                }

                GUI.color = Color.white;

                if (expandedKeys.Contains(kvp.Key) || isSearching)
                {
                    foreach (var type in lookups[kvp.Key])
                    {
                        EditorGUILayout.BeginHorizontal();

                        GUILayout.Space(20);
                        if (GUILayout.Button(type.Name))
                        {
                            var node = DialogueEditorWindow.CreateAndAddNodeToCurrentDialog(type);
                            if (node != null)
                            {
                                DevdogLogger.LogVerbose("Add new node of type " + type.Name + " with index: " + node.index);
                            }
                            else
                            {
                                DevdogLogger.Log("Couldn't add node, no dialogue selected.");
                            }
                        }

                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
        }
        public virtual void SaveAllQuestsAndAchievementsForAll()
        {
            var db = QuestManager.instance.GetAllQuestStates();

            foreach (var kvp in db)
            {
                SaveAllQuestsAndAchievementsFor(kvp.Key);
            }

            DevdogLogger.Log("Saved " + db.Count + " player's quests");
        }
Example #6
0
 public virtual void Fail()
 {
     if (status != TaskStatus.Completed)
     {
         status = TaskStatus.Failed;
         StopTimer();
     }
     else
     {
         DevdogLogger.Log("Trying to fail completed task. If you wish to start it again call SetProgress instead.");
     }
 }
Example #7
0
        public Variable Get(string name)
        {
            foreach (var variable in variables)
            {
                if (variable.name == name)
                {
                    return(variable);
                }
            }

            DevdogLogger.Log("Trying to get variable with name " + name + " - Not found.");
            return(null);
        }
Example #8
0
        public Variable Get(Guid g)
        {
            foreach (var variable in variables)
            {
                if (variable.guid == g)
                {
                    return(variable);
                }
            }

            DevdogLogger.Log("Trying to get variable with GUID " + g + " - Not found.");
            return(null);
        }
Example #9
0
        protected virtual void OnPlayerDecisionClicked(int decisionIndex)
        {
            var decisionNode = (IPlayerDecisionNode)currentNode;

            if (ReferenceEquals(_decisions, decisionNode.playerDecisions) == false)
            {
                DevdogLogger.Log("Player decisions changed during repaint and user click - Forcing repaint.");
                Repaint(currentNode); // Force repaint
                return;
            }

            decisionNode.SetPlayerDecisionAndMoveToNextNode(decisionIndex);
        }
Example #10
0
 public virtual void Activate()
 {
     if (status == TaskStatus.InActive)
     {
         startTime = DateTime.Now;
         if (useTimeLimit)
         {
             StartTimer();
         }
         status = TaskStatus.Active;
     }
     else if (status == TaskStatus.Completed)
     {
         DevdogLogger.Log("Trying to activate completed task. If you wish to start it again call SetProgress instead.");
     }
 }
        protected void SubscribeToMailingList(string email)
        {
            string result;
            var    success = NewsletterEditorUtility.SubscribeToMailingList(email, out result);

            if (success)
            {
                DevdogLogger.Log("Successfully subscribed to mailing list :)");
                Repaint();
            }
            else
            {
                DevdogLogger.Log("Whoops something went wrong while subscribing");
                DevdogLogger.Log(result);
            }

            GetImages();
        }
Example #12
0
        protected virtual void Kill()
        {
            if (isDead)
            {
                return;
            }

            isDead = true;
            DevdogLogger.Log("You killed it!");
            if (_onKilled != null)
            {
                _onKilled.OnKilled();
            }

            if (_agent.isOnNavMesh)
            {
                _agent.Stop();
            }

            StartCoroutine(SinkIntoGround());
        }
Example #13
0
        public bool CanStart(ILocalIdentifier localIdentifier)
        {
//            if (status == DialogueStatus.Active)
//            {
//                return false;
//            }

            if (nodes.Length <= 1)
            {
                DevdogLogger.Log("Can't start a dialogue with with 0 or 1 nodes (start node). Add some nodes first.");
                return(false);
            }

            foreach (var condition in conditions)
            {
                if (condition.CanStart(this, localIdentifier).status == false)
                {
                    return(false);
                }
            }

            return(true);
        }
Example #14
0
        /// <summary>
        /// The method implements deep clone using reflection.
        /// </summary>
        /// <param name="obj">It is the object used to deep clone.</param>
        /// <returns>Return the deep clone.</returns>
        public static object CreateDeepClone(object obj)
        {
            if (obj == null)
            {
                return(null);
            }

            var type = obj.GetType();

            // No need to clone simple types
            if (type.IsPrimitive || type.IsEnum || type == typeof(string))
            {
                return(obj);
            }

            // If the type of the object is the Array, we use the CreateInstance method to get
            // a new instance of the array. We also process recursively this method in the
            // elements of the original array because the type of the element may be the reference
            // type.
            if (type.IsArray)
            {
                string typeName    = type.AssemblyQualifiedName.Replace("[]", string.Empty);
                Type   typeElement = Type.GetType(typeName);
                if (typeElement != null)
                {
                    var   array       = obj as Array;
                    Array copiedArray = Array.CreateInstance(typeElement, array.Length);
                    for (int i = 0; i < array.Length; i++)
                    {
                        copiedArray.SetValue(CreateDeepClone(array.GetValue(i)), i);
                    }

                    return(copiedArray);
                }

                DevdogLogger.Log("Couldn't copy array of type " + typeName);
                return(obj);
            }

            // Scriptable objects should be created and saved in a folder; Use the same folder as source item...
            if (typeof(ScriptableObject).IsAssignableFrom(type))
            {
                var currentFolder = AssetDatabase.GetAssetPath((UnityEngine.Object)obj);
                currentFolder = currentFolder.Substring(0, currentFolder.LastIndexOf('/'));

//                DevdogLogger.Log("Creating deepclone of scriptable object: saving to :: " + currentFolder);

                if (AssetDatabase.IsValidFolder(currentFolder))
                {
                    var copy = ScriptableObjectUtility.CreateAsset(type, currentFolder, DateTime.Now.ToFileTimeUtc() + ".asset");
                    ReflectionUtility.CopySerializableValues(obj, copy);
                    return(copy);
                }

                return(null);
            }

            // If the type of the object is class or struct, it may contain the reference fields,
            // so we use reflection and process recursively this method in the fields of the object
            // to get the deep clone of the object.
            // We use Type.IsValueType method here because there is no way to indicate directly whether
            // the Type is a struct type.
            if (type.IsClass || type.IsValueType)
            {
                // A reference that we actually want to keep
                if (obj is UnityEngine.Object)
                {
                    return(obj);
                }

                object copiedObject = Activator.CreateInstance(obj.GetType());

                // Get all FieldInfo.
                FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                foreach (FieldInfo field in fields)
                {
                    object fieldValue = field.GetValue(obj);
                    if (fieldValue != null)
                    {
                        // Don't clone unity objects any further, just go with a ref.
                        if (field.FieldType.IsAssignableFrom(typeof(UnityEngine.Object)) || field.FieldType.IsAssignableFrom(typeof(MonoBehaviour)))
                        {
                            field.SetValue(copiedObject, fieldValue);
                            continue;
                        }

                        // Get the deep clone of the field in the original object and assign the
                        // clone to the field in the new object.
                        field.SetValue(copiedObject, CreateDeepClone(fieldValue));
                    }
                }

                return(copiedObject);
            }

            throw new ArgumentException("The object is unknown type (" + obj.GetType() + ")");
        }