private IEnumerator spawnRandomFruit() { while (gameSceneController.gameOver == false) { yield return(new WaitForSeconds(UnityEngine.Random.Range(minSpawnTime, maxSpawnTime))); Vector3 randomPosition = new Vector3( UnityEngine.Random.Range(bounds.min.x, bounds.max.x), UnityEngine.Random.Range(bounds.min.y, bounds.max.y), gameSceneController.transform.position.z); int accumulator; Collider2D[] colliders = Physics2D.OverlapBoxAll(randomPosition, fruitExtents, 0); for (accumulator = 0; accumulator < colliders.Length; accumulator++) { Tagger colTagger = colliders[accumulator].gameObject.GetComponentInParent <Tagger>(); if (colTagger != null && (colTagger.containsCustomTag("obstacle") || colTagger.containsCustomTag("anti fruit aura"))) { break; } } if (accumulator == colliders.Length) { GameObject fruitObject = Instantiate(fruit, randomPosition, Quaternion.identity); fruitObject.GetComponent <Fruit>().exitedScreen += lostFruit; Spawned(); } } }
private void OnCollisionEnter2D(Collision2D collision) { Tagger tagger = collision.gameObject.GetComponent <Tagger>(); if (tagger) { if (gameSceneController.gameOver == false) { if (tagger.containsCustomTag("obstacle")) { head.onChildObstacleHit(); } else if (tagger.containsCustomTag("teleporter")) { head.teleport(); } else if (tagger.containsCustomTag("accelerator")) { head.accelerate(2); } else if (tagger.containsCustomTag("decelerator")) { head.accelerate(0.5f); } } } }
private void OnCollisionExit2D(Collision2D collision) { Tagger tagger = collision.gameObject.GetComponent <Tagger>(); if (tagger != null && tagger.containsCustomTag("obstacle") && !tagger.containsCustomTag("snake part")) { Color original = associatedRenderer.color; associatedRenderer.color = new Color(original.r, original.g, original.b, 1f); } }
private void OnCollisionEnter2D(Collision2D collision) { Tagger tagger = collision.gameObject.GetComponent <Tagger>(); if (tagger != null) { if (tagger.containsCustomTag("outer screen bounds")) { adjustTarget(); } else if (tagger.containsCustomTag("player") && playerTouched == false) { playerTouched = true; } } }
private void OnCollisionExit2D(Collision2D collision) { Tagger tagger = collision.gameObject.GetComponent <Tagger>(); if (tagger) { if (tagger.containsCustomTag("outer screen bounds")) { isOffScreen = true; } else if (tagger.containsCustomTag("inner screen bounds")) { if (isOffScreen == false) { //here would be a code to flash before disappearing, if playtest indicates we should implement that } } } }
private void OnCollisionEnter2D(Collision2D collision) { Tagger tagger = collision.gameObject.GetComponent <Tagger>(); if (tagger != null) { if (aditionalSpeedEnabled == false && tagger.containsCustomTag("outer screen bounds")) { aditionalSpeedEnabled = true; originalDirection = gameSceneController.getRoomDirectionAsVector(); } } }
private void OnCollisionEnter2D(Collision2D collision) { Tagger tagger = collision.gameObject.GetComponent <Tagger>(); if (tagger != null && tagger.containsCustomTag("player")) { if (state == SavePointStates.ReadyToActivate) { GetComponent <AudioSource>().PlayOneShot(activationClip); savedLength = collision.gameObject.GetComponent <PlayerController>().getLength(); Activate(null); } } else if (tagger != null && tagger.containsCustomTag("outer screen bounds")) { if (state == SavePointStates.OffScreen) { state = SavePointStates.OnScreen; adjustTarget(); } } }
private void OnTriggerEnter2D(Collider2D collider) { Tagger tagger = collider.gameObject.GetComponent <Tagger>(); if (tagger) { if (gameSceneController.gameOver == false) { if (tagger.containsCustomTag("obstacle")) { head.onChildObstacleHit(); } } } }
private void OnCollisionExit2D(Collision2D collision) { Tagger tagger = collision.gameObject.GetComponent <Tagger>(); if (tagger) { if (gameSceneController.gameOver == false) { if (tagger.containsCustomTag("outer game bounds")) { die(); } } } }
private void OnCollisionEnter2D(Collision2D collision) { Tagger tagger = collision.gameObject.GetComponent <Tagger>(); if (tagger) { if (gameSceneController.gameOver == false) { if (tagger.containsCustomTag("fruit")) { audioSource.PlayOneShot(getFruitClip); FruitCollected(); Destroy(collision.gameObject); growParts(); } } } }