Ejemplo n.º 1
0
        private void OnDragged(SwipeInput input)
        {
            // If this input's already picked up some trash, ignore this
            if (swipeMapping.ContainsKey(input.InputId))
            {
                return;
            }

            Vector2 worldPrevious = cachedCamera.ScreenToWorldPoint(input.PreviousPosition);
            Vector2 worldCurrent  = cachedCamera.ScreenToWorldPoint(input.EndPosition);

            //Try find trash to grab for this swipe
            RaycastHit2D hit = Physics2D.Linecast(worldPrevious, worldCurrent, castLayerMask);

            if (hit.collider != null)
            {
                // Try find a Trash object on this hit component
                var trash = hit.collider.GetComponent <Trash>();
                if (trash != null &&
                    !trash.HasFlung)
                {
                    // Remember that this swipe went over this object
                    swipeMapping[input.InputId] = trash;
                }
            }
        }
Ejemplo n.º 2
0
    void SubscribeInput()
    {
        swipeInput = GetComponent <SwipeInput>();
        swipeInput.allowedInGUI = true;
        swipeInput.threshold    = int.MaxValue;
        swipeInput.isCancelable = false;

        swipeInput.OnSwipeEnd.AddListener(swipeInfo => {
            if (sticking != null)
            {
                StopCoroutine(sticking);
            }

            if (swipeInfo.direction == Vector2.right)
            {
                sticking = StartCoroutine(StartStickTo(itemIndex - 1));
            }
            else if (swipeInfo.direction == Vector2.left)
            {
                sticking = StartCoroutine(StartStickTo(itemIndex + 1));
            }
            else
            {
                sticking = StartCoroutine(StartStickTo(itemIndex));
            }
        });
    }
Ejemplo n.º 3
0
        public override void OnInspectorGUI()
        {
            _target = (SwipeInput)target;

            #if UNITY_4_2
            Undo.RegisterUndo(_target, "SwipeEditor");
            #elif UNITY_4_3
            Undo.RecordObject(_target, "SwipeEditor");
            #endif

            EditorGUILayout.HelpBox("HOW FAST DO YOU NEED TO SWIPE?", MessageType.None);
            int speed = Mathf.RoundToInt((_target.velocityThreshold / 4000) * 100);
            EditorGUILayout.HelpBox("SPEED: " + speed + "%", MessageType.None);

            _target.velocityThreshold = GUILayout.HorizontalSlider(_target.velocityThreshold, 0, 4000);

            if (_target.velocityThreshold < 1500 && _target.velocityThreshold > 0)
            {
                EditorGUILayout.HelpBox("SLOW", MessageType.None);
            }
            if (_target.velocityThreshold < 3000 && _target.velocityThreshold > 1500)
            {
                EditorGUILayout.HelpBox("MEDIUM", MessageType.None);
            }
            if (_target.velocityThreshold < 4000 && _target.velocityThreshold > 3000)
            {
                EditorGUILayout.HelpBox("FAST!", MessageType.None);
            }
            EditorUtility.SetDirty(_target);
        }
Ejemplo n.º 4
0
    void SubscribeInput()
    {
        swipeInput = GetComponent <SwipeInput>();
        swipeInput.OnSwipeStart.AddListener(swipeInfo => {
            Vector3 pos      = Camera.main.ScreenToWorldPoint(swipeInfo.touchBegin);
            RaycastHit2D hit = Physics2D.Raycast(pos, Vector2.zero);
            if (hit && hit.collider != null)
            {
                gemSelected = hit.collider.gameObject.GetComponent <GemView>();
                gemSelected.Squash();
            }
        });
        swipeInput.OnSwipeCancel.AddListener(() => {
            gemSelected = null;
        });
        swipeInput.OnSwipeEnd.AddListener(swipeInfo => {
            if (isPlaying)
            {
                Toast.Show("A coroutine is still running.", .8f);
                return;
            }

            if (gemSelected != null)
            {
                var sourceGemModel = Controller.GetGemModel(gemSelected.Position);
                ActBySwipe(sourceGemModel, swipeInfo.direction);
                gemSelected = null;
            }
        });
    }
