Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DamageEffect : EffectBase {
- public int dano;
- // Use this for initialization
- protected override void Effect(){
- targetBase.target.TomaDano (dano);
- }
- }
- ---
- public abstract class EffectBase : MonoBehaviour {
- protected Personagem dono;
- protected Skill skill;
- protected TargetBase targetBase;
- void Start(){
- skill = GetComponent<Skill> ();
- dono = skill.dono;
- targetBase = GetComponent<TargetBase> ();
- targetBase.onFindTargetDo.Add (Effect);
- }
- protected virtual void Effect(){
- }
- }
- ---
- public class HealEffect : EffectBase {
- public int cura;
- // Use this for initialization
- protected override void Effect(){
- if (targetBase.target != null) {
- targetBase.target.TomaHeal (cura);
- }
- }
- }
- ---
- public class InputController : MonoBehaviour {
- float horizontalAxis;
- public float rotateSpeed;
- float verticalAxis;
- public float moveSpeed;
- public Transform player;
- Personagem personagem;
- bool isShiftDown;
- // Use this for initialization
- void Start () {
- personagem = player.GetComponent<Personagem> ();
- }
- // Update is called once per frame
- void Update () {
- if (Input.GetKey (KeyCode.LeftShift)) {
- isShiftDown = true;
- } else {
- isShiftDown = false;
- }
- if (Input.GetKeyDown (KeyCode.Space) && isShiftDown) {
- Debug.Log ("Combo shift+space");
- }else if (Input.GetKeyDown (KeyCode.Space)) {
- Debug.Log ("Apertou espaço");
- personagem.skillBar [0].testeFire = true;
- }
- horizontalAxis = Input.GetAxis ("Horizontal");
- player.Rotate (0, horizontalAxis*rotateSpeed*Time.deltaTime, 0);
- verticalAxis = Input.GetAxis ("Vertical");
- player.Translate (new Vector3 (0, 0, moveSpeed * verticalAxis * Time.deltaTime));
- }
- }
- ---
- public class Personagem : MonoBehaviour {
- public int armor;
- public int vida;
- public List<Skill> skillBar;
- public void TomaDano(int dano){
- if ((dano - armor) < 0)
- dano = 0;
- vida -= dano;
- Debug.Log ("Eu, " + transform + " tomei " + dano + " e fiquei com " +
- vida + " de vida");
- }
- public void TomaHeal(int heal){
- vida += heal;
- }
- }
- ---
- public class Skill : MonoBehaviour {
- public List<OnSkillDo> onSkillDo;
- public bool testeFire;
- public Personagem dono;
- public float cooldown;
- public float cooldownTimer;
- float tickTime = 0.5f;
- // Use this for initialization
- void Awake(){
- dono = GetComponentInParent<Personagem> ();
- onSkillDo = new List<OnSkillDo> ();
- onSkillDo.Add (CooldownCounter);
- }
- void CooldownCounter(){
- cooldownTimer = cooldown;
- StartCoroutine (CooldownCoroutine ());
- }
- IEnumerator CooldownCoroutine(){
- while(cooldownTimer>0){
- yield return new WaitForSeconds(tickTime);
- cooldownTimer-=tickTime;
- }
- }
- // Update is called once per frame
- void Update () {
- if (testeFire) {
- testeFire = false;
- if(cooldownTimer<=0)
- UsaSkill ();
- }
- }
- void UsaSkill(){
- Debug.Log ("usou o skill");
- for (int i = 0; i < onSkillDo.Count; i++) {
- onSkillDo [i] ();
- }
- //target = null;
- }
- }
- ---
- public class ProjectileBehaviour : MonoBehaviour {
- public float moveSpeed;
- public float duration;
- public float durationHitPenalty;
- public TargetProjectile targetProjectile;
- // Use this for initialization
- void Start () {
- }
- void DestroyProjectile(){
- Destroy (this.gameObject);
- }
- // Update is called once per frame
- void Update () {
- transform.Translate (0, 0, moveSpeed * Time.deltaTime);
- duration -= Time.deltaTime;
- if (duration <= 0)
- DestroyProjectile ();
- }
- void OnTriggerEnter(Collider coll){
- if (coll.GetComponent<Personagem> ()) {
- Debug.Log ("Acertou " + coll);
- targetProjectile.OnHit(coll.GetComponent<Personagem>());
- duration -= durationHitPenalty;
- }
- }
- }
- ---
- public class SkillSoundFX : MonoBehaviour {
- public AudioClip soundfx;
- public float duration;
- public float fadeSpeed;
- Skill skill;
- AudioSource source;
- void Start(){
- skill = GetComponent<Skill> ();
- skill.onSkillDo.Add (PlaySoundFX);
- source = transform.parent.GetComponent<AudioSource> ();
- }
- void PlaySoundFX(){
- source.clip = soundfx;
- source.pitch = RandomizePitch ();
- source.Play ();
- Invoke ("EndSound", duration);
- }
- float RandomizePitch(){
- float pitch;
- pitch = Random.Range (0, 3f);
- return pitch;
- }
- void EndSound(){
- //source.Stop ();
- StartCoroutine(Fade());
- }
- IEnumerator Fade(){
- float tempVolume = source.volume;
- while (source.volume>=0.1) {
- source.volume -= fadeSpeed;
- yield return null;
- }
- source.volume = tempVolume;
- source.Stop ();
- }
- }
- ---
- public class SkillVisualFX : MonoBehaviour {
- public Transform particleHolder;
- List<ParticleSystem> particleSystems;
- Skill skill;
- // Use this for initialization
- void Start () {
- skill = GetComponent<Skill> ();
- skill.onSkillDo.Add (PlayFX);
- particleSystems = new List<ParticleSystem> ();
- particleSystems.AddRange(particleHolder.GetComponentsInChildren<ParticleSystem> ());
- }
- void PlayFX(){
- for(int i=0; i<particleSystems.Count; i++){
- particleSystems [i].Play ();
- }
- }
- }
- ---
- public abstract class TargetBase : MonoBehaviour {
- protected Personagem dono;
- public Personagem target;
- protected Skill skill;
- public List<OnFindTargetDo> onFindTargetDo;
- void Awake(){
- onFindTargetDo = new List<OnFindTargetDo> ();
- dono = this.transform.GetComponent<Personagem> ();
- skill = GetComponent<Skill> ();
- }
- void Start(){
- skill.onSkillDo.Add (FindTarget);
- }
- protected virtual void FindTarget(){
- Debug.Log ("setou target");
- target = dono;
- ExecuteOnFindTarget ();
- }
- protected void ExecuteOnFindTarget(){
- for (int i = 0; i < onFindTargetDo.Count; i++) {
- onFindTargetDo [i] ();
- }
- }
- }
- ---
- public class TargetManual : TargetBase {
- public Personagem manualTarget;
- protected override void FindTarget ()
- {
- Debug.Log ("setou target2");
- ExecuteOnFindTarget ();
- }
- }
- --
- public class TargetProjectile : TargetBase {
- public GameObject projectile;
- GameObject flyingProjectile;
- ProjectileBehaviour pb;
- Personagem wasHit;
- // Use this for initialization
- void Start () {
- flyingProjectile = GameObject.Instantiate (projectile);
- pb = flyingProjectile.GetComponent<ProjectileBehaviour> ();
- pb.targetProjectile = this;
- }
- public void OnHit(Personagem hit){
- wasHit = hit;
- FindTarget ();
- }
- protected override void FindTarget ()
- {
- target = wasHit;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement