public void SpawnNewEnemy(GameObject enemyObject) { // If the next spawn point in line is not aleady taken if (m_queueEnd.m_occupant == null && m_queueEnd.m_reserved == false) { GameObject enemy = StaticPool.GetObj(enemyObject); enemy.transform.position = m_queueEnd.transform.position; enemy.GetComponent <Enemy>().Reset(); if (m_queueEnd.gameObject.name == "Waypoint 0" || m_queueEnd.gameObject.name == "Waypoint 1" || m_queueEnd.gameObject.name == "Waypoint 2") { enemy.GetComponent <Enemy>().inWarmUp = true; enemy.GetComponent <Enemy>().ChooseBallPowerUp(); } // (GameObject)Instantiate( enemyObject, m_queueEnd.transform.position, Quaternion.identity ); // Turn colliders off when they spawn in the line Collider[] colliders = enemy.GetComponentsInChildren <Collider>(); foreach (Collider col in colliders) { col.enabled = false; } m_queueEnd.m_occupant = enemy; FaceNextWaypoint(enemy.transform, m_queueEnd); // If we aren't at the end of the queue, move the spawnpoint one position back if (m_queueEnd.m_previous != null) { m_queueEnd = m_queueEnd.m_previous; } } }
void Shoot() { // print("Shoot - " + prefabProjectile.ToString()); GameObject obj = StaticPool.GetObj(prefabProjectile); obj.GetComponent <ProjectileTwo>().Reset(gameObject, transform.forward); StartCoroutine("Cooldown", cooldownTime); }
IEnumerator Cooldown(float time) { shotReady = false; yield return(new WaitForSeconds(time / 2f)); GameObject obj = StaticPool.GetObj(prefabProjectile); obj.GetComponent <ProjectileTwo>().Reset(gameObject, Camera.main.transform.forward); yield return(new WaitForSeconds(time / 2)); m_animator.SetLayerWeight(1, 0f); m_animator.SetBool("Shoot", false); shotReady = true; }
public void MeleeAttack() { foreach (Stats enemy in enemiesToMeleeAttack) { enemy.TakeDamager(3); } if (enemiesToMeleeAttack.Count > 0) { GetComponent <Stats>().StartShake(); GameObject temp = StaticPool.GetObj(slashFXPrefab); temp.transform.SetParent(lookTransform.transform, false); temp.transform.localPosition = (new Vector3(0f, 1f, -1f)); temp.transform.Rotate(0f, 180f, 0f); temp.GetComponentInChildren <ParticleSystem>().enableEmission = true; attackLightFX.SetActive(true); StartCoroutine(Lightflicker(0.4f)); } }
private void GetMissedShotParticle(Vector3 newPos, Vector3 newRotation) { if (missedShotParticle != null) { // Get paricle and set position/rotation GameObject particle = StaticPool.GetObj(missedShotParticle); particle.transform.position = newPos; particle.transform.rotation = Quaternion.LookRotation(newRotation); // Play the particle ParticleSystem pSystem = particle.GetComponentInChildren <ParticleSystem>(); pSystem.Play(); StartCoroutine(ResetParticle(particle)); } else { Debug.LogWarning(gameObject.name + "'s missing a prefab for it's public particle variable."); } }
/// <summary> /// Gets the hit particle from the static pool, sets it to the right position, and then gets rid of it when it's done playing. /// </summary> /// <param name="newPos">New position.</param> /// <param name="newRotation">New rotation.</param> private void GetHitParticle(Vector3 newPos, Vector3 newRotation, GameObject particlePrefab) { if (particlePrefab != null) { // Get paricle and set position/rotation GameObject particle = StaticPool.GetObj(particlePrefab); particle.transform.position = newPos; particle.transform.rotation = Quaternion.LookRotation(newRotation); // Play the particle ParticleSystem pSystem = particle.GetComponentInChildren <ParticleSystem>(); pSystem.Play(); //networkView.RPC( "NetworkPlayParticle", RPCMode.Others, particle.networkView.viewID ); StartCoroutine(ResetParticle(particle)); } else { Debug.LogWarning(gameObject.name + "'s missing a prefab for it's public particle variable."); } }
void Shoot(ShootData shootData) { // print (shootData.start); Vector3 startPos = shootData.start; if (DebugMode.CENTERSPAWN) { startPos.z -= Camera.main.transform.position.z / 4f; // - nearPlane.transform.position.z; } GameObject ball = StaticPool.GetObj(ballPrefabDict[shootData.color.ToString()]); ball.GetComponent <Ball>().Reset(); ball.transform.position = Camera.main.ScreenToWorldPoint(startPos + Camera.main.transform.forward * 4f); ball.GetComponent <Rigidbody>().velocity = Vector3.zero; PlayerManager.IncreaseShots(shootData.color); Vector3 shootDir = shootData.dest - ball.transform.position; shootDir.Normalize(); if (DebugMode.FORWARDMODE) { ball.GetComponent <Rigidbody>().AddForce(Vector3.forward * (shootStrength + DebugMode.FORCECHANGE)); } else { ball.GetComponent <Rigidbody>().AddForce(shootDir * (shootStrength + DebugMode.FORCECHANGE)); } // Debug.Break(); ball.GetComponent <Rigidbody>().useGravity = DebugMode.GRAVITY; // Destroy (ball, 10f); }
void Throw() { GameObject ball = StaticPool.GetObj(ballPrefab); gameMan.activeBalls.Add(ball.GetComponent <EnemyBall>()); if (gameMan.gamePhaseInt == 1) { gameMan.warmUpBallsThrown += 1; } playerPos = throwDestination.position; float randomX = Random.Range(0.8f, 1.6f); if (curColumn <= 1) { playerPos += new Vector3(-1f * randomX, 0, 0); } else { playerPos += new Vector3(1f * randomX, 0, 0); } if (curRow != 2) { timeToPlayer = 2 * Vector3.Distance(activeFakeBall.transform.position, playerPos) / 18f; } else { timeToPlayer = 2 * Vector3.Distance(activeFakeBall.transform.position, playerPos) / 12f; } if (gameMan.easyMode == false) { timeToPlayer /= 1.33f; } ball.GetComponent <EnemyBall> ().tutorialBall = false; ball.GetComponent <EnemyBall> ().Reset(); ball.GetComponent <EnemyBall> ().ChoosePowerUp(powerUpChoice); ball.transform.position = activeFakeBall.transform.position; //throwPoint.position; ball.transform.rotation = activeFakeBall.transform.rotation; //ball.GetComponent<EnemyBall> ().SetColliderEnableTime( timeToPlayer * 1f / 4f ); if (ball.transform.childCount > 0) { for (int i = 0; i < ball.transform.childCount; i++) { Destroy(ball.transform.GetChild(i).gameObject); } } GameObject particle = activeFakeBall.transform.GetChild(0).gameObject; particle.transform.parent = ball.transform; particle.transform.localPosition = Vector3.zero; float hVel = Vector3.Distance(playerPos, activeFakeBall.transform.position) / timeToPlayer; //float vVel = (4f + 0.5f * -Physics.gravity.y * Mathf.Pow (timeToPlayer, 2) - throwPoint.position.y) / timeToPlayer; float vVel = (0.5f * Physics.gravity.y * Mathf.Pow(timeToPlayer, 2) + activeFakeBall.transform.position.y - playerPos.y) / -timeToPlayer; Vector3 ballDir = (playerPos - activeFakeBall.transform.position).normalized; ballDir *= hVel; ballDir.y = vVel; // /1.5f; Rigidbody ballRB = ball.GetComponent <Rigidbody> (); ballRB.velocity = ballDir; ballRB.AddTorque(Random.insideUnitSphere * 100f); }