Quantcast
Channel: Questions in topic: "melee"
Viewing all articles
Browse latest Browse all 201

rpg, skills and characters the structure, confused

$
0
0
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 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 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 ().SetInteger ("skillID",p_AnimID); sourceObj.GetComponent().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 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 ().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.

Viewing all articles
Browse latest Browse all 201

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>