// 発動 bool move(AutoExplosion parent) { v_ += g_; parent.transform.position += v_ / 60.0f; t_ += Time.deltaTime; if (destroyCondition_ != null) { var flag = destroyCondition_(t_); if (flag == DestroyFlag.GameObject) { GameObject.Destroy(parent.gameObject); state_ = null; return(true); } else if (flag == DestroyFlag.Component) { GameObject.Destroy(parent); state_ = null; return(true); } else if (flag == DestroyFlag.Unit) { state_ = null; return(true); } } return(false); }
public override void Initalize(BulletController controller) { updateController(controller); explosion = controller.GetComponentInChildren<AutoExplosion>(); target = enemy.transform; m_startPosition = bulletController.gameObject.transform.localPosition; // tinh khoang cach giua vien dan va muc tieu m_fX = bulletController.gameObject.transform.InverseTransformPoint(target.position).x; if (m_fX >= 0 && m_fX < 5) { m_fX = 5; } else if(m_fX < 0 && m_fX > -5) { m_fX = -5; } m_fY = bulletController.gameObject.transform.InverseTransformPoint(target.position).y; calculatorByTime(calculatorByVelocity(Random.Range(55, 60))); //canCollision = false; }
public override void Initalize(BulletController controller) { updateController(controller); explosion = controller.GetComponentInChildren <AutoExplosion>(); target = enemy.transform; m_startPosition = bulletController.gameObject.transform.localPosition; // tinh khoang cach giua vien dan va muc tieu m_fX = bulletController.gameObject.transform.InverseTransformPoint(target.position).x; if (m_fX >= 0 && m_fX < 5) { m_fX = 5; } else if (m_fX < 0 && m_fX > -5) { m_fX = -5; } m_fY = bulletController.gameObject.transform.InverseTransformPoint(target.position).y; calculatorByTime(calculatorByVelocity(Random.Range(55, 60))); //canCollision = false; }
// 衝撃波が伝わるまで bool sonicCheck(AutoExplosion parent) { t_ += Time.deltaTime; var p = parent.transform.position; float d = (corePos_ - p).magnitude; if (sonicVector_ * t_ >= d) { // 発動 state_ = move; v_ = (p - corePos_).normalized * (corePower_ * Mathf.Pow(decRate_, d)); t_ = 0.0f; } return(false); }
public bool update(AutoExplosion parent) { if (state_ == null) { return(true); } if (parent == null) { return(true); } var preState = state_; bool res = state_(parent); if (preState != state_) { return(update(parent)); } return(res); }