Exemple #1
0
        // Use this for initialization
        public void Awake()
        {
            rarityParticleEffectPool = GameObject.FindGameObjectWithTag("RarityParticleEffectPool").GetComponent <Managers.PoolManager>();
            _playerBase = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerBase>();
            myRigidbody = GetComponent <Rigidbody>();
            enviornment = GameObject.FindGameObjectWithTag("Enviornment");

            GameObject particleffectObj = rarityParticleEffectPool.GetAvailableObj();

            Items.RarityParticleEffectScript particleEffect = null;
            if (particleffectObj != null)
            {
                particleEffect = particleffectObj.GetComponent <Items.RarityParticleEffectScript>();
            }
            else
            {
                rarityParticleEffectPool.SpawnAmmount(100, true);
                particleffectObj = rarityParticleEffectPool.GetAvailableObj();
                particleEffect   = particleffectObj.GetComponent <Items.RarityParticleEffectScript>();
            }
            particleEffect.ActivateRarityEffect(this);
        }
Exemple #2
0
        public void ThrowAway(Vector3 pos, Vector3 throwDirection)
        {
            itemPickedUp            = false;
            myRigidbody.useGravity  = true;
            myRigidbody.constraints = RigidbodyConstraints.None;
            itemCollider.SetActive(true);
            transform.position = pos;
            transform.SetParent(enviornment.transform);
            float twistX = Random.Range(-1, 1);
            float twistZ = Random.Range(-1, 1);

            this.gameObject.SetActive(true);

            myRigidbody.AddForceAtPosition(throwDirection, pos - new Vector3(twistX, -1, twistZ), ForceMode.Force);

            Items.RarityParticleEffectScript particleEffect = rarityParticleEffectPool.GetAvailableObj().GetComponent <Items.RarityParticleEffectScript>();
            if (particleEffect != null)
            {
                particleEffect.ActivateRarityEffect(this);
            }
            //myRigidbody.AddExplosionForce(200, pos, 2);
        }