/// <summary> /// Author: Ben Hoffman /// Purpose of method: To check when I am colliding and /// what I am colliding with /// </summary> /// <param name="c"> What I am colliding with </param> void OnCollisionEnter(Collision c) { ColorController cColor = c.gameObject.GetComponent <ColorController>(); if (cColor != null && c.gameObject.tag == "changer" && c.gameObject.layer != gameObject.layer) { colorControls.ChangeColor(cColor.color); } // If the collision is with the death bounds, then make a short pause, and then show the menu // That gives the options to restart or go to the main menu if (c.gameObject.tag == "bounds" || c.gameObject.tag == "triangleOfDoom") { // Reset the players spot gameController.Lose(gameObject); } if (c.gameObject.tag == "winner") { // The player has won! gameController.HitWinBlock(); Destroy(c.gameObject); } if (c.gameObject.tag == "teleporter") { c.gameObject.GetComponent <Teleporter>().Teleport(gameObject); } }
private void FixedUpdate() { //Null check if (ZoneCompleteText != null) { //Update the instance ZoneCompleteText.Update(); //Check to see if we still need the object if (!ZoneCompleteText.DisplayText && m_still_playing) { if (ZoneLevel > 1) { asteroidSpawner.state = AsteroidSpawner.State.Normal; Debug.Log("Normal"); } ZoneCompleteText = null; //Set to null, garbage collector kills this PlanetControllerScript.DeletePlanet(); PlanetControllerScript.SpawnPlanet(); } } if (nextZone) { if (timer.GetHasFinished() == true) { //Update the color ColorScript.ChangeColor(); ResetParticleSystems(); nextZone = false; PlanetControllerScript.SpeedOff(); ZoneCompleteText = new TextManager(CompleteLevelTextObject, particlesystem, FeelGoodWords[Random.Range(0, FeelGoodWords.Capacity)], 0.5f, 4.0f); } else { timer.Update(); } } }
/// <summary> /// Author: Ben Hoffman /// Purpose of method: To switch between the colors /// </summary> private void ChangeColor() { currentColor++; if (currentColor > possibleColors.Length - 1) { currentColor = 0; } colorController.ChangeColor(possibleColors[currentColor]); }
void GoStartPosition() { Vector3 up = new Vector3(0, 0.2f, 0); if (firstPart.activeInHierarchy) { firstPart.SetActive(false); firstPart.transform.position += up; secondPart.transform.localScale = new Vector3(_lastPart.transform.localScale.z, _lastPart.transform.localScale.y, _lastPart.transform.localScale.x); secondPart.transform.position = new Vector3(2.8f, secondPart.transform.position.y, _lastPart.transform.position.z); secondPart.GetComponent <MovePart>().moveSpeed = 1f + (Score.score / 60f) + series; //ChangeColor secondPart.GetComponent <Renderer>().material.color = colorController.ChangeColor(); _currentPart = secondPart; _currentPart.SetActive(true); Score.score++; } else { secondPart.SetActive(false); secondPart.transform.position += up; firstPart.transform.localScale = new Vector3(_lastPart.transform.localScale.z, _lastPart.transform.localScale.y, _lastPart.transform.localScale.x); firstPart.transform.position = new Vector3(_lastPart.transform.position.x, firstPart.transform.position.y, -2.8f); firstPart.GetComponent <MovePart>().moveSpeed = 1f + (Score.score / 60f); //ChangeColor firstPart.GetComponent <Renderer>().material.color = colorController.ChangeColor(); _currentPart = firstPart; _currentPart.SetActive(true); Score.score++; } }
// Use this for initialization void Start() { colorController = GetComponent <ColorController>(); timeSinceLastSwitch = flashSpeed; if (possibleColors != null) { currentColor = 0; colorController.ChangeColor(possibleColors[currentColor]); } else { Debug.Log("You need some colors in that array!"); } }
void Update() { // Quit in ESC if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // ray from camera to screen pont if (Physics.Raycast(ray, out hit) && hit.transform.tag == "Column") { if (startColumn == null) // check first hit { // find start column startColumn = hit.transform; // change ints color to green ColorController column = startColumn.gameObject.GetComponent <ColorController>(); column.ChangeColor((int)ColumnColors.green); } else if (endColumn == null && startColumn != hit.transform) // check second hit (second column not the same with first { // find end column endColumn = hit.transform; // change ints color to red ColorController column = endColumn.gameObject.GetComponent <ColorController>(); column.ChangeColor((int)ColumnColors.red); // Find spownpoints in columns Transform startPoint = startColumn.GetChild(0).transform; Transform endPoint = endColumn.GetChild(0).transform; GameObject newBall = Instantiate(ballPrefub, startPoint.position, Quaternion.identity); // create ball in first spawnpoint newBall.GetComponent <BallMovement>().StartMove(startPoint.position, endPoint.position); // start the ball movement } } } }