void Aiming() { if (Input.GetMouseButton(0)) { if (!gameManager.playerHasGun) { return; } ammoBehaviour.NoAmmo(); ammoBehaviour.SpendAmmo(1); //Debug.Log("Spending ammo..."); var em = Nozzle.emission; em.enabled = true; Vector2 mousePos = Camera.main.ScreenToViewportPoint(Input.mousePosition); Vector3 axis = new Vector3(0, 0, 1); } else { var em = Nozzle.emission; em.enabled = false; } }
void OnParticleCollision(GameObject other) { ammoBehaviour.SpendAmmo(1); //Debug.Log("OnParticleCollision -> " + other); if (other.CompareTag("Acid") || other.gameObject.layer.ToString() == "Acid") { return; } int i = 0; int numCollisionEvents = PrS.GetCollisionEvents(other, collisionEvents); while (i < numCollisionEvents) { switch (ammoType) { case AmmoType.Bouncy: { if (other.CompareTag("Ground") || other.gameObject.layer.ToString() == "Ground") //if the bouncy ink is selected and the particles collide with the ground, instantiate a puddle of the correct type { Vector3 pos = collisionEvents[i].intersection; GameObject newInkPuddle = Instantiate(inkPuddleBouncyPrefab, pos + offsetY, Quaternion.identity); newInkPuddle.transform.up = collisionEvents[i].normal; //transform the instantiated puddle so that it matches the surface it spawns on TODO:Fix the diagonal ink spawning. } if (other.CompareTag("Enemy") || other.gameObject.layer.ToString() == "Enemy") //if the particles hit an enemy... { if (ammoBehaviour.currentBouncyAmmo == 0) { return; //do nothing if there's no ammo TODO: NOT WORKING, prevent ink from being spawned when there's no ammo. } var enemyStats = other.GetComponent <EnemyStats>(); //get the Enemy Stats component of the specific enemy that we hit enemyStats.ApplyDamage(1); //reduce the enemy's HP by 1 if (enemyStats.type == EnemyType.Bouncy) //if the enemy hit is of the bouncy type... { Debug.Log("Enemy is already " + enemyStats.type); return; //do nothing because it doesn't need to change type } if (enemyStats.type == EnemyType.Speedy) //if the enemy hit is of the speedy type... { enemyStats.type = EnemyType.Sticky; //change its type to sticky } if (enemyStats.type == EnemyType.Sticky) //if the enemy hit is of the sticky type... { return; //do nothing because sticky can only be cleared with clear ink } if (enemyStats.type == EnemyType.Clear) //if the enemy hit is of the clear type... { enemyStats.type = EnemyType.Bouncy; //change its type to bouncy return; } } if (other.CompareTag("Puddle") || other.gameObject.layer.ToString() == "Puddle") { return; } i++; break; } case (AmmoType.Speedy): { if (ammoBehaviour.currentSpeedyAmmo == 0) { return; } if (other.CompareTag("Ground") || other.gameObject.layer.ToString() == "Ground") //if the speedy ink is selected and the particles collide with the ground, instantiate a puddle of the correct type { Vector3 pos = collisionEvents[i].intersection; GameObject newInkPuddle = Instantiate(inkPuddleSpeedyPrefab, pos + offsetY, Quaternion.identity); newInkPuddle.transform.up = collisionEvents[i].normal; } if (other.CompareTag("Enemy") || other.gameObject.layer.ToString() == "Enemy") //if the particles hit an enemy... { var enemyStats = other.GetComponent <EnemyStats>(); enemyStats.ApplyDamage(1); if (enemyStats.type == EnemyType.Sticky) //if the enemy hit is of the sticky type... { Debug.Log("Enemy is already " + enemyStats.type + ", can't change it back."); return; //do nothing, sticky can only be cleared with clear ink } if (enemyStats.type == EnemyType.Speedy) //if the enemy hit is of the speedy type... { Debug.Log("Enemy is already " + enemyStats.type); return; //do nothing, it already is the correct type } Debug.Log(enemyStats.type); if (enemyStats.type == EnemyType.Bouncy) //if the enemy hit is of the speedy type... { enemyStats.type = EnemyType.Sticky; //change its type to sticky } else { enemyStats.type = EnemyType.Speedy; //if not, change it to speedy } if (enemyStats.type == EnemyType.Clear) //if the enemy hit is of the clear type... { enemyStats.type = EnemyType.Speedy; //change its type to speedy } } if (other.CompareTag("Puddle") || other.gameObject.layer.ToString() == "Puddle") { return; } i++; break; } case (AmmoType.Sticky): { if (ammoBehaviour.currentStickyAmmo == 0) { return; } if (other.CompareTag("Ground") || other.gameObject.layer.ToString() == "Ground") //if the sticky ink is selected and the particles collide with the ground, instantiate a puddle of the correct type { Vector3 pos = collisionEvents[i].intersection; GameObject newInkPuddle = Instantiate(inkPuddleStickyPrefab, pos + offsetY, Quaternion.identity); newInkPuddle.transform.up = collisionEvents[i].normal; } if (other.CompareTag("Walls") || other.gameObject.layer.ToString() == "Walls") { Vector3 pos = collisionEvents[i].intersection; GameObject newInkPuddle = Instantiate(inkPuddleStickyPrefab, pos + wallOffset, Quaternion.identity); newInkPuddle.transform.up = collisionEvents[i].normal; } if (other.CompareTag("Enemy") || other.gameObject.layer.ToString() == "Enemy") { var enemyStats = other.GetComponent <EnemyStats>(); enemyStats.ApplyDamage(1); enemyStats.type = EnemyType.Sticky; //sticky overwrites every other type if (enemyStats.type == EnemyType.Clear) //if the enemy hit is of the clear type... { enemyStats.type = EnemyType.Sticky; //change its type to sticky return; } } if (other.CompareTag("Puddle") || other.gameObject.layer.ToString() == "Puddle") { return; //do not instantiate a puddle where there already is one TODO: NOT WORKING, fix this to improve performance. } i++; break; } case (AmmoType.Clear): { if (other.gameObject.CompareTag("Puddle") || other.gameObject.layer.ToString() == "Puddle" || other.gameObject.layer.ToString() == "Sticky Puddle") //if we hit a puddle with the clear ink... { Destroy(other.gameObject); //destroy the puddle } if (other.CompareTag("Enemy") || other.gameObject.layer.ToString() == "Enemy") //if the particles hit an enemy... { var enemyStats = other.GetComponent <EnemyStats>(); enemyStats.ApplyDamage(1); //reduce the enemy's HP by 1 Debug.Log(enemyStats.type); enemyStats.type = EnemyType.Clear; //change its type to clear } i++; break; } } } }