/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private static void SelectMineral(Transform thisTransform, float chance, int mineralType) { //-------------- Random.InitState(System.DateTime.Now.Millisecond); float random = Random.value; if (random > 0 && random <= chance) { GameObject mineral = MineralsPool.GiveMineral(mineralType); if (mineral != null) { mineral.transform.position = thisTransform.position + Random.insideUnitSphere; mineral.SetActive(true); } } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static IEnumerator FakeUpdate(Transform thisTransform, Rigidbody thisRigidbody, GameObject gameObject, LineRenderer thisLineRenderer) { //-------------- int counter0 = 0; thisRigidbody.isKinematic = false; thisRigidbody.detectCollisions = true; thisLineRenderer.enabled = false; //-------------- while (counter0++ < 60) { yield return(delay0); if (thisLineRenderer.enabled == true) { thisLineRenderer.enabled = false; } float sqrMagnitudeToPlayer = Class_Controller.SqrMagnitudeToPlayer(thisTransform); if (sqrMagnitudeToPlayer < 10000) { if (counter0 != 0) { counter0 = 0; } if (thisRigidbody.isKinematic == true) { thisRigidbody.isKinematic = false; } if (thisRigidbody.detectCollisions == false) { thisRigidbody.detectCollisions = true; } if (Class_Controller.mineralsCollector == true && sqrMagnitudeToPlayer < 1600) { thisRigidbody.AddForce((Class_Controller.playerPosition - thisTransform.position).normalized * 800, ForceMode.Acceleration); if (thisLineRenderer.enabled == false) { thisLineRenderer.enabled = true; } thisLineRenderer.SetPosition(0, thisTransform.position); thisLineRenderer.SetPosition(1, Class_Controller.playerPosition); } } else if (sqrMagnitudeToPlayer >= 10000 && sqrMagnitudeToPlayer > 250000) { if (thisRigidbody.isKinematic == false) { thisRigidbody.isKinematic = true; } if (thisRigidbody.detectCollisions == true) { thisRigidbody.detectCollisions = false; } } else if (sqrMagnitudeToPlayer >= 250000) { MineralsPool.TakeMineral(gameObject); } } //-------------- MineralsPool.TakeMineral(gameObject); //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static void RandomMinerals(Transform thisTransform, bool addForce) { //-------------- GameObject minerals = null; int randomMinerals = Random.Range(1, 13); if (randomMinerals == 1) { minerals = MineralsPool.GiveMineral(0); } else if (randomMinerals == 2) { minerals = MineralsPool.GiveMineral(1); } else if (randomMinerals == 3) { minerals = MineralsPool.GiveMineral(2); } else if (randomMinerals == 4) { minerals = MineralsPool.GiveMineral(3); } else if (randomMinerals == 5) { minerals = MineralsPool.GiveMineral(4); } else if (randomMinerals == 6) { minerals = MineralsPool.GiveMineral(5); } else if (randomMinerals == 7) { minerals = MineralsPool.GiveMineral(6); } else if (randomMinerals == 8) { minerals = MineralsPool.GiveMineral(7); } else if (randomMinerals == 9) { minerals = MineralsPool.GiveMineral(8); } else if (randomMinerals == 10) { minerals = MineralsPool.GiveMineral(9); } else if (randomMinerals == 11) { minerals = MineralsPool.GiveMineral(10); } else if (randomMinerals == 12) { minerals = MineralsPool.GiveMineral(11); } if (minerals != null) { minerals.transform.position = thisTransform.position; minerals.SetActive(true); if (addForce == true) { minerals.GetComponent <Rigidbody>().AddForce(thisTransform.forward * 1); } } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void OnCollisionEnter(Collision collision) { //-------------- collisionObject = collision.collider.gameObject; if (dead == false) { if (collisionObject.layer == 12) { if (Class_Interface.powerEnabled == false) { if (collisionObject.CompareTag("Bullet Default")) { currentDamage = 2; } if (collisionObject.CompareTag("Bullet Light")) { currentDamage = 4; counter6 = 40; contusion = true; } if (collisionObject.CompareTag("Bullet Laser")) { currentDamage = 2; } } else { if (collisionObject.CompareTag("Bullet Default")) { currentDamage = 4; counter6 = 3; contusion = true; } if (collisionObject.CompareTag("Bullet Light")) { currentDamage = 7; counter6 = 80; contusion = true; } if (collisionObject.CompareTag("Bullet Laser")) { currentDamage = 3; } } if (collisionObject.CompareTag("Bullet Destroyer")) { currentDamage = 40; counter6 = 30; contusion = true; } injuredByPlayer = true; Damage(); } if (collisionObject.layer == 15) { if (collisionObject.CompareTag("Bullet Default")) { currentDamage = 4; counter6 = 3; contusion = true; injuredByPlayer = false; } Damage(); } } if (collisionObject.gameObject.layer == 25) { TrashForAI.InTrash(gameObject); } //-------------- if (dead == false && collisionObject.layer == 11 && collisionObject != null) { MineralsPool.TakeMineral(collisionObject); if (collisionObject.CompareTag("Mineral 0")) { amountDamage = 0; } } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void OnCollisionEnter(Collision collision) { //-------------- if (Class_Controller.playerAlive == true) { GameObject collisionObject = collision.gameObject; if (collisionObject.layer == 11 && collisionObject != null) { MineralsPool.TakeMineral(collisionObject); if (collisionObject.CompareTag("Mineral 0")) { Class_Interface.lifeCounter++; } else if (collisionObject.CompareTag("Mineral 1")) { Class_Interface.powerCounter++; } else if (collisionObject.CompareTag("Mineral 2")) { Class_Interface.speedCounter++; } else if (collisionObject.CompareTag("Mineral 3")) { Class_Interface.lightningCounter++; } else if (collisionObject.CompareTag("Mineral 4")) { Class_Interface.laserCounter++; } else if (collisionObject.CompareTag("Mineral 5")) { Class_Interface.pulseCounter++; } else if (collisionObject.CompareTag("Mineral 6")) { Class_Interface.maskerCounter++; } else if (collisionObject.CompareTag("Mineral 7")) { Class_Interface.antigravityCounter++; } else if (collisionObject.CompareTag("Mineral 8")) { Class_Interface.tamingCounter++; } else if (collisionObject.CompareTag("Mineral 9")) { Class_Interface.eraserCounter++; } else if (collisionObject.CompareTag("Mineral 10")) { Class_Interface.collapsarCounter++; } else if (collisionObject.CompareTag("Mineral 11")) { Class_Interface.destroyerCounter++; } } if (collisionObject.layer == 13 && collisionObject.CompareTag("Bullet Default")) { SubtractionLife(); } } //-------------- }