public void OnRespawnCursedTeleporter() { if (_POOL_DEAD_MINIONS.Count > 0 && _CrystalCursedLives > 0) { // Get the character from the end of the dead array GameObject aiObj = _POOL_DEAD_MINIONS[_POOL_DEAD_MINIONS.Count - 1].gameObject; Char_Crystal crystal = aiObj.GetComponent <Char_Crystal>(); // Precaution if (crystal.GetVariantType() == Char_Crystal.CrystalType.Cursed) { // Get random int (min = 0, max = vector array.size -1) int randIndex = Random.Range(0, _TeleportingGateSpawnPositions.Count - 1); // Set crystal's transform to a random spawn position RespawnCrystal(crystal, _TeleportingGateSpawnPositions[randIndex].position); // Deduct 1 from respawn lives counter if (_UnlimitedLivesCursed == false) { _CrystalCursedLives -= 1; } } } }
//-------------------------------------------------------------- // *** RESPAWNING *** public void RespawnCrystal(Char_Crystal crystal, Vector3 position) { // Show the ai's mesh renderer crystal.gameObject.GetComponentInChildren <Renderer>().enabled = true; // Add ai (newAI variable) to active minion array _POOL_ALIVE_MINIONS.Add(crystal.gameObject); // Remove ai (new AI variable) from dead minion array _POOL_DEAD_MINIONS.RemoveAt(_POOL_DEAD_MINIONS.Count - 1); // Set position crystal.transform.position = position; // Set LinearGoToTarget behaviour to be active crystal.GetComponent <LinearGoToTarget>().enabled = true; // Disable agency crystal.GetComponent <NavMeshAgent>().enabled = false; // Disable all behaviours crystal.SetWanderEnable(false); crystal.SetFleeEnable(false); crystal.SetSeekEnable(false); }
public void OnTriggerEnter(Collider other) { if (_Active == true) { // Check against the static collisions if (other.gameObject.tag == "Collision") { // Play impact effect ParticleSystem effect = Instantiate(WeaponManager._pInstance._FireballImpactEffect, gameObject.transform.position, Quaternion.identity); effect.gameObject.GetComponent <DestroyAfterTime>().enabled = true; // Destroy projectile FreeProjectile(); } // Has the fireball collided with the minion's collision? if (other.gameObject.tag == "Enemy") { Char_Crystal crystal = other.gameObject.GetComponent <Char_Crystal>(); // Damage minion crystal.Damage(_Owner.GetOwner(), _ImpactDamage); // Check if minion has been killed if (crystal.GetHealth() <= 0) { // Add to instigator's kill count _Owner.GetOwner()._Player.AddKillCount(); } // Play impact effect ParticleSystem effect = Instantiate(WeaponManager._pInstance._FireballImpactEffect, gameObject.transform.position, Quaternion.identity); effect.gameObject.GetComponent <DestroyAfterTime>().enabled = true; // Destroy fireball FreeProjectile(); // Play impact sound SoundManager._pInstance.PlayFireballImpact(); } // Check against face tree if (other.gameObject.tag == "FaceTree") { FaceTree tree = other.gameObject.GetComponent <FaceTree>(); tree.OnHit(); // Play impact effect ParticleSystem effect = Instantiate(WeaponManager._pInstance._FireballImpactEffect, gameObject.transform.position, Quaternion.identity); effect.gameObject.GetComponent <DestroyAfterTime>().enabled = true; // Destroy fireball FreeProjectile(); // Play impact sound SoundManager._pInstance.PlayFireballImpact(); } } }
public void Start() { // Get all ai prefabs in the scene GameObject[] startupAi = GameObject.FindGameObjectsWithTag("Enemy"); foreach (var ai in startupAi) { // If the AI is meant to be active at the start of the match if (ai.GetComponent <Char_Crystal>().GetSpawningTime() == AiSpawningTime.MatchStart) { // Add to alive pool _POOL_ALIVE_MINIONS.Add(ai.gameObject); // Enable agency ai.GetComponent <NavMeshAgent>().enabled = true; } // Ai is not meant to be active in the arena at match startup else { // Remove the minion from the arena ai.GetComponent <SkinnedMeshRenderer>().enabled = false; ai.transform.position = new Vector3(1000, 1, 1000); // Disable ALL behaviours Char_Crystal crystal = ai.GetComponent <Char_Crystal>(); crystal.SetFleeEnable(false); crystal.SetWanderEnable(false); crystal.SetSeekEnable(false); crystal.SetLinearSeekEnable(false); } // Allocate minor types to their pool if (ai.GetComponent <Char_Crystal>().GetVariantType() == Char_Crystal.CrystalType.Minor) { // Add to minor pool _POOL_MINOR_MINIONS.Add(ai.gameObject); } // Allocate major types to their pool if (ai.GetComponent <Char_Crystal>().GetVariantType() == Char_Crystal.CrystalType.Major) { // Add to major pool _POOL_MAJOR_MINIONS.Add(ai.gameObject); } // Allocate cursed types to their pool if (ai.GetComponent <Char_Crystal>().GetVariantType() == Char_Crystal.CrystalType.Cursed) { // Add to cursed pool _POOL_CURSED_MINIONS.Add(ai.gameObject); } } }
//-------------------------------------------------------------- // *** OBJECT POOL *** public void AddMinion(Char_Crystal wyrm) { // If minion count hasnt reached max capacity yet if (_MinionCount < _MaxMinions) { // Add minion to the shield _PreviousMinionCount = _MinionCount; _MinionCount += 1; Init(); // Deduct movement speed from the player associated to the shield _Owner.SetMovementSpeed(_Owner.GetMovementSpeed() - WeaponManager._pInstance._MovementSpeedSap); } }
public void Init(Char_Crystal Char, PickupType type) { // Check if random if (type == PickupType.Random && DeviceManager._pInstance.GetRandomKilltagList().Count >= 1) { // Generate a random pickup type int i; ///i = Random.Range(0, System.Enum.GetValues(typeof(PickupType)).Length - 1); i = Random.Range(0, DeviceManager._pInstance.GetRandomKilltagList().Count); _Type = DeviceManager._pInstance.GetRandomKilltagList()[i]; } else if (type == PickupType.Random && DeviceManager._pInstance.GetRandomKilltagList().Count < 1) { // Default to the first in the enum list _Type = (PickupType)0; } // Set OnPickupType switch (_Type) { // SHIELD MINION PICKUP case PickupType.AddToShield: { // Set movement speed and apply material GetComponent <MeshRenderer>().material = DeviceManager._pInstance._AddShieldTypeMaterial; _RotationSpeed = DeviceManager._pInstance._AddShieldRotationSpeed; _BobHeight = DeviceManager._pInstance._AddShieldBobHeight; _BobSpeed = DeviceManager._pInstance._AddShieldBobSpeed; break; } // SPEED BOOST case PickupType.SpeedBoost: { // Set movement speed and apply material GetComponent <MeshRenderer>().material = DeviceManager._pInstance._SpeedBoostTypeMaterial; _RotationSpeed = DeviceManager._pInstance._SpeedBoostRotationSpeed; _BobHeight = DeviceManager._pInstance._SpeedBoostBobHeight; _BobSpeed = DeviceManager._pInstance._SpeedBoostBobSpeed; break; } // HEALTHPACK case PickupType.Healthpack: { // Set movement speed and apply material GetComponent <MeshRenderer>().material = DeviceManager._pInstance._HealthpackTypeMaterial; _RotationSpeed = DeviceManager._pInstance._HealthpackRotationSpeed; _BobHeight = DeviceManager._pInstance._HealthpackBobHeight; _BobSpeed = DeviceManager._pInstance._HealthpackBobSpeed; break; } // INVINCIBILITY case PickupType.Invincibility: { // Set movement speed and apply material GetComponent <MeshRenderer>().material = DeviceManager._pInstance._InvincibilityTypeMaterial; _RotationSpeed = DeviceManager._pInstance._InvincibilityRotationSpeed; _BobHeight = DeviceManager._pInstance._InvincibilityRotationSpeed; _BobSpeed = DeviceManager._pInstance._InvincibilityBobSpeed; break; } default: { break; } } // Set reference to the crystal to be used in the meat shield _Crystal = Char; // Tag is now active in the world _Active = true; }
public void CollisionChecks() { // Check against all alive minions foreach (var minion in AiManager._pInstance.GetActiveMinions()) { Char_Crystal crystal = minion.GetComponent <Char_Crystal>(); // Precaution if (crystal != null) { // If minion has valid collision reference set if (crystal.GetCollider() != null) { // Has the fireball collided with the minion's collision? if (_Collision.bounds.Intersects(crystal.GetCollider().bounds)) { // Damage minion crystal.Damage(_Owner.GetOwner(), _Damage); // Play impact sound SoundManager._pInstance.PlayFireballImpact(); // Check if minion has been killed if (crystal.GetHealth() <= 0) { // Add to instigator's kill count _Owner.GetOwner()._Player.AddKillCount(); } // Destroy fireball FreeProjectile(); break; } } } } if (MatchManager._pInstance.GetGameState() == MatchManager.GameState.Phase2) { // Check against all alive players foreach (var necromancer in PlayerManager._pInstance.GetActiveNecromancers()) { // If necromancer has valid collision reference set if (necromancer.GetCollider() != null) { // If it isnt the instigator who is being tested against if (necromancer != _Owner.GetOwner()) { // Check against all meat shield minions associated to the player foreach (GameObject meatMinion in necromancer.GetSpecialWeapon().GetComponent <Wep_Shield>().GetMeatMinionPool()) { Proj_ShieldMinion minion = meatMinion.GetComponent <Proj_ShieldMinion>(); // Has the fireball collided with the minions's collision? if (_Collision.bounds.Intersects(minion.GetCollision().bounds)) { // Damage minion minion.Damage(_Owner.GetOwner(), _Damage); // Play impact sound SoundManager._pInstance.PlayFireballImpact(); // Check if minion has been killed if (minion.GetHealth() <= 0) { // Add to instigator's kill count _Owner.GetOwner()._Player.AddKillCount(); // Remove minion from the shield count (-1) ///meatMinion.GetOwner().GetOwner().GetComponentInChildren<Wep_Shield>().SetMinionCount(meatMinion.getowner) ///meatMinion.GetOwner().GetComponent<Wep_Shield>().SetMinionCount(meatMinion.GetOwner().GetComponent<Wep_Shield>().GetMinionCount() - 1); } // Destroy fireball FreeProjectile(); _Active = false; break; } } // Has the fireball collided with the necromancer's collision? if (_Collision.bounds.Intersects(necromancer.GetCollider().bounds) && _Active) { // Damage necromancer necromancer.Damage(_Owner.GetOwner(), _Damage); // Apply burn necromancer.GetComponent <Char_Geomancer>().SetBurnState(true); // Play impact sound SoundManager._pInstance.PlayFireballImpact(); // Check if necromancer has been killed if (necromancer.GetHealth() <= 0) { // Add to instigator's kill count _Owner.GetOwner()._Player.AddKillCount(); } // Destroy fireball FreeProjectile(); break; } } } } } }