KochamMaslo

CreateNewCharacter:

Sep 11th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.27 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.SceneManagement;
  4. using UnityEditor;
  5.  
  6. public class CreateNewCharacter : MonoBehaviour {
  7.  
  8.     private BasePlayer newPlayer;
  9.     private bool isMageClass = false;
  10.     private bool isWarriorClass = false;
  11.     private bool isRogueClass = false;
  12.     private bool isArcherClass = false;
  13.     private bool isWarlockClass = false;
  14.     private bool isPaladinClass = false;
  15.     private string playerName = "Wprowadź imię";
  16.  
  17.     void Start () {
  18.         newPlayer = new BasePlayer();
  19.     }
  20.  
  21.     void Update () {
  22.    
  23.     }
  24.  
  25.     void OnGUI(){
  26.         playerName = GUILayout.TextArea (playerName,15);
  27.         isMageClass = EditorGUILayout.Toggle ("Mag", isMageClass);
  28.         isWarriorClass = EditorGUILayout.Toggle ("Wojownik", isWarriorClass);
  29.         isRogueClass = EditorGUILayout.Toggle ( "Łotrzyk", isRogueClass);
  30.         isArcherClass = EditorGUILayout.Toggle ( "Łucznik", isArcherClass);
  31.         isWarlockClass = EditorGUILayout.Toggle ( "Czarodziej", isWarlockClass);
  32.         isPaladinClass = EditorGUILayout.Toggle ( "Paladyn", isPaladinClass);
  33.         if (GUILayout.Button ("Stwórz")) {
  34.             if (isMageClass) {
  35.                 newPlayer.PlayerClass = new BaseMageClass ();
  36.             } else if (isWarriorClass) {
  37.                 newPlayer.PlayerClass = new BaseWarriorClass ();
  38.             } else if (isRogueClass) {
  39.                 newPlayer.PlayerClass = new BaseRogueClass ();
  40.             } else if (isArcherClass) {
  41.                 newPlayer.PlayerClass = new BaseArcherClass ();
  42.             } else if (isWarlockClass) {
  43.                 newPlayer.PlayerClass = new BaseWarlockClass ();
  44.             } else if (isPaladinClass) {
  45.                 newPlayer.PlayerClass = new BasePaladinClass ();
  46.             }
  47.             CreateNewPlayer ();
  48.             StoreNewPlayerInfo ();
  49.             SaveInformation.SaveAllInformation ();
  50.         }
  51.         if (GUILayout.Button ("Load")) {
  52.             SceneManager.LoadScene ("tset");
  53.         }
  54.     }
  55.  
  56.  
  57.     private void StoreNewPlayerInfo(){
  58.         GameInformation.PlayerName = newPlayer.PlayerName;
  59.         GameInformation.PlayerLevel = newPlayer.PlayerLevel;
  60.         GameInformation.Stamina =  newPlayer.Stamina;
  61.         GameInformation.Endurance = newPlayer.Endurance;
  62.         GameInformation.Intellect = newPlayer.Intellect;
  63.         GameInformation.Strength = newPlayer.Strength;
  64.         GameInformation.Agility = newPlayer.Agility;
  65.         GameInformation.Resistance = newPlayer.Resistance;
  66.         GameInformation.Gold = newPlayer.Gold;
  67.     }
  68.  
  69.     private void CreateNewPlayer(){
  70.         newPlayer.PlayerLevel = 1;
  71.         newPlayer.Stamina = newPlayer.PlayerClass.Stamina;
  72.         newPlayer.Endurance = newPlayer.PlayerClass.Endurance;
  73.         newPlayer.Intellect = newPlayer.PlayerClass.Intellect;
  74.         newPlayer.Strength = newPlayer.PlayerClass.Strength;
  75.         newPlayer.Agility = newPlayer.PlayerClass.Agility;
  76.         newPlayer.Resistance = newPlayer.PlayerClass.Resistance;
  77.         newPlayer.Gold = 10;
  78.         newPlayer.PlayerName = playerName;
  79.         Debug.Log("Imię postaci: " + newPlayer.PlayerName);
  80.         Debug.Log("Klasa postaci: " + newPlayer.PlayerClass.CharacterClassName);
  81.         Debug.Log("Poziom postaci: " + newPlayer.PlayerLevel);
  82.         Debug.Log("Poziom staminy: " + newPlayer.Stamina);
  83.         Debug.Log("Poziom wytrzymałości: " + newPlayer.Endurance);
  84.         Debug.Log("Poziom intelektu: " + newPlayer.Intellect);
  85.         Debug.Log("Poziom siły: " + newPlayer.Strength);
  86.         Debug.Log("Poziom zwinności: " + newPlayer.Agility);
  87.         Debug.Log("Poziom odporności: " + newPlayer.Resistance);
  88.         Debug.Log("Ilość złota: " + newPlayer.Gold);
  89.     }
  90.  
  91. }
Add Comment
Please, Sign In to add comment