Ejemplo n.º 1
0
    public void VibrationSuccess()
    {
#if UNITY_IOS
        Vibration.VibratePop();
#elif UNITY_ANDROID
        Vibration.Vibrate(15);
#endif
    }
Ejemplo n.º 2
0
    public void VibrateStandart()
    {
#if UNITY_IOS
        Vibration.VibratePop();
#elif UNITY_ANDROID
        Vibration.Vibrate(15);
#endif
    }
Ejemplo n.º 3
0
    //Pop vibration: weak boom (only available with the haptic engine: iPhone 6s minimum)
    public void TapPopVibrate()
    {
        if (IsHapticFeedbackEnabled())
        {
#if UNITY_IOS && !UNITY_EDITOR
            Vibration.VibratePop();
#endif
        }
    }
Ejemplo n.º 4
0
    public static void SmallVibrate()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        Vibration.Vibrate(50);
#endif
#if UNITY_IOS && !UNITY_EDITOR
        Vibration.VibratePop();
#endif
    }
Ejemplo n.º 5
0
    public void KillEnemy()
    {
        Vibration.Init();
        Vibration.VibratePop();
        AudioSource.PlayClipAtPoint(deathSound, new Vector3(0, 0, -10), 0.7f);
        var splatter = Instantiate(enemySplatter, gameObject.transform.position, gameObject.transform.rotation);

        splatter.Play();
        Destroy(gameObject);
    }
Ejemplo n.º 6
0
    private IEnumerator TargetFlashCoroutine()
    {
        Vibration.VibratePop();
        target.GetComponent <SpriteRenderer>().color = new Color(1, .75f, 75f);
        target.transform.position += new Vector3(0, .1f, 0);
        yield return(new WaitForSeconds(.1f));

        target.GetComponent <SpriteRenderer>().color = Color.white;
        target.transform.position += new Vector3(0, -.1f, 0);
    }
Ejemplo n.º 7
0
    public void SetVibrate()
    {
        if (!canVibrate)
        {
            return;
        }

        Vibration.VibratePop();
        Debug.Log("Vibrating");
    }
Ejemplo n.º 8
0
    private void SmallVibrate()
    {
        if (!Application.isEditor)
        {
#if UNITY_ANDROID
            Vibration.Vibrate(100);
#elif UNITY_IOS
            Vibration.VibratePop();
#endif
        }
    }
Ejemplo n.º 9
0
        public void AddHitPoint()
        {
            _numOfHitLog++;
            Vibration.VibratePop();
            if (_numOfHitLog == _numOfKnivesToSpawn)
            {
                _logSpawner.ExploreLog();

                NextLevel();
            }
        }
Ejemplo n.º 10
0
    private void AppleHitting()
    {
        PlaySound(GameObjects.gameObjects.AppleHitting);
        Vibration.VibratePop();
        Score += 10;
        UIObjects.objectsUI.ScoreUI.GetComponent <TextMeshProUGUI>().SetText("Score: " + Score);
        foreach (Transform piece in GameObjects.gameObjects.Apple.GetComponent <FruitPB>().Pieces)
        {
            Vector2 vector2 = piece.position - GameObjects.gameObjects.ExpPoint.position;

            piece.gameObject.AddComponent <Rigidbody2D>();
            piece.GetComponent <Rigidbody2D>().AddForce(vector2 * 50);
        }
    }
Ejemplo n.º 11
0
    IEnumerator nextStage()
    {
        Vibration.VibratePop();
        scoreAmount = spin.score;
        if (scoreAmount > record)
        {
            record = scoreAmount;
        }

        boss.SetActive(false);
        coin.GetComponent <SpriteRenderer>().color = Color.white;
        enemy.SetActive(false);
        enemy1.SetActive(false);
        //
        if (!bossBattle)
        {
            counters[index].GetComponent <Image>().color = Color.green;
        }
        ++localStage;
        ++index;
        if (localStage > stageMax)
        {
            stageMax = localStage;
        }
        stageText.GetComponent <Text>().text     = "Stage - " + localStage.ToString();
        stageMenuText.GetComponent <Text>().text = localStage.ToString();
        spin.win = false;
        Save.SavePlayer(this);
        yield return(new WaitForSeconds(1f));

        for (int i = 0; i < Random.Range(1, 4); i++)
        {
            var position = new Vector2(coin.transform.GetComponent <Renderer>().bounds.min.x, coin.transform.GetComponent <Renderer>().bounds.min.y);
            Instantiate(fakeKnife, position, Quaternion.identity);
        }
        yield return(new WaitForSeconds(1f));

        if (Random.value < bonusSpawn.chance / 100) //%25 percent chance
        {
            var position = new Vector2(Random.Range(coin.transform.GetComponent <Renderer>().bounds.min.x, coin.transform.GetComponent <Renderer>().bounds.max.x), Random.Range(coin.transform.GetComponent <Renderer>().bounds.min.y, coin.transform.GetComponent <Renderer>().bounds.max.y));
            Instantiate(bonus, position, Quaternion.identity);
        }

        Instantiate(knife, transform.position, Quaternion.identity);
        knifeCount = Random.Range(1, 7);
        yield return(null);
    }
