Jump to content
Unity Insider Forum

Lässt sich eine alte GridSelectionfunktion in eine Tooglegroup umwandeln ?


Recommended Posts

Hallo zusammen,

 

ich bin neu bei Unity und schau mir gerade die Tutserie von Make an RPG von"HardlyBriefDan" an, leider stammt ein großer Teil der Reihe aus einer Zeit als es die neue GUI noch nicht gab.

 

Kann man den Code in eine Tooglegroup unterbingen oder müsste ich dieses Scipt quasi nochmals irgendwie aufteilen ?

 

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;
public class DisplayPlayerGUI
{
private StatAllocation statAllocation = new StatAllocation();
private int classSelection;
private string[] classSelectionName = new string[] { "Mage", "Warrior", "Archer", "Rouge", "Warlock", "Paladin" };

public void DisplayClassSelection()
{
	//Choose Your Class
	classSelection = GUI.SelectionGrid(new Rect(150f,150f,150f,200f), classSelection, classSelectionName, 1);
	GUI.Label(new Rect(450, 175, 300, 300), FindClassDescription(classSelection));
	GUI.Label(new Rect(450,275,300,300), FindClassStatValue(classSelection));
}
private string FindClassDescription(int classSelection)
{

	//Shows Description of choosen Class
	if(classSelection == 0)
	{
		BaseCharacterClass tempClass = new BaseMageClass();
		return tempClass.CharacterClassDescription;
	}
	else if(classSelection == 1)
		{
			BaseCharacterClass tempClass = new BaseWarriorClass();
			return tempClass.CharacterClassDescription;
		}
	return "Sorry,No Description Found";
}

private string FindClassStatValue(int classSelection)
{
	//Show Stats from Choosen Class
	if(classSelection == 0)
	{
		BaseCharacterClass tempClass = new BaseMageClass();
		string tempStats = "Stamina " + tempClass.Stamina + "\n" + "Strength " + tempClass.Strength + "\n" + "Intellect " + tempClass.Intellect + "\n" + "Endurance" + tempClass.Endurance;
		return tempStats;
	}
	else if(classSelection == 1)
	{
		BaseCharacterClass tempClass = new BaseWarriorClass();
		string tempStats = "Stamina " + tempClass.Stamina + "\n" + "Strength " + tempClass.Strength + "\n" + "Intellect " + tempClass.Intellect + "\n" + "Endurance" + tempClass.Endurance;
		return tempStats;
	}
	return "Sorry, No Stats Found";
}

public void DisplayStatAllocation()
{
	statAllocation.DisplayStatAllocation();
}
public void DisplayFinalSetup()
{
}
public void DisplayMains()
{
	// Rotatefunction for Showmodel
	Transform player = GameObject.FindGameObjectWithTag("Player").transform;
	GUI.Label(new Rect(Screen.width / 2, 125, 250, 100), "Create New Player");
	if (GUI.Button(new Rect(725,450,50,50), "<<<<"))
	{
		player.Rotate(Vector3.up *25);
	}
	if (GUI.Button(new Rect(875,450,50,50), ">>>>"))
	{
		player.Rotate(Vector3.down *25);
	}
}
}

 

vielen Dank für Eure Hilfe

Link zu diesem Kommentar
Auf anderen Seiten teilen

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Auf dieses Thema antworten...

×   Du hast formatierten Text eingefügt.   Formatierung jetzt entfernen

  Only 75 emoji are allowed.

×   Dein Link wurde automatisch eingebettet.   Einbetten rückgängig machen und als Link darstellen

×   Dein vorheriger Inhalt wurde wiederhergestellt.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Lädt...
×
×
  • Neu erstellen...