Exemplo n.º 1
0
    void Awake()
    {
        _audioSource = GetComponent <AudioSource>();

        _pool = new PoolBullet(_bulletPrefab, _poolCapacity);

        GameObject.FindGameObjectWithTag(ArcadeGameObjectTags.UnityPool.ToString()).GetComponent <UnityPool>().AddPool(_pool);

        _pool.Add(_poolCapacity);
    }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            PoolBullet pool = PoolBullet.Instance;
            pool.SetMaxPoolSize(10);

            
            while (true)
            {
                Bullet bullet = pool.AcquireBullet();
                bullet.Move(new Point());
                pool.ReleaseBullet(bullet);
            }
        }
Exemplo n.º 3
0
    GameObject InstantiatePrefab()
    {
        GameObject obj = Instantiate(Bullet, transform.position, Quaternion.identity);

        obj.transform.parent = transform;
        PoolBullet nhobj = obj.AddComponent <PoolBullet>();

        nhobj.SetBulletInactive();
        if (isServer)
        {
            NetworkServer.Spawn(obj);
        }

        return(obj);
    }
Exemplo n.º 4
0
    public void SendArrow()
    {
        if (hit2D != null)
        {
            PoolBullet arrow = PoolManager.Instance.UsePoolObject(poolBullet, bulletSpawnTransform.position, bulletSpawnTransform.rotation) as PoolBullet;
            AudioManager.Instance.PlaySound(effectSound);
            arrow.damageableLayer = damageableLayer;
            arrow.damage          = damage;
            float distance = Vector2.Distance(transform.position, hit2D.GetComponent <Transform>().position);

            if (hit2D.gameObject.GetComponent <Enemy>().isWalking)
            {
                arrow.rb.velocity = new Vector2(0.5f, yOfVelocity) * (multiplierOfVelocity + (distance / diveder) - multiplierOfEnemySpeed * hit2D.gameObject.GetComponent <Enemy>().speed);
            }
            else
            {
                arrow.rb.velocity = new Vector2(0.5f, yOfVelocity) * (multiplierOfVelocity + (distance / diveder));
            }
        }
    }