public void ExecuteSkill(int skill_id, Vector2 dir, Vector2 pos) { var model = SkillModel.Get(skill_id); if (dir.x > 0) { transform.rotation = Quaternion.identity; } else if (dir.x < 0) { transform.rotation = Quaternion.Euler(0, 180, 0); } SkillPos = pos; SkillDirection = dir; ActorModel.Model.SetEngery(-model.GetConsumeEnergy()); _anim.SetTrigger("skill" + skill_id.ToString()); }
// Update is called once per frame void Update() { var cols = Physics2D.OverlapCircleAll(transform.position, radius, LayerMask.GetMask("enemy")); foreach (var col in cols) { var enemy_ctr = col.GetComponent <BaseEnemyController>(); if (enemy_ctr && !enemys.Contains(enemy_ctr)) { enemys.Add(enemy_ctr); } } timer += Time.deltaTime; if (timer >= attack_timer_interval) { foreach (var enemy in enemys) { if (!enemy) { timer = 0; return; } enemy.GetHurt(new AttackData( SkillModel.Get(skill_id).GetHurtValue(), false, transform.position, HitType.普通 )); timer = 0; } } foreach (var enemy in enemys) { if (!enemy.isSuperArmor) { enemy.transform.position = Vector3.MoveTowards(enemy.transform.position, transform.position, speed * Time.deltaTime); } } }
private void Awake() { model = SkillModel.Get(skill_id); }