Exemplo n.º 1
0
    public virtual void Start()
    {
        m_Rigidbody = GetComponent <Rigidbody>();
        m_Stats     = GetComponent <EntityStats>();
        m_Agent     = GetComponent <NavMeshAgent>();

        //Set navmeshagent values
        m_Agent.updateRotation   = false;
        m_Agent.speed            = GetStats().GetMovementSpeed();
        m_Agent.stoppingDistance = GetStats().GetAttackRange();

        //Find and set chargebar
        m_Chargebar = transform.FindChild("Chargebar").GetComponent <Healthbar>();

        if (m_Chargebar)
        {
            m_Chargebar.SetScale(0);
            m_Chargebar.gameObject.SetActive(false);
        }
        else
        {
            Debug.Log("Entity " + gameObject.name + " could not find chargebar!");
        }

        //Set rotation
        transform.eulerAngles = new Vector3(90.0f, 0, 0);
        m_MovetoPosition      = transform.position;
    }
Exemplo n.º 2
0
    public override void AttackUpdate(float attackSpeed, float attackTime)
    {
        //Reload if ammo is <= 0
        if (m_CurAmmo <= 0)
        {
            m_IsReloading = true;
        }
        else
        {
            if (!m_IsReloading)
            {
                if (m_CurAmmo < m_Ammo)
                {
                    m_TimeSinceLast += Time.deltaTime;
                    if (m_TimeSinceLast > 1.5f)
                    {
                        m_TimeSinceLast = 0.0f;
                        m_IsReloading   = true;
                    }
                }
                else
                {
                    m_TimeSinceLast = 0.0f;
                }
            }
        }

        //Reload cooldown etc
        if (m_IsReloading)
        {
            m_CurReload -= Time.deltaTime;
            if (m_CurReload <= 0.0f)
            {
                m_CurReload   = m_ReloadTime;
                m_IsReloading = false;
                m_CurAmmo     = m_Ammo;
                m_AmmoBar.SetScale(m_CurAmmo);
            }
        }

        //Firerate
        if (m_CurFire < m_FireRate)
        {
            m_CurFire += Time.deltaTime;
        }
        m_CurFire = Mathf.Clamp(m_CurFire, 0.0f, m_FireRate);
    }
Exemplo n.º 3
0
 public virtual void ChargeUpdate(bool trueState, float maxValue)
 {
     //Activates and sets scale on chargebar if truestate is set
     if (m_Chargebar)
     {
         if (trueState)
         {
             m_Chargebar.gameObject.SetActive(true);
             m_Chargebar.ChangeScale(Time.deltaTime / maxValue);
             m_CurCharge += Time.deltaTime;
             m_CurCharge  = Mathf.Clamp(m_CurCharge, 0.0f, maxValue);
             m_IsCharging = true;
         }
         else
         {
             m_IsCharging = false;
             m_CurCharge  = 0.0f;
             m_Chargebar.SetScale(0);
             m_Chargebar.gameObject.SetActive(false);
         }
     }
 }
Exemplo n.º 4
0
 public void SetHealth(int val)
 {
     m_CurHealth = val;
     m_Healthbar.SetScale(val);
 }