public static void spiderWakeUp() { GameScript.gameState = GameScript.GameStates.walking; SpecialEffectsScript.StopAllAudio(); SpecialEffectsScript.PlayAlertSound(); spiderAnimation.clip = spiderAnimation.GetClip("taunt"); spiderAnimation.Play(); }
void Awake() { // Register singleton if (INSTANCE != null) { Debug.LogError("Too many instances of SpecialEffects!"); } INSTANCE = this; }
void OnCollisionEnter(Collision col) { if (col.gameObject.tag == "Zid" && GameScript.gameState != GameScript.GameStates.wallHit) { SpecialEffectsScript.PlayAttackSound(); WallScript.disableWall(); GameScript.gameState = GameScript.GameStates.wallHit; GameScript.advanceLevel(0.1f); Debug.Log("Lovit"); } }
void Update() { foreach (Touch touch in Input.touches) { // -- Drag // ------------------------------------------------ if (touch.phase == TouchPhase.Began) { // Store this new value if (!trails.ContainsKey(touch.fingerId)) { Vector3 position = Camera.main.ScreenToWorldPoint(touch.position); position.z = 0; // Make sure the trail is visible GameObject trail = SpecialEffectsScript.MakeTrail(position); if (trail != null) { Debug.Log(trail); TrailHistory trailHistory = new TrailHistory(trail); trails.Add(touch.fingerId, trailHistory); } } } else if (touch.phase == TouchPhase.Moved) { // Move the trail if (trails.ContainsKey(touch.fingerId)) { TrailHistory trailHistory = trails[touch.fingerId]; Vector3 position = Camera.main.ScreenToWorldPoint(touch.position); position.z = 0; // Make sure the trail is visible trailHistory.trail.transform.position = position; trailHistory.addPosition(position); } } else if (touch.phase == TouchPhase.Ended) { // Clear known trails if (trails.ContainsKey(touch.fingerId)) { TrailHistory trailHistory = trails[touch.fingerId]; // Let the trail fade out Destroy(trailHistory.trail, trailHistory.trail.GetComponent <TrailRenderer> ().time); trails.Remove(touch.fingerId); } } } }
public static void killSpider() { //Instance.StartCoroutine(Instance.startRunning()); //Instance.StartCoroutine (Instance.scrollPlaneCo(0.14f)); Instance.StopAllCoroutines(); Instance.bootEndPosition.z = Instance.spider.transform.position.z; SpecialEffectsScript.StopAllAudio(); Instance.StartCoroutine(Instance.slideCamera(Instance.endCameraPosition, 0.6f)); Instance.boot.SetActive(true); Instance.boot.transform.position = Instance.bootStartPosition; Instance.boot.transform.eulerAngles = new Vector3(0, 270, 0); Instance.StartCoroutine(Instance.crushSpider()); gameState = GameStates.dying; SpecialEffectsScript.PlayDieSound(0.6f); }
public void gameButtonClick() { Debug.Log("gameButtonClicked: " + GameScript.gameState); switch (GameScript.gameState) { case GameScript.GameStates.sleeping: GameScript.spiderWakeUp(); gameText.text = "Scared?\nTap to block the spider"; endText.SetActive(false); GameScript.Instance.startLevel(1); break; case GameScript.GameStates.stopped: GameScript.spiderStartSleeping(); gameText.text = "Touch to wake up the spider"; break; case GameScript.GameStates.walking: if (GameScript.currentLevel < 5) { GameScript.createWall(); gameText.text = ""; } else { gameText.text = "Touch to restart"; endText.SetActive(true); GameScript.spiderStartSleeping(); GameScript.Instance.startLevel(6); } break; case GameScript.GameStates.dead: gameText.text = "Touch to wake up the spider"; GameScript.positionCameraAtStart(); GameScript.Instance.boot.SetActive(false); GameScript.spiderStartSleeping(); SpecialEffectsScript.PlaySleepingSound(); break; } }
void Awake() { instance = this; }
void Update() { // -- Pinch // ------------------------------------------------ // Works only with two fingers if (Input.touchCount == 2) { var finger1 = Input.GetTouch(0); var finger2 = Input.GetTouch(1); if (finger1.phase == TouchPhase.Began && finger2.phase == TouchPhase.Began) { this.pinchFinger1 = finger1; this.pinchFinger2 = finger2; } // On move, update if (finger1.phase == TouchPhase.Moved || finger2.phase == TouchPhase.Moved) { float baseDistance = Vector2.Distance(this.pinchFinger1.position, this.pinchFinger2.position); float currentDistance = Vector2.Distance(finger1.position, finger2.position); // Purcent float currentDistancePurcent = currentDistance / baseDistance; // Create an effect between the fingers if it doesn't exists if (vortex == null) { Vector3 finger1position = Camera.main.ScreenToWorldPoint(this.pinchFinger1.position); Vector3 finger2position = Camera.main.ScreenToWorldPoint(this.pinchFinger2.position); // Find the center between the two fingers Vector3 vortexPosition = Vector3.Lerp(finger1position, finger2position, 0.5f); vortex = SpecialEffectsScript.MakeVortex(vortexPosition); } // Take the base scale and make it smaller/bigger vortex.transform.localScale = Vector3.one * (currentDistancePurcent * 1.5f); } } else { // Pinch release ? if (vortex != null) { // Create explosions!!!!!!!!!!! for (int i = 0; i < 10; i++) { var explosion = SpecialEffectsScript.MakeExplosion(vortex.transform.position); explosion.transform.localScale = vortex.transform.localScale; } // Destroy vortex Destroy(vortex.gameObject); } // Look for all fingers for (int i = 0; i < Input.touchCount; i++) { Touch touch = Input.GetTouch(i); // -- Tap: quick touch & release // ------------------------------------------------ if (touch.phase == TouchPhase.Ended && touch.tapCount == 1) { // Touch are screens location. Convert to world Vector3 position = Camera.main.ScreenToWorldPoint(touch.position); // Effect for feedback SpecialEffectsScript.MakeExplosion((position)); } else { // -- Drag // ------------------------------------------------ if (touch.phase == TouchPhase.Began) { // Store this new value if (trails.ContainsKey(i) == false) { Vector3 position = Camera.main.ScreenToWorldPoint(touch.position); position.z = 0; // Make sure the trail is visible GameObject trail = SpecialEffectsScript.MakeTrail(position); if (trail != null) { Debug.Log(trail); trails.Add(i, trail); } } } else if (touch.phase == TouchPhase.Moved) { // Move the trail if (trails.ContainsKey(i)) { GameObject trail = trails[i]; Camera.main.ScreenToWorldPoint(touch.position); Vector3 position = Camera.main.ScreenToWorldPoint(touch.position); position.z = 0; // Make sure the trail is visible trail.transform.position = position; } } else if (touch.phase == TouchPhase.Ended) { // Clear known trails if (trails.ContainsKey(i)) { GameObject trail = trails[i]; // Let the trail fade out Destroy(trail, trail.GetComponent <TrailRenderer>().time); trails.Remove(i); } } } } } }
void Awake() { instance = this; }
public void startLevel(int level) { if (level < 6) { GUI.Instance.gameText.text = "Scared?\nTap to block the spider"; } Debug.Log(level); currentLevel = level; Instance.StopAllCoroutines(); SpecialEffectsScript.StopAllAudio(); if (level > 1 && level < 6) { SpecialEffectsScript.PlayWallFallingSound(); } switch (level) { case 0: boot.SetActive(false); spider.transform.localScale = Vector3.one; spider.transform.position = spiderStartPosition; break; case 1: gameState = GameStates.walking; boot.SetActive(false); spider.transform.localScale = Vector3.one; Instance.StartCoroutine(startWalking(1.0f)); Instance.StartCoroutine(Instance.scrollPlaneCo(0.07f, 1.0f)); SpecialEffectsScript.PlayWalkinSound(); SpecialEffectsScript.PlayAlertSound(); StartCoroutine(slideCamera(startCameraPosition, 0.5f)); break; case 2: gameState = GameStates.walking; spider.transform.localScale = Vector3.one * 1.1f; Instance.StartCoroutine(startWalking()); Instance.StartCoroutine(Instance.scrollPlaneCo(0.07f)); SpecialEffectsScript.PlayWalkinSound(); break; case 3: gameState = GameStates.walking; spider.transform.localScale = Vector3.one * 1.2f; Instance.StartCoroutine(startWalking()); Instance.StartCoroutine(Instance.scrollPlaneCo(0.07f)); SpecialEffectsScript.PlayWalkinSound(); break; case 4: gameState = GameStates.walking; spider.transform.localScale = Vector3.one * 1.3f; Instance.StartCoroutine(startRunning()); Instance.StartCoroutine(Instance.scrollPlaneCo(0.14f)); SpecialEffectsScript.PlayWalkinSound(); SpecialEffectsScript.PlayRunningSound(); break; case 5: gameState = GameStates.walking; spider.transform.localScale = Vector3.one * 1.4f; Instance.StartCoroutine(Instance.scrollPlaneCo(0.14f)); Instance.StartCoroutine(startRunning()); SpecialEffectsScript.PlayWalkinSound(); SpecialEffectsScript.PlayRunningSound(); break; case 6: killSpider(); break; } }
// Use this for initialization void Start() { SpecialEffectsScript.PlaySleepingSound(); gameButton.SetActive(false); }