Ejemplo n.º 5
0
        private void OnSwiped(SwipeInput input)
        {
            // Try find a grabbed trash for this swipe
            Trash swipedTrash;

            if (!swipeMapping.TryGetValue(input.InputId, out swipedTrash))
            {
                return;
            }

            swipeMapping.Remove(input.InputId);

            // Launch trash at target if it hasn't been launched yet
            if (swipedTrash == null ||
                swipedTrash.HasFlung)
            {
                return;
            }

            // Find bin in swipe direction
            Bin     targetBin      = FindTargetBinForSwipe(input);
            Vector2 targetPosition = targetBin != null
                ? targetBin.transform.position
                : swipedTrash.transform.position + (Vector3)input.SwipeDirection;

            swipedTrash.LaunchAt(targetPosition, input.SwipeVelocity * screenUnitsToWorldUnits);
        }
Ejemplo n.º 6
0
 private void Start()
 {
     obstacleCollision = new ObstacleCollision(transform);
     waterCollision    = new WaterCollision(transform);
     squeezeAnimation  = new SqueezeAnimation(transform);
     swipeInput        = new SwipeInput();
 }
Ejemplo n.º 7
0
 private void GestureControllerOnDragged(SwipeInput obj)
 {
     if (!_currentCarClicked)
     {
         return;
     }
     _lastSwipeInput = obj;
 }
Ejemplo n.º 8
0
 private void Start()
 {
     startGameButton.onClick.AddListener(StartButtonClicked);
     restartGameButton.onClick.AddListener(OnRestart);
     activeBar    = timerObj.transform.Find("ActiveBar");
     loadingBar   = activeBar.GetComponent <Image>();
     scrollScript = ApplicationManager.Instance.ScrollScript;
     swipeScript  = ApplicationManager.Instance.SwipeInput;
 }
 protected override void OnInputDown(int pointerId, float2 inputPos)
 {
     swipeInputs[pointerId + 1] = new SwipeInput
     {
         pointerId     = pointerId,
         startTime     = Time.ElapsedTime,
         startPosition = inputPos
     };
 }
Ejemplo n.º 10
0
 private void GestureControllerOnReleased(SwipeInput obj)
 {
     if (!_currentCarClicked)
     {
         return;
     }
     _currentCarClicked.SetCarMoving(false);
     _currentCarClicked = null;
     _isMovingCar       = false;
 }
    private void CreateNewSwipeInput(Touch t)
    {
        int idx = FindNullInput( );

        if (idx < 0)
        {
            return;
        }

        _inputDetection[idx] = new SwipeInput(t.fingerId);
    }
Ejemplo n.º 12
0
    // Start is called before the first frame update
    void Start()
    {
        spawnPos     = transform.position;
        noteSpawner  = GameObject.Find("Spawner").GetComponent <NoteSpawner>();
        swipeinput   = GetComponent <SwipeInput>();
        scoreManager = GameObject.Find("ScoreManager").GetComponent <ScoreManager>();


        NoteDeathTimer = 1000;
        isSwiped       = false;
        canSwipe       = false;
    }
Ejemplo n.º 13
0
    public void Start()
    {
        ui    = GameObject.FindGameObjectWithTag("UIStore").GetComponent <StoreUIController>();
        camTr = Camera.main.GetComponent <Transform>();
        swipe = GameObject.FindGameObjectWithTag("Swipe").GetComponent <SwipeInput>();

        if (PlayerInfo.info.unlockNextShape)
        {
            UnlockNextShape();
            delayInSeconds = 1;
        }
    }
Ejemplo n.º 14
0
        public DeviceResult Swipe([FromBody] SwipeInput input)
        {
            DeviceResult res = new DeviceResult();

            res.IDTessera = input.IDTessera;
            res.IDGateway = input.IDGateway;
            res.Nome      = "Alessio ";
            res.Cognome   = "Calero " + input.IDGateway;
            res.Response  = "OK";
            res.Status    = 3;
            return(res);
        }
