예제 #1
0
 /// <summary>
 /// Gets the sibling components needed for this component
 /// </summary>
 private void GetSiblingComponents()
 {
     if (m_audioSource == null)
     {
         m_audioSource = GetComponent <AudioSource>();
     }
     if (m_rigidbody == null)
     {
         m_rigidbody = GetComponentInParent <Rigidbody2D>();
     }
     if (m_weapon == null)
     {
         m_weapon = GetComponent <ABR_Weapon>();
     }
 }
예제 #2
0
    /// <summary>
    /// switches the current weapon to the type passed in
    /// </summary>
    /// <param name="bulletType">The type that the weapon will change to</param>
    public void SwitchWeapons(eBulletType bulletType)
    {
        //Weapon reference to replace m_weapon
        ABR_Weapon newWeapon = null;

        //Determine Which weapon is going to be added and then add them
        switch (bulletType)
        {
        case eBulletType.BASIC:
            //New weapon will be a basic weapon
            newWeapon = gameObject.AddComponent <ABR_BasicWeapon>();
            break;

        case eBulletType.SHOTGUN:
            //newWeapon will be a shotgun weapon
            newWeapon = gameObject.AddComponent <ABR_ShotgunWeapon>();
            break;

        case eBulletType.EXPLOSION:
            //new weapon will be an explosion weapon
            newWeapon = gameObject.AddComponent <ABR_ExplosionWeapon>();
            break;

        case eBulletType.PIERCE:
            //new weapon will be a piece weapon
            newWeapon = gameObject.AddComponent <ABR_PierceWeapon>();
            break;

        case eBulletType.LASER:
            //new weapon will be a laser weapon
            newWeapon = gameObject.AddComponent <ABR_LaserWeapon>();
            break;
        }
        //set the fire timer to the weapons delay
        m_fireTimer = newWeapon.GetFireDelay();
        //set the bullet spawn location of the new weapon to the current spawn location
        newWeapon.m_bulletSpawnLocation = m_weapon.m_bulletSpawnLocation;
        //remove old weapon component
        Destroy(m_weapon);
        //set the m_weapon reference to the new Weapon
        m_weapon = newWeapon;
    }