public void shoot()
    {
        if (timestamp > Time.time)
        {
            return;
        }
        timestamp = Time.time + cooldown_seconds;

        Vector2 vel = Camera.main.ScreenToWorldPoint(Input.mousePosition) - this.transform.position;

        if (vel.magnitude < 0.05)
        {
            return;
        }

        vel = vel.normalized;

        GameObject obj = BulletPoolManager.getBulletPoolManager().getNewBullet();

        obj.transform.position = bulletSpawn.position;
        obj.transform.rotation = bulletSpawn.rotation;
        obj.SetActive(true);

        BulletDeluxe bullet = obj.GetComponent <BulletDeluxe>();

        bullet.setData(bulletData, this.transform);
        bullet.setVelocity(this.transform.up);

        current_bullet_ID++;
        // StartCoroutine(end_cooldown());
    }
    IEnumerator FireBullet()
    {
        while (true)
        {
            // Check every 0.2 seconds if shoot button is pressed
            yield return(new WaitForSeconds(0.15f));

            if (isFiring)
            {
                _bulletSound.Play();

                //TODO: this code needs to change to user the BulletPoolManager's
                if (bulletType == 1)
                {
                    nextBullet = BulletPoolManager.getInstance().GetBullet();
                    nextBullet.transform.position = bulletSpawn.transform.position;
                    nextBullet.SetActive(true);
                }
                else if (bulletType == 2)
                {
                    nextBullet = BulletPoolManager.getInstance().GetBullet2();
                    nextBullet.transform.position = bulletSpawn.transform.position;
                    nextBullet.SetActive(true);
                }


                //TODO: bullet object.
                //TODO: Ensure you position the new bullet at the bulletSpawn position
            }
        }
    }
Beispiel #3
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Beispiel #4
0
    void Start()
    {
        if (instance != null)
        {
            Debug.Log("Singleton violated for BulletPoolManager");
            Destroy(this);
        }

        instance = this;

        for (int i = 0; i < ToPool.Count; i++)
        {
            List <Bullet> list = new List <Bullet> ();

            for (int x = 0; x < poolSize; x++)
            {
                GameObject go = Instantiate(ToPool [i]);
                list.Add(go.GetComponent <Bullet> ());
                go.SetActive(false);
                go.transform.SetParent(this.transform);
            }

            UnityObjectPool <Bullet> pool = new UnityObjectPool <Bullet> (list.ToArray());
            mapping.Add(ToPool[i].GetComponent <Bullet>().BASE_NAME, pool);
        }
    }
Beispiel #5
0
    void Start()
    {
        // Assign the bullet pool to instance
        bPool = BulletPoolManager.Instance;

        boundary.Top = 2.45f;
    }
    void Start()
    {
        pool = BulletPoolManager.getBulletPoolManager();

        emitterSurrogates = new List <GameObject>();

        StartCoroutine(emit());
    }
Beispiel #7
0
 public static BulletPoolManager getInstance()
 {
     if (instance == null)
     {
         instance = new BulletPoolManager();
     }
     return(instance);
 }
    public static BulletPoolManager GetInstance()
    {
        if (m_Instance == null)
        {
            m_Instance = new BulletPoolManager();
        }

        return(m_Instance);
    }
Beispiel #9
0
 // Use this for initialization
 void Awake()
 {
     if (Instance != null)
     {
         Debug.LogError("BulletPoolManager singleton fail");
         return;
     }
     Instance = this;
 }
Beispiel #10
0
 public void loadLevel(int level)
 {
     States.gamePhaseGuiEnabled = true;
     States.inPauseMenu         = false;
     clearStorage();
     BulletPoolManager.getInstance().initialize();
     MisslePoolManager.getInstance().initialize();
     UnityEngine.SceneManagement.SceneManager.LoadScene(Templates.getInstance().getLevel((int)States.currentCampaign.levels[level]).file);
 }
Beispiel #11
0
 private void Awake()
 {
     if (singleton == null)
     {
         singleton = this;
         return;
     }
     Destroy(this);
 }
