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; }
private void SetDifficulty() { DifficultySetting difficulty = difficultySettings[currentDifficulty]; switch (SceneManager.GetActiveScene().name) { case "WarScene": FindObjectOfType <WarScene>().CollectableLifeSeconds = difficulty.CollectableLifeSeconds; BombEmitter bombEmitter = FindObjectOfType <BombEmitter>(); bombEmitter.BombIntervalSeconds = difficulty.BombInterval; bombEmitter.BombDrag = difficulty.BombDrag; foreach (BombScript bomb in FindObjectsOfType <BombScript>()) { bomb.GetComponent <Rigidbody2D>().drag = difficulty.BombDrag; } break; case "SeaScene": SeaScene sea = FindObjectOfType <SeaScene>(); sea.StartingWaveStrength = difficulty.StartingWaveSize; sea.EndingWaveStrength = difficulty.EndingWaveSize; LandScene.FindObjectsOfTypeAll <EnemyGun>()[0].ShootDelay = difficulty.ShootDelay; break; case "LandScene": Searchlight light = LandScene.FindObjectsOfTypeAll <Searchlight>()[0]; //Find it even if it is disabled light.SweepSpeed = difficulty.SearchlightSpeed; light.FramesVisibleForLoss = difficulty.SearchlightTime; GuardScript guard = LandScene.FindObjectsOfTypeAll <GuardScript>()[0]; guard.FramesVisibleForLoss = difficulty.GuardTime; guard.WalkSpeed = difficulty.GuardSpeed; LandScene.FindObjectsOfTypeAll <FenceCut>()[0].CutSpeed = difficulty.CutFenceSpeed; break; default: Debug.Log("Can't change difficulty in this scene"); break; } ShowText(); DiffText.color = DifficultyTextColours[currentDifficulty]; switch (currentDifficulty) { case 0: DiffText.text = "E"; break; case 1: DiffText.text = "N"; break; case 2: DiffText.text = "H"; break; case 3: DiffText.text = "EX"; break; default: Debug.LogError("...What just happened?"); break; } }