void CreateInstance() { if (instance == null) { instance = this; } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("PipePoint")) { Debug.Log("Collided with pipe"); connectedPipe = collision.transform.parent.GetComponent <PipeScript>(); countCount++; } }
private void CalculateTargetScale(GameObject pipe) { currentPipe = pipe.GetComponent <PipeScript>(); if (holding) { if ((lastPipeIndex >= currentPipe.index)) { updateScale = currentPipe.targetScale; } else { Fail(); } } lastPipeIndex = currentPipe.index; }
// Use this for initialization void Start() { //Getting game difficulty difficulty = GameSettings.Difficulty; print(difficulty); if (difficulty == 0) //assuring difficulty is set { difficulty = 1; } //starting audio source.Play(); source2.Play(); valveStatus = new bool[valves.Length]; //setting the correct game timer if (difficulty == 1) { timeLeft = 300.0f; } else if (difficulty == 2) { timeLeft = 200.0f; } else if (difficulty == 3) { timeLeft = 100.0f; } for (int x = 0; x < valves.Length; x++) { PipeScript pipe = valves[x].GetComponent <PipeScript>(); valveStatus[x] = pipe.isOpen; } fadeScreen.GetComponent <Animator>().SetBool("isFading", false); }
void SpawnPipe() { float y = maxMinOffset * Mathf.Sin(Time.time); holeSize = Random.Range(minHoleSize, maxHoleSize); PipeScript newPipeUp = Instantiate(pipeUp, transform.position, Quaternion.Euler(0, 0, 180)); newPipeUp.transform.position += Vector3.up * (holeSize / 2); newPipeUp.transform.position += Vector3.up * y; newPipeUp.gameObject.SetActive(true); PipeScript newPipeDown = Instantiate(pipeDown, transform.position, Quaternion.identity); newPipeDown.transform.position += Vector3.down * (holeSize / 2); newPipeDown.transform.position += Vector3.up * y; newPipeDown.gameObject.SetActive(true); PointScript newPoint = Instantiate(point, transform.position, Quaternion.identity); newPoint.gameObject.SetActive(true); newPoint.SetSize(Camera.main.orthographicSize * 2); newPoint.transform.position += Vector3.up * y; }