public void SpawnBullet(eBulletType aBulletType, float aSpeedIncrement, Vector3 aPosition, Quaternion aRotation)
    {
        GameObject bulletObject    = Instantiate(GetBulletPrefabFromType(aBulletType), aPosition, aRotation, mBulletContainer.transform);
        Bullet     bulletComponent = bulletObject.GetComponent <Bullet>();

        bulletComponent.Spawner = this;
        bulletComponent.GetComponent <Bullet>().IncrementSpeed(aSpeedIncrement);
        IgnoreCollision(bulletObject);
    }
예제 #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag(ABR_Tags.WeaponTag))
     {
         eBulletType weapontype = collision.gameObject.GetComponent <ABR_WeaponPickup>().m_weaponType;
         m_turret.SwitchWeapons(weapontype);
         m_weaponPickupEvent.Invoke();
     }
 }
    private GameObject GetBulletPrefabFromType(eBulletType aBulletType)
    {
        switch (aBulletType)
        {
        case eBulletType.Normal: return(mBulletPrefab);

        case eBulletType.Dividable: return(mDividableBulletPrefab);

        default: return(null);
        }
    }
예제 #4
0
    public GameObject CreateBullet(eBulletType type)
    {
        switch (type)
        {
        case eBulletType.NormalBullet:
            return(Instantiate(BulletResource.Instance.GetBullet(eBulletType.NormalBullet.ToString())));

        case eBulletType.SkillSplashBullet:
            return(Instantiate(BulletResource.Instance.GetBullet(eBulletType.SkillSplashBullet.ToString())));

        case eBulletType.SkillWaveBullet:
            return(Instantiate(BulletResource.Instance.GetBullet(eBulletType.SkillWaveBullet.ToString())));
        }
        return(null);
    }
예제 #5
0
        public Bullet(Game i_Game, eBulletType i_BulletType) : base(k_AssteName, i_Game)
        {
            this.m_Type = i_BulletType;

            if (this.m_Type == eBulletType.EnemyBullet)
            {
                this.m_TintColor = Color.Blue;
            }
            else
            {
                this.m_TintColor  = Color.Red;
                k_BulletVelocity *= -1;
            }
            InitOrigins();
            m_Velocity = new Vector2(0, k_BulletVelocity); // TODO: in initialize???
        }
예제 #6
0
        public Bullet(Game i_Game, eBulletType i_BulletType, Sprite i_Shooter) : base(i_Game)
        {
            this.m_AssetName = @"Sprites\Bullet";
            this.m_Type      = i_BulletType;

            if (this.m_Type == eBulletType.EnemyBullet)
            {
                this.m_Tint = Color.Blue;
            }
            else
            {
                this.m_Tint = Color.Red;
            }

            this.InitBulletPosition(i_Shooter);
        }
예제 #7
0
        public Bullet(GameScreen i_GameScreen, eBulletType i_BulletType) : base(k_AssteName, i_GameScreen)
        {
            this.m_Type = i_BulletType;

            if (this.m_Type == eBulletType.EnemyBullet)
            {
                this.Velocity    = this.k_BulletVelocity;
                this.m_TintColor = Color.Blue;
            }
            else
            {
                this.Velocity          = this.k_BulletVelocity * new Vector2(0, -1);
                this.m_TintColor       = Color.Red;
                this.k_BulletVelocity *= -1;
            }

            this.InitOrigins();
        }
예제 #8
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;
    }
예제 #9
0
    public void Init(Entity caster, CSVSkill skillInfo, BulletHitCallback notify = null, Entity target = null)
    {
        m_effect = EffectManager.Instance.GetEffect(skillInfo.BulletEffect);
        if (m_effect == null)
        {
            Log.Error("不存在特效 " + skillInfo.BulletEffect);
            return;
        }
        m_caster = caster;
        m_target = target;
        if (target == null)
        {
            bulletType = eBulletType.Dir;
            m_dir      = m_caster.Forward;
        }
        else
        {
            bulletType = eBulletType.Target;
            m_dir      = (m_target.Pos - m_caster.Pos).normalized;
        }

        m_skillInfo = skillInfo;
        m_hitNotify = notify;
        //子弹存在的时间 = 子弹的攻击距离 / 子弹的飞行速度  小学物理知识  呵呵哒
        duration = m_skillInfo.attackDistance / m_skillInfo.flySpeed;
        m_effect.Init(eDestroyType.Time, duration);
        m_fSpeed = m_skillInfo.flySpeed;

        if (!string.IsNullOrEmpty(m_skillInfo.BulletBindBone))
        {
            m_effect.Pos = GetBonePos(m_caster, m_skillInfo.BulletBindBone);
        }
        else
        {
            m_effect.Pos = new Vector3(m_caster.Pos.x, m_caster.Pos.y + 0.5f, m_caster.Pos.z);
        }

        IsUsing = true;
    }
 public void SpawnBullet(eBulletType aBulletType, float aSpeedIncrement, Vector3 aPosition, Vector3 aDirection)
 {
     SpawnBullet(aBulletType, aSpeedIncrement, aPosition, StaticFunctions.Get2DQuaternionFromDirection(aDirection));
 }