private void Awake() { Mesh = gameObject.GetComponentInChildren <MeshRenderer>(); WarCollectable = this.gameObject.GetComponent <WarCollectable>(); WarCollectable.OnCollected += CoinCollected; WarCollectable.OnDestroyed += CoinDestroyed; WarCollectable.OnHide += WarCollectable_OnHide; WarCollectable.OnShow += WarCollectable_OnShow; }
public override void FirstUpdate() { base.FirstUpdate(); PlayerScript.Instance.transform.rotation = Quaternion.identity; PlayerScript.Instance.transform.position = PlayerStartPosition; BombEmitterScript = BombEmitter.GetComponent <BombEmitter>(); PlayerScript.Instance.ShowKinect(1); GetComponentInChildren <ChildScript>().StartFollowing(PlayerScript.Instance.transform); // Find Collectables not collected CollectablesDroppedCount = 0; var allCollectables = GameObject.Find("WarCollectables").GetComponentsInChildren <WarCollectable>(); Collectables = allCollectables.Where(c => c.Collected == false).ToArray(); Debug.Log("Items to collect: " + Collectables.Length); if (Collectables.Length < 1) { // Start over if nothing left Collectables = allCollectables; Debug.Log("Revised Items to collect: " + Collectables.Length); foreach (var collectable in Collectables) { collectable.Collected = false; collectable.Hide(); } } LastCollectable = Collectables[Collectables.Length - 1]; // todo: delete this //LastCollectable = Collectables[0]; // Watch for last collectable collected or destroyed LastCollectable.OnCollected += CollectablesDone; LastCollectable.OnDestroyed += CollectablesDone; // Delay so this happens after invitation so we can get the player start X this.Delay(0.2f, () => { // Start dropping stuff BombEmitter.GetComponent <BombEmitter>().StartBombing(); DropCollectable(); }); // When the player dies PlayerScript.Instance.OnDeath += WarScene_OnDeath; }