Exemple #1
0
 void OnDestroy()
 {
     OnBeattackActionFinish = null;
     OnMoveBackActionFinish = null;
     run_     = false;
     back_    = false;
     forward_ = false;
     StopCoroutine(StartShake());
 }
Exemple #2
0
 // Update is called once per frame
 void Update()
 {
     if (run_)
     {
         crtTimer_   += Time.deltaTime;
         totalTimer_ += Time.deltaTime;
         if (totalTimer_ > totalTime_)
         {
             run_                    = false;
             crtTimer_               = 0f;
             totalTimer_             = 0f;
             transform.localPosition = originPos_;
             back_                   = true;
         }
         if (crtTimer_ < frequency_)
         {
             return;
         }
         if (frontBackFlag_)
         {
             transform.localPosition = originPos_ + transform.forward * 0.03f;
         }
         else
         {
             transform.localPosition = originPos_ - transform.forward * 0.03f;
         }
         frontBackFlag_ = !frontBackFlag_;
         crtTimer_      = 0f;
     }
     if (back_)
     {
         crtTimer_ += Time.deltaTime * 5f;
         transform.localPosition = Vector3.Lerp(originPos_, originPos_ - transform.forward * 0.5f, crtTimer_);
         if (crtTimer_ > 1f)
         {
             crtTimer_ = 0f;
             back_     = false;
             forward_  = true;
         }
     }
     if (forward_)
     {
         crtTimer_ += Time.deltaTime * 5f;
         transform.localPosition = Vector3.Lerp(transform.position, originPos_, crtTimer_);
         if (crtTimer_ > 1f)
         {
             crtTimer_ = 0f;
             forward_  = false;
             if (OnBeattackActionFinish != null)
             {
                 OnBeattackActionFinish();
                 OnBeattackActionFinish = null;
             }
         }
         if (OnMoveBackActionFinish != null)
         {
             OnMoveBackActionFinish();
             OnMoveBackActionFinish = null;
         }
     }
 }