void DisplayInfiniteAmmo() { Ammo t_ammo = LoadNewAmmo(); t_ammo.m_NewLocalPosition = new Vector2(t_ammo.GetComponent <SpriteRenderer>().bounds.size.x * 1.5f, 0); m_infinitysign = Instantiate(AssetManager.m_Instance.GetPrefab("InfinitySign")).GetComponent <Infinity>(); m_infinitysign.transform.SetParent(m_ammunition[0].transform); m_infinitysign.transform.localScale = new Vector3(1, 1); m_infinitysign.transform.localScale *= m_ammunition[0].GetComponent <SpriteRenderer>().bounds.size.y / m_infinitysign.GetComponent <SpriteRenderer>().bounds.size.y; m_infinitysign.transform.localPosition = new Vector2(t_ammo.GetComponent <SpriteRenderer>().bounds.size.x + m_infinitysign.GetComponent <SpriteRenderer>().bounds.size.x / 2f, 0); }
public void SetColors() { //myGrip.GetComponent<Renderer>().material = colors[myGrip.GetCurPos()]; //myBarrel.GetComponent<Renderer>().material = colors[myBarrel.GetCurPos()]; //myAmmo.GetComponent<Renderer>().material = colors[myAmmo.GetCurPos()]; //Slidertexts(); if (myGrip.swiMod == null) { myGrip.swiMod = myGrip.GetComponent <SwitchModel>(); } if (myBarrel.swiMod == null) { myBarrel.swiMod = myBarrel.GetComponent <SwitchModel>(); } if (myAmmo.swiMod == null) { myAmmo.swiMod = myAmmo.GetComponent <SwitchModel>(); } myGrip.SetModels(); myGrip.swiMod.SetModel(myGrip.GetCurPos()); myBarrel.SetModels(); myBarrel.swiMod.SetModel(myBarrel.GetCurPos()); myAmmo.SetModels(); myAmmo.swiMod.SetModel(myAmmo.GetCurPos()); }
public void Throw() { Ammo thrown = Instantiate(projectilePrefab, origin.position, origin.rotation, origin) as Ammo; //create projectile object Ammo ThrownScript = thrown.GetComponent <Ammo>(); //get component from new projectile thrown.gameObject.layer = gameObject.layer; //assign thrown object to parent objecst layer thrown.from = origin; }
public void FireSpell(Transform origin) { Ammo spell = Instantiate(projectilePrefab, origin.position, origin.rotation, origin) as Ammo; //create projectile object Ammo spellScript = spell.GetComponent <Ammo>(); //get component from new projectile spell.gameObject.layer = gameObject.layer; //assign thrown object to parent objecst layer spellScript.from = origin; }
void OnTriggerEnter(Collider col) //poziva se kada se igrač sudari sa collider-om koji je trigger { if (playing) { if (Scene.currentGameState != Scene.GameState.editing) { if (col.tag == "AI") //ako je objekt s kojim se igrač sudario tipa AI { AI ai = col.GetComponent <AI>(); //referenca za lakše i brže baratanje komponentom if (transform.position.y - cs.height / 2f > col.transform.position.y + col.bounds.size.y / 2f && ai.alive) //ako je igrač iznad AI-jevog trigger collider-a i AI je je živ { ai.gainHp(-1); //ai dobiva štetu (umire jer mu je hp 1) //if (currentJump + 1 > jumps.Length) //resertiraj skokove ako je potrebno // currentJump = 0; anim.CrossFade("JumpPrepare", 0.18f, 0); //napravi jedan skok od AI objekta killingAI = true; //uloga ove varijable je uglavnom ta da se u FixedUpdate-u currentJump opet ne resetira na nulu jer kad igrač skoči ili padne na AI raycast gotovo uvijek detektira da je on došao na tlo jumpPending = false; //poništi trenutni skok (ako uopče ima skoka) //print("ai hit " + currentJump); //korišteno prilikom debug-a } } if (col.gameObject.layer == 4) //ako je objekt voda { if (rig.velocity.y < -0.5) { waterSplashParticle.transform.position = new Vector3(transform.position.x, col.transform.position.y + 0.1f, transform.position.z); //postavi splash objekt na xz poziciju igrača i malo više od vode waterSplashParticle.SetActive(true); } } if (col.gameObject.layer == 11) //ako je objekt municija AI-a { GainHp(-1); Ammo amm = col.gameObject.GetComponent <Ammo>(); //isključi taj ammo amm.StopAllCoroutines(); ParticleSystem ps = amm.GetComponent <ParticleSystem>(); if (ps) { ps.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear); } for (int i = 0; i < amm.transform.childCount; i++) { ps = amm.transform.GetChild(i).GetComponent <ParticleSystem>(); if (ps) { ps.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear); } } if (amm.onCollisionParticles) { amm.onCollisionParticles.SetActive(true); amm.onCollisionParticles.transform.position = (amm.transform.position + transform.position) / 2f; amm.onCollisionParticles.GetComponent <ParticleSystem>().Play(); } amm.gameObject.SetActive(false); } } } }
public void SetAmmoAndShoot(int amount, Transform target, Transform muzzle, float damage, float speed, Material material, int layer) { int counter = 1; for (int i = 0; i < amount; i++) { counter *= -1; Ammo temp = ammoGiver.GiveAmmo(); temp.transform.position = muzzle.position; temp.gameObject.layer = layer; temp.Damage = damage; temp.transform.LookAt(target); temp.transform.Rotate(0, (i + 1) / 2 * 30 * counter, 0); temp.GetComponent <MeshRenderer>().material = material; temp.GetComponent <Rigidbody>().velocity = temp.transform.forward * speed; temp.gameObject.SetActive(true); } }
private void PoolAmmo(WeaponType weaponType, Ammo ammo, int poolSize) { PooledObject pooledObject = ammo?.GetComponent <PooledObject>(); if (null != pooledObject) { ObjectPoolManager.Instance.InitializePool(GetAmmoPool(weaponType), pooledObject, poolSize); } if (null != ammo?.ImpactPrefab) { PoolImpact(weaponType, ammo.ImpactPrefab, poolSize); } }