private IEnumerator Burst(float _killTime) { for (int i = 0; i < 3; i++) { if (m_PaintballPool == null) { m_PaintballPool = PoolSystem.FindPool("Projectile"); } GameObject burst = m_PaintballPool.m_NextObject; burst.transform.position = m_Gun.position; burst.transform.rotation = m_Gun.rotation; burst.SetActive(true); float accuracy = 2.5f; CalculateAccuracy(ref burst, accuracy); int randomSound = Random.Range(0, fireClips.Length); aSource.PlayOneShot(fireClips[randomSound]); burst.GetComponent <Rigidbody>().AddForce(burst.transform.forward * m_Force); burst.GetComponent <Projectile>().SetOwner(gameObject, (CompareTag(GameManager.TeamEnum.Blue.ToString())) ? GameManager.TeamEnum.Blue : GameManager.TeamEnum.Red); yield return(new WaitForSeconds(BURST_FIRE_RATE)); } yield return(null); }
// Use this for initialization void Start() { trackedObject = viveCntrl.GetComponent <SteamVR_TrackedObject>(); m_Pool = PoolSystem.FindPool("Projectile"); g_Pool = PoolSystem.FindPool("Grenade"); m_Stock = GetComponentInChildren <StockAttributes>(); m_Barrel = GetComponentInChildren <BarrelAttributes>(); activeBarrelList.Add(m_BarrelParts[0]); activeStockList.Add(m_StockParts[0]); m_BarrelIndex = 0; m_StockIndex = 0; //manager = GetComponentInChildren<PartManager>(); Commander = GetComponent <SquadCommand>(); aSource = GetComponent <AudioSource>(); isShooting = false; m_Ammunition = 200; m_Part = Part.Barrel; m_StateMachine = WeaponState.Weapon; reset = false; resetParts = true; feedback.enabled = false; }
void Init() { pathTime = animTime = 0; rotationDir = RallyPos = PosMem = storedPos = Vector3.zero; nameCheckPoint = GameObject.Find("NameCheck").GetComponent <Collider>(); rifle = GetComponentInChildren <FindRifle>().gameObject; anim = GetComponentInChildren <Animator>(); aSource = GetComponent <AudioSource>(); visibleObjects = new List <GameObject>(); nameReady = false; //Get Components m_SkinRenderer = GetComponentInChildren <SkinnedMeshRenderer>(); m_HealthManager = GetComponentInChildren <HealthManager>(); m_NavAgent = GetComponent <UnityEngine.AI.NavMeshAgent>(); m_NavAgent.updateRotation = false; m_Camera = GetComponentInChildren <Camera>(); m_PaintballPool = PoolSystem.FindPool("Projectile"); //set the health according to what enemy type it is if (isLeader) { m_HealthManager.SetEntityToMinionLeader(); transform.localScale = new Vector3(0.75f, 0.75f, 0.75f); } else { m_HealthManager.SetEntityToMinion(); } currentState = States.Patrol; //set things to false SwitchOff(); //set things to zero gunTimer = targetLockTimer = pathTime = 0; //floats target = null; //precalculations m_FireRate = 60.0f / m_FireRate; sinTurn = Mathf.Sin(30.0f); cosTurn = Mathf.Cos(30.0f); }
public void Fire() { anim.SetBool("Attack", true); anim.SetBool("Walk", false); rifle.transform.LookAt(target.position); int randomSound; GameObject obj; Transform objTransform; if (isLeader) { StartCoroutine("Burst", KILL_TIME); } else { if (m_PaintballPool == null) { m_PaintballPool = PoolSystem.FindPool("Projectile"); } obj = m_PaintballPool.m_NextObject; if (obj == null) { return; } objTransform = obj.transform; objTransform.position = m_Gun.position; objTransform.rotation = m_Gun.rotation; obj.SetActive(true); randomSound = Random.Range(0, fireClips.Length); if (fireClips[randomSound] != null) { aSource.PlayOneShot(fireClips[randomSound]); } obj.GetComponent <Rigidbody>().AddForce(m_Gun.forward * m_Force); obj.GetComponent <Projectile>().SetOwner(gameObject, (CompareTag(GameManager.TeamEnum.Blue.ToString())) ? GameManager.TeamEnum.Blue : GameManager.TeamEnum.Red); } }