public void init(Quaternion direction, SkillStat stat, Transform target) { transform.rotation = direction; List <float> stats = stat.getStats(); damage = stats[2]; duration = stats[3]; speed = stats[4]; normalizedSpeed = (transform.rotation * new Vector3(1, 0, 0)).normalized * speed; type = stat.getSkillType(); this.target = target; }
public void ShowSkillRange(int skill) { currentSkill = skillStats[skill]; Transform transform = GetComponent <Transform>(); switch (currentSkill.getSkillType()) { case SkillStat.SkillType.Projectile: skillRange = Instantiate(currentSkill.getPrefabs()[1], new Vector3(transform.position.x, transform.position.y, -2), Quaternion.identity); skillRange.GetComponent <SkillRange>().init(this, false); currentSkillNum = skill; break; case SkillStat.SkillType.TargetedProjectile: skillRange = Instantiate(currentSkill.getPrefabs()[1], new Vector3(transform.position.x, transform.position.y, -2), Quaternion.identity); skillRange.GetComponent <SkillRange>().init(this, true); currentSkillNum = skill; break; } }
public void activateSkill() { switch (currentSkill.getSkillType()) { case SkillStat.SkillType.Projectile: var projectile = Instantiate(currentSkill.getPrefabs()[0], new Vector3(transform.position.x, transform.position.y, -1), Quaternion.identity); projectile.GetComponent <Skill>().init(skillRange.GetComponent <SkillRange>().direction(), currentSkill, null); mp -= currentSkill.getStats()[0]; cooldown[currentSkillNum] += currentSkill.getStats()[1]; currentSkillNum = -1; break; case SkillStat.SkillType.TargetedProjectile: var targetedProjectile = Instantiate(currentSkill.getPrefabs()[0], new Vector3(transform.position.x, transform.position.y, -1), Quaternion.identity); targetedProjectile.GetComponent <Skill>().init(skillRange.GetComponent <SkillRange>().direction(), currentSkill, skillRange.GetComponent <SkillRange>().getTarget().transform); mp -= currentSkill.getStats()[0]; cooldown[currentSkillNum] += currentSkill.getStats()[1]; currentSkillNum = -1; break; } DeleteSkillRange(); }