Esempio n. 1
0
	IEnumerator Start() 
	{
		UniRPGGlobal.Instance.OnMenusLoaded(); // tell UnIRPG that the menu is loaded

		gui = UniRPGGlobal.DB.menuGUIData.GetComponent<DefaultMainMenuGUIData>();

		// init New Screen defaults
		newCharacter = UniRPGGlobal.MainMenuData.GetDefaultPlayerCharacter(UniRPGGlobal.DB.playerCanSelectCharacter);
		if (newCharacter == null) Debug.LogError("Could not find a default player character. There must be at least one Actor (PlayerCharacter) set as 'Avail at Start'");

		if (UniRPGGlobal.DB.playerCanSelectClass)
		{
			if (newCharacter != null) newClass = UniRPGGlobal.MainMenuData.GetDefaultPlayerClass(newCharacter.Actor);
		}

		// wait a frame before doing the following
		yield return null;

		CalcRecs();

		// ready
		SetState(State.MainMenu);

		AudioListener.volume = UniRPGGlobal.DB.audioMainVolume;

		// start random song
		if (gui.menuMusic.Count > 0)
		{
			int id = 0;
			if (gui.menuMusic.Count > 1) id = Random.Range(0, gui.menuMusic.Count);
			music = camObject.AddComponent<AudioSource>();
			music.clip = gui.menuMusic[id];
			music.volume = UniRPGGlobal.DB.musicVolume;
			music.bypassEffects = true;
			music.bypassReverbZones = true;
			music.bypassListenerEffects = true;
			music.loop = true;
			music.Play();
		}

		// create buton click audio source if needed
		if (gui.sfxButton)
		{
			sfxButton = camObject.AddComponent<AudioSource>();
			sfxButton.clip = gui.sfxButton;
			sfxButton.volume = UniRPGGlobal.DB.guiAudioVolume;
			sfxButton.playOnAwake = false;
			sfxButton.bypassEffects = true;
			sfxButton.bypassReverbZones = true;
			sfxButton.bypassListenerEffects = true;
			sfxButton.loop = false;
		}
	}
Esempio n. 2
0
	void OnGUI()
	{
		if (!inited) Init();
		UniRPGEdGui.UseSkin();
		
		scroll = UniRPGEdGui.BeginScrollView(scroll);
		{
			if (UniRPGEditorGlobal.DB.classes.Count > 0)
			{
				foreach (RPGActorClass cl in UniRPGEditorGlobal.DB.classes)
				{
					Rect r = EditorGUILayout.BeginHorizontal();
					{
						r.x = 3; r.width = 19; r.height = 19;
						GUI.DrawTexture(r, (cl.icon[0] != null ? cl.icon[0] : UniRPGEdGui.Texture_NoPreview));
						GUILayout.Space(21);
						if (UniRPGEdGui.ToggleButton(selectedClass == cl, cl.screenName, UniRPGEdGui.ButtonRightStyle, UniRPGEdGui.ButtonOnColor, GUILayout.Width(150)))
						{
							selectedClass = cl;
						}
					}
					EditorGUILayout.EndHorizontal();
				}
			}
			else
			{
				GUILayout.Label("No Actor Classes are defined", UniRPGEdGui.WarningLabelStyle);
			}
		}
		UniRPGEdGui.EndScrollView();
		UniRPGEdGui.DrawHorizontalLine(1, UniRPGEdGui.DividerColor, 0, 10);

		EditorGUILayout.BeginHorizontal();
		{
			GUILayout.FlexibleSpace();

			if (selectedClass == null) GUI.enabled = false;
			if (GUILayout.Button("Accept", UniRPGEdGui.ButtonStyle)) accepted = true;
			GUI.enabled = true;

			if (GUILayout.Button("Cancel", UniRPGEdGui.ButtonStyle)) this.Close();
			GUILayout.FlexibleSpace();
		}
		EditorGUILayout.EndHorizontal();
		GUILayout.Space(10);
	}
Esempio n. 3
0
	// ================================================================================================================
	#region init and update 

	public void CopyTo(RPGActorClass ac)
	{
		ac.id = this.id.Copy();
		ac.screenName = this.screenName;
		ac.description = this.description;
		ac.notes = this.notes;
		ac.icon = new Texture2D[3] { this.icon[0], this.icon[1], this.icon[2] };
		ac.guiHelper = this.guiHelper;
		ac.availAtStart = this.availAtStart;
		ac.xpAttribId = this.xpAttribId;
		ac.maxXP = this.maxXP;
		ac.maxLevel = this.maxLevel;
		ac.levelCurve = AnimationCurve.Linear(1, 1, ac.maxXP, ac.maxLevel);

		if (this.attribDataFabs != null)
		{
			ac.attribDataFabs = new List<RPGAttributeData>();
			foreach (RPGAttributeData dat in this.attribDataFabs)
			{
				ac.attribDataFabs.Add(dat.Copy(this.maxLevel));
			}
		}
		else ac.attribDataFabs = null;
	}
Esempio n. 4
0
	private void LeftPanel()
	{
		EditorGUILayout.BeginVertical(GUILayout.Width(DatabaseEditor.LeftPanelWidth));
		GUILayout.Space(5);
		// -------------------------------------------------------------

		// the add button
		EditorGUILayout.Space();
		EditorGUILayout.BeginHorizontal();
		{
			GUILayout.FlexibleSpace();
			if (GUILayout.Button(new GUIContent("Add Class", UniRPGEdGui.Icon_Plus), EditorStyles.miniButtonLeft))
			{
				GUI.FocusControl("");
				curr = ScriptableObject.CreateInstance<RPGActorClass>();
				UniRPGEdUtil.AddObjectToAssetFile(curr, UniRPGEditorGlobal.DB_DEF_CLASSES_FILE);
				curr.screenName = "ActorClass";
				ed.db.classes.Add(curr);
				EditorUtility.SetDirty(curr);
				EditorUtility.SetDirty(ed.db);
				selAttrib = null;
			}
			if (curr == null) GUI.enabled = false;
			if (GUILayout.Button(new GUIContent(UniRPGEdGui.Icon_Copy, "Copy"), EditorStyles.miniButtonMid))
			{
				GUI.FocusControl("");
				RPGActorClass newAC = ScriptableObject.CreateInstance<RPGActorClass>();

				curr.CopyTo(newAC);
				curr = newAC;

				UniRPGEdUtil.AddObjectToAssetFile(curr, UniRPGEditorGlobal.DB_DEF_CLASSES_FILE);
				
				ed.db.classes.Add(curr);
				EditorUtility.SetDirty(curr);
				EditorUtility.SetDirty(ed.db);
				selAttrib = null;
			}
			GUI.enabled = true;
		}
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.Space();

		scroll[0] = UniRPGEdGui.BeginScrollView(scroll[0], GUILayout.Width(DatabaseEditor.LeftPanelWidth));
		{
			if (ed.db.classes.Count > 0)
			{
				foreach (RPGActorClass charaClass in ed.db.classes)
				{
					Rect r = EditorGUILayout.BeginHorizontal(GUILayout.Width(DatabaseEditor.LeftPanelWidth - 20), GUILayout.ExpandWidth(false));
					{
						r.x = 3; r.width = 19; r.height = 19;
						GUI.DrawTexture(r, (charaClass.icon[0] != null ? charaClass.icon[0] : UniRPGEdGui.Texture_NoPreview));
						GUILayout.Space(21);
						if (UniRPGEdGui.ToggleButton(curr == charaClass, charaClass.screenName, UniRPGEdGui.ButtonMidStyle, GUILayout.Width(140), GUILayout.ExpandWidth(false)))
						{
							selAttrib = null;
							curr = charaClass;
							GUI.FocusControl("");
							CheckXPAttrib();
						}
						if (ed.db.classes.Count == 1) GUI.enabled = false; // can't allow deleting the class if there is only one left since runtime depends on at least one being present
						if (GUILayout.Button("X", UniRPGEdGui.ButtonRightStyle, GUILayout.Width(20)))
						{
							del = charaClass;
						}
						GUI.enabled = true;
					}
					EditorGUILayout.EndHorizontal();
				}
			}
			else
			{
				GUILayout.Label("No Classes are defined", UniRPGEdGui.WarningLabelStyle);
			}
		}
		UniRPGEdGui.EndScrollView();

		// -------------------------------------------------------------
		GUILayout.Space(3);
		EditorGUILayout.EndVertical();
		// -------------------------------------------------------------

		if (del != null)
		{
			if (curr == del)
			{
				curr = null;
				selAttrib = null;
			}
			ed.db.classes.Remove(del);
			Object.DestroyImmediate(del, true);
			del = null;
			EditorUtility.SetDirty(ed.db);
			AssetDatabase.SaveAssets();
		}
	}
Esempio n. 5
0
	private void Draw_SelectCharacter()
	{
		if (gui.texLogo && (state == State.SelectName || gui.newGameCharaBackFab == null)) GUI.DrawTexture(rMenu[0], gui.texLogo);

		if (UniRPGGlobal.DB.playerCanSelectCharacter)
		{
			GUILayout.BeginArea(rNew[0], gui.labelSelectChara, GUI.skin.window);
			scroll[0] = GUILayout.BeginScrollView(scroll[0]);
			{
				foreach (CharacterBase chara in UniRPGGlobal.MainMenuData.playerCharacters)
				{	// show the characters that can be chosen from
					if (chara.Actor.availAtStart)
					{
						if (ListItem(newCharacter == chara, new GUIContent("  " + chara.Actor.screenName, chara.Actor.portrait[0]), gui.ListItem))
						{
							newCharacter = chara;
							LoadActorPreview(newCharacter.gameObject);
						}
					}
				}
			}
			GUILayout.EndScrollView();
			GUILayout.EndArea();

			if (newCharacter)
			{
				if (!string.IsNullOrEmpty(newCharacter.Actor.description))
				{
					GUILayout.BeginArea(rNew[3], GUI.skin.box);
					scroll[2] = GUILayout.BeginScrollView(scroll[2]);
					GUILayout.Label(newCharacter.Actor.description);
					GUILayout.EndScrollView();
					GUILayout.EndArea();
				}
			}

		}

		if (UniRPGGlobal.DB.playerCanSelectClass)
		{
			GUILayout.BeginArea(rNew[1], gui.labelSelectClass, GUI.skin.window);
			scroll[1] = GUILayout.BeginScrollView(scroll[1]);
			{
				foreach (RPGActorClass c in UniRPGGlobal.DB.classes)
				{	// show the characters that can be chosen from
					if (c.availAtStart)
					{
						if (ListItem(newClass == c, new GUIContent("  " + c.screenName, c.icon[0]), gui.ListItem)) newClass = c;
					}
				}
			}
			GUILayout.EndScrollView();
			GUILayout.EndArea();

			if (newClass)
			{
				if (!string.IsNullOrEmpty(newClass.description))
				{
					GUILayout.BeginArea(rNew[4], GUI.skin.box);
					scroll[3] = GUILayout.BeginScrollView(scroll[3]);
					GUILayout.Label(newClass.description);
					GUILayout.EndScrollView();
					GUILayout.EndArea();
				}
			}
		}

		GUILayout.BeginArea(rNew[2], GUI.skin.box);
		{
			GUILayout.BeginHorizontal();
			{
				GUILayout.BeginVertical();
				{
					if (UniRPGGlobal.DB.playerCanChooseName)
					{
						GUILayout.Label("Name");
						newName = GUILayout.TextField(newName);
					}
				}
				GUILayout.EndVertical();
				GUILayout.FlexibleSpace();
				GUILayout.BeginVertical();
				{
					if (GUILayout.Button("Start"))
					{
						ButtonClickFX();
						SetState(State.CreateNewGame);
					}
					if (GUILayout.Button("Back"))
					{
						ButtonClickFX();
						SetState(State.MainMenu);
					}
				}
				GUILayout.EndVertical();
			}
			GUILayout.EndHorizontal();
		}
		GUILayout.EndArea();
	}
Esempio n. 6
0
	public void Start() 
	{
		if (UniRPGGlobal.Instance.state == UniRPGGlobal.State.InMainMenu)
		{
			// Actor should be disabled when viewing character in the menu
			enabled = false;
			return;
		}

		// cache the equip slot transforms
		mountPoints = new Transform[UniRPGGlobal.DB.equipSlots.Count];
		for (int i = 0; i < UniRPGGlobal.DB.equipSlots.Count; i++)
		{
			mountPoints[i] = FindMarkedTransform(UniRPGGlobal.DB.equipSlots[i], _tr);
			//if (mountPoints[i] != null) Debug.Log("Found mount: " + mountPoints[i].name);
		}

		// These must be in Start because it depend on the DB being inited. If a designer run a scene
		// directly then the DB will be init in UniRPGGlobal.Awake, so can't do these in Awake

		// init the skills. all skills that can be mounted must be present in the 
		// SKILLS list and will be added there if not inited from startingSkills

		skills = new List<RPGSkill>(0);
		for (int i = 0; i < startingSkills.Count; i++)
		{
			AddSkill(startingSkills[i]);
		}

		if (actionSlotCount > 0)
		{
			actionSlots = new List<ActionSlot>(actionSlotCount);
			for (int i = 0; i < actionSlotCount; i++)
			{	// create the new action slot
				actionSlots.Add(new ActionSlot());

				// set a skill in it if needed
				if (i < startingSkillSlots.Count)
				{
					SetActionSlot(i, startingSkillSlots[i]);
				}
			}
		}

		// instantiate ActorClass (grab the 1st avail class if none set)
		if (actorClassPrefab == null) actorClassPrefab = UniRPGGlobal.DB.classes[0];
		this.ActorClass = (RPGActorClass)ScriptableObject.Instantiate(actorClassPrefab);
		this.ActorClass.Init(gameObject, startingXP);

		// init the starting states
		for (int i = 0; i < startingStates.Count; i++)
		{
			AddState(startingStates[i]);
		}
	}