// Update is called once per frame void Update() { if (collectedFromBlock) { timer += Time.deltaTime; transform.position += new Vector3(0, yVelocityFloatingUp * Time.deltaTime); if (timer >= timeFloatUpFromBlock) { masterHud = GameObject.FindGameObjectWithTag("MasterHUD").GetComponent <MasterHUD>(); masterHud.SendMessage("IncrementCoins", 1); GameObject newEffect = Instantiate(collectEffect); newEffect.transform.position = gameObject.GetComponent <BoxCollider2D>().bounds.center; Destroy(gameObject); } } else { if (!GetComponent <BoxCollider2D>().enabled) { GetComponent <BoxCollider2D>().enabled = true; } } }
void Activated() { masterHud = GameObject.FindGameObjectWithTag("MasterHUD").GetComponent <MasterHUD>(); masterHud.SendMessage("IncrementCoins", 1); GameObject newEffect = Instantiate(collectEffect); newEffect.transform.position = gameObject.GetComponent <BoxCollider2D>().bounds.center; Destroy(gameObject); }
// Use this for initialization void Start() { Inventory.ItemUsed += Inventory_ItemUsed; Inventory.ItemRemoved += Inventory_ItemRemoved; Inventory = GameObject.FindWithTag("Inventory").GetComponent <MasterInventory>(); HUD = GameObject.FindWithTag("HUD").GetComponent <MasterHUD>(); DetectionBar = GameObject.FindWithTag("DetectionBar"); StaminaBar = GameObject.FindWithTag("StaminaBar"); BulletTimeBar = GameObject.FindWithTag("BulletTimeBar"); InventoryPanel = GameObject.FindWithTag("InventoryPanel"); SleepDartHUD = GameObject.FindWithTag("SleepDartHUD"); BuffDeBuffPanel = GameObject.FindWithTag("BuffDebuff"); }
// Use this for initialization public void Start() { if (!transitionaryStage) { MasterHUD masterHud = GameObject.FindGameObjectWithTag("MasterHUD").GetComponent <MasterHUD>(); if (masterHud != null) { masterHud.newSession(); masterHud.time = startingTime; } //New Feature: //Audio Manager Controller Thingy MusicAmbienceController mac = MusicAmbienceController.Instance; if (levelMusic != null) { mac.PlayMusic(levelMusic, levelMusicVolume); } else { mac.StopMusic(); } if (ambience != null) { mac.PlayAmbience(ambience, ambienceVolume); } else { mac.StopAmbience(); } Transform playerTransform = GameObject.FindGameObjectWithTag("Player").transform; if (playerTransform != null) { playerTransform.position = marioPosition.transform.position; SpriteRenderer background = GameObject.Find("Background").gameObject.GetComponent <SpriteRenderer>(); if (background != null) { background.sprite = backgroundImage; } } } else { //Transitionary stages have 'multiple' entrances. We need to know where they came out of. //This will be done somewhere else... int entrance = GameObject.FindObjectOfType <PlayerController>().transitionNumber; Transform playerTransform = GameObject.FindGameObjectWithTag("Player").transform; if (playerTransform != null) { if (transform.childCount > entrance) { Transform entranceTransform = transform.GetChild(entrance); playerTransform.position = entranceTransform.position; } SpriteRenderer background = GameObject.Find("Background").gameObject.GetComponent <SpriteRenderer>(); if (background != null) { background.sprite = backgroundImage; } } //New Feature: //Audio Manager Controller Thingy MusicAmbienceController mac = MusicAmbienceController.Instance; if (levelMusic != null) { mac.PlayMusic(levelMusic, levelMusicVolume); } else { //Leave whats playing, playing. } if (ambience != null) { mac.PlayAmbience(ambience, ambienceVolume); } else { mac.StopAmbience(); } } }