So I’m mocking up a turned based rpg combat system. My plan is to store each of the members of the combat in an array and then using a sort function of the array based on speed to figure of each member’s turn. Since each mob and PC will have unique attacks etc, each will have a unique animation script. The problem I’m running in to is that I can’t find a way to reference each member’s script in a generic way. I want to be able to call “attack #3” on the animation script and have that character’s unique attack fire. I tried adding the name of each Animation script to the base class for each as a string, then tried to look up that name from the getcomponent(“string”) but I get errors.
//create mobs for testing
robo = new CharacterAttributes(Player.Robo, "Robo", CombatPosition.PlayerFrontCenter, "Combat Robo" , "RoboAnimationController" ,20,21,19,20,18,22,22,57000);
robo.AddWeapon(new Weapon("Ion Gun", 1, 100, false, Element.physical, 100, Player.Robo));
var monster : NPCAttributes = new NPCAttributes("Psy Auto", "Psy Auto", "PsyAutoAnimationController", 8, 200, 20, 30, 1, 1, 5, 1, 15, false, 50);
//populate the battle field
robo.myInstance = Instantiate(robo.model, Vector3(combatPositions[robo.combatPosition].x, (robo.model.collider as BoxCollider).size.y/2,combatPositions[robo.combatPosition].z), Quaternion.Euler(0,0,0));
monster.myInstance = Instantiate(monster.model, Vector3(combatPositions[8].x,(monster.model.collider as BoxCollider).size.y/2,combatPositions[8].z), Quaternion.Euler(0,180,0));
while(true){
//create a loop that loops through party and monsters and returns the highest initiative TBA
//Select next attacker based on return TBA
//need to call a menu here with options for player on party turn populated with options for each character individually TBA
yield robo.myInstance.GetComponent(robo.myAnimationScript).AttackTarget(robo, monster);// Here I get errors that .AttackTarget isn't a component of UnityEngine.Component
if(gameMasterController.inCombat == false) break;
Any ideas. I’m pretty new to OOP, but I’m learning fast.
Cheers
Thank you very much. I've been avoiding rewriting my code to embrace inheritance. This will give me the kick to convert over to C# and rework my logic.
– Charva1976