void Update() { // TODO: make a function that can start a new round if (personInDoor.affectionMeter >= 100) { initNewPerson(Random.Range(0, soData.people.Length - 1)); } // Change the person manually for testing. if (Input.GetKeyDown(KeyCode.L)) { try { initNewPerson(1); } catch { } } // Create 4 new ObjectBubble's to test the Text bubbles if (Input.GetKeyDown(KeyCode.K)) { ObjectBubble bubble1 = new ObjectBubble() { BuisinessOrientedness = 11, Intelligence = 12, Caringness = 13, HealthandStrength = 14, TextMessage = "Left" }; ObjectBubble bubble2 = new ObjectBubble() { BuisinessOrientedness = 21, Intelligence = 22, Caringness = 23, HealthandStrength = 24, TextMessage = "Right" }; ObjectBubble bubble3 = new ObjectBubble() { BuisinessOrientedness = 31, Intelligence = 32, Caringness = 33, HealthandStrength = 34, TextMessage = "Top" }; ObjectBubble bubble4 = new ObjectBubble() { BuisinessOrientedness = 41, Intelligence = 42, Caringness = 43, HealthandStrength = 44, TextMessage = "Bottom" }; // Set the data for the new buttons SetButtonData(bubble1, bubble2, bubble3, bubble4); } }
/// <summary></summary> /// <param name="newBubble">The Object Bubble</param> /// <param name="FilePath"></param> private void CreateFile(ObjectBubble newBubble) { // Save the new Asset File AssetDatabase.CreateAsset(newBubble, string.Format("{0}/{1}.asset", BubbleSavePath, newScriptableObjectName)); AssetDatabase.SaveAssets(); Selection.activeObject = newBubble; AssetDatabase.Refresh(); }
/// <summary>This function will set all the data for the buttons, this needs to be called when a new round is initiated and the buttons need to be reset.</summary> /// <param name="leftButtonData" >Give an object with all the data for the Left Button. </param> /// <param name="rightButtonData" >Give an object with all the data for the Right Button. </param> /// <param name="topButtonData" >Give an object with all the data for the Top Button. </param> /// <param name="bottomButtonData" >Give an object with all the data for the Bottom Button.</param> public void SetButtonData(ObjectBubble leftButtonData, ObjectBubble rightButtonData, ObjectBubble topButtonData, ObjectBubble bottomButtonData) { for (int i = 0; i < 4; i++) { // set the current Button that needs to be changed. ObjectBubble currentButton; // Check the current button and set currentButton to the correct version. ObjectBubble newButtonValue = new ObjectBubble(); switch (buttons[i].name) { case "Left Button": newButtonValue = leftButtonData; break; case "Right Button": newButtonValue = rightButtonData; break; case "Top Button": newButtonValue = topButtonData; break; case "Bottom Button": newButtonValue = bottomButtonData; break; } // set all the values and data for the current ObjectBubble. buttons[i].GetComponent <bubbleHoldData>().Bubble = newButtonValue; // clear local variables. currentButton = null; newButtonValue = null; } // clear local variables. leftButtonData = null; rightButtonData = null; topButtonData = null; bottomButtonData = null; }
public void buttonHasBeenClicked(ObjectBubble ClickedObjectBubble) { //Debug.Log(ClickedObjectBubble.name); //float intelligence = ((ClickedObjectBubble.Intelligence / personInDoor.objectPerson.Intelligence) * 0.001f) + 1f; //float buisiness = ((ClickedObjectBubble.BuisinessOrientedness / personInDoor.objectPerson.BuisinessOrientedness) * 0.001f) + 1f; //float care = ((ClickedObjectBubble.Caringness / personInDoor.objectPerson.Caringness) * 0.001f) + 0.5f; //float health = ((ClickedObjectBubble.HealthandStrength / personInDoor.objectPerson.HealthandStrength) * 0.001f) + 1f; float intelligence = (ClickedObjectBubble.Intelligence / (personInDoor.objectPerson.Intelligence)); float buisiness = (ClickedObjectBubble.BuisinessOrientedness / (personInDoor.objectPerson.BuisinessOrientedness)); float care = (ClickedObjectBubble.Caringness / (personInDoor.objectPerson.Caringness)); float health = (ClickedObjectBubble.HealthandStrength / (personInDoor.objectPerson.HealthandStrength)); Debug.LogFormat("I {0} / B {1} / C {2} / H {3}", intelligence, buisiness, care, health); //Debug.Log(AffectionCount); float lastAffectioCount = AffectionCount; AffectionCount += (intelligence * buisiness * care * health); Debug.LogFormat("name: {0} | AffectionCount: {1} | added AffectionCount: {2}", ClickedObjectBubble.name, AffectionCount, AffectionCount - lastAffectioCount); }
// GUI window code, buttons and other items need to be set here. private void OnGUI() { GUILayout.Label("Create new Scriptable Object", EditorStyles.boldLabel); GUILayout.Space(2); GUILayout.Label("Select Scriptable Object type you want to create!", EditorStyles.boldLabel); GUILayout.Space(1); selectedType = (SelectedScriptableObjectType)EditorGUILayout.EnumPopup(selectedType); if (selectedType != lastType) { newScriptableObjectName = ""; lastType = selectedType; } GUILayout.Space(5); GUILayout.Label("Scriptabel Object Specific Values and Variables", EditorStyles.boldLabel); GUILayout.Space(5); #region Personality Traits #region Intelligence GUILayout.BeginHorizontal(); GUILayout.Label("Intelligence"); Rect IRect = new Rect(IntFieldStartPos, getRectPos(1), getPropperScreenWidth(), 15); m_intelligence = (byte)EditorGUI.IntSlider(IRect, m_intelligence, 0, 100); GUILayout.EndHorizontal(); #endregion GUILayout.Space(2); #region BuisinessOrientedness GUILayout.BeginHorizontal(); GUILayout.Label("BuisinessOrientedness"); Rect BORect = new Rect(IntFieldStartPos, getRectPos(2), getPropperScreenWidth(), 15); m_buisinessOrientedness = (byte)EditorGUI.IntSlider(BORect, m_buisinessOrientedness, 0, 100); GUILayout.EndHorizontal(); #endregion GUILayout.Space(2); #region Caringness GUILayout.BeginHorizontal(); GUILayout.Label("Caringness"); Rect CRect = new Rect(IntFieldStartPos, getRectPos(3), getPropperScreenWidth(), 15); m_caringness = (byte)EditorGUI.IntSlider(CRect, m_caringness, 0, 100); GUILayout.EndHorizontal(); #endregion GUILayout.Space(2); #region HealthandStrenght GUILayout.BeginHorizontal(); GUILayout.Label("HealthandStrength"); Rect HaSRect = new Rect(IntFieldStartPos, getRectPos(4), getPropperScreenWidth(), 15); m_healthandStrength = (byte)EditorGUI.IntSlider(HaSRect, m_healthandStrength, 0, 100); GUILayout.EndHorizontal(); #endregion #endregion GUILayout.Space(1); GUILayout.BeginHorizontal(); GUILayout.Label("Personality traits collective total = "); GUILayout.Space(-84); // Set the color for the text short statCount = (short)(m_intelligence + m_buisinessOrientedness + m_healthandStrength + m_caringness); if (statCount >= 0 && statCount <= 100) { GUI.color = Color.green; } else { GUI.color = Color.red; } GUILayout.Label(string.Format("{0} / {1}", m_intelligence + m_buisinessOrientedness + m_healthandStrength + m_caringness, maxCollectiveTraits)); // Reset The Layout GUI.color = Color.white; GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.Label("Scriptable Object specific values", EditorStyles.boldLabel); GUILayout.Space(4); if (selectedType == SelectedScriptableObjectType.ObjectBubble) { EditorGUILayout.BeginHorizontal(); // Input the round that the user wants to add a new GUILayout.Space(80); GUILayout.Label(new GUIContent("New Object Name = ", "This number can't be 0, Round 0 doesn't exist")); // Prevent the Round from being 0, there is no Round 0. It's quite a simple spell but unbreakable if (m_roundNumber < 1) { m_roundNumber = 1; } // Set roundList roundList = null; roundList = getAllScriptableObjects(); if (m_roundNumber > roundList.Count + 1) { GUI.color = Color.red; } else if (m_roundNumber == roundList.Count + 1) { GUI.color = Color.white; } else { GUI.color = Color.green; } // Set roundList roundList = null; roundList = getAllScriptableObjects(); // set the Round number m_roundNumber = (byte)EditorGUILayout.IntField(m_roundNumber); GUI.color = Color.white; // Set index number and check if the round exists, if not set Index to 1. try { m_indexNumber = (byte)(roundList.ToArray()[m_roundNumber - 1].Count + 1); } catch { m_indexNumber = 1; } GUILayout.Label(string.Format("_ {0}", m_indexNumber.ToString())); // Set the name of the new Scriptable Object. newScriptableObjectName = string.Format("{0}_{1}", m_roundNumber, m_indexNumber); GUILayout.Space(70); EditorGUILayout.EndHorizontal(); GUILayout.Space(5); m_newTextMessage = EditorGUILayout.TextField("Text Message", m_newTextMessage); } if (selectedType == SelectedScriptableObjectType.ObjectPerson) { newScriptableObjectName = EditorGUILayout.TextField("Person Name", newScriptableObjectName); GUILayout.Space(10); // Set the Face of the person m_PersonFace = EditorGUILayout.ObjectField(m_PersonFace, typeof(Sprite), false); GUILayout.Space(2); // Set the body of the person m_PersonBody = EditorGUILayout.ObjectField(m_PersonBody, typeof(Sprite), false); } GUILayout.Space(10); if (GUILayout.Button("Create new Scriptable Object")) { if ((m_intelligence + m_buisinessOrientedness + m_healthandStrength + m_caringness) <= maxCollectiveTraits) { if (!string.IsNullOrEmpty(newScriptableObjectName) && !string.IsNullOrWhiteSpace(newScriptableObjectName)) { // Create a new Scriptable Object if (selectedType == SelectedScriptableObjectType.ObjectBubble) { if (string.IsNullOrEmpty(m_newTextMessage) || string.IsNullOrWhiteSpace(m_newTextMessage)) { Debug.LogErrorFormat("Error with Text Message! message: {0}.", m_newTextMessage); return; } ObjectBubble newBubble = new ObjectBubble() { Intelligence = m_intelligence, BuisinessOrientedness = m_buisinessOrientedness, Caringness = m_caringness, HealthandStrength = m_healthandStrength, // Object Specific values TextMessage = m_newTextMessage }; CreateFile(newBubble); } if (selectedType == SelectedScriptableObjectType.ObjectPerson) { ObjectPerson newPerson = new ObjectPerson() { Intelligence = m_intelligence, BuisinessOrientedness = m_buisinessOrientedness, Caringness = m_caringness, HealthandStrength = m_healthandStrength, // Object Specific values PersonName = newScriptableObjectName, Face = (Sprite)m_PersonFace, Body = (Sprite)m_PersonBody }; CreateFile(newPerson); } } else { Debug.LogErrorFormat("Error with newScriptableObjectName! name: {0}.", newScriptableObjectName); } } else { Debug.Log("Personality traits exceted the maximum total amount, lower some settings to stay under the collective limit"); } } }