// Update is called once per frame void Update() { var globalGameState = GetComponent<GlobalGameStateBehavior>(); if (globalGameState.GameOver) { if (mouseClick && globalGameState.SecondsSinceGameOver > 10.0f) { globalGameState.LoadIntroLevel(); return; } } else { if (pointHits != null && pointHits.Length > 0) { for (int i = 0; i < pointHits.Length; ++i) { IndexedHit hitInfo = new IndexedHit() { index = i, hit = pointHits[i] }; if (mouseDown) { hitInfo.hit.transform.gameObject.SendMessage("OnMouseDown", hitInfo, SendMessageOptions.DontRequireReceiver); } if (mouseClick) { hitInfo.hit.transform.gameObject.SendMessage("OnMouseClicked", hitInfo, SendMessageOptions.DontRequireReceiver); //print(hitInfo.hit.transform.name + " clicked at " + hitInfo.hit.point); } } } } mouseClick = false; }
public void OnMouseClicked(IndexedHit hitInfo) { if (!alive || hitInfo.index > 1) { return; } PlayDeathSounds(); GetComponent<SpriteAnimator>().currentFrame = 1; GetComponent<SpriteAnimator>().Frames = 1; GetComponent<SpriteAnimator>().SetMaterial(Death); alive = false; // Move to no-raycast zone. gameObject.layer = 2; if (GlobalObjects.GetGlobbalGameState().houseCount == 0) { GlobalObjects.GetGlobbalGameState().addkillscore(); GlobalObjects.GetGlobbalGameState().addkillscore(); } else if (GlobalObjects.GetGlobbalGameState().houseCount > 0) { GlobalObjects.GetGlobbalGameState().addkillscore(); } Vector3 offset; if (runDirection.x > 0) offset = new Vector3(-0.7f, -0.7f, 0); else offset = new Vector3(0.7f, -0.7f, 0); Transform escapee = (Transform) Instantiate(Blood, transform.localPosition + offset, transform.rotation); GlobalObjects.GetGlobbalGameState().ScaleInstance(escapee); }
public void OnMouseClicked(IndexedHit hitInfo) { if (!isSetForDestruction) { IndieDevCount = IndieDevCount - 1; System.Diagnostics.Debug.Assert(location.houseTileInd >= 0); SpawnIndieDevs(1, location.houseTileInd); if (indieDevCount == 0) { isSetForDestruction = true; location.HouseDestroyed(); PlayRandomExplotionSound(); } } }