-
-
Save alucard55/53122364a584e02f543fdde2b47838df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System; //Last 3 for Serialization | |
using System.Runtime.Serialization.Formatters.Binary; | |
using System.IO; | |
public class GameControl : MonoBehaviour { | |
public static GameControl control; | |
/* | |
//type | |
//Text | |
private string PlayerName; | |
private string PlayerType; | |
//Ints/Floats | |
private int PlayerLevel; | |
private float Health; | |
private float Mana; | |
private float TP; //Tech Points | |
private float Attack; | |
private float Defense; | |
private float MagicAttack; | |
private float MagicDefense; | |
private float Critical; | |
private float Dexterity; //Speed | |
private float HitRate; | |
//class | |
private string PlayerClass; | |
private string PlayerClassDescription; | |
*/ | |
void Awake () | |
{ | |
if (control == null) { | |
DontDestroyOnLoad (gameObject); //keep only one object, there can be only one | |
control = this; | |
} | |
else if (control != this) | |
{ | |
Destroy (gameObject); | |
} | |
} | |
public void Save () | |
{ | |
//Create Formatter and Stream, then serialize data TO the Stream under the Formatter ex. bf.Serialize(Stream, info) | |
BinaryFormatter bf = new BinaryFormatter (); | |
FileStream file = File.Create (Application.persistentDataPath + "/playerInfo.dat"); //where it's going and what it's called, create place for it | |
GuardA data = new GuardA (); | |
bf.Serialize (file, data); | |
file.Close (); | |
} | |
public void Load () | |
{ | |
if (File.Exists (Application.persistentDataPath + "/playerInfo.dat")) | |
{ | |
BinaryFormatter bf = new BinaryFormatter (); | |
FileStream file = File.Open (Application.persistentDataPath + "/playerInfo.dat", FileMode.Open); | |
GuardA data = (GuardA)bf.Deserialize (file); //if exists, pull info and assign to PlayerData | |
file.Close(); | |
//Health = //...unsure of what to put... | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System; //Last 3 for Serialization | |
using System.Runtime.Serialization.Formatters.Binary; | |
using System.IO; | |
[Serializable] | |
public class GuardA : MonoBehaviour { | |
private StandardPlayerParadigm profile; | |
private Mercenary job; | |
private GuardPrototype type; | |
// Use this for initialization | |
void Start () { | |
profile = new StandardPlayerParadigm (); | |
job = new Mercenary (); | |
type = new GuardPrototype (); | |
profile.playerName = "Guard A"; | |
profile.TypeInfo = type.TypeInfo; | |
profile.CharacterClassName = job.CharacterClassName; | |
profile.CharacterClassDescription = job.CharacterClassDescription; | |
profile.playerLevel = 1; | |
profile.health = type.health; | |
profile.mana = type.mana; | |
profile.tp = type.tp; | |
profile.attack = type.attack; | |
profile.defense = type.defense; | |
profile.magicAttack = type.magicAttack; | |
profile.magicDefense = type.magicDefense; | |
profile.critical = type.critical; | |
profile.dexterity = type.dexterity; | |
profile.hitRate = type.hitRate; | |
} | |
// Update is called once per frame | |
void Update () { | |
} | |
void OnGUI() | |
{ | |
GUILayout.Label (profile.playerName); | |
GUILayout.Label (profile.TypeInfo); | |
GUILayout.Label (profile.playerLevel.ToString()); | |
GUILayout.Label (profile.CharacterClassName); | |
GUILayout.Label (profile.CharacterClassDescription); | |
GUILayout.Label (profile.health.ToString()); | |
GUILayout.Label (profile.mana.ToString()); | |
GUILayout.Label (profile.tp.ToString()); | |
GUILayout.Label (profile.attack.ToString()); | |
GUILayout.Label (profile.defense.ToString()); | |
GUILayout.Label (profile.magicAttack.ToString()); | |
GUILayout.Label (profile.magicDefense.ToString()); | |
GUILayout.Label (profile.critical.ToString()); | |
GUILayout.Label (profile.dexterity.ToString()); | |
GUILayout.Label (profile.hitRate.ToString()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System; //Last 3 for Serialization | |
using System.Runtime.Serialization.Formatters.Binary; | |
using System.IO; | |
[Serializable] | |
public class GuardPrototype : StandardParadigm{ | |
public GuardPrototype() | |
{ | |
TypeInfo = "Typical Guard"; | |
health = 20f; | |
mana = 0f; //for now | |
tp = 0f; //for now | |
attack = 12f; | |
defense = 6f; | |
magicAttack = 3f; | |
magicDefense = 5f; | |
critical = .03f; | |
dexterity = 0f; //for now | |
hitRate = .7f; //for now | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System; //Last 3 for Serialization | |
using System.Runtime.Serialization.Formatters.Binary; | |
using System.IO; | |
[Serializable] | |
public class Mercenary : ClassParadigm { | |
public Mercenary() | |
{ | |
CharacterClassName = "Mercenary"; | |
CharacterClassDescription = "Made a living out of it -- must be good at it!"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System; //Last 3 for Serialization | |
using System.Runtime.Serialization.Formatters.Binary; | |
using System.IO; | |
[Serializable] | |
public class StandardParadigm : TypeParadigm { | |
private string stdType; | |
private float Health; | |
private float Mana; | |
private float TP; //Tech Points | |
private float Attack; | |
private float Defense; | |
private float MagicAttack; | |
private float MagicDefense; | |
private float Critical; | |
private float Dexterity; //Speed | |
private float HitRate; | |
public string TypeInfo //What kind of Standard | |
{ | |
get{return stdType;} | |
set{stdType = value;} | |
} | |
public string typeOf //Is Standard | |
{ | |
get{return TypeOfCharacter;} | |
set{TypeOfCharacter = "Standard";} | |
} | |
public float health | |
{ | |
get{return Health;} | |
set{Health = value;} | |
} | |
public float mana | |
{ | |
get{return Mana;} | |
set{Mana = value;} | |
} | |
public float tp | |
{ | |
get{return TP;} | |
set{TP = value;} | |
} | |
public float attack | |
{ | |
get{return Attack;} | |
set{Attack = value;} | |
} | |
public float defense | |
{ | |
get{return Defense;} | |
set{Defense = value;} | |
} | |
public float magicAttack | |
{ | |
get{return MagicAttack;} | |
set{MagicAttack = value;} | |
} | |
public float magicDefense | |
{ | |
get{return MagicDefense;} | |
set{MagicDefense = value;} | |
} | |
public float critical | |
{ | |
get{return Critical;} | |
set{Critical = value;} | |
} | |
public float dexterity | |
{ | |
get{return Dexterity;} | |
set{Dexterity = value;} | |
} | |
public float hitRate | |
{ | |
get{return HitRate;} | |
set{HitRate = value;} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System; //Last 3 for Serialization | |
using System.Runtime.Serialization.Formatters.Binary; | |
using System.IO; | |
[Serializable] | |
public class StandardPlayerParadigm : StandardParadigm { | |
//calls type and class info in one place for singleton use | |
//type | |
//Text | |
private string PlayerName; | |
private string PlayerType; | |
//Ints/Floats | |
private int PlayerLevel; | |
private float Health; | |
private float Mana; | |
private float TP; //Tech Points | |
private float Attack; | |
private float Defense; | |
private float MagicAttack; | |
private float MagicDefense; | |
private float Critical; | |
private float Dexterity; //Speed | |
private float HitRate; | |
//class | |
private string PlayerClass; | |
private string PlayerClassDescription; | |
//Get/Set | |
public string playerName | |
{ | |
get{return PlayerName;} | |
set{PlayerName = value;} | |
} | |
public int playerLevel | |
{ | |
get{return PlayerLevel;} | |
set{PlayerLevel = value;} | |
} | |
public string CharacterClassName | |
{ | |
get{return PlayerClass;} | |
set{PlayerClass = value;} | |
} | |
public string CharacterClassDescription | |
{ | |
get{return PlayerClassDescription;} | |
set{PlayerClassDescription = value;} | |
} | |
public string TypeInfo | |
{ | |
get{return PlayerType;} | |
set{PlayerType = value;} | |
} | |
public float health | |
{ | |
get{return Health;} | |
set{Health = value;} | |
} | |
public float mana | |
{ | |
get{return Mana;} | |
set{Mana = value;} | |
} | |
public float tp | |
{ | |
get{return TP;} | |
set{TP = value;} | |
} | |
public float attack | |
{ | |
get{return Attack;} | |
set{Attack = value;} | |
} | |
public float defense | |
{ | |
get{return Defense;} | |
set{Defense = value;} | |
} | |
public float magicAttack | |
{ | |
get{return MagicAttack;} | |
set{MagicAttack = value;} | |
} | |
public float magicDefense | |
{ | |
get{return MagicDefense;} | |
set{MagicDefense = value;} | |
} | |
public float critical | |
{ | |
get{return Critical;} | |
set{Critical = value;} | |
} | |
public float dexterity | |
{ | |
get{return Dexterity;} | |
set{Dexterity = value;} | |
} | |
public float hitRate | |
{ | |
get{return HitRate;} | |
set{HitRate = value;} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class SwitchScene : MonoBehaviour { | |
public int sceneToLoad; | |
void OnGUI() | |
{ | |
GUI.Label (new Rect (Screen.width / 2 - 50, Screen.height - 80, 100, 30), "Current Scene: " + (Application.loadedLevel + 1)); | |
if (GUI.Button (new Rect (Screen.width / 2 - 50, Screen.height - 50, 100, 40), "Load Scene: " + (sceneToLoad + 1))) | |
{ | |
Application.LoadLevel (sceneToLoad); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment