Hi all, need a bit of help with this.
I want to basally have monsters that can pull from a giant list of all available moves to put in their available moves list, which then i can refer to when I need to use the attack for it’s info.
I’m having a problem with seeing how I could do this, and the solution I’m working with right now is limited (such as I can refer forward but not back, meaning I can’t have cooldown on moves). What’s the best way to approach this?
Current Setup:
Class used when using a move:
using UnityEngine;
using System;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
public class MonsterMoves : MonoBehaviour, IAbility{
public List<MoveInfo> Moves = new List<MoveInfo>();
public void Use(string MoveName, Vector3 Pos, Quaternion Rot){
Debug.Log ("Used " + MoveName + "!");
MethodInfo mi = this.GetType().GetMethod("Use" + MoveName);
mi.Invoke (this, new object[] {"Ember", Pos, Rot});
}
public void UseEmber(string MoveName, Vector3 PosToStart, Quaternion Rot){
ProjectileAttk (MoveName, PosToStart, Rot);
}
//Attk Types
public void ProjectileAttk(string MoveName, Vector3 PosToStart, Quaternion Rot){
GameObject temp = (GameObject) Instantiate (Moves[0].ParticleEffect, PosToStart, Rot);
temp.audio.clip = Moves[0].SoundEffect;
temp.audio.Play ();
}
}
public interface IAbility {
//Fill this with all the move types (projectile, transformation, etc)
void Use(string MoveName, Vector3 Pos, Quaternion Rot);
void ProjectileAttk (string MoveName, Vector3 Pos, Quaternion Rot);
}
[System.Serializable]
public class MoveInfo{
public string Name;
public float CooldownTime;
public GameObject ParticleEffect;
public AudioClip SoundEffect
}
How I refer to use a move currently (In the monster class):
GameObject.FindGameObjectWithTag("MainStuff").GetComponent<MonsterMoves>().Use (KnownMoves[AttkNum], transform.position, transform.rotation);