Ejemplo n.º 15
0
    void Start()
    {
        board        = GameObject.FindObjectOfType <Board>();
        swipeInput   = FindObjectOfType <SwipeInput>();
        rotateButton = GameObject.Find("RotateButton").GetComponent <Button>();
        rotateButton.onClick.AddListener(() => SetRotate());

        // Default position not valid? Then it's game over
        if (!board.IsValidGridPos(transform))
        {
            Destroy(gameObject);
            board.GameOver();
        }
    }
Ejemplo n.º 16
0
    void Start()
    {
        rotationTiles = GetComponentsInChildren <TetrominoRotationTile>();

        for (int i = 1; i < transform.childCount; ++i)
        {
            tetrominoTiles[i - 1] = transform.GetChild(i).GetComponent <TetrominoTile>();
        }
        game        = Camera.main.GetComponent <Game>();
        input       = Camera.main.GetComponent <SwipeInput>();
        spawner     = GameObject.FindGameObjectWithTag("TetrominoSpawner").GetComponent <TetrominoSpawner>();
        fallingTime = game.tetromino.fallTime;

        assignToInputEvents();
        StartCoroutine(fallingCoroutine());
    }
Ejemplo n.º 17
0
    public void Start()
    {
        chooseButtonText  = chooseButton.GetComponentInChildren <Text>();
        chooseButtonImage = chooseButton.GetComponent <Image>();

        blur        = Camera.main.GetComponent <BlurOptimized>();
        swipe       = GameObject.FindGameObjectWithTag("Swipe").GetComponent <SwipeInput>();
        money.text  = PlayerInfo.info.allCoins.ToString();
        bonusesText = new Text[bonuses.Length];
        for (int i = 0; i < bonusesText.Length; i++)
        {
            bonusesText[i] = bonuses[i].GetComponent <Text>();
        }

        ChangeButtonText(PlayerInfo.info.activePlayerShapeIndex, store.GetShape(PlayerInfo.info.activePlayerShapeIndex));

        lightening.GetComponent <DynamicLight>().lightMaterial.color = PlayerInfo.info.GetMainColor(lightSaturation);
        Camera.main.backgroundColor = PlayerInfo.info.GetMainColor(backgroundSaturation);
    }
Ejemplo n.º 18
0
        /// <summary>
        /// Given a swipe, find the nearest bin (within reason) of the swipe direction.
        /// </summary>
        private Bin FindTargetBinForSwipe(SwipeInput input)
        {
            Vector2 swipeEndPosition = cachedCamera.ScreenToWorldPoint(input.EndPosition);
            var     biggestDot       = 0.0f;
            Bin     targetBin        = null;

            foreach (Bin bin in bins)
            {
                Vector2 toTargetBin = (Vector2)bin.transform.position - swipeEndPosition;
                float   toTargetDot = Vector2.Dot(input.SwipeDirection, toTargetBin.normalized);

                if (toTargetDot > biggestDot &&
                    toTargetDot >= minimumCosineForBinTargetting)
                {
                    biggestDot = toTargetDot;
                    targetBin  = bin;
                }
            }
            return(targetBin);
        }
Ejemplo n.º 19
0
        private void GestureControllerOnPressed(SwipeInput obj)
        {
            _lastSwipeInput = obj;

            Ray ray = mainCam.ScreenPointToRay(obj.EndPosition);

            if (!Physics.Raycast(ray, out RaycastHit hit, 500f))
            {
                return;
            }
            if (hit.collider.GetComponent <Car.Car>())
            {
                _isMovingCar = true;
                Car.Car hitCar = hit.collider.GetComponent <Car.Car>();
                _currentCarClicked = hitCar;
                Vector3 point = hit.point;
                point.y = 0;
                _currentCarClicked.SetTargetPosition(point + touchOffset);
                _currentCarClicked.SetCarMoving(true);
            }
        }