Beispiel #12
0
 private void CheckBounds()
 {
     if (transform.position.y >= boundary.Top)
     {
         //TODO: This code needs to change to use the BulletPoolManager's
         //TODO: ResetBullet function which will return the bullet to the pool
         BulletPoolManager.GetInstance().ResetBullet(bulletType, this.gameObject);
     }
 }
    public void STEP()
    {
        if (!exploded)
        {
            foreach (Templates.GunOnShuttle gun in planeTemplate.guns)
            {
                gunTemp = Templates.getInstance().getGunTemplate(gun.gunId);
                if (!gun.ready)
                {
                    if (gun.shotTime + gunTemp.reuse < Time.time)
                    {
                        gun.ready = true;
                    }
                }

                enemy = GameStorage.getInstance().getFriendlyInFireZone(this, gun);
                if (gun.ready && enemy != null)
                {
                    f = Quaternion.Euler(0, 0, -gameObject.transform.eulerAngles.y) * gun.pos;
                    BulletPoolManager.getInstance().shotBullet(BulletSide.ENEMY, new Vector3(transform.position.x + f.x, 5, transform.position.z + f.y), enemy.transform.position, gunTemp.damage, gunTemp.bulletSpeed, gunTemp.gunType, gunTemp.attackRange, gunTemp.bulletDispersion);
                    gun.ready    = false;
                    gun.shotTime = Time.time;
                }
            }

            if (underGas)
            {
                if (Time.time >= lastGasBurned + Abilities.GasParameters.gasReuse)
                {
                    Attacked(Abilities.GasParameters.gasDamage);
                    lastGasBurned = Time.time;
                }
            }

            t       += 1f / 151f;
            x        = (1 - t) * (1 - t) * (1 - t) * point1.x + 3 * (1 - t) * (1 - t) * t * point2.x + 3 * (1 - t) * t * t * point3.x + t * t * t * point4.x;
            y        = (1 - t) * (1 - t) * (1 - t) * point1.y + 3 * (1 - t) * (1 - t) * t * point2.y + 3 * (1 - t) * t * t * point3.y + t * t * t * point4.y;
            tmpVec.x = x;
            tmpVec.y = 5;
            tmpVec.z = y;

            v2tmp1.x = x - transform.position.x;
            v2tmp1.y = y - transform.position.z;
            v2tmp2   = new Vector2(0, 5);
            f1tmp    = (v2tmp2.x * v2tmp1.y - v2tmp2.y * v2tmp1.x);
            f2tmp    = Vector2.Angle(v2tmp2, v2tmp1);
            if (f1tmp > 0)
            {
                f2tmp = (180 - f2tmp) + 180;
            }
            transform.eulerAngles = new Vector3(270, f2tmp, 0);
            fortestAngle          = f2tmp;

            transform.position = tmpVec;
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        _thunderSound = gameController.audioSources[(int)SoundClip.THUNDER];
        _yaySound     = gameController.audioSources[(int)SoundClip.YAY];
        _bulletSound  = GetComponent <AudioSource>();
        bulletPooling = GameObject.FindObjectOfType <BulletPoolManager>();

        // Shoots bullet on a delay if button is pressed
        StartCoroutine(FireBullet());
    }
    // Start is called before the first frame update
    void Start()
    {
        coll = GetComponent <Collision>();
        rb   = GetComponent <Rigidbody2D>();
        anim = GetComponentInChildren <AnimationScript>();
        bp   = GameObject.Find("BulletPoolManager").GetComponent <BulletPoolManager>();

        StartCoroutine(FireBullet());
        SetInputVariables();
    }
Beispiel #16
0
    protected override void Awake()
    {
        base.Awake();
        if (Instance == null)
        {
            Instance = this;
        }

        Statics.Pools[(int)Statics.KnownPools.BULLET] = Instance;
    }
Beispiel #17
0
    protected override void Initialize()
    {
        // 총알 초기화
        BulletPoolManager bulletPoolManager = BulletPoolManager.Instance;

        _rigidbody = this.GetComponent <Rigidbody>();

        _bulletUpdateEvent    = bulletPoolManager.BulletUpdateEvent;
        _bulletCollisionEvent = bulletPoolManager.BulletCollisionEvent;
    }
    //TODO: create a reference to the BulletPoolManager here

    // Start is called before the first frame update
    void Start()
    {
        BulletPool    = new BulletPoolManager(bullet);
        _thunderSound = gameController.audioSources[(int)SoundClip.THUNDER];
        _yaySound     = gameController.audioSources[(int)SoundClip.YAY];
        _bulletSound  = GetComponent <AudioSource>();

        // Shoots bullet on a delay if button is pressed
        StartCoroutine(FireBullet());
    }
Beispiel #19
0
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
     }
 }
