void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } if (!GameManager.GetInstance()) { SwitchScene switchScene = this.gameObject.AddComponent <SwitchScene> (); switchScene.loadScene("Start"); } else { difficultyLevel = GameManager.GetInstance().GetLevel("Brainbow"); scoreGoals = new Dictionary <int, int> () { { 1, 8 }, { 2, 12 }, { 3, 20 }, { 4, 20 }, { 5, 20 } }; } }
private int nextDest = 0; /*!< The index of the next avaliable position in the ColorDetector */ /** * \brief Adds a food to the ColorDetector * @param food: A GameObject representing the food that was just matched */ public void AddFood(GameObject food) { food.transform.position = destinations[nextDest++].position; if (BrainbowGameManager.GetInstance().IsRunningTutorial()) { nextDest = 0; } }
void OnMouseDown() { BrainbowGameManager.GetInstance().timer.AddTime(5.0f); SoundManager.GetInstance().PlaySFXClip(waterClip); CreatePlusFive(); BrainbowGameManager.GetInstance().waterBottleList.Remove(gameObject); Destroy(gameObject); }
public void StartTutorial() { if (!BrainbowGameManager.Instance.GetGameStarted()) { brainbowManager = BrainbowGameManager.Instance; tutorialCoroutine = StartCoroutine(RunTutorial()); } }
void FixedUpdate() { if (moving && !BrainbowGameManager.GetInstance().isGameOver()) { Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z); Vector3 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset; gameObject.GetComponent <Rigidbody2D>().MovePosition(curPosition); } }
void OnMouseDown() { if (isActive) { // gameObject.transform.Find("Subtitle").GetComponent<SubtitlePanel>().Display("Water", waterClip); BrainbowGameManager.GetInstance().timer.AddTime(5.0f); nextSpawnTime = Time.time + Random.Range(5, 10); Despawn(); } }
void OnMouseDown() { if (!busy && !BrainbowGameManager.GetInstance().isGameOver() && GameManager.GetInstance().GetIsInputAllowed()) { moving = true; BrainbowGameManager.GetInstance().SetActiveFood(this); offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z)); //Display the food's name //move this into game manager with method call BrainbowGameManager.GetInstance().ShowSubtitles(gameObject.name, gameObject.GetComponent <Food>().clipOfName); } }
// Update is called once per frame void Update() { if (!isActive && BrainbowGameManager.GetInstance().GameStarted() && Time.time > nextSpawnTime) { isActive = true; despawnTime = Time.time + Random.Range(5, 10); Spawn(); } if (isActive && Time.time > despawnTime) { Despawn(); } }
void OnTriggerEnter2D(Collider2D other) { if (BrainbowGameManager.GetInstance()) { if (BrainbowGameManager.GetInstance().isGameOver()) { if (other.tag == "Player") { gameObject.SetActive(false); SoundManager.GetInstance().PlaySFXClip(BrainbowGameManager.GetInstance().munchSound); } } } }
void Awake() { if(instance == null) { instance = this; } else if(instance != this) { Destroy(gameObject); } difficultyLevel = GameManager.GetInstance().GetLevel("Brainbow"); scoreGoals = new Dictionary<int, int>() { {1, 8}, {2, 12}, {3, 20} }; }
void OnMouseUp() { if (GameManager.GetInstance().GetIsInputAllowed()) { if (!busy && moving) { busy = true; RaycastHit2D hit = Physics2D.Raycast(transform.position, -Vector2.up, 1.0f, BrainbowGameManager.GetInstance().foodLayerMask); if (hit.collider != null && hit.collider.gameObject.GetComponent <ColorDetector> ().color == GetComponent <Food> ().color) { BrainbowGameManager.GetInstance().SetActiveFood(null); ColorDetector detector = hit.collider.gameObject.GetComponent <ColorDetector> (); SoundManager.GetInstance().PlaySFXClip(BrainbowGameManager.GetInstance().correctSound); Vector3 oldPos = gameObject.transform.position; detector.AddFood(gameObject); if (Random.value < 0.3f) { int randomClipIndex = Random.Range(0, BrainbowGameManager.GetInstance().correctMatchClips.Length); SoundManager.GetInstance().PlayVoiceOverClip(BrainbowGameManager.GetInstance().correctMatchClips [randomClipIndex]); } gameObject.GetComponent <Collider2D> ().enabled = false; BrainbowGameManager.GetInstance().Replace(gameObject); } else { MoveBack(); int randomClipIndex = Random.Range(0, BrainbowGameManager.GetInstance().wrongMatchClips.Length); SoundManager.GetInstance().PlayVoiceOverClip(BrainbowGameManager.GetInstance().wrongMatchClips [randomClipIndex]); } } moving = false; busy = false; Debug.Log("About to hide sutitle"); StartCoroutine(HideSubtitle()); } }
void Start() { BrainbowGameManager.GetInstance().waterBottleList.Add(gameObject); }
void CreatePlusFive() { GameObject plusFive = Instantiate(plus5, transform.position, Quaternion.identity, BrainbowGameManager.GetInstance().mainCanvas.transform); Destroy(plusFive, 2.5f); }
void MoveBack() { gameObject.transform.position = GetOrigin().position; SoundManager.GetInstance().PlaySFXClip(BrainbowGameManager.GetInstance().incorrectSound); }
IEnumerator HideSubtitle() { yield return(new WaitForSeconds(0.5f)); BrainbowGameManager.GetInstance().HideSubtitles(); }