Ejemplo n.º 12
0
        public void VibrateWeak()
        {
#if !UNITY_EDITOR
#if UNITY_ANDROID
            Vibration.Vibrate(AndroidWeakDuration);
#elif UNITY_IOS
            if (!iosHasOldVibrator)
            {
                Vibration.VibratePop();
            }
            else if (IosOldVibratorReplacementEnabled)
            {
                UnityEngine.Debug.Log("iOS OldVibration replacement.");
                Vibration.VibrateOldShort();
            }
#endif
#endif
        }
Ejemplo n.º 13
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (!isActive)
        {
            return;
        }

        isActive = false;

        if (collision.collider.tag == "Target")
        {
            GetComponent <ParticleSystem>().Play();

            knifeRigidbody.velocity = new Vector2(0, 0);
            knifeRigidbody.bodyType = RigidbodyType2D.Kinematic;
            this.transform.SetParent(collision.collider.transform);
            knifeCollider.offset = new Vector2(knifeCollider.offset.x, -0.4f);
            knifeCollider.size   = new Vector2(knifeCollider.size.x, 1.2f);

            Vibration.VibratePop();

            GameController.Instance.OnSuccessfullKnifeHit();

            attachedToWood = true;
        }
        else if (collision.collider.tag == "Knife")
        {
            knifeRigidbody.velocity = new Vector2(knifeRigidbody.velocity.x, -2);

            knifeCollider.enabled = false;

            Vibration.Vibrate(200);

            GameController.Instance.StartGameOverSequence(false);
        }
        else if (collision.collider.tag == "Orange")
        {
            GetComponent <ParticleSystem>().Play();
        }
    }
Ejemplo n.º 14
0
    public void SelectJewelleryPiece()
    {
        var mouseRay = GenerateMouseRay();

        if (Physics.Raycast(mouseRay.origin, mouseRay.direction, out var hit))
        {
            if (hit.transform.CompareTag(_selectableTag))
            {
                Vibration.VibratePop();
                _gObj            = hit.transform.gameObject;
                _objectBehaviour = _gObj.GetComponent <ObjectBehaviour>();
                _objectBehaviour.EnableBehaviour();

                var planePos = new Vector3(_gObj.transform.position.x, _gObj.transform.position.y + .3f, _gObj.transform.position.z);
                _plane = new Plane(Camera.main.transform.forward * -1f, planePos);

                var mRay = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
                _plane.Raycast(mRay, out var rayDistance);
                _offset = _gObj.transform.position + new Vector3(0, 0f, 0.2f) - mRay.GetPoint(rayDistance);
            }
        }
    }
Ejemplo n.º 15
0
    void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.tag == "Circle")
        {
            Vibration.VibratePop();

            hitsScript.countHits++;

            PlayerPrefs.SetInt("TemporaryScore", PlayerPrefs.GetInt("TemporaryScore") + 1);
            transform.parent = circle.transform;
            newKnife         = true;

            GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezePositionY
                                                       | RigidbodyConstraints2D.FreezeRotation;
        }
        if (other.gameObject.tag == "Knife" || other.gameObject.tag == "KnifeStatic")
        {
            Vibration.VibratePop();

            hitsScript._isDead = true;
            MCanvas.SetActive(false);
            Time.timeScale = 0;

            if (PlayerPrefs.GetInt("RecordStage") < PlayerPrefs.GetInt("Stage"))
            {
                PlayerPrefs.SetInt("RecordStage", PlayerPrefs.GetInt("Stage"));
            }

            PlayerPrefs.SetInt("Stage", 1);

            if (PlayerPrefs.GetInt("TemporaryScore") > PlayerPrefs.GetInt("RecordScore"))
            {
                PlayerPrefs.SetInt("RecordScore", PlayerPrefs.GetInt("TemporaryScore"));
            }

            PlayerPrefs.SetInt("TemporaryScore", 0);
        }
    }
Ejemplo n.º 16
0
 public void VibratePop()
 {
     Vibration.VibratePop();
 }
Ejemplo n.º 17
0
 public void TapPopVibrate()
 {
     Vibration.VibratePop();
 }