Ejemplo n.º 20
0
    public static void Update()
    {
        if (StateManager.AppState == Enumerators.AppState.GAME)
        {
            SwipeInput.SetDirection();
            GameManager.Update();
            UIManager.UpdateScore(DataManager.currentData.score.ToString());
        }
        else if (StateManager.AppState == Enumerators.AppState.MENU)
        {
            UIManager.UpdateMenu();
        }

        for (int i = 0; i < _timers.Count; i++)
        {
            if (!_timers[i].UpdateTimer())
            {
                _timers.RemoveAt(i);
            }
        }
    }
Ejemplo n.º 21
0
        void Awake()
        {
            instance      = this;
            this._gridMap = GameObject.FindGameObjectWithTag("GridMap").gameObject;
            GameController.FindOrCreate();
            GameMenuController.FindOrCreate();
            GameController.instance.PrepareNextLevel();
            GameMenuController.instance.fade.PlayFadeToMin();
            this._explosionPosition = new Vector3(GridMap.instance.columns * 0.5f, 0.5f, GridMap.instance.rows * 0.5f);
            this._explosionRadius   = (GridMap.instance.rows * GridMap.instance.columns);

            this._warningTexture            = ((GameObject)Instantiate(ResourceManager.instance.warningTexture) as GameObject).GetComponent <GUITexture>();
            this._warningTexture.pixelInset = new Rect(0.0f, 0.0f, GlobalInfo.ScreenWidth, GlobalInfo.ScreenHeight);
            this.warningColor          = new Color(0.8f, 0.1f, 0.1f, 0.0f);
            this._warningTexture.color = this.warningColor;

            this.gameObject.AddComponent <GridAudio>();

#if UNITY_IPHONE || UNITY_ANDROID
            this.transform.gameObject.AddComponent <SwipeInput>();
            this._swipeController = this.transform.GetComponent <SwipeInput>() as SwipeInput;
#endif
        }
Ejemplo n.º 22
0
        private void OnPressed(SwipeInput input)
        {
            // Make sure that the swipe mapping doesn't contain this swipe
            swipeMapping.Remove(input.InputId);

            // Try also find grabbed trash on first press
            Vector2 worldCurrent = cachedCamera.ScreenToWorldPoint(input.EndPosition);

            // Try find trash to grab for this touch
            Collider2D collider = Physics2D.OverlapPoint(worldCurrent, castLayerMask);

            if (collider != null)
            {
                // Try find a Trash object on this hit component
                var trash = collider.GetComponent <Trash>();
                if (trash != null &&
                    !trash.HasFlung)
                {
                    // Remember that this swipe went over this object
                    swipeMapping[input.InputId] = trash;
                }
            }
        }
Ejemplo n.º 23
0
    private void SearchDerection()
    {
        if (_isSwiping)
        {
            if (Input.GetMouseButton(0))
            {
                _swipeDelta = (Vector2)Input.mousePosition - _tapPosition;
            }
        }

        if (_swipeDelta.magnitude > _deadZone)
        {
            if (Mathf.Abs(_swipeDelta.x) > Mathf.Abs(_swipeDelta.y))
            {
                SwipeInput?.Invoke(_swipeDelta.x > 0? Vector2.right : Vector2.left);
            }
            else
            {
                SwipeInput?.Invoke(_swipeDelta.y > 0? Vector2.up : Vector2.down);
            }

            ResetSwipe();
        }
    }
 private void Awake()
 {
     Swipe             = gameObject.AddComponent <SwipeInput>();
     _mobileButtons    = new List <MobileButton>();
     _registeredInputs = new List <MobileInputKeys>();
 }
Ejemplo n.º 25
0
 void Start()
 {
     controller     = GetComponent <CharacterController>();
     playerPosition = GetComponent <Transform>();
     input          = gameObject.GetComponent <SwipeInput>();
 }
Ejemplo n.º 26
0
    public float z;             //z Position von pos

    private void Start()
    {
        // Referenz auf unser SpawnBase Script
        sBase = GameObject.Find("SpawnManager").GetComponent <SpawnBases>();
        Touch = GameObject.Find("SpawnManager").GetComponent <SwipeInput>();
    }
Ejemplo n.º 27
0
 private void Awake()
 {
     instance = this;
 }