void OnTriggerEnter(Collider collider) { if (collider.gameObject.tag == Constants.TAG_PLAYER && !collider.gameObject.GetComponent <PlayerBehaviour>().Hitted&& !Statics.Player.GetComponent <Avanzar>().ghost) { Handheld.Vibrate(); if (gameObject.transform.position.x < collider.gameObject.transform.position.x) { collider.gameObject.GetComponent <PlayerBehaviour>().ImpulseH = 10; } else if (gameObject.transform.position.x > collider.gameObject.transform.position.x) { collider.gameObject.GetComponent <PlayerBehaviour>().ImpulseH = -10; } if (collider.gameObject.GetComponent <PlayerBehaviour>().Attack) { Debug.Log("salvado"); Statics.SmashedEnemies++; } else { Hit(); } } else if (collider.gameObject.tag == Constants.TAG_TREE) { if (gameObject.transform.position.x < collider.gameObject.transform.position.x) { ImpulseH = 0.5f; } else if (gameObject.transform.position.x > collider.gameObject.transform.position.x) { ImpulseH = -0.5f; } } }
/// <summary> /// Updates the bottom text description of how to perform the requested trigger gesture. If the triggers are done then it displays the end message /// </summary> private void UpdateTriggerGestureDescription() { string currentDescription = ""; if (_currentInstructionStep < _instructionSteps - 1) { currentDescription = triggerGesturesToPerformInstructions[_currentInstructionStep].howToPerformTriggerDescription[ammountOfTriggersPerformed]; } else if (_currentInstructionStep == _instructionSteps - 1) { Debug.Log("Inside 1"); ApplicationManager.Instance.howToInstructor.HighlightConfirmation(); Debug.Log("Inside 2"); StopResponding(); Debug.Log("Inside 3"); Handheld.Vibrate(); string endMessage = "Great! You are ready to see more features. Tap on the thumbs up icon."; currentDescription = endMessage; Debug.Log("Inside 4"); } ApplicationManager.Instance.howToInstructor.UpdateCurrentInstructionStepOnCanvas(currentDescription); }
/// <summary> /// インジケーターの表示終了 /// 表示要求しているオブジェクトはあちこちから設定できる。 /// 全ての要求が終了しない限りは表示を続ける /// </summary> /// <param name="obj">表示を要求していたオブジェクト</param> public void StopIndicator(System.Object obj) { DecRef(obj); if (objList.Count > 0) { return; } if (!isStarting) { return; } if (IsDeviceIndicator()) { #if UNITY_IPHONE || UNITY_ANDROID && !UNITY_EDITOR Handheld.StopActivityIndicator(); #endif } else { CancelInvoke(); } this.gameObject.SetActive(false); isStarting = false; }
protected override IEnumerator Level_Coroutine() { StartCoroutine(MoveWithBouncing(ball.transform, 3f, waypoints[0].position, waypoints[1].position, 2.5f)); child.transform.LookAt(waypoints[3].position); yield return(WaitAndMove(2f, child.transform, 3f, waypoints[2].position, waypoints[3].position)); ui.SetActive(true); // Wait for user's answer yield return(new WaitUntil(() => _answer != null)); ui.SetActive(false); if (_answer == 0) { StartCoroutine(Move(child.transform, 2.5f, waypoints[3].position, waypoints[6].position)); yield return(WaitAndMove(1f, dumper.transform, 2f, waypoints[4].position, waypoints[5].position)); // Crash Handheld.Vibrate(); resultUi.SetActive(true); resultText.text = "Вас сбил грузовик, будьте внимательны!\n<size=60%>Нельзя выбегать на проезжую часть!</size>"; } else { StartCoroutine(WaitAndMove(1f, dumper.transform, 2f, waypoints[4].position, waypoints[7].position)); yield return(new WaitForSeconds(2.75f)); yield return(Explode(ball.transform, 1.75f, 0.35f)); yield return(new WaitForSeconds(1f)); //Success resultUi.SetActive(true); resultText.text = "Молодец!\n<size=60%>Нельзя выбегать на проезжую часть!</size>"; } }
private void UpdateTogglesOnClick() { if (english.isOn) { LevelManager.CurrentLevelLanguage = Language.English; } else if (brazilianPortuguese.isOn) { LevelManager.CurrentLevelLanguage = Language.BrazilianPortuguese; } if (soundOn.isOn) { SoundManager.Mute = false; } else if (soundOff.isOn) { SoundManager.Mute = true; } if (vibrateOn.isOn) { VibrateManager.Enable = true; if (!vibrateOnce) { Handheld.Vibrate(); vibrateOnce = true; } } else if (vibrateOff.isOn) { VibrateManager.Enable = false; vibrateOnce = false; } }
public void OnToggle() { Handheld.Vibrate(); toggled = !toggled; if (toggled) { Menu_Background.gameObject.SetActive(true); Menubar.DORotate(new Vector3(0, 0, 90), 1); Menu_Background.GetComponent <Image>().DOFade(1, 1F); if (IfMyHive) { Toolbar.DOMoveX(0, 1); return; } Toolbar.DOMoveX(-250, 1); } if (!toggled) { Menu_Background.gameObject.SetActive(false); Menubar.DORotate(Vector3.zero, 1); Menu_Background.GetComponent <Image>().DOFade(0, 1F); Toolbar.DOMoveX(-1000, 1); } }
//Method executed if hit by bullet. Takes damage. public void TakeDamage() { if (!dead) { health -= bulletDamage; healHealth -= bulletDamage; damageEffect.Play(); damageLightEffect.Play(); AudioManager.instance.Play("HitSound", Random.Range(0.9f, 1.1f)); if (ColorDataBase.Vibration()) { Handheld.Vibrate(); } // round is over if (health <= 0) { FindObjectOfType <AudioManager>().Pause("Footsteps"); gameOverState.enabled = true; dead = true; this.GetComponent <PlayerAnimationController>().Die(); } } }
/// <summary> /// Обработка нажатия на вершину /// </summary> void OnMouseUp() { //Проверка: заблокирована ли кнопка для нажатия или нет if (fillingTime == 0 && Controller.shared.state == GameState.playing && !IsAnimationInProcess) { //Проверка: есть ли у вершины видимые ребра для поворота или у нее нет смежных ребер if (CheckForVisibleEdges() && !IsBlocked) { Controller.touchEvent = true; Controller.shared.GetTouch(Index); //Play sound this.transform.parent.GetComponent <Controller>().soundController.GetComponent <GameSoundController>().PopEffect2(); //Время(_time) = расстояние необходимое для поворота (в данном случае 90 градусов) / скорость (speed) _rotationTime = Mathf.Abs(90 / rotationSpeed); //Блокировка кнопки на время анимации IsAnimationInProcess = true; //Разблокирование кнопки по истечению анимации Invoke("Prorogue", 0.6f); //Создание вершины - подложки для анимации Point.setFilledPoint(Index, IsBlocked); objectColor = Filling.GetComponent <SpriteRenderer> ().material.color; fillingTime = 0.5f; } else { if (IsBlocked) { Point.setFilledPoint(Index, IsBlocked); objectColor = Filling.GetComponent <SpriteRenderer> ().material.color; fillingTime = 0.5f; this.transform.parent.GetComponent <Controller>().soundController.GetComponent <GameSoundController>().BadClick(); } Handheld.Vibrate(); } } }
void OnTriggerExit(Collider other) { if (other.tag == "Boundary" || other.tag == "Laser" || other.tag == "FireUp") //Do nothing if the other object is of { // there tags return; } if (other.tag == "Player") // If player then initiate GameOver { Instantiate(playerExplosion, other.transform.position, other.transform.rotation); Handheld.Vibrate(); //Vibrating the mobile device gameController.GameOver(); other.gameObject.SetActive(false); } Instantiate(explosion, transform.position, transform.rotation); // Show Explosion gameController.AddScore(newScoreValue: scoreValue); // Increment Score if (other.tag != "Player") //If not player then destroy both objects { Destroy(other.gameObject); } Destroy(gameObject); }
public void UpdateHealth(float damage) { health += damage; UpdateHealthBar(health); if (health <= 0) { Destroy(this.gameObject); Vector3 effectPosition = transform.position + new Vector3(0, 0, -3); GameObject dEffect = (GameObject)Instantiate(destroyEffectPrefab, effectPosition, destroyEffectPrefab.transform.rotation); Destroy(dEffect, 1f); if (this.GetComponent <Factory>()) { Handheld.Vibrate(); if (this.CompareTag("TeamBlue")) { gameManager.uiManager.DisableShopButton(this.GetComponent <Factory>().shopButton); this.GetComponent <Factory>().shopButton.GetComponent <ShopButton>().factoryDestroyed = true; } else if (this.CompareTag("TeamRed")) { // gameManager.weaponManagerScript.RemoveFactoryFromList(this); } } if (this.GetComponent <Castle>()) { if (this.CompareTag("TeamRed")) //if red castle destroyed you won, else you lost. { PlayerStats.YouWon = true; } gameManager.EndGame(); } } }
// check if a scanned url exists in our database public IEnumerator checkURL(string barCodeValue) { //helper method for coroutines with data - returns response from ARGO servers CoroutineWithData cd = new CoroutineWithData(this, CheckArgoDB(barCodeValue)); yield return(cd.coroutine); _qrid = barCodeValue; //parse response string in to json var responseObject = JSON.Parse(cd.result.ToString()); //give feeback to signal that a barcode has been scanned #if UNITY_ANDROID || UNITY_IOS Handheld.Vibrate(); #endif if (responseObject["url"] == "false") //no matching qrid in database { _OpenVideoPicker(); } else //video found in database //response is not an error - start vuforia { if (cd.result.ToString() != "error") { videoName = responseObject["url"]; currentAspectRatio = responseObject ["aspect_ratio"]; StartCoroutine( StartVuforia() ); } } }
private void OnDestroy() { if (aliveFlag == true && paleFlag == false && Game1Manager.instance.quitSceneFlag == false) { //상하지 않았는데 파괴되면, 먹힌것으로 가정하여 현재 위치에 점수를 띄우고, 점수를 합산한다. Vector3 pos = transform.position; Quaternion angle = Quaternion.Euler(0, 0, 0); if (myScore > 0) { GameObject explode = (GameObject)Instantiate(explosion, pos + new Vector3(0, 2, 1), angle); Sound1Manager.instance.EatGoodSound(); } else { GameObject explode = (GameObject)Instantiate(explosion, pos + new Vector3(0, 0, 1), angle); Game1Manager.instance.badFlag = true; Handheld.Vibrate(); Sound1Manager.instance.EatBadSound(); Bar1Script.instance.TimePanelty(1); } GameObject score = (GameObject)Instantiate(Score, pos, angle); Game1Manager.instance.AddScore(myScore); } }
void OnCollisionEnter2D(Collision2D colision) { #if UNITY_ANDROID Handheld.Vibrate(); #endif if (colision.gameObject.tag == "Player") { AudioSource.PlayClipAtPoint(Player_Hit, this.transform.position); GameObject[] allied = GameObject.FindGameObjectsWithTag("Allied"); foreach (GameObject id in allied) { Destroy(id.gameObject); } } if (colision.gameObject.tag == "Bullet") { AudioSource.PlayClipAtPoint(Player_Hit, this.transform.position); HP--; } }
// Update is called once per frame void Update() { if (ActualLeft < SoundLeft || ActualRight < SoundRight) { SoundLeft = 0; SoundRight = 0; Handheld.Vibrate(); SceneManager.LoadScene("Level 2"); } if (SoundLeft == ActualLeft && SoundRight == ActualRight) { SceneManager.LoadScene("Level 3"); } if (Input.touchCount > 0) { float middle = Screen.width / 2; if (Input.GetTouch(0).phase == TouchPhase.Began) { if (Input.GetTouch(0).position.x < middle && Input.GetTouch(0).phase == TouchPhase.Began) { left(); } if (Input.GetTouch(0).position.x > middle && Input.GetTouch(0).phase == TouchPhase.Began) { right(); } } } }
private IEnumerator PlayMovie() { _isPlaying = true; //直到播完消失 //Handheld.PlayFullScreenMovie(_currFilePath, Color.black, FullScreenMovieControlMode.Hidden, FullScreenMovieScalingMode.AspectFit); //点击消失 Handheld.PlayFullScreenMovie(_currFilePath, Color.black, FullScreenMovieControlMode.CancelOnInput, FullScreenMovieScalingMode.AspectFit); yield return(new WaitForEndOfFrame()); //恢复背景音乐 if (_isCloseBackGroundMusic) { SoundManager.BgmMute = false; } _isPlaying = false; if (_currVedioSet != null) { _currVedioSet.isPlayed = true; ResDataManager.instance.SaveToLocalCache <VideoSet>(_currVedioSet, _currFileName); _currVedioSet = null; } }
private void OnTriggerEnter(Collider _c) { if (_c.gameObject.GetComponent <PlanetAI>()) { Debug.Log("Hit until Planet"); PlanetAI planet = _c.gameObject.GetComponent <PlanetAI>(); PlayerController.Instance.SubtractHealth(planet.Damage); #if UNITY_ANDROID || UNITY_IPHONE Handheld.Vibrate(); #endif planet.IsEnabled = false; StartCoroutine(EffectManager.Instance.PlayExplosion(2.0f, _c.gameObject)); } if (_c.gameObject.GetComponent <NoteAI>()) { Debug.Log("Hit until Notes"); NoteAI note = _c.gameObject.GetComponent <NoteAI>(); if (NoteSequence.Instance.GetCurrentNote() == note.Type) { NoteSequence.Instance.NextNote(); switch (NoteSequence.Instance.GetCurrentNote()) { case NoteType.typeA: EffectManager.Instance.ChangeAuroraWaveColor(Color.cyan); break; case NoteType.typeB: EffectManager.Instance.ChangeAuroraWaveColor(Color.yellow); break; case NoteType.typeC: EffectManager.Instance.ChangeAuroraWaveColor(Color.green); break; case NoteType.typeD: EffectManager.Instance.ChangeAuroraWaveColor(Color.red); break; } note.IsEnabled = false; StartCoroutine(EffectManager.Instance.PlayFireworks(1.0f)); PointsManager.Instance.CurrentScore += PointsManager.Instance.NotePoints; } } }
private IEnumerator LoadAd() { string apiKey = ""; string spotId = ""; #if UNITY_IPHONE apiKey = "308c2499c75c4a192f03c02b2fcebd16dcb45cc9"; spotId = "213208"; #if UNITY_5 Handheld.SetActivityIndicatorStyle(UnityEngine.iOS.ActivityIndicatorStyle.Gray); #else Handheld.SetActivityIndicatorStyle(iOSActivityIndicatorStyle.Gray); #endif #elif UNITY_ANDROID apiKey = "8c278673ac6f676dae60a1f56d16dad122e23516"; spotId = "213206"; Handheld.SetActivityIndicatorStyle(AndroidActivityIndicatorStyle.Small); #endif Handheld.StartActivityIndicator(); yield return(new WaitForSeconds(0.0f)); NendAdInterstitial.Instance.Load(apiKey, spotId); }
private void TextUIShow(GameObject UI, string text, bool vibrate = false) { Text uiText = UI.GetComponentInChildren <Text>(); if (text == "c") // Hide UI if text is "c" for close { UI.SetActive(false); uiText.text = ""; } else { if (vibrate) { Handheld.Vibrate(); } if (UI == errorUI) { text = "ERROR:\n\n" + text; } uiText.text = text; UI.SetActive(true); } }
void TakeDamage() { _lives--; Handheld.Vibrate(); Handheld.Vibrate(); switch (_lives) { case 3: // Everything good :) break; case 2: StartCoroutine(Blink(Health3n, Health2)); break; case 1: StartCoroutine(Blink(Health2n, Health1)); break; default: Die(); break; } }
private void StartScanner() { //initialiseCamera(); BarcodeScanner.StatusChanged += (sender, arg) => { TextHeader.text = "Status: " + BarcodeScanner.Status; }; BarcodeScanner.Scan((barCodeType, barCodeValue) => { BarcodeScanner.Stop(); /* if (TextHeader.text.Length > 250) * { * TextHeader.text = ""; * } */ TextHeader.text += "Found: " + barCodeType + " / " + barCodeValue + "\n"; RestartTime += Time.realtimeSinceStartup + 5f; saveType(barCodeType); saveValue(barCodeValue); //Debug.Log("QR Code? " + isQR); //if (isQR) { QRCode = barCodeValue; } //QRCode = barCodeValue; Debug.Log(barCodeType); Debug.Log(barCodeValue); Debug.Log("Saved Check in Scanner(): " + isQR); Debug.Log("Saved Value in Scanner(): " + QRCode); //ClickCompare(); //This is to compare winning card. Change it to add to userprefs CheckCardExist(); #if UNITY_ANDROID || UNITY_IOS Handheld.Vibrate(); #endif }); }
public void Damage(int amount) { Handheld.Vibrate(); health -= amount; UI.instance.UpdateHealthUi(); //Death process if (health > 0) { return; } Time.timeScale = 0.0f; UI.instance.ShowDeathScreen(); var highscore = Score.instance.score; if (PlayerPrefs.HasKey("Last")) { var last = PlayerPrefs.GetInt("Last"); highscore = Score.instance.score > last ? Score.instance.score : last; } PlayerPrefs.SetInt("Last", highscore); }
//checks the camera for something that may resemble a QR code and handles it appropriately void OnGUI() { if (!isDecoding && camTexture.isPlaying) { try { var result = barcodeReader.Decode(camTexture.GetPixels32(), camTexture.width, camTexture.height); if (result != null) { isDecoding = true; Debug.Log("DECODED TEXT FROM QR: " + result.Text); if (Variables.Vibration == 1) { Handheld.Vibrate(); } ParseInput(result.Text); } } catch (Exception ex) { Debug.LogWarning(ex.Message); } } }
void enemyDetected() { Debug.DrawRay(transform.position + transform.up / 2f, transform.right * 0.5f, Color.red); RaycastHit info; int mask = 1 << 14; if (Physics.Raycast(transform.position + transform.up / 2f, transform.right * 0.5f, out info, 0.5f, mask) && !Enemy.manage.isDead && isWeaponGet) { if (PlayerPrefs.GetInt("Vibro") == 0) { Handheld.Vibrate(); } isEnemyDetected = true; GetComponentInChildren <Animator>().SetBool("Walk", false); GetComponentInChildren <Animator>().SetBool("Stand", true); GetComponentInChildren <Animator>().SetBool("Ready", true); GetComponentInChildren <Animator>().SetTrigger("Slash"); GameObject snd = GameObject.Find("Attack"); snd.GetComponent <AudioSource>().Play(); //_player.GetComponent<Rigidbody>().position = new Vector3(transform.position.x,transform.position.y,0); //isDead = true; //PlayaDeadSnd.GetComponent<AudioSource>().Play(); } }
private void OnTriggerEnter2D(Collider2D collision) //trigger condition for coins and poisions { if (collision.CompareTag("Player")) { switch (gameObject.tag) //check what collide with unicorn { case "Box": Handheld.Vibrate(); break; case "Coin": gameMaster.GetComponent <GameMaster>().score++; //score up audioMaster.GetComponent <AudioMaster>().PlaySound("coinSound"); //turn on coin sound Destroy(gameObject, 0.1f); //destroy break; case "Poision": audioMaster.GetComponent <AudioMaster>().PlaySound("boostSound"); //turn on coin sound gameMaster.GetComponent <GameMaster>().MoveToStart(5f); Destroy(gameObject, 0.1f); //destroy break; } } }
private void OnTriggerEnter(Collider other) { if (isPlaying) { if (other.gameObject.tag == "Missile") { Handheld.Vibrate(); isPlaying = false; gameController.HandleShipDestroy(); GameObject explosion = Instantiate(ExplosionPrefab, transform.position, Quaternion.identity); } else if (other.gameObject.tag == "Coin") { Destroy(other.gameObject); gameController.HandleCoinCollect(); Instantiate(CoinCollectPrefab, Vector3.zero, Quaternion.identity); } else if (other.gameObject.tag == "Boost") { Instantiate(BoostCollectPrefab, Vector3.zero, Quaternion.identity); boostEnd = Time.time + 10f; } } }
private void OnTriggerEnter2D(Collider2D collision) { Debug.Log("Collision detected"); if (collision.CompareTag("Fish") && fishCount <= strength) { Handheld.Vibrate(); fishCount++; Fish _targetFish = collision.GetComponent <Fish>(); hookedFishes.Add(_targetFish); _targetFish.Hooked(); collision.transform.SetParent(hookedTransform); collision.transform.position = hookedTransform.position; collision.transform.eulerAngles = new Vector3(collision.transform.eulerAngles.x, collision.transform.eulerAngles.y, -90); //collision.transform.localScale = Vector3.one; collision.transform.DOShakeRotation(5, Vector3.forward * 60, 20, 90).SetLoops(1, LoopType.Yoyo).OnComplete(delegate { collision.transform.rotation = Quaternion.identity; }); if (fishCount == strength) { stopFishing(); } } }
public void Hurt(float damage) { if (cheat) { damage /= 2; } HP -= damage; #if UNITY_ANDROID Handheld.Vibrate(); #endif if (OnHurt != null) { OnHurt.Invoke(); } if (HP <= 0) { HP = 0; Die(); } }
// Update is called once per frame void Update() { if (showPointer != pointer.gameObject.activeSelf && !menu.gameObject.activeSelf) { pointer.gameObject.SetActive(true); } if (showMenu != menu.gameObject.activeSelf) { menu.gameObject.SetActive(showMenu); if (menu.gameObject.activeSelf) { pointer.gameObject.SetActive(true); UpdateMenuTransform(); Handheld.Vibrate(); } } if (Input.GetMouseButtonDown(1) || ( orientation != Input.deviceOrientation && ( Input.deviceOrientation == DeviceOrientation.Portrait || Input.deviceOrientation == DeviceOrientation.PortraitUpsideDown))) { Debug.Log("mouse 1 down"); autoWalk.move = false; showMenu = !showMenu; orientation = Input.deviceOrientation; } else if (orientation != Input.deviceOrientation) { orientation = Input.deviceOrientation; } if (Input.GetMouseButtonDown(0) && !menu.gameObject.activeSelf) { Debug.Log("mouse 0 down"); autoWalk.move = !autoWalk.move; } }
void Die() { isDied = true; bottleSprRen.sprite = bottleDieSpr; bottleRgb.isKinematic = false; corkRgb.gameObject.SetActive(true); corkRgb.transform.parent = null; corkRgb.isKinematic = false; corkRgb.AddForce(new Vector3(Random.Range(-5f, 5.1f), Random.Range(10f, 20f), 0), ForceMode.Impulse); corkRgb.AddTorque(new Vector3(0, 0, Random.Range(-10f, 10.1f)), ForceMode.Impulse); bottleRgb.AddForce(new Vector3(Random.Range(-5f, 5.1f), Random.Range(10f, 20f), 0), ForceMode.Impulse); bottleRgb.AddTorque(new Vector3(0, 0, Random.Range(-10f, 10.1f)), ForceMode.Impulse); // 스마트폰 진동 #if UNITY_IOS || UNITY_ANDROID if (GameManager.instance.isVibrateOn) { Handheld.Vibrate(); } #endif Destroy(corkRgb.gameObject, 2f); Destroy(gameObject, 2f); }
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Hive") && isTriggered && !hasCollided) { hasCollided = true; honeyCounter.HoneyAmount -= StealAmount; #if UNITY_ANDROID || UNITY_IOS Handheld.Vibrate(); #endif Destroy(gameObject); } else if (other.CompareTag("Blade") && !isTriggered) { isTriggered = true; angerSymbol.SetActive(true); speed *= 1.5f; animator.speed *= 1.25f; animator.SetLayerWeight(animator.GetLayerIndex("Attack"), 1f); animator.SetTrigger("Prepare"); hiveDirection = Hive.transform.position - transform.position; transformRightTarget = (headsRight ? 1 : -1) * hiveDirection; iTween.Stop(gameObject); iTween.ValueTo(gameObject, iTween.Hash( "from", 0f, "to", 1f, "time", 0.5f, "ignoretimescale", false, "onupdate", "tweenOnUpdateTransformRightCallback", "easetype", iTween.EaseType.easeInOutCubic ) ); } }