Ejemplo n.º 18
0
    // Update is called once per frame
    void Update()
    {
        //float rotationY = Quaternion.RotateTowards(lastCameraPosition, Camera.current.transform.rotation,360).eulerAngles.y;
        float rotationY = (Camera.current.transform.rotation.eulerAngles.y - lastCameraPosition.eulerAngles.y) % 360;

        placementIndicator.transform.Rotate(0f, rotationY, 0f, Space.World);
        lastCameraPosition = Camera.current.transform.rotation;

        switch (interactionMode)
        {
        case InteractionMode.Placement:

            if (!floorIsPlaced)
            {
                UpdateFloorIndicator();
            }
            else
            {
                UpdatePlacementIndicator();
            }

            if (Input.touchCount > 0 && !EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
            {
                Touch touch = Input.GetTouch(0);
                if (touch.phase == TouchPhase.Began)
                {
                    if (floorIsPlaced)
                    {
                        shouldReactToTapEvents = true;
                        moveDistanceX          = 0;
                        moveDistanceY          = 0;
                        moveDistanceTotal      = 0;
                    }
                    else
                    {
                        PlacePlank();
                    }
                }
                if (touch.phase == TouchPhase.Stationary && shouldReactToTapEvents)
                {
                    // Do nothing
                }
                if ((touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled) && shouldReactToTapEvents)
                {
                    // timeStationary differentiaties between a "tap" for placement and rotation
                    if (moveDistanceTotal <= moveTreshold)
                    {
                        PlacePlank();
                    }
                    shouldReactToTapEvents = false;
                }
                if (touch.phase == TouchPhase.Moved && shouldReactToTapEvents)
                {
                    float dx = Input.GetTouch(0).deltaPosition.x / Screen.width * 360;
                    float dy = Input.GetTouch(0).deltaPosition.y / Screen.height * 360;
                    moveDistanceX     += dx;
                    moveDistanceY     += dy;
                    moveDistanceTotal += Input.GetTouch(0).deltaPosition.magnitude;
                    if (Math.Abs(moveDistanceX) >= 5)
                    {
                        moveDistanceX %= 5;
                        // Vibration.VibratePop();

                        RotateInstant(new Vector3(Math.Sign(moveDistanceX) * 5f, 0f, 0f));
                    }
                    if (Math.Abs(moveDistanceY) >= 20)
                    {
                        moveDistanceY %= 20;
                        Vibration.VibratePop();
                        RotateInstant(new Vector3(0f, Math.Sign(moveDistanceY) * 90f, 0f));
                    }
                    // y-axis is UP -> dx for rotation around it.
                }
            }
            break;

        case InteractionMode.Slicing:
            if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began && !EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
            {
                objectToSlice.GetComponent <SlicePiece>().Split(slicePostion);
            }
            break;
        }
    }
Ejemplo n.º 19
0
 public void LoadLoseCanvas()
 {
     AndroidNotificationController.instance.CreatNotification();
     Vibration.VibratePop();
     StartCoroutine(LoadingRestart());
 }
Ejemplo n.º 20
0
        public override void Update()
        {
            if (!Context.Available)
            {
                return;
            }
            base.Update();

            var inputMousePos = Input.mousePosition;

            if (Input.GetMouseButtonDown(0))
            {
                isMouseDonw = true;
                Ray        ray = currentCamera.ScreenPointToRay(inputMousePos);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit, rayDepth, lineLayerMask))
                {
                    Debug.Log(hit.collider.gameObject.transform.position);
                    var amidaInfo = hit.collider.gameObject.GetComponent <AmidaLineInformation>();
                    if (amidaInfo != null)
                    {
                        if (amidaInfo.LineType == AmidaLineType.Vertical)
                        {
                            mouseDownPosition =
                                currentCamera.ScreenToWorldPoint(
                                    new Vector3(inputMousePos.x, inputMousePos.z, rayDepth));
                            currentAmidaLine = Context.AddHorizonLine(amidaInfo.LineIndex);

                            subscribe = currentAmidaLine.OnDrawFinished.Subscribe(x => FinishDraw(x));
                            currentAmidaLine.Length = 0;
                            var vAmida = amidaInfo.AmidaLine;
                            currentAmidaLine.transform.position = new Vector3(vAmida.transform.position.x,
                                                                              vAmida.transform.position.y, hit.point.z);

                            digParticle.Play();
                        }
                        else
                        {
                        }
                    }
                }

                Debug.DrawRay(ray.origin, ray.direction * 60, Color.red, 5);
            }
            else if (Input.GetMouseButton(0))
            {
                if (!isMouseDonw)
                {
                    return;
                }
                if (currentAmidaLine != null)
                {
                    var currentPosition = currentCamera.ScreenToWorldPoint(
                        new Vector3(inputMousePos.x, inputMousePos.z, rayDepth));
                    var diff = mouseDownPosition - currentPosition;

                    currentAmidaLine.transform.localEulerAngles = new Vector3(0, 90, 0);
                    currentAmidaLine.Length = diff.x;
                    var lineEndPos = currentAmidaLine.EndNode.transform.position;
                    var digPos     = new Vector3(lineEndPos.x, 2, lineEndPos.z);
                    digParticle.transform.position = digPos;
                    Vibration.VibratePop();
                }
            }
            else if (Input.GetMouseButtonUp(0))
            {
                isMouseDonw = false;
                if (currentAmidaLine == null)
                {
                    return;
                }
                currentAmidaLine = null;
                subscribe.Dispose();
                digParticle.Stop();
            }
        }
    public void TapPopVibrate()
    {
#if UNITY_IOS && !UNITY_EDITOR
        Vibration.VibratePop();
#endif
    }