Example #1
0
 protected virtual void OnTriggerExit2D(Collider2D collision)
 {
     if (m_EleCtrlerState == EleCtrlState.Charging)
     {
         if (collision.gameObject.CompareTag(GameConstVal.DamageRangeTag) || collision.gameObject.CompareTag(GameConstVal.CarrierTag))
         {
             m_EleCtrlerState = EleCtrlState.UnCharging;
         }
     }
 }
Example #2
0
 protected void PowerRunOut()
 {
     RevertEleState();
     if (m_LeftActiveTimes > 0)
     {
         TimeOver();
     }
     else
     {
         m_EleCtrlerState = EleCtrlState.Close;
         Close();
     }
 }
Example #3
0
        protected virtual void Update()
        {
            float dtTime = BaseScene.GetDtTime();

            if (dtTime > 0)
            {
                if (m_EleCtrlerState == EleCtrlState.Charging)
                {
                    if (CheckMatEnough())
                    {
                        m_CurChargeTime += dtTime;
                        if (m_CurChargeTime < ChargeTime)
                        {
                            PowerIncrease(m_CurChargeTime / ChargeTime);
                        }
                        else
                        {
                            m_EleCtrlerState = EleCtrlState.Active;
                            EleActive();
                        }
                    }
                }
                else if (m_EleCtrlerState == EleCtrlState.UnCharging)
                {
                    m_CurChargeTime -= dtTime;
                    if (m_CurChargeTime <= 0)
                    {
                        m_CurChargeTime  = 0;
                        m_EleCtrlerState = EleCtrlState.None;
                        PowerDecreaseEnd();
                    }
                    else
                    {
                        PowerDecrease(m_CurChargeTime / ChargeTime);
                    }
                }
                else if (m_EleCtrlerState == EleCtrlState.Active)
                {
                    m_CurChargeTime = 0;
                    m_CurLiveTime  += dtTime;
                    if (m_CurLiveTime >= LiveTime)
                    {
                        m_EleCtrlerState = EleCtrlState.None;
                        m_CurLiveTime    = 0;
                        PowerRunOut();
                    }
                }
            }
        }