Beispiel #20
0
    private void Start()
    {
        IBullet currentBullet = CurrentBulletGOPrefab.GetComponent <IBullet>();

        if (currentBullet == null)
        {
            return;
        }
        BulletID      = currentBullet.ID;
        bulletManager = FindObjectOfType <BulletPoolManager>();
    }
    //TODO: create a structure to contain a collection of bullets

    // Start is called before the first frame update
    public static BulletPoolManager getInstance()
    {
        if (bulletManager == null)
        {
            GameObject bullet  = GameObject.Find("Player").GetComponent <PlayerController>().bullet;
            GameObject bullet2 = GameObject.Find("Player").GetComponent <PlayerController>().bullet2;
            bulletManager = new BulletPoolManager(bullet, bullet2);
        }

        return(bulletManager);
    }
 // Turns an instance of this script into a singleton for public use
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        // Assign the bullet pool to instance
        bPool = BulletPoolManager.Instance;

        _thunderSound = gameController.audioSources[(int)SoundClip.THUNDER];
        _yaySound     = gameController.audioSources[(int)SoundClip.YAY];
        _bulletSound  = GetComponent <AudioSource>();

        // Shoots bullet on a delay if button is pressed
        StartCoroutine(FireBullet());
    }
Beispiel #24
0
 private void Awake()
 {
     if (!instance)
     {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     else if (instance != this)
     {
         Destroy(this.gameObject);
     }
 }
    private void CheckBounds()
    {
        if (transform.position.y >= boundary.Top)
        {
            //TODO: This code needs to change to use the BulletPoolManager's
            //TODO: ResetBullet function which will return the bullet to the pool
            //refers to resetbullet
            BulletPoolManager.ResetBullet();

            Destroy(this.gameObject);
        }
    }
 // Use this for initialization
 void Start()
 {
     bulletManager = FindObjectOfType <BulletPoolManager> ();
     if (GetComponent <Player>() != null)
     {
         player = GetComponent <Player>();
     }
     else if (GetComponent <Enemy>() != null)
     {
         enemy = GetComponent <Enemy>();
     }
 }
Beispiel #27
0
    void Start()
    {
        pool          = BulletPoolManager.getBulletPoolManager();
        event_manager = BulletEventManager.getBulletEventManager();
        player        = GameObject.FindGameObjectWithTag("Player").transform;
        interrogation = InterrogationManager.getInterrogationManager();

        if (startTestingCard)
        {
            PlayCard(testCard, emitter, -1);
        }

        interrogation.startPressEvent += stopCurrentCard;
    }
    static public BulletPoolManager GetInstance()
    {
        if (Singleton == null)
        {
            Singleton = new GameObject("Container").AddComponent <BulletPoolManager>();
            for (int i = 0; i < BulletAmt; i++)
            {
                BulletContainer temp = new BulletContainer(BulletsInPool, Instantiate(BulletPrefab), false);
                BulletsInPool++;
                GetInstance().Bullets.Add(temp);
            }
        }

        return(Singleton);
    }
 private void Accelerates()
 {
     GameStorage.getInstance().processExplode();
     if (States.WorldRunning)
     {
         GameStorage.getInstance().AccelerateAllUnits();
         BulletPoolManager.getInstance().stepAllBullets();
         MisslePoolManager.getInstance().MoveRocketsAndThorpeds();
         if (Time.time >= GameStorage.getInstance().getEndTime())
         {
             States.WorldRunning = false;
             GameStorage.getInstance().toggleOnStepEnd();
         }
     }
 }
Beispiel #30
0
    public void Init(PlayerController playerController)
    {
        _playerController   = playerController;
        _bulletPoolManager  = BulletPoolManager.Instance;
        _bulletAttributeMgr = _bulletPoolManager.GetAttributeMgr();
        _magicalMuzzle      = GameObject.Find("Weapons").GetComponent <MagicalMuzzle>();

        _magicalMuzzle.AddEvent(Single);
        // 유도
//         _bulletPoolManager.AddEvent(GuidedBullet);
//         // 관통
//         _bulletPoolManager.GetCollisionTags().Remove("Monster");
//         // 바운싱
//         _bulletPoolManager.GetCollisionTags().Remove("Wall");
//         _bulletPoolManager.AddEvent(BouncingBullet);
    }
 // Use this for initialization
 void Start()
 {
     m_gameproperties = m_instance.GetComponent<GameProperties>();
     m_inputmanager = gameObject.AddComponent<InputManager>();
     m_gamestatemanager = gameObject.AddComponent<GameStateManager>();
     m_commandmanager = gameObject.AddComponent<CommandManager>();
     m_loadmanager = gameObject.AddComponent<LoadManager>();
     m_enemymanager = gameObject.AddComponent<EnemyManager>();
     m_guimanager = gameObject.AddComponent<GUIManager>();
     m_bulletPoolManager = gameObject.AddComponent<BulletPoolManager>();
     m_enemyPoolManager = gameObject.AddComponent<EnemyPoolManager>();
     m_gamestatemanager.Init();
 }
	public static BulletPoolManager getInstance()
	{
		if(instance==null)
			instance=new BulletPoolManager();
		return instance;
	}