Пример #1
0
    public void shootBullet(EnemyShotType shotType)
    {
        GameObject bulletClone;

        bulletClone = (GameObject)Instantiate(Resources.Load(bulletPath), this.transform.position, Quaternion.identity);

        if (shotType == EnemyShotType.directRandom)
        {
        }

        if (shotType == EnemyShotType.directPlayer)
        {
            //set bullet end distance
            bulletClone.GetComponent <bulletCheckDistance> ().setDistance(mbulletDistance);
            //子弹的damage + 速度 +方向
            setBulletProperty(bulletClone);
            shotScript = bulletClone.GetComponent <bulletGetSpeed> ();
            setBulletSpeed(shotScript, mbulletSpeed);
        }
        if (shotType == EnemyShotType.random)
        {
            bulletClone.GetComponent <bulletCheckDistance> ().setDistance(mbulletDistance);
            //子弹的damage + 速度 +方向
            setBulletProperty(bulletClone);
            shotScript = bulletClone.GetComponent <bulletGetSpeed> ();
            setRandomSpeed(shotScript, mbulletSpeed);
        }
    }
Пример #2
0
 public void shootMultiBullets(EnemyShotType shotType, int bulletAmount, int angle)
 {
     //子弹是向着主角方向发散型
     if (shotType == EnemyShotType.directDiverging)
     {
         Vector3 playerPos = getPlayerPosExact();
         for (int i = 1; i <= bulletAmount; i++)
         {
             GameObject bulletClone = (GameObject)Instantiate(Resources.Load(bulletPath), this.transform.position, Quaternion.identity);
             bulletClone.GetComponent <bulletCheckDistance> ().setDistance(mbulletDistance);
             setBulletProperty(bulletClone);
             shotScript = bulletClone.GetComponent <bulletGetSpeed> ();
             setDirectionDivergingSpeed(shotScript, mbulletSpeed, playerPos, i, angle);
         }
     }
 }