コード例 #1
0
    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;
            }
        }
    }
コード例 #2
0
    /// <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);
    }
コード例 #3
0
        /// <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;
        }
コード例 #4
0
    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>";
        }
    }
コード例 #5
0
    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;
        }
    }
コード例 #6
0
ファイル: Interface_Manager.cs プロジェクト: RavBit/BEEGIN
 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);
     }
 }
コード例 #7
0
    //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();
            }
        }
    }
コード例 #8
0
 /// <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();
         }
     }
 }
コード例 #9
0
    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);
    }
コード例 #10
0
    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();
            }
        }
    }
コード例 #11
0
    // 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()
                    );
            }
        }
    }
コード例 #12
0
ファイル: Food1Manager.cs プロジェクト: JuSugang/ARYumGame
    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);
        }
    }
コード例 #13
0
    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--;
        }
    }
コード例 #14
0
    // 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();
                }
            }
        }
    }
コード例 #15
0
ファイル: VideoMananger.cs プロジェクト: ghrguse/ss
    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;
        }
    }
コード例 #16
0
    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;
            }
        }
    }
コード例 #17
0
    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);
    }
コード例 #18
0
    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);
        }
    }
コード例 #19
0
ファイル: PlayerManager.cs プロジェクト: i-h/Starfaller
    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;
        }
    }
コード例 #20
0
ファイル: QRCardScript.cs プロジェクト: rdelnez/Bingo-3D-new
    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
        });
    }
コード例 #21
0
    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);
    }
コード例 #22
0
 //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);
         }
     }
 }
コード例 #23
0
    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();
        }
    }
コード例 #24
0
ファイル: Obstacle.cs プロジェクト: Go2SleepD/Unicorn-Run
    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;
            }
        }
    }
コード例 #25
0
 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;
         }
     }
 }
コード例 #26
0
ファイル: Hook.cs プロジェクト: avinvvij/Max-Fish-Master
 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();
         }
     }
 }
コード例 #27
0
        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();
            }
        }
コード例 #28
0
ファイル: InputManager.cs プロジェクト: romanzes637/obj2unity
 // 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;
     }
 }
コード例 #29
0
    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);
    }
コード例 #30
0
ファイル: BirdScript.cs プロジェクト: tmwitczak/peradventure
    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
                               )
                           );
        }
    }