Beispiel #1
0
 protected void Start()
 {
     satelite     = GetComponent <Satelite>();
     angle        = Random.value * 360f;
     bulletParent = Hierarchy.GetComponentWithTag <BulletParent>();
     isReloading  = new Timer(reloadDuration);
 }
Beispiel #2
0
    public override void Shoot()
    {
        if (animator != null && currentTarget != null && currentTarget.GetComponent <EnemyParent>().blood > 0)
        {
            if (barrelList != null && barrelList.Count > 0)
            {
                for (int i = 0; i < barrelList.Count; i++)
                {
                    MusicManager.Play(MusicType.cannonBatteryLv1);
                    animator.SetTrigger("shootTrigger");
                    tempParticleSystem.SetActive(false);
                    tempParticleSystem.SetActive(true);

                    Transform  tt     = barrelList[i].transform;
                    GameObject bullet = Instantiate(Resources.Load("CannonBullet")) as GameObject;
                    bullet.transform.position = tt.position;
                    //bullet.transform.localScale = Vector3.one;
                    BulletParent bp = bullet.GetComponent <BulletParent>();
                    bp.target = currentTarget;
                    bp.speed  = 30;
                    bp.damage = attackValue / barrelList.Count;
                }
            }
        }
    }
    protected virtual void CreateAmmo()     //this is allowed to be overwritten, but has a default method that should be used in most cases
    {
        Transform bulletPrefab = bulletInfo.ammoPrefab;

        //create a bullet for each spot in the array
        for (int i = 0; i < bulletInfo.maxAmmoCount; i++)
        {
            Transform newBullet = Instantiate(bulletPrefab, new Vector3(0, -10, 0), barrelEnd.rotation, bulletParent);
            ammoList.Add(newBullet);
            newBullet.gameObject.GetComponentInChildren <Rigidbody>().gameObject.SetActive(false);            //create a bullet from the prefab

            //if we have a TeamManager then add it to the team list
            teamManager?.AddTeamObject(newBullet.GetComponentInChildren <Rigidbody>(true).transform);

            if (teamManager == null)             //if not, set it to Team Blue
            {
                newBullet.GetComponentInChildren <Rigidbody>(true).transform.tag = TeamManager.Team_Blue;
            }

            BulletParent bulletScript = newBullet.gameObject.GetComponentInChildren <BulletParent>(true);            //get the BulletParent script from the prefab, pass it the UI and initialize it
            bulletScript.bulletSliderManager = bulletSliderManager;
            bulletScript.Initialize();
        }

        //reset the currentBullets
        ammoCount = bulletInfo.maxAmmoCount;
    }
 public override void Shoot()
 {
     if (shooting)
     {
         if (currentTarget != null && currentTarget.GetComponent <EnemyParent>().blood > 0)
         {
             if (barrelList != null && barrelList.Count > 0)
             {
                 for (int i = 0; i < barrelList.Count; i++)
                 {
                     Transform  tt     = barrelList[i].transform;
                     GameObject bullet = Instantiate(Resources.Load("GatlinGunBullet")) as GameObject;
                     bullet.transform.position = tt.position;
                     BulletParent bp = bullet.GetComponent <BulletParent>();
                     bp.target = currentTarget;
                     bp.speed  = 100;
                     bp.damage = attackValue / barrelList.Count;
                 }
                 MusicManager.Play(MusicType.gatlinGunBatteryLv1);
             }
         }
     }
 }