Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by golddevrush · Apr 09, 2017 at 05:29 AM · classesrpgmeleeskillsmagic

rpg, skills and characters the structure, confused

hi everyone, i am trying to develop a rpg. i intend to use turn-base battle system similar to ffvii(or ffviii, ffix,etc)

i have make classes :

 [System.Serializable]
 public class cSkillSet {    
     public List<cSkill> listSkill=null;
 
     public int TotalSkills(){
         if (listSkill != null ){
             return listSkill.Count;
         }else {
             return 0;
         }
     }
     public int TotalPercentChanceSkills(){
         int value = 0;
         if (listSkill != null ){
             for(int i=0;i<=(listSkill.Count -1);i++){
                 value += listSkill[i].PercentChance ;
             }
         }
         return value;
     }
     public int TotalPercentChanceSkillsBefore(int skillPos){
         int value = 0;
         if (listSkill != null ){
             if (skillPos == 2) {
                 value = listSkill [0].PercentChance;    
             } else {
                 for(int i=0;i<=(skillPos - 1);i++){
                     value += (listSkill[i].PercentChance + 1) ;
                 }
             }
         }
         return value;
     }
 
 }
 
 [System.Serializable]
 public class cSkill {
     public string p_Name = "Skill1";
     public int p_AnimID = 1;
     public int PercentChance=1;
     public Transform p_Prefab_Effect = null;
     public Vector3 StartPosition = Vector3.zero ;
     public SkillTarget p_SkillTarget = SkillTarget.OneTargetFoe;
 
     public void AnimateSkill (GameObject sourceObj, List<GameObject> targetObj){
         float xPos,yPos,zPos;
         xPos =targetObj[0].transform.position.x - StartPosition.x;
         yPos =targetObj[0].transform.position.y - StartPosition.y;
         zPos = targetObj[0].transform.position.z - StartPosition.z;
         sourceObj.transform.position=new Vector3(xPos ,yPos ,zPos ); 
         sourceObj.GetComponent<Animator> ().SetInteger ("skillID",p_AnimID);
         sourceObj.GetComponent<Animator>().SetTrigger ("AtkNormal");
     }
 
 }
 

and i make a class that i intend to put (as component) into my character objects (like this below) :

 public class sEnemy : MonoBehaviour {
     public cSkillSet mySkillSet;
     public List<GameObject> p_Targets = null;
     private Vector3 defaultPosition;
     public string MyName = "";
 
     void Awake(){
         defaultPosition = this.transform.position;
         HadapLawan ();
     }
 
     public void HadapLawan(){
         this.transform.LookAt (new Vector3(this.transform.position.x,this.transform.position.y,0));
     }
 
     public void PilihAksi(){
         if (mySkillSet.TotalPercentChanceSkills() <= 0) {
             Debug.Log ("Tak ada skill dalam skill set.");
             return;
         }
         int NomorPilihanAksi = Random.Range (1,mySkillSet.TotalPercentChanceSkills() +1);
         bool Ketemu = false;
         int i = 0;
         while ((Ketemu != true) && (i <(mySkillSet.TotalSkills() - 1)) ) {
             if (NomorPilihanAksi < mySkillSet.TotalPercentChanceSkillsBefore (i + 1)) {
                 DoAction (mySkillSet.listSkill[i]);
                 TampilPesanAksi (MyName + " : " + this.gameObject.name  + " --> " + mySkillSet.listSkill[i].p_Name );
                 Ketemu = true;
             } else {
                 i++;
             }
         }
         if (Ketemu != true) {
             DoAction (mySkillSet.listSkill[i]);
             TampilPesanAksi (MyName + " : " + this.gameObject.name  + " --> " + mySkillSet.listSkill[i].p_Name );
         }
     }
 
     void TampilPesanAksi(string xStr) {
         GameObject.Find ("ActionMessage").GetComponent<ActionMessage> ().DisplayMessageToScreen (xStr);
     }
 
     public void SomethingAfterAnimation(){
         this.transform.position = defaultPosition;
         TampilPesanAksi ("");
     }
 
     public void DoAction(cSkill tSkill){
         //choose the target
         ChooseTarget(tSkill);
 
         //do animation
         tSkill.AnimateSkill(this.gameObject,p_Targets );
         //show the message
         TampilPesanAksi (MyName + " : " + this.gameObject.name  + " --> " + tSkill.p_Name );
     }
 
     public void ChooseTarget(cSkill tSkill){
         switch (tSkill.p_SkillTarget) {
         case SkillTarget.OneTargetFoe:
             if (p_Targets == null ){
                 //get one of the enemies as the target    
                 if (this.gameObject.tag=="enemies"){
                     p_Targets.Add(GameObject.FindGameObjectWithTag("pemain"));
                 }else if(this.gameObject.tag=="pemain"){
                     p_Targets.Add(GameObject.FindGameObjectWithTag("enemies"));
                 }
             }else if (p_Targets.Count >1) {
                 p_Targets = null;
                 ChooseTarget (tSkill);
             }
             break;
         }
     }
 
 }
 

My Question is, if (as we know we have to supply many skills for our game) the skills have different behaviour from each other (some have same behaviour) and the characters have different skillset, how to build the class structure so that it will make me easy to arrange and more efficient way. example : character A have 3 skill with all melee but character B have 5 skill with 2 melee and 3 magical

thx in advance for the response.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How do skills affect damage you can do 2 Answers

Top Down RPG sword swing detection 1 Answer

Localmotion head spinning. 0 Answers

Problem with making skill system for my creatures 1 Answer

RPG Swing attack hit detection 6 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges