/* * Funcion llamada al inicio de lanzar una habilidad * */ public static void startAction(GameObject target, _Skill script) { HUD.setUserActive(false); _Stats stats = turns[0].GetComponent <_Stats>(); stats.armor = 0f; //Animacion que desencadena la mierda que toque turns [0].GetComponent <Animator> ().SetTrigger("Skill" + script.pos); //en primer caso llama attack y endTurn //en ser cargada no llamara nada //Lanzamos accion inmediata if (script.speed == 1f) { stats.nextSkill = null; stats.preparingSkill = false; stats.nextTarget = target; int pos = Mathf.CeilToInt(stats.turns * (1f + stats.speed * 0.1f)); placeTurn(turns[0], stats, pos); turns[0] = null; HUD.addTimelineImage(null, 0); //Lanzamos accion con carga } else { int pos = Mathf.CeilToInt(stats.turns * (1f + stats.speed * 0.1f)) / 2; stats.nextSkill = script; stats.preparingSkill = true; stats.nextTarget = target; stats.nextSkillTrigger = "Skill" + script.pos; placeTurn(turns [0], stats, pos); endTurn(); } }
/* * Realiza una habilidad(skill) de attacker a target * Si se puede realizar la accion se debe comprobar antes de esta funcion * */ public static void attack(GameObject attacker, GameObject target, _Skill skill) { if (attacker == null || target == null || skill == null) { return; } _Stats statsAttacker = attacker.GetComponent <_Stats> (); if (target == null) { target = selectNewTarget(statsAttacker.team); } _Stats statsTarget = target.GetComponent <_Stats> (); int damage = (int)(statsAttacker.attack * skill.attack); statsAttacker.cost -= skill.cost; if (skill.both) { if (skill.area) { for (int i = 0; i < units.Count; ++i) { //aplicar dano a todos los enemigos _Stats tmp = units [i].GetComponent <_Stats> (); tmp.getAttack(damage, statsAttacker.type); tmp.armor = skill.armor; recalculateTurn(units [i], tmp); } } else { statsAttacker.getAttack(damage, statsAttacker.type); recalculateTurn(attacker, statsAttacker); statsTarget.getAttack(damage, statsAttacker.type); recalculateTurn(target, statsTarget); } } else { if (skill.area) { List <GameObject> targets; targets = (statsTarget.team == Team.Ally) ? allies : enemies; for (int i = 0; i < targets.Count; ++i) { _Stats tmp = targets [i].GetComponent <_Stats> (); tmp.getAttack(damage, statsAttacker.type); tmp.armor = skill.armor; recalculateTurn(targets [i], tmp); } } else { statsTarget.getAttack(damage, statsAttacker.type); statsTarget.armor = skill.armor; recalculateTurn(target, statsTarget); } } }
public void setText(_Skill skill) { descripcion.text = "Damage multiplier: " + skill.attack + salto; descripcion.text += "Turn multiplier: " + skill.speed + salto; descripcion.text += ((skill.area) ? "Area: Yes" : "Area: No") + salto; descripcion.text += ((skill.both) ? "Both: Yes" : "Area: No") + salto; image.sprite = skill.image; }
/* * Funcion llamada mientras estamos en seleccion de habilidad * */ public static int previewNextTurn(_Skill script) { if (script.speed == 1f) { return(0); } else { _Stats stats = turns[0].GetComponent <_Stats>(); int t = Mathf.CeilToInt(script.speed * (1f + stats.speed * 0.1f)) / 2; if (turns [t] == null) { return(t); } if (stats.initiative <= turns [t].GetComponent <_Stats> ().initiative) { return(t + 1); } return(t); } }
public void setSkill(_Skill s) { skill = s; _name.text = s.name; }