Search Unity

[C#] - Improving current MMORPG Spell System/Spellbars

Discussion in 'Scripting' started by silvansly, Apr 12, 2014.

  1. silvansly

    silvansly

    Joined:
    Oct 24, 2013
    Posts:
    6
    Hey Guys,

    I appreciate your time to help me out. Let me explain a little more before pasting a whole bunch of scripts. I have the MMORPG kit, and it has photon networking attached, everything works however there are many things I'd like to change, with your help I could do so.




    1. The action bars are established in HeroStats, and AI, however I can't see to find where I can add more action bars (for example on the side of the screen) where would I add the extra Action Bars? I understand that line 126- 161 is the action command for the action bars, in the HeroStats script, as well as Abilities are established as of line 237-294(or 314).

    2. I don't know where i should add an <<if>> statement to depend the abilities on the game_class, so in order for the spells to show depending on persons class.





    Scripts Below are the Main scripts for ActionBar and Abilities script.
    [HeroStats] - Hero's stats, health, energy, and menue, as well contains the 'abilities' or acitonbar (i believe)
    [AI] - Has the AI for the game player
    [SpellBook] - The spellbook of the player


    ---Other Scripts for information Reference. ---
    [INFO] - info about the game, also used among them
    [SpellTypes] - Distributing the spell types
    [SpellEditor] - [ Server Client] - The spell editor used to create the spells
    [SynchSpell] - [Server client] - Synchronise spells created from server client to game client


    Hero Stats-
    Code (csharp):
    1. /*
    2. Ultimate MMORPG Kit - GameScripts/HeroStats - Client's script -
    3. This script is for displaying Player's stats (picture, health, energy, level) on the screen.
    4. Also it contains the death's function and attacks' animations. It shares the stats of this Player between other Players and enemies.
    5. For correct work you need to set Player's picture, two GUISkins and two animations of attacking.
    6. */
    7.  
    8. using UnityEngine;
    9. using System.Collections;
    10.  
    11. public class HeroStats : Photon.MonoBehaviour {
    12.  
    13.     public GUISkin g;               //Default GUISkin
    14.     public GUISkin finalSkin;       //Good-looking GUISKin
    15.    
    16.     float max_health;               //Hero's health
    17.     float max_energy;               //Hero's energy (like mana)
    18.     int level;                      //Hero's level.
    19.     public Texture2D photo;         //Hero's photo.
    20.     float cur_health;               //Hero's current health
    21.     float cur_energy;               //Hero's current energy
    22.     bool game_start;                //We don't need to show it when we are choosing a server
    23.     bool show_menu;                 //Fast menu
    24.     public AnimationClip attack1;
    25.     public AnimationClip attack2;
    26.     GameObject hero;
    27.     GameObject childSpell;
    28.     bool reg;
    29.     public static int[] spells;
    30.     SphereCollider sc;
    31.     public static bool[] notReady;
    32.     int[] doubleW;
    33.     public static bool booH;
    34.     public static string animName;
    35.        
    36.     public void UpdateHealthStat(){
    37.         max_health = level*100;             //Our formula for max health. You can edit it and create your own.
    38.         if(INFO.ReturnWeapon()!="None"){
    39.             max_health+=float.Parse(Weapons.ReturnWeapon(INFO.ReturnWeapon()).Split(':')[5]);
    40.         }
    41.         if(INFO.ReturnShield()!="None"){
    42.             max_health+=float.Parse(Weapons.ReturnWeapon(INFO.ReturnShield()).Split(':')[5]);
    43.         }
    44.     }
    45.    
    46.     void GameStarted(){
    47.         game_start=true;
    48.         doubleW = new int[9];
    49.         notReady = new bool[9];
    50.         max_health = level*100;
    51.         if(INFO.ReturnWeapon()!="None"){
    52.             max_health+=float.Parse(Weapons.ReturnWeapon(INFO.ReturnWeapon()).Split(':')[5]);
    53.         }
    54.         if(INFO.ReturnShield()!="None"){
    55.             max_health+=float.Parse(Weapons.ReturnWeapon(INFO.ReturnShield()).Split(':')[5]);
    56.         }
    57.         max_energy = level*50;
    58.         cur_health = max_health;
    59.         cur_energy = max_energy;
    60.         Hashtable prop = new Hashtable()
    61.         { { "Game_race", INFO.ReturnInfo().Split(':')[1] }, { "Game_class", INFO.ReturnInfo().Split(':')[2] }, { "Level", INFO.ReturnInfo().Split(':')[3] }, { "Health", max_health  }, { "Energy", max_energy } };
    62.         PhotonNetwork.player.SetCustomProperties(prop);
    63.         spells = new int[9];
    64.         for(int s=0; s<spells.Length;s++){
    65.             if(PlayerPrefs.GetInt(INFO.ReturnEmail()+"_"+INFO.ReturnName()+"_Spell"+s.ToString())==0){             
    66.                 spells[s]=-1;  
    67.             }else{
    68.                 spells[s]=PlayerPrefs.GetInt(INFO.ReturnEmail()+"_"+INFO.ReturnName()+"_Spell"+s.ToString())-1;
    69.             }
    70.         }
    71.         SpellBook.show=true;
    72.         SpellBook.show=false;
    73.        
    74.        
    75.     }
    76.    
    77.     void Awake(){
    78.         if(GameObject.Find("INFO")==null){              //If there isn't any "INFO" script, loading of "MainMenu" scene begins
    79.             Application.LoadLevel("MainMenu");
    80.         }
    81.         level = int.Parse(INFO.ReturnInfo().Split(':')[3]);
    82.        
    83.         /*There we calculate our max_health and max energy. You can invent your own formula. Or simply use your own values for each level, like this:
    84.         if(level==1){
    85.             max_health=130;
    86.             max_energy=40;
    87.         }else
    88.         if(level==2){
    89.             max_health=160;
    90.             max_energy=50;
    91.         }else...(etc.)
    92.         */
    93.        
    94.         max_health = level*100;
    95.         max_energy = level*50;
    96.         cur_health = max_health;
    97.         cur_energy = max_energy;
    98.         Hashtable prop = new Hashtable()
    99.         { { "Game_race", INFO.ReturnInfo().Split(':')[1] }, { "Game_class", INFO.ReturnInfo().Split(':')[2] }, { "Level", INFO.ReturnInfo().Split(':')[3] }, { "Health", max_health  }, { "Energy", max_energy } };
    100.         PhotonNetwork.player.SetCustomProperties(prop);
    101.     }
    102.    
    103.     void Update(){
    104.        
    105.         if(cur_health>max_health){              //If current health is greater than max health, it will equal max health
    106.             cur_health=max_health; 
    107.         }
    108.         if(cur_health<=0){                      //If current health is less than 0, it will equal 0 and the Player will die
    109.             cur_health=0;
    110.             Die();
    111.         }
    112.         if(cur_energy>max_energy){              //If current energy is greater than max energy, it will equal max energy
    113.             cur_energy=max_energy; 
    114.         }
    115.         if(cur_energy<0){                       //If current energy is less than 0, it will equal 0
    116.             cur_energy=0;  
    117.         }
    118.         if(Input.GetKeyDown(KeyCode.Escape))    //If Player presses the <Escape> button, the script will open/close the window
    119.         {
    120.             if(show_menu==false){
    121.                 show_menu=true;
    122.             }else{
    123.                 show_menu=false;   
    124.             }
    125.         }
    126.         if(Input.GetKeyDown(KeyCode.Alpha1)  spells[0]>=0  !notReady[0]){
    127.             MakeSpell(spells[0],0);
    128.             notReady[0]=true;
    129.         }
    130.         if(Input.GetKeyDown(KeyCode.Alpha2)  spells[1]>=0  !notReady[1]){
    131.             MakeSpell(spells[1],1);
    132.             notReady[1]=true;
    133.         }
    134.         if(Input.GetKeyDown(KeyCode.Alpha3)  spells[2]>=0  !notReady[2]){
    135.             MakeSpell(spells[2],2);
    136.             notReady[2]=true;
    137.         }
    138.         if(Input.GetKeyDown(KeyCode.Alpha4)  spells[3]>=0  !notReady[3]){
    139.             MakeSpell(spells[3],3);
    140.             notReady[3]=true;
    141.         }
    142.         if(Input.GetKeyDown(KeyCode.Alpha5)  spells[4]>=0  !notReady[4]){
    143.             MakeSpell(spells[4],4);
    144.             notReady[4]=true;
    145.         }
    146.         if(Input.GetKeyDown(KeyCode.Alpha6)  spells[5]>=0  !notReady[5]){
    147.             MakeSpell(spells[5],5);
    148.             notReady[5]=true;
    149.         }
    150.         if(Input.GetKeyDown(KeyCode.Alpha7)  spells[6]>=0  !notReady[6]){
    151.             MakeSpell(spells[6],6);
    152.             notReady[6]=true;
    153.         }
    154.         if(Input.GetKeyDown(KeyCode.Alpha8)  spells[7]>=0  !notReady[7]){
    155.             MakeSpell(spells[7],7);
    156.             notReady[7]=true;
    157.         }
    158.         if(Input.GetKeyDown(KeyCode.Alpha9)  spells[8]>=0  !notReady[8]){
    159.             MakeSpell(spells[8],8);
    160.             notReady[8]=true;
    161.         }
    162.        
    163.     }
    164.    
    165.     void LateUpdate(){
    166.        
    167.         cur_health = float.Parse(PhotonNetwork.player.customProperties["Health"].ToString());           //The script takes values from PhotonNetwork player's properties
    168.         cur_energy =  float.Parse(PhotonNetwork.player.customProperties["Energy"].ToString());
    169.         if(cur_health>max_health){
    170.             Hashtable prop = new Hashtable()
    171.                         { { "Game_race", PhotonNetwork.player.customProperties["Game_race"] },
    172.                         { "Game_class", PhotonNetwork.player.customProperties["Game_class"] },
    173.                         { "Level", PhotonNetwork.player.customProperties["Level"] },
    174.                         { "Health", max_health},
    175.                         { "Energy",  PhotonNetwork.player.customProperties["Energy"] } };
    176.                         PhotonNetwork.player.SetCustomProperties(prop);
    177.         }
    178.         if(cur_energy>max_energy){
    179.             Hashtable prop = new Hashtable()
    180.                         { { "Game_race", PhotonNetwork.player.customProperties["Game_race"] },
    181.                         { "Game_class", PhotonNetwork.player.customProperties["Game_class"] },
    182.                         { "Level", PhotonNetwork.player.customProperties["Level"] },
    183.                         { "Health", PhotonNetwork.player.customProperties["Health"]},
    184.                         { "Energy", max_energy} };
    185.                         PhotonNetwork.player.SetCustomProperties(prop);
    186.         }
    187.     }
    188.    
    189.     void OnGUI(){
    190.         GUI.skin=g;
    191.         float width = 297/1.5f-6;
    192.         if(game_start==true){
    193.             //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////FAST MENU
    194.             if(show_menu==true){
    195.                 GUI.skin = finalSkin;
    196.                 GUI.Box(new Rect(Screen.width/2.3f-30,Screen.height/4-50,260,320), "", "Window");
    197.                 GUI.Label(new Rect(Screen.width/2.3f+5,Screen.height/4-20,190,30), "Menu");
    198.                 if(GUI.Button(new Rect(Screen.width/2.3f+10,Screen.height/4+53,178,25),"Back to game")){
    199.                     show_menu=false;
    200.                 }
    201.                 if(GUI.Button(new Rect(Screen.width/2.3f+10,Screen.height/4+83,178,25),"Settings")){
    202.                     //You can add any settings there.
    203.                 }
    204.                 if(GUI.Button(new Rect(Screen.width/2.3f+10,Screen.height/4+113,178,25),"Exit from World")){
    205.                     PhotonNetwork.LeaveRoom();
    206.                     Application.LoadLevel("ChooseCharacter");
    207.                 }
    208.                 if(GUI.Button(new Rect(Screen.width/2.3f+10,Screen.height/4+143,178,25),"Main Menu")){
    209.                     PhotonNetwork.LeaveRoom();
    210.                     Application.LoadLevel("MainMenu");
    211.                 }
    212.                 if(GUI.Button(new Rect(Screen.width/2.3f+10,Screen.height/4+173,178,25),"Quit")){
    213.                     Application.Quit();
    214.                 }
    215.                 GUI.skin = g;
    216.             }
    217.             //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////STATS
    218.             GUI.skin=finalSkin;
    219.             GUI.Box(new Rect(-13,-18,350,113),"", "Window2");
    220.             GUI.skin=g;
    221.             GUI.DrawTexture(new Rect(20,10,297/4,47), photo);
    222.             GUI.Label(new Rect(20,57,297,30), INFO.ReturnInfo().Split(':')[0],"Name");
    223.             GUI.Label(new Rect(20,57,287,30),"Level "+INFO.ReturnInfo().Split(':')[3],"Level");
    224.             //Health
    225.             GUI.Box(new Rect(30+297/4, 10,297/1.5f,57/3),"");
    226.             if(cur_health<=max_health){
    227.                 GUI.Box(new Rect(30+297/4+3, 10+3, width/100*(cur_health/(max_health/100)),57/3-6),"");
    228.             }else{
    229.                 GUI.Box(new Rect(30+297/4+3, 10+3, width,57/3-6),"");
    230.             }
    231.             GUI.Label(new Rect(30+297/4+3, 10+3,297/1.5f-6,57/3-6), cur_health.ToString()+"/"+max_health.ToString());
    232.             //Energy
    233.             GUI.Box(new Rect(30+297/4, 15+57/3,297/1.5f,57/3),"");
    234.             GUI.Box(new Rect(30+297/4+3, 15+3+57/3, width/100*(cur_energy/(max_energy/100)),57/3-6),"");
    235.             GUI.Label(new Rect(30+297/4+3, 15+3+57/3,297/1.5f-6,57/3-6), cur_energy.ToString()+"/"+max_energy.ToString());
    236.             ///////////////////////////////////////////////////////////////////////////////////////////////ABILITIES
    237.             float boxWidth=Screen.width/3;
    238.             for(int b=0; b<9; b++){
    239.                 if(new Rect(boxWidth,Screen.height-50,35,35).Contains(new Vector2(SpellBook.dragOb.x,SpellBook.dragOb.y))  SpellBook.show  SpellBook.dragging){
    240.                     spells[b]=SpellBook.dragS;
    241.                     SpellBook.dragging=false;
    242.                     PlayerPrefs.SetInt(INFO.ReturnEmail()+"_"+INFO.ReturnName()+"_Spell"+b.ToString(), spells[b]+1);   
    243.                    
    244.                 }
    245.                 if(spells[b]<0){
    246.                     GUI.Box(new Rect(boxWidth,Screen.height-50,35,35),"");
    247.                 }else{ 
    248.                     if(SpellBook.fitLvl[spells[b]]!=null){
    249.                         if(GUI.Button(new Rect(boxWidth,Screen.height-50,35,35),(Texture2D)Resources.Load("Spells/"+SpellBook.fitLvl[spells[b]].Split(';')[6],typeof(Texture2D)),"Box")  !notReady[b]){
    250.                             MakeSpell(spells[b],b);
    251.                             notReady[b]=true;
    252.                         }
    253.                     }else{
    254.                         GUI.Box(new Rect(boxWidth,Screen.height-50,35,35),"");
    255.                     }
    256.                 }
    257.                 GUI.Label(new Rect(boxWidth-1,Screen.height-50,35,35),(b+1).ToString(),"AbilityUp");
    258.                 if(doubleW[b]>0){
    259.                     GUI.Label(new Rect(boxWidth,Screen.height-50,35,35), doubleW[b].ToString(),"Ability");
    260.                 }
    261.                 boxWidth+=30;
    262.             }
    263.         }
    264.     }
    265.    
    266.     void MakeSpell(int s,int b){
    267.        
    268.         childSpell = GameObject.Find(INFO.ReturnName()+":player/childSpell:collider");
    269.         if(int.Parse(SpellBook.fitLvl[s].Split(';')[2])==0 || int.Parse(SpellBook.fitLvl[s].Split(';')[2])==1){
    270.             childSpell.name = "childSpell:"+s.ToString();
    271.         }else
    272.         if(int.Parse(SpellBook.fitLvl[s].Split(';')[2])==2){
    273.             cur_health+=int.Parse(SpellBook.fitLvl[s].Split(';')[1]);
    274.             Hashtable prop = new Hashtable()
    275.                         { { "Game_race", PhotonNetwork.player.customProperties["Game_race"] },
    276.                         { "Game_class", PhotonNetwork.player.customProperties["Game_class"] },
    277.                         { "Level", PhotonNetwork.player.customProperties["Level"] },
    278.                         { "Health", cur_health},
    279.                         { "Energy",  PhotonNetwork.player.customProperties["Energy"] } };
    280.                         PhotonNetwork.player.SetCustomProperties(prop);
    281.         }else
    282.         if(int.Parse(SpellBook.fitLvl[s].Split(';')[2])==3){
    283.             booH=true;
    284.             StartCoroutine(DefenceSkill(SpellBook.fitLvl[s]));
    285.         }
    286.         sc = childSpell.GetComponent<SphereCollider>();
    287.         sc.enabled=false;
    288.         sc = childSpell.GetComponent<SphereCollider>();
    289.         sc.enabled=true;
    290.         sc.radius=float.Parse(SpellBook.fitLvl[s].Split(';')[3]);
    291.         StartCoroutine(BeReady(float.Parse(SpellBook.fitLvl[s].Split(';')[1]),b));
    292.         StartCoroutine(TimeReady(float.Parse(SpellBook.fitLvl[s].Split(';')[1]),b));
    293.        
    294.     }
    295.    
    296.     IEnumerator DefenceSkill(string d){
    297.         yield return new WaitForSeconds(float.Parse(d.Split(';')[1]));
    298.         booH=false;
    299.     }
    300.    
    301.     IEnumerator TimeReady(float wait,int b){
    302.         doubleW[b]=(int)(wait/4);
    303.         while(doubleW[b]>0){
    304.             yield return new WaitForSeconds(1);
    305.             doubleW[b]--;
    306.         }
    307.     }
    308.    
    309.     IEnumerator BeReady(float wait,int b){
    310.         yield return new WaitForSeconds(0.25f);
    311.         childSpell.name = "childSpell:collider";
    312.         yield return new WaitForSeconds(wait/4-0.5f);
    313.         notReady[b]=false;
    314.     }
    315.    
    316.     void Die(){
    317.         hero = GameObject.Find(PhotonNetwork.player.name+":player");
    318.         GameObject[] spawn = GameObject.FindGameObjectsWithTag("Graveyard");    //Find the nearest Graveyard. Graveyard's GameObject needs to have "Graveyard" tag
    319.         if(hero!=null){
    320.             float dif = Mathf.Abs(hero.transform.position.x-spawn[0].transform.position.x)+Mathf.Abs(hero.transform.position.z-spawn[0].transform.position.z);
    321.             GameObject choice = spawn[0];
    322.             foreach(GameObject go in spawn){
    323.                 if(Mathf.Abs(hero.transform.position.x-go.transform.position.x)+Mathf.Abs(hero.transform.position.z-go.transform.position.z)<dif){
    324.                     dif = Mathf.Abs(hero.transform.position.x-go.transform.position.x)+Mathf.Abs(hero.transform.position.z-go.transform.position.z);
    325.                     choice = go;
    326.                 }
    327.             }
    328.             hero.transform.position = GameObject.Find(choice.name+"/SpawnPoint").transform.position;
    329.             Hashtable prop = new Hashtable()
    330.                         { { "Game_race", PhotonPlayer.Find(hero.gameObject.GetPhotonView().ownerId).customProperties["Game_race"] },
    331.                         { "Game_class", PhotonPlayer.Find(hero.gameObject.GetPhotonView().ownerId).customProperties["Game_class"] },
    332.                         { "Level", PhotonPlayer.Find(hero.gameObject.GetPhotonView().ownerId).customProperties["Level"] },
    333.                         { "Health", max_health},
    334.                         { "Energy", max_energy } };    
    335.             PhotonPlayer.Find(hero.gameObject.GetPhotonView().ownerId).SetCustomProperties(prop);       //Update PhotonNetwork player properties
    336.         }
    337.     }
    338. }
    339.  



    AI
    Code (csharp):
    1. /*
    2. Ultimate MMORPG Kit - GameScripts/AI - Client's script - skeletarik@gmail.com - 2013
    3. This script is for enemies. It contains simple AI. You can choose type of the enemy: agressive or not.
    4. If it is agressive, enemy will attack the Player when he enters in his trigger. You can edit the radius in the inspector.
    5. Enemy has two different attacks: usual hit and critical hit. You can edit the possibility of the critical hit in the inspector (<attack2chance> in the Server!).
    6. If you don't want to use the critical hit, set <attack2chance> to 0.
    7. For correct work you need to set 4 animations clips.
    8. Also you can set enemy's rotation, moving and attacking speed in the inspector (the server's values MUST be equal to the client's values!).
    9.  
    10. NB! It is the client's version of the script. The Server's version of the script also exists. You can find it in the Server folders.
    11. */
    12.  
    13. using UnityEngine;
    14. using System.Collections;
    15.  
    16. public class AI : Photon.MonoBehaviour {
    17.  
    18.     public bool aggressive;         //Will enemy attack at once when player enters in his trigger?
    19.     public AnimationClip hit;       //Animation clip for usual hit
    20.     public AnimationClip hit2;      //Animation clip for critical hit
    21.     public AnimationClip run;       //Animation clip for run
    22.     public AnimationClip idle;      //Animation clip for idle
    23.    
    24.     Transform enemy;                //Automatically-detected target.
    25.    
    26.     public int rotationSpeed=1;     //Enemy's rotation speed
    27.     public int movingSpeed=1;       //Enemy's moving speed
    28.     public float speedAttack1=1.0f; //Enemy's attacking speed
    29.    
    30.     static bool at;                 //Is enemy attacking?
    31.     bool numAttack;                 //Usual or critical hit
    32.    
    33.     bool oneT;
    34.        
    35.     void OnTriggerEnter(Collider other){                        //If player enters in the enemy's trigger, the enemy will attack
    36.         if(other.gameObject.name.Split(':')[1]=="player"){
    37.             if(aggressive==true){
    38.                 enemy = other.gameObject.transform;
    39.                 at=true;
    40.             }
    41.         }
    42.     }
    43.    
    44.     void OnTriggerExit(Collider other){                         //If player exits from the enemy's trigger, the enemy will stop attacking
    45.         if(enemy!=null){
    46.             if(other.gameObject.name == enemy.gameObject.name){
    47.                 at=false;
    48.                 enemy = null;
    49.             }
    50.         }
    51.     }
    52.    
    53.     void Update(){
    54.         if(at==true  photonView!=null  !HeroStats.booH){
    55.             photonView.RPC("Attack", PhotonTargets.All);
    56.         }
    57.         if(HeroStats.booH){
    58.             oneT=false;
    59.             photonView.RPC("StopAttack", PhotonTargets.MasterClient);
    60.         }
    61.         if(HeroStats.booH==false  !oneT){
    62.             photonView.RPC("AttackAgain", PhotonTargets.MasterClient);
    63.             oneT=true;
    64.         }
    65.     }
    66.    
    67.     [RPC]
    68.     void StopAttack(){
    69.         at=false;  
    70.     }
    71.    
    72.     [RPC]
    73.     void AttackAgain(){
    74.         at=true;   
    75.     }
    76.        
    77.     [RPC]
    78.     void RandomAttack(bool b){
    79.         numAttack=b;                //Receive from Server what type of hit enemy will use
    80.     }
    81.    
    82.     [RPC]
    83.         void Attack(){
    84.             if(animation.clip.name!="death"){
    85.                 at=false;
    86.                 if(enemy!=null){
    87.                     /*We use the Viking's model. So, the "real" model is called Viking, and it is a children of the Charprefab.
    88.                      * If you added your own model, you need to get transform of it.*/
    89.                     GameObject trueEnemy = GameObject.Find(enemy.name+"/Viking");
    90.                     //Attacking only if the enemy is looking at the player. In other way the enemy will run or turn to the player
    91.                     if(Mathf.Abs(transform.position.x-trueEnemy.transform.position.x)<=1.5f  Mathf.Abs(transform.position.z-trueEnemy.transform.position.z)<=1.5f){
    92.                         if(speedAttack1 > 0){
    93.                             speedAttack1 -= Time.deltaTime;         //Timer
    94.                         }
    95.                         if(speedAttack1 <= 0){                      //Only if it is time for attack, the enemy will attack
    96.                             if(numAttack==true){       
    97.                                 gameObject.animation.clip = hit2;   //There the enemy uses usual hit or critical hit.
    98.                             }else{
    99.                                 gameObject.animation.clip = hit;
    100.                             }
    101.                             gameObject.animation.Play();
    102.                             StartCoroutine("Ability");
    103.                             speedAttack1=1.0f;                      //Reset timer
    104.                         }
    105.                         StartCoroutine("Ability");                  //Reset bool
    106.                     }else{                                          //If the enemy isn't looking at the player, the enemy will run or turn to the player
    107.                         gameObject.animation.clip = run;
    108.                         gameObject.animation.Play();
    109.                         transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(trueEnemy.transform.position - transform.position), rotationSpeed * Time.deltaTime);
    110.                         transform.position += transform.forward * movingSpeed * Time.deltaTime;
    111.                         at=true;
    112.                     }
    113.                 }
    114.             }
    115.         }
    116.    
    117.     IEnumerator Ability(){
    118.         at=false;
    119.         yield return new WaitForSeconds(0);
    120.         at=true;
    121.     }
    122. }


    SpellBook
    Code (csharp):
    1. /*
    2. Ultimate MMORPG Kit - GameScripts/SpellBook - Client's script - skeletarik@gmail.com - 2013
    3. This script is for Player's spells (skills). Player can open this window by clicking on the "Spells" button
    4. or using the "K" key. Also he can Drag&Drop them to the skills panel.
    5. Spells can be set in the SpellEditor. Look ReadMe, WhatsNew files and videos on YouTube for more detailed information.
    6. */
    7. using UnityEngine;
    8. using System.Collections;
    9.  
    10. public class SpellBook : MonoBehaviour {
    11.  
    12.     public static bool show;                        //Is window opened?
    13.     public GUISkin finalSkin;       //Good-looking GUISkin
    14.     public GUISkin defaultSkin;     //Default GUISkin
    15.    
    16.     bool started;                   //Is the game started?
    17.     string pathS;
    18.     string[] spells;
    19.     public static string[] fitLvl;
    20.     string[] highLvl;
    21.     string allInfo;
    22.     int i=0;
    23.     int hL;
    24.     public static int fL;
    25.     int curS=-1;
    26.     public static Rect dragOb;
    27.     Rect curOb;
    28.     int width;
    29.     int height;
    30.     public static bool dragging;
    31.     public static int dragS;
    32.    
    33.     void GameStartedSB(){           //Receive information about Player's profession
    34.         started=true;
    35.         pathS = Application.dataPath+"/UMK_Files/SpellFileC.umk";
    36.         spells = new string[Crypt.lineCount(pathS)];
    37.         WriteAllLines();
    38.         fitLvl=new string[spells.Length];
    39.         highLvl=new string[spells.Length];
    40.     }
    41.    
    42.     void Update(){
    43.                 if (Input.GetKeyDown (KeyCode.K)) {         //If Player presses the <K> button, spells' window will be opened/closed
    44.                         if (show == false) {
    45.                                 show = true;   
    46.                    
    47.                                 } else {
    48.                                         show = false;  
    49.                                 }
    50.                         }
    51.  
    52.         if(Input.GetKeyDown(KeyCode.Escape))            //If Player presses <Escape> button, the script will close spellbook
    53.         {
    54.             show=false;
    55.         }
    56.  
    57.                 }
    58.    
    59.     void OnGUI(){
    60.         if(started){
    61.             hL=0;
    62.                 fL=0;
    63.                 for(int iS=1; iS<spells.Length;iS++){
    64.                     if(int.Parse(spells[iS].Split(';')[4])>INFO.ReturnLevel()){
    65.                         highLvl[hL]=spells[iS];
    66.                         hL++;
    67.                     }else{
    68.                         fitLvl[fL]=spells[iS];
    69.                         fL++;
    70.                     }
    71.                    
    72.                 }
    73.             GUI.skin=finalSkin;
    74.             if(GUI.Button(new Rect(Screen.width-340,Screen.height-40,125,22), "Spells")){       //If Player presses the "Profession" button,
    75.                 if(show==false){                                                                    //the profession's window will be opened/closed
    76.                     show=true; 
    77.                 }else{
    78.                     show=false;
    79.                 }
    80.             }
    81.             if(show){
    82.                 GUI.depth=101;
    83.                 GUI.Window(101, new Rect(100, Screen.height/6,700,350), spellsWindow, ""); 
    84.                 GUI.depth=0;
    85.             }else{
    86.                 dragging=false;
    87.             }
    88.             if(dragging){
    89.                 GUI.skin=defaultSkin;
    90.                 int di = GUI.depth;
    91.                 GUI.depth=1;
    92.                 GUI.Button(dragOb,(Texture2D)Resources.Load("Spells/"+fitLvl[dragS].Split(';')[6],typeof(Texture2D)),"Box");
    93.                 GUI.skin=finalSkin;
    94.                 GUI.depth=di;
    95.             }
    96.             if(Event.current.type == EventType.MouseDown  dragging){
    97.                                 dragging=false;
    98.                             }
    99.         }
    100.     }
    101.    
    102.     void spellsWindow(int id){
    103.                
    104.                 height=100;
    105.                 width=50;
    106.                 for(i=0; i<24;i=i){
    107.                    
    108.                     int i2=0;
    109.                     width=50;
    110.                     for(i2=0; i2<8;i2++){
    111.                         dragOb=new Rect(width-360 + Event.current.mousePosition.x, height-Screen.height/6 + Event.current.mousePosition.y,25,25);
    112.                         curOb=new Rect(width,height,50,50);
    113.                         if(i>23){
    114.                             break;
    115.                         }
    116.                         if(i<fL){
    117.                             if(Event.current.type == EventType.MouseDown  curOb.Contains(Event.current.mousePosition)  !dragging){
    118.                                 dragging=true;
    119.                             }
    120.                             if(GUI.Button(curOb,(Texture2D)Resources.Load("Spells/"+fitLvl[i].Split(';')[6],typeof(Texture2D)),"Box")){
    121.                                 curS=i;
    122.                                 dragS=curS;
    123.                             }
    124.                            
    125.                         }else{
    126.                             GUI.Button(curOb,"","Box");
    127.                         }
    128.                         i++;
    129.                         width+=60;
    130.                     }
    131.                     height+=60;
    132.                 }
    133.        
    134.         GUILayout.BeginArea(new Rect(100,0,700,350));
    135.             GUILayout.BeginVertical();
    136.             GUILayout.Space(30);
    137.             GUILayout.Label("Spell Book",GUILayout.Width(700));
    138.             GUILayout.Space(50);
    139.             GUILayout.BeginArea(new Rect(60,100,670,500));
    140.                
    141.             GUILayout.EndArea();
    142.             GUILayout.BeginArea(new Rect(550,100,100,500));
    143.                 if(curS!=-1){
    144.                     GUILayout.Label(fitLvl[curS].ToString().Split(';')[5],"CursedText");
    145.                 }
    146.                 GUILayout.Space(5);
    147.                 if(curS!=-1){
    148.                     GUILayout.Label("Type:  "+((SpellTypes)int.Parse(fitLvl[curS].ToString().Split(';')[2])).ToString(),"PlainText");
    149.                 }
    150.                 GUILayout.Space(5);
    151.                 if(curS!=-1){
    152.                     GUILayout.Label("Strength:  "+int.Parse(fitLvl[curS].ToString().Split(';')[1]).ToString(),"PlainText");
    153.                 }
    154.                 GUILayout.Space(5);
    155.                 if(curS!=-1){
    156.                     GUILayout.Label("Description:","PlainText");
    157.                     GUILayout.TextArea(fitLvl[curS].ToString().Split(';')[8],"PlainText");
    158.                 }
    159.             GUILayout.EndArea();
    160.         GUILayout.EndArea();
    161.        
    162.        
    163.     }
    164.    
    165.     void WriteAllLines(){
    166.         string str2;
    167.         System.IO.StreamReader file = new System.IO.StreamReader(pathS);
    168.         str2 = Crypt.Decrypt(file.ReadToEnd(),Crypt.password1,Crypt.password2,"SHA1",2,"16CHARSLONG12345",256);    
    169.         spells = str2.Split('\n');
    170.        
    171.         file.Close();  
    172.     }
    173. }
    174.  






    3. [Advanced - Additional] I would also like to add more attributes to the spell editor to make the spells more realistic. I would like to add a cast time, and particle system so the spell looks real, like a "fireball". Do I add all these extra things in the Spell Editor in the additional scripts posted below, or where do i edit these attributes?

    [The Server Client of Unity has a spell editor which pops up a window, adding attributes to create spells, and synchronise them to the Game Client of Unity, in which the spells are visible in-game. If the answers 1-2 are questioned to distributing the spells distribution for classes, then all I need is to edit the Spell Editor to make the spells more realistic, adding Particle System to it, and casting a spell to target, and destroy upon collision..ect. however I don't know where to add this, maybe you can help?]

    Below are the extra additional scripts for further information:



    SpellType
    Code (csharp):
    1. public enum SpellTypes{
    2.     Attack,
    3.     LongRangeAttack,
    4.     Healing,
    5.     Defence
    6. }
    7.  




    SpellEditor[Server Client]
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEditor;
    4. using System.IO;
    5.  
    6. public class SpellEditor : EditorWindow {
    7.  
    8.     [MenuItem("Ultimate MMORPG Kit/Spell Editor")]
    9.     public static void ShowWindow()
    10.     {
    11.         EditorWindow.GetWindow(typeof(SpellEditor));
    12.     }
    13.    
    14.     Vector2 scrollPosition;
    15.     string line;
    16.     int counter;
    17.     public static string pathS = Application.dataPath+"/UMK_Files/SpellFile.umk";
    18.     bool plusOne;
    19.    
    20.     Editor gameObjectEditor;
    21.     string spell_name="";
    22.     public static string spell_realname="";
    23.     int spell_strength=10;
    24.     SpellTypes spell_type=SpellTypes.Attack;
    25.     float spell_distance=1.5f;
    26.     int player_level=1;
    27.     public static string[] spells;
    28.     public bool countNew;
    29.     bool created;
    30.     int curN=-1;
    31.     bool editing;
    32.     int editNumber;
    33.     public static string editLine;
    34.     bool updated;
    35.     string password1="AndyKillsChicken";
    36.     string password2="SecretPassword";
    37.     public static int iL=0;
    38.     string spell_info="";
    39.    
    40.     AnimationClip spell_anim;
    41.     Texture2D spell_pic;
    42.    
    43.     bool thereIs;
    44.     bool clicked;
    45.    
    46.    
    47.     void Update(){
    48.        
    49.         try{
    50.             if(curN!=lineCount()  System.IO.File.Exists(pathS)  thereIs){
    51.                 curN=lineCount();
    52.                 countNew=false;
    53.             }
    54.         }catch(IOException){
    55.            
    56.         }
    57.     }
    58.    
    59.     void OnGUI(){
    60.        
    61.         System.IO.Directory.CreateDirectory(Application.dataPath+"/UMK_Files");
    62.         if (!System.IO.File.Exists(pathS))
    63.         {
    64.            
    65.            if(GUILayout.Button("Begin the Setting", GUILayout.Width(300),GUILayout.Height(50))){
    66.                 System.IO.Directory.CreateDirectory(Application.dataPath+"/UMK_Files");
    67.                 File.Create(pathS);
    68.        
    69.             }
    70.         }
    71.         else
    72.         {
    73.            thereIs=true;
    74.             if(GUILayout.Button("Add new Spell", GUILayout.Width(200),GUILayout.Height(25))){
    75.                 editing=false;
    76.                 plusOne=true;
    77.                 created=false;
    78.                 updated=false; 
    79.                 spell_name="";
    80.                 spell_realname="";
    81.                 spell_strength=10;
    82.                 spell_type=SpellTypes.Attack;
    83.                 spell_distance=1.5f;
    84.                 player_level=1;
    85.                 spell_pic=null;
    86.                 spell_anim=null;
    87.                 spell_info="";
    88.                
    89.             }
    90.             if(GUILayout.Button("Delete All Spells", GUILayout.Width(200),GUILayout.Height(25))){
    91.                 EditorWindow.GetWindowWithRect(typeof(DeleteSpell), new Rect(300,300,350,100),false,"Warning!");
    92.             }
    93.             GUIStyle cuLabel = EditorStyles.largeLabel;
    94.             cuLabel.fontSize=18;
    95.             cuLabel.fontStyle=FontStyle.Bold;
    96.             GUILayout.Label("List of Spells:", cuLabel);
    97.  
    98.             if(countNew==false){
    99.                 try{
    100.                     spells = new string[lineCount()];
    101.                     WriteSpell();
    102.                 }catch(IOException){
    103.                    
    104.                 }
    105.                 countNew=true;
    106.             }
    107.             scrollPosition = GUILayout.BeginScrollView(scrollPosition, false,true,GUILayout.Width(225), GUILayout.Height(363));
    108.             if(spells!=null){
    109.                 iL=0;
    110.                 clicked=false;
    111.                 foreach(string l in spells){
    112.                    
    113.                     if(l!=""  spells.Length>1){
    114.                         string norm = l.Split('!')[2];
    115.                         if(GUILayout.Button(norm.Split(';')[0], EditorStyles.boldLabel)){
    116.                             updated=false;
    117.                             created=false;
    118.                             EditSpell(l);  
    119.                             clicked=true;
    120.                         }
    121.                         if(clicked==false){
    122.                             iL++;  
    123.                         }
    124.                         GUILayout.Label("Type: "+(SpellTypes)int.Parse((norm.Split(';')[2])));
    125.                         GUILayout.Label("Strength: "+norm.Split(';')[1]);
    126.                         GUILayout.Space(5);
    127.                        
    128.                     }
    129.                 }
    130.             }
    131.             GUILayout.EndScrollView();
    132.            
    133.             if(created){
    134.                 GUILayout.BeginArea(new Rect(250,5,300,1000));
    135.                 GUILayout.Label("Spell was successfully created!", EditorStyles.boldLabel);
    136.                 GUILayout.Space(10);
    137.                 if(GUILayout.Button("Ok")){
    138.                     created=false; 
    139.                 }
    140.                 GUILayout.EndArea();
    141.             }
    142.             if(updated){
    143.                 GUILayout.BeginArea(new Rect(250,5,300,1000));
    144.                 GUILayout.Label("Spell was successfully updated!", EditorStyles.boldLabel);
    145.                 GUILayout.Space(10);
    146.                 if(GUILayout.Button("Ok")){
    147.                     updated=false; 
    148.                 }
    149.                 GUILayout.EndArea();
    150.             }
    151.             if(plusOne==true){
    152.                 GUILayout.BeginArea(new Rect(250,50,300,1000));
    153.                     GUILayout.Label("Spell Image", EditorStyles.boldLabel);
    154.                     spell_pic = EditorGUILayout.ObjectField(spell_pic,typeof(Texture2D),true, GUILayout.Width(250),GUILayout.Height(250)) as Texture2D;
    155.                     GUILayout.Label("Spell Info", EditorStyles.boldLabel);
    156.                     spell_info = GUILayout.TextArea(spell_info, GUILayout.Width(250),GUILayout.Height(43));
    157.                 GUILayout.EndArea();
    158.                 if(spell_name!=null){
    159.                     GUILayout.BeginArea(new Rect(525,50,150,1000));
    160.                         GUILayout.Label("Spell Name", EditorStyles.boldLabel);
    161.                         spell_name = GUILayout.TextField(spell_name);
    162.                         GUILayout.Space(10);
    163.                         GUILayout.Label("Displaying Name", EditorStyles.boldLabel);
    164.                         spell_realname = GUILayout.TextField(spell_realname);
    165.                         GUILayout.Space(10);
    166.                         GUILayout.Label("Spell Type", EditorStyles.boldLabel);
    167.                         spell_type = (SpellTypes)EditorGUILayout.EnumPopup(spell_type);
    168.                         GUILayout.Space(10);
    169.                         GUILayout.Label("Spell Animation", EditorStyles.boldLabel);
    170.                         spell_anim = EditorGUILayout.ObjectField(spell_anim,typeof(AnimationClip),true) as AnimationClip;
    171.                         GUILayout.Space(10);
    172.                         GUILayout.Label("Spell Strength", EditorStyles.boldLabel);
    173.                         spell_strength = EditorGUILayout.IntField(spell_strength);
    174.                         GUILayout.Space(10);
    175.                         GUILayout.Label("Spell Distance", EditorStyles.boldLabel);
    176.                         spell_distance = EditorGUILayout.FloatField(spell_distance);
    177.                         GUILayout.Space(10);
    178.                         GUILayout.Label("Player's level", EditorStyles.boldLabel);
    179.                         player_level = EditorGUILayout.IntField(player_level);
    180.                         GUILayout.Space(10);
    181.                     GUILayout.EndArea();
    182.                    
    183.                     if(editing==false){
    184.                         if(GUI.Button(new Rect(250,415,200,35),"Create!")){
    185.                             string str1;
    186.                             using (System.IO.StreamReader reader = System.IO.File.OpenText(pathS))
    187.                             {
    188.                                 str1 = Crypt.Decrypt(reader.ReadToEnd(),password1,password2,"SHA1",2,"16CHARSLONG12345",256);
    189.                             }
    190.                             string pic_name;
    191.                             if(spell_pic==null){
    192.                                 pic_name="";
    193.                             }else{
    194.                                 pic_name=spell_pic.name;   
    195.                             }
    196.                             string anim_name;
    197.                             if(spell_anim==null){
    198.                                 anim_name="";
    199.                             }else{
    200.                                 anim_name=spell_anim.name; 
    201.                             }
    202.                             str1=str1+"\n!["+(lineCount()-1).ToString()+"]!"+spell_name+";"+spell_strength.ToString()+";"+((int)spell_type).ToString()+";"+spell_distance.ToString()+";"+player_level.ToString()+";"+spell_realname+";"+pic_name+";"+anim_name+";"+spell_info;
    203.                            
    204.                             string crStr = Crypt.Encrypt(str1,password1,password2,"SHA1",2,"16CHARSLONG12345", 256);
    205.                        
    206.                             System.IO.File.WriteAllText(pathS, crStr); 
    207.                             plusOne=false;
    208.                             created=true;
    209.                             countNew=false;
    210.                         }
    211.                         if(GUI.Button(new Rect(475,415,200,35),"Cancel")){
    212.                             spell_name="";
    213.                             spell_realname="";
    214.                             spell_strength=10;
    215.                             spell_type=SpellTypes.Attack;
    216.                             spell_distance=1.5f;
    217.                             player_level=1;
    218.                             plusOne=false;
    219.                             spell_pic=null;
    220.                             spell_anim=null;
    221.                             spell_info="";
    222.                            
    223.                         }
    224.                     }else{
    225.                         if(GUI.Button(new Rect(250,415,200,35),"Save")){
    226.                             string str = string.Empty;
    227.                             using (System.IO.StreamReader reader = System.IO.File.OpenText(pathS))
    228.                             {
    229.                                 str = Crypt.Decrypt(reader.ReadToEnd(),password1,password2,"SHA1",2,"16CHARSLONG12345",256);
    230.                             }
    231.                             string pic_name;
    232.                             if(spell_pic==null){
    233.                                 pic_name="";
    234.                             }else{
    235.                                 pic_name=spell_pic.name;   
    236.                             }
    237.                             string anim_name;
    238.                             if(spell_anim==null){
    239.                                 anim_name="";
    240.                             }else{
    241.                                 anim_name=spell_anim.name; 
    242.                             }
    243.            
    244.                             str = str.Replace(editLine, "!["+(editNumber).ToString()+"]!"+spell_name+";"+spell_strength.ToString()+";"+((int)spell_type).ToString()+";"+spell_distance.ToString()+";"+player_level.ToString()+";"+spell_realname+";"+pic_name+";"+anim_name+";"+spell_info);            
    245.                          
    246.                              using (System.IO.StreamWriter file = new System.IO.StreamWriter(pathS))
    247.                              {
    248.                                 string crL = Crypt.Encrypt(str, password1, password2, "SHA1", 2, "16CHARSLONG12345", 256);
    249.                                
    250.                                 file.Write(crL);
    251.                              }
    252.                             plusOne=false;
    253.                             updated=true;
    254.                             countNew=false;
    255.                             editing=false;
    256.                         }
    257.                         if(GUI.Button(new Rect(475,415,200,35),"Cancel")){
    258.                             spell_name="";
    259.                             spell_realname="";
    260.                             spell_strength=10;
    261.                             spell_type=SpellTypes.Attack;
    262.                             spell_distance=1.5f;
    263.                             player_level=1;
    264.                             plusOne=false;
    265.                             spell_pic=null;
    266.                             spell_anim=null;
    267.                             spell_info="";
    268.                         }
    269.                     }
    270.                    
    271.                 }
    272.            
    273.             }
    274.            
    275.         }  
    276.     }
    277.    
    278.     void EditSpell(string e){
    279.         plusOne=true;
    280.         string norm = e.Split('!')[2];
    281.         spell_name=norm.Split(';')[0];
    282.         spell_strength=int.Parse(norm.Split(';')[1]);
    283.         spell_type=(SpellTypes)int.Parse(norm.Split(';')[2]);
    284.         spell_distance=float.Parse(norm.Split(';')[3]);
    285.         player_level=int.Parse(norm.Split(';')[4]);
    286.         spell_realname=norm.Split(';')[5];
    287.         spell_info=norm.Split(';')[8];
    288.         if(norm.Split(';')[6]!=null  norm.Split(';')[6]!=""){
    289.             spell_pic = (Texture2D)Resources.Load("Spells/"+norm.Split(';')[6],typeof(Texture2D));
    290.         }else{
    291.             spell_pic=null;
    292.         }
    293.         if(norm.Split(';')[7]!=null  norm.Split(';')[7]!=""){
    294.             spell_anim=(AnimationClip)Resources.Load("Animations/"+norm.Split(';')[7],typeof(AnimationClip));
    295.         }else{
    296.             spell_anim=null;   
    297.         }
    298.         editNumber=int.Parse((e.Split('!')[1]).ToString()[1].ToString());
    299.         editLine=e;
    300.         editing=true;
    301.     }
    302.    
    303.     int BoolToInt(bool b){
    304.         if(b==true){
    305.             return 1;  
    306.         }else{
    307.             return 0;  
    308.         }
    309.     }
    310.    
    311.     bool IntToBool(int b){
    312.         if(b==0){
    313.             return false;  
    314.         }else{
    315.             return true;   
    316.         }
    317.     }
    318.    
    319.     int lineCount(){
    320.         int lC=1;
    321.         string str2;
    322.         if(thereIs){
    323.         System.IO.StreamReader file = new System.IO.StreamReader(pathS);
    324.             str2 = Crypt.Decrypt(file.ReadToEnd(),password1,password2,"SHA1",2,"16CHARSLONG12345",256);
    325.             foreach(char c in str2){
    326.                 if(c=='\n'){
    327.                     lC++;  
    328.                 }
    329.             }
    330.             if(lC==0){
    331.                 lC=1;  
    332.             }
    333.             file.Close();
    334.         }
    335.         return lC;
    336.     }
    337.    
    338.     void WriteAllLines(){
    339.         counter=1;
    340.         string str2;
    341.         System.IO.StreamReader file = new System.IO.StreamReader(pathS);
    342.         str2 = Crypt.Decrypt(file.ReadToEnd(),password1,password2,"SHA1",2,"16CHARSLONG12345",256);
    343.         foreach(char c in str2){
    344.             if(c=='\n'){
    345.                 counter++; 
    346.             }
    347.         }
    348.         if(counter==0){
    349.             counter=1; 
    350.         }
    351.         file.Close();  
    352.     }
    353.    
    354.     public void WriteSpell(){
    355.         string str2;
    356.         System.IO.StreamReader file = new System.IO.StreamReader(pathS);
    357.         str2 = Crypt.Decrypt(file.ReadToEnd(),password1,password2,"SHA1",2,"16CHARSLONG12345",256);    
    358.         spells = str2.Split('\n');
    359.        
    360.         file.Close();  
    361.     }
    362.    
    363.     Vector3 parseVector3(string sourceString) {
    364.           string outString;
    365.           Vector3 outVector3;
    366.             string[] splitString;
    367.             outString = sourceString.Substring(1, sourceString.Length - 2);
    368.             splitString = outString.Split("," [0]);
    369.    
    370.             outVector3.x = float.Parse(splitString[0]);
    371.    
    372.             outVector3.y = float.Parse(splitString[1]);
    373.    
    374.             outVector3.z = float.Parse(splitString[2]);
    375.             return outVector3;
    376.     }
    377.    
    378.     public static string NowEditing(){
    379.         return editLine;   
    380.     }
    381. }
    382.  


    SynchSpell [SERVER CLIENT] -

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEditor;
    4. using System.IO;
    5.  
    6. public class SynchSpell : EditorWindow {
    7.  
    8.     [MenuItem("Ultimate MMORPG Kit/Synchronize Spells")]
    9.     public static void ShowWindow()
    10.     {
    11.         EditorWindow.GetWindow(typeof(SynchSpell));
    12.         ye=false;
    13.         path="";
    14.     }
    15.    
    16.     string [] pA = Application.dataPath.Split('/');
    17.     static string path="";
    18.     string [] client2;
    19.     static bool ye;
    20.     string fileS="";
    21.     string pathS = Application.dataPath+"/UMK_Files/SpellFile.umk";
    22.     bool on;
    23.    
    24.     void OnGUI(){
    25.         if(!ye){
    26.             for(int i=0;i<pA.Length-3;i++){
    27.                 path=path+pA[i]+"/";   
    28.             }
    29.             ye=true;
    30.         }
    31.         GUILayout.Space(10);
    32.         if(GUILayout.Button("Synchronize Spells",GUILayout.Width(350),GUILayout.Height(40))){
    33.             client2 = Directory.GetFiles(path,"SpellFileC.umk",SearchOption.AllDirectories);
    34.             on=true;
    35.             if(client2.Length>0){
    36.                 on=false;
    37.                 fileS=client2[0];
    38.                 string str1;
    39.                                 using (System.IO.StreamReader reader = System.IO.File.OpenText(pathS))
    40.                                 {
    41.                                     str1 = reader.ReadToEnd();
    42.                                 }
    43.                                 using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileS))
    44.                                  {
    45.                                    
    46.                                     file.Write(str1);
    47.                                     file.Close();
    48.                                  }
    49.             }
    50.         }
    51.         if(client2!=null){
    52.             if(client2.Length==0  on){
    53.                 GUILayout.Label("Set the Spell Editor in the Client's Project firstly!",EditorStyles.boldLabel);       
    54.             }
    55.         }
    56.     }
    57. }
    58.  


    INFO - Game info
    Code (csharp):
    1. /*
    2. Ultimate MMORPG Kit - GameScripts/INFO - Client's script - skeletarik@gmail.com - 2013
    3. This script is very important. It contains all information about Player. It receives it from the "ChooseCharacter" script (INFO <- ChooseCharacter <- Chars <- MySQL Database)
    4. From any script you can get any information you want. Just call "INFO.Return...()" where "..." is the thing you want to know (e.g. INFO.ReturnEmail())
    5. This script must be added on the GameObject called "INFO" in the "MainMenu" scene (the first one). Check you have got only one GameObject with this script.
    6. */
    7.  
    8. using UnityEngine;
    9. using System.Collections;
    10.  
    11. public class INFO : MonoBehaviour {
    12.    
    13.     static string[] inf;            //Received information from the "ChooseCharacter" script (not only from that script)
    14.     static string email;            //Account's email
    15.     static int characters;          //The quantity of characters in one account
    16.     static string game_name;        //Character's name
    17.     static string race;             //Character's race
    18.     static string game_class;       //Character's class
    19.     static int level;               //Character's level
    20.     static int exp;                 //Character's experience
    21.     static string bag;              //Character's bag
    22.     static int coins;               //Character's money
    23.     static string weapon;           //Character's weapon
    24.     static string shield;           //Character's shield
    25.     static string quests;           //Character's quest (taken and made)
    26.     static string profession;       //Character's profession
    27.     static int ability1;            //The first character's ability
    28.     static int ability2;            //The second character's ability
    29.        
    30.     void Awake(){
    31.         DontDestroyOnLoad(gameObject);  //Don't destroy that GameObject on load! We need it
    32.     }
    33.    
    34.     void Start () {
    35.         ability1 = 0;
    36.         ability2 = 0;  
    37.     }
    38.    
    39.     public void SetCoins(string c){
    40.         coins=int.Parse(c);
    41.     }
    42.    
    43.     void GetInfo(string i){             //Receive information from the "ChooseCharacter" script
    44.         inf = i.Split(':');
    45.         game_name=inf[0];
    46.         race=inf[1];
    47.         game_class=inf[2];
    48.         level=int.Parse(inf[3]);
    49.         exp=int.Parse(inf[4]);
    50.         bag=inf[5];
    51.         coins=int.Parse(inf[6]);
    52.         weapon=inf[7];
    53.         shield=inf[8];
    54.         quests=inf[9];
    55.         profession=inf[10];
    56.        
    57.         if(Application.loadedLevelName=="CreateCharacter"){
    58.             GameObject.Find("WEB_Create").GetComponent("Create").SendMessage("GetData", email+":"+game_name+":"+race+":"+game_class+":"+race); 
    59.         }
    60.     }
    61.    
    62.     void GetEmail(string i){
    63.         i = i.Remove(0,1);
    64.         if(i.Split(':')[0]=="Correct"){
    65.             email = i.Split(':')[2];
    66.             characters = int.Parse(i.Split(':')[1]);
    67.         }
    68.     }
    69.    
    70.     void GetCharacters(string i){
    71.         i = i.Remove(0,1);
    72.         string[] s = i.Split('^');
    73.         if(s.Length==2){
    74.             characters = int.Parse(i.Split('^')[1]);
    75.         }
    76.     }
    77.    
    78.     public void DeleteChar(string i){
    79.         GameObject.Find("WEB_Delete").GetComponent("Delete").SendMessage("GetData", email+":"+i);  
    80.     }
    81.    
    82.     public static string ReturnInfo(){
    83.         return game_name+":"+race+":"+game_class+":"+level.ToString()+":"+exp.ToString();
    84.     }
    85.    
    86.     public static string ReturnChars(){
    87.         return characters.ToString();
    88.     }
    89.    
    90.     public static string ReturnEmail(){
    91.         return email;
    92.     }
    93.    
    94.     public static string ReturnCoins(){
    95.         return coins.ToString();
    96.     }
    97.    
    98.     public static string ReturnWeapon(){
    99.         return weapon;
    100.     }
    101.    
    102.     public static string ReturnShield(){
    103.         return shield;
    104.     }
    105.    
    106.     public static string ReturnName(){
    107.         return game_name;
    108.     }
    109.    
    110.     public static int ReturnLevel(){
    111.         return level;
    112.     }
    113.    
    114.     public static string ReturnQuests(){
    115.         return quests;
    116.     }
    117.    
    118.     public static string ReturnProfession(){
    119.         return profession;
    120.     }
    121.    
    122.     public static int ReturnExp(){
    123.         return exp;
    124.     }
    125.    
    126.     public static void SetWeapon(string w){
    127.         weapon = w;
    128.     }
    129.    
    130.     public static void SetShield(string s){
    131.         shield = s;
    132.     }
    133.    
    134.     public static void SetQuests(string q){
    135.         quests = q;
    136.     }
    137.    
    138.     public static void SetProfession(string p){
    139.         profession = p;
    140.     }
    141.    
    142.     public static void PlusExp(int e){
    143.         exp = exp+e;
    144.         if(exp>=level*100){                 //If Player has more experience that he needs, he will level up
    145.             int more = exp-(level*100);
    146.             level++;
    147.             exp=0;
    148.             exp+=more;
    149.         }
    150.         if (level >= 20) {
    151.             level = 20;
    152.             exp=0;
    153.         }
    154.         GameObject.Find("WEB_Exp").SendMessage("GetData", email+"^"+PhotonNetwork.player.name+"^"+level.ToString()+"^"+exp.ToString());
    155.         GameObject.Find(PhotonNetwork.player.name+":player/Main Camera").GetComponent("UpdateHealthStat");
    156.     }
    157.  
    158.     public void ReturnAll(){
    159.         GameObject.Find("WEB_Create").SendMessage("SetAll", email+":"+game_name+":"+race+":"+game_class+":"+level.ToString()+":"+exp.ToString());  
    160.     }
    161.    
    162.     public static void GameStarted(){                                                           //Sending to all main scripts that the game has been started
    163.         GameObject.Find("Main Camera").GetComponent("HeroStats").SendMessage("GameStarted","");
    164.         GameObject.Find("Main Camera").GetComponent("Bag").SendMessage("GameStartedBag", bag);
    165.         GameObject.Find("Main Camera").GetComponent("Equipment").SendMessage("GameStartedEq", game_class+":"+level.ToString()+":"+weapon+":"+shield+":"+race);
    166.         GameObject.Find("Main Camera").GetComponent("QuestWindow").SendMessage("GameStartedQW", quests);
    167.         GameObject.Find("Main Camera").GetComponent("Profession").SendMessage("GameStartedP", profession);
    168.         GameObject.Find("Main Camera").GetComponent("ExpWindow").SendMessage("GameStartedExp");
    169.         GameObject.Find("Main Camera").GetComponent("SpellBook").SendMessage("GameStartedSB");
    170.         GameObject.Find("GUIManager").GetComponent("GUIManager").SendMessage("GameStartedGUI");
    171.     }
    172.    
    173.     public static int ReturnValue(string a){
    174.         if(a=="ability1"){
    175.             return ability1;   
    176.         }else
    177.         if(a=="ability2"){
    178.             return ability2;   
    179.         }else{
    180.             return -1;
    181.         }
    182.     }
    183.    
    184.     public void Cooldown(string a){
    185.         if(a=="ability1"){
    186.             StartCoroutine("a1CD","");
    187.         }
    188.         if(a=="ability2"){
    189.             StartCoroutine("a2CD","");
    190.         }
    191.     }
    192.    
    193.     public IEnumerator a1CD(){
    194.         ability1=1;
    195.         while(ability1!=0){
    196.             yield return new WaitForSeconds(1);
    197.             ability1=ability1-1;
    198.         }
    199.     }
    200.    
    201.     public IEnumerator a2CD(){
    202.         ability2=3;
    203.         while(ability2!=0){
    204.             yield return new WaitForSeconds(1);
    205.             ability2=ability2-1;
    206.         }
    207.     }
    208. }
    209.  



    I appreciate any help you can provide. I want to make sure that the spells can be altered to be distributed to each class, and have a particle system as well. If you are really interested, and want to help in a further matter, I am also currently looking for a c# fellow developer which I can trust, so if you have a good rate, and want to help more in depth in a MMORPG, contact me at silvanschwarz23@gmail.com.

    Have an awesome day,
    Cordially,
    Silvan Schwarz.
     
    Last edited: Apr 13, 2014
  2. Rezasdemon

    Rezasdemon

    Joined:
    Oct 25, 2014
    Posts:
    1
    Add me to skype man id love for you to work with me on this . I tried to contact you in a pm but failed to do so. so i emailed you.