// Update is called once per frame void Update() { life_time -= Time.deltaTime; if (life_time < 0) { Object.Destroy(this.gameObject); } if (target == null) { // Object.Destroy(this.gameObject); } else { for (int i = 0; i < bulletlist.Count; i++) { if (bulletlist[i] != null) { bulletlist[i].transform.position = Vector3.MoveTowards(bulletlist[i].transform.position, target_pos - Vector3.up * 1.0f + target_offset_list[i], vel * Time.deltaTime); Chessman surrounding_target = null; Debug.Log(target_x + " : " + target_offset_list[i].x + " : " + target_y + " : " + target_offset_list[i].z); if (target_x + target_offset_list[i].x >= 0 && target_x + target_offset_list[i].x <= 7 && target_y + target_offset_list[i].z >= 0 && target_y + target_offset_list[i].z <= 7) { surrounding_target = BoardManager.Instance.Chessmans[target_x + target_offset_list[i].x, target_y + target_offset_list[i].z]; } if (surrounding_target == null) { // pass, only have anim } else { if (Vector3.Distance(bulletlist[i].transform.position, surrounding_target.transform.position) < 0.25f) { if (isHeal) { surrounding_target.GetHeal(this.damage); } else { surrounding_target.GetDamage(this.damage, 1); } Object.Destroy(bulletlist[i]); bulletlist[i] = null; } } } } } }
// Update is called once per frame void Update() { if (target == null) { Object.Destroy(this.gameObject); } else { this.transform.position = Vector3.MoveTowards(this.transform.position, target.transform.position, vel * Time.deltaTime); if (Vector3.Distance(this.transform.position, target.transform.position) < 0.25f) { if (isHeal) { target.GetHeal(this.damage); } else { target.GetDamage(this.damage, 1); } Object.Destroy(this.gameObject); } } }