public void landSpawning() { Debug.Log("In landSpawning function"); int numGolems = (int)(Random.Range(1, 3) + 0.5f); int numShrabs = 1; for (int i = 1; i <= numGolems; i++) { RandomEnemySpawn.spawnEnemyWithinRadius(EnemyType.Brawler, golemPrefab, 2.0f, instantiationPoint.position, 1.0f); } for (int i = 1; i <= numShrabs; i++) { RandomEnemySpawn.spawnEnemyWithinRadius(EnemyType.Shrab, shrabPrefab, 4.0f, instantiationPoint.position, 1.0f); } landSpawingCheck = false; }
// Update is called once per frame void Update() { player = RandomEnemySpawn.getClosestPlayer(transform, RandomEnemySpawn.playerCenterList).gameObject; float disToPlayer = Vector3.Distance(transform.position, player.transform.position); transform.rotation = Quaternion.LookRotation(rb.velocity); //Debug.Log("Player position is " + player.transform.position); if (disToPlayer <= idleBehaviorRadius && disToPlayer > attackRadius) { neutralMovement(); } else if (disToPlayer <= attackRadius) { //center = player.GetComponent<SkinnedMeshRenderer>().bounds.center; //speed = GetComponent<StatManager>().shly.enemyStats.getSpeed(); speed = GetComponent <StatManager>().shly.enemyStats.getSpeed(); bullChargeSpeed = GetComponent <StatManager>().shly.getBullChargeSpeed(); //transform.LookAt(player.transform); if (shly == null) { shly = GetComponent <StatManager>().shly; } if (shly.getAggregateNum() > 1) { if (!shly.sprainActive) { bullCharge(player.transform.position); } } else { if (!shly.sprainActive) { PelletDrop(); } } shly.sprain(sprainEffectRadius); } else { rb.velocity = Vector3.zero; } }
public void spawnEnemy(EnemyType[] types, Dictionary <GameObject, int> enemiesToSpawn, float radius) { Debug.Log("In spawnEnemy function"); if (enemyStats.getHealth() <= enemyStats.getMaxHealth() * 0.1) { //Spawn code for other enemies - Anshul Task 6 float maxHPProportion = Random.Range(1, 101) * 0.01f; int j = 0; foreach (KeyValuePair <GameObject, int> kvp in enemiesToSpawn) { EnemyType typeToPass = types[j]; for (int i = 0; i < kvp.Value; i++) { RandomEnemySpawn.spawnEnemyWithinRadius(typeToPass, kvp.Key, radius, referenceObject.transform.position, maxHPProportion); } j++; } } }
// Update is called once per frame void Update() { player = RandomEnemySpawn.getClosestPlayer(transform, RandomEnemySpawn.playerCenterList).gameObject; //Logic for running behaviors, ground pound is a close range attack, charge is mid-range attack and projectile launch is far range-attack float playerDist = Vector3.Distance(player.transform.position, transform.position); if (playerDist < groundPoundRange) { //mainCamera.GetComponent<cameraSoundManager>().enemyInRange = true; groundPound(); } else if (playerDist > groundPoundRange && playerDist < chargeRange) { //mainCamera.GetComponent<cameraSoundManager>().enemyInRange = true; charge(); } else if (playerDist > chargeRange && playerDist < shootRange) { //mainCamera.GetComponent<cameraSoundManager>().enemyInRange = true; setShootTrigger(); } else if (playerDist > shootRange && playerDist < noActionRange) { //mainCamera.GetComponent<cameraSoundManager>().enemyInRange = false; Debug.Log("Golem is too far from player to enact behavior"); idleTimer -= Time.deltaTime; if (idleTimer <= 0) { targetPoint = randomPointInRadius(); searchForNewIdlePoint = false; idleTimer = oIdleTimer; } if (!searchForNewIdlePoint) { sphericalMovement(targetPoint, speed); } if (Vector3.Distance(transform.position, targetPoint) <= 0.8f) { rb.velocity = Vector3.zero; searchForNewIdlePoint = true; } } }
// Update is called once per frame void Update() { player = RandomEnemySpawn.getClosestPlayer(transform, RandomEnemySpawn.playerList).gameObject; diveSpeed = GetComponent <StatManager>().flyingKam.getDiveSpeed(); transform.LookAt(player.transform); //Ensures they're always looking at the player Vector3 playerPos = player.transform.position; Vector3 enemyPos = transform.position; //Debug.Log("Player position is " + playerPos); //Debug.Log("Distance between player and kamikaze is " + Vector3.Distance(playerPos, enemyPos)); if (Vector3.Distance(playerPos, enemyPos) < distance) { anim.SetTrigger("Dive"); Debug.Log("Player is at " + playerPos); r.velocity = (playerPos - enemyPos).normalized * diveSpeed; //Kamikazes move towards player when player is within certain distance } else { neutralMovement(); } }
// Update is called once per frame void Update() { player = RandomEnemySpawn.getClosestPlayer(transform, RandomEnemySpawn.playerList).gameObject; leftPlayerLeg = RandomEnemySpawn.getClosestPlayer(transform, leftLegList).gameObject; rightPlayerLeg = RandomEnemySpawn.getClosestPlayer(transform, rightLegList).gameObject; shrabMovementSpeed = GetComponent <StatManager>().shrabMovementSpeed; float raycastDistancePlayer = Vector3.Distance(transform.position, findRaycastPointOnSphere(player.transform.position)); //transform.LookAt(player.transform); if (raycastDistancePlayer <= attackRadius) { pincerMovement(); } else if (raycastDistancePlayer <= idleRadius && raycastDistancePlayer > attackRadius) { idleTimer -= Time.deltaTime; if (idleTimer <= 0) { targetPoint = randomPointInRadius(); searchForNewIdlePoint = false; idleTimer = oIdleTimer; } if (!searchForNewIdlePoint) { shrabSphereMovement(targetPoint); } if (Vector3.Distance(transform.position, targetPoint) <= 0.5f) { rb.velocity = Vector3.zero; searchForNewIdlePoint = true; } } else if (raycastDistancePlayer > idleRadius) { rb.velocity = Vector3.zero; //rb.freezeRotation = true; } RaycastHit hit; int layerMask = ~LayerMask.GetMask("Self"); if (Physics.Raycast(transform.position + transform.position.normalized * 10.0f, (planet.transform.position - transform.position).normalized, out hit, Mathf.Infinity, layerMask)) { transform.position = hit.point; } /* if(Vector3.Distance(transform.position, player.transform.position) > 3.0f) * { * waterShurikenAttack(); * } * /* * foreach(Shrab s in Shrab.shrabList) * { * if(Vector3.Distance(s.referenceObject.transform.position, transform.position) < pincerMovementRange) * { * shrabsInRange.Add(s); * } * } * int numShrabs = 0; * foreach(Shrab s in shrabsInRange) * { * numShrabs += s.getNumShrabs(); * } * if(numShrabs >= 12) * { * pincerMovement(); * } */ }
// Update is called once per frame void Update() { //Assumes that the timers are in the order presented above /* * shlyTimer -= Time.deltaTime; * if(shlyTimer <= 0 && activateShly) * { * shly.SetActive(true); * activateShly = false; * } * * kamikazeTimer -= Time.deltaTime; * if (kamikazeTimer <= 0 && activateKamikaze) * { * kamikaze.SetActive(true); * //kamikaze.GetComponent<PlayerAttack>().enabled = true; * activateKamikaze = false; * } * * starshipTimer -= Time.deltaTime; * if(starshipTimer <= 0 && activateStarship) * { * Instantiate(starship, starshipInstantionPoint, Quaternion.identity); * starshipTimer = oStarshipTimer; * //starship.GetComponent<StarshipEndgame>().enabled = true; * //activateStarship = false; * } * shrab1Timer -= Time.deltaTime; * if (shrab1Timer <= 0 && activateShrab1) * { * shrab1.SetActive(true); * activateShrab1 = false; * } * * shrab2Timer -= Time.deltaTime; * if (shrab2Timer <= 0 && activateShrab2) * { * shrab2.SetActive(true); * activateShrab2 = false; * } * * shrab3Timer -= Time.deltaTime; * if (shrab3Timer <= 0 && activateShrab3) * { * shrab3.SetActive(true); * activateShrab3 = false; * } * * shrab4Timer -= Time.deltaTime; * if (shrab4Timer <= 0 && activateShrab4) * { * shrab4.SetActive(true); * activateShrab4 = false; * } * * golemTimer -= Time.deltaTime; * if(golemTimer <= 0 && activateGolem) * { * golem.SetActive(true); * activateGolem = false; * * } */ shlyTimer -= Time.deltaTime; if (shlyTimer <= 0 && activateShly) { for (int i = 1; i <= 3; i++) { RandomEnemySpawn.spawnEnemyWithinRadius(EnemyType.Shly, shlyPrefab, 20.0f, player.transform.position + new Vector3(0f, 30f, 0f), 1.0f); } shlyTimer = oShlyTimer; } shrabTimer -= Time.deltaTime; if (shrabTimer <= 0 && activateShrab) { for (int i = 1; i <= 10; i++) { RandomEnemySpawn.spawnEnemyWithinRadius(EnemyType.Shrab, shrabPrefab, 20.0f, player.transform.position + new Vector3(0f, 30f, 0f), 1.0f); } shrabTimer = oShrabTimer; } kamikazeTimer -= Time.deltaTime; if (kamikazeTimer <= 0 && activateKamikaze) { for (int i = 1; i <= 3; i++) { RandomEnemySpawn.spawnEnemyWithinRadius(EnemyType.FlyingKamikaze, kamikazePrefab, 20f, player.transform.position + new Vector3(0f, 30f, 0f), 1.0f); } kamikazeTimer = oKamikazeTimer; } golemTimer -= Time.deltaTime; if (golemTimer <= 0 && activateGolem) { for (int i = 1; i <= 4; i++) { RandomEnemySpawn.spawnEnemyWithinRadius(EnemyType.Brawler, golemPrefab, 20f, player.transform.position + new Vector3(0f, 30f, 0f), 1.0f); } golemTimer = oGolemTimer; } }