public void Attack02(Tap tap)
 {
     Debug.Log("ATTACK 02");
     StopAllCoroutines();
     StartCoroutine(Move(enemy.transform.position + new Vector3(0.0f, -1.0f)));
     enemyEn.AddjustCurrentHealth((int)-melee);
 }
    void OnMultiTap(Tap tap)
    {
        bool objDetected=false;

        //check if the tap has landed on any UIElement
        if(IT_Utility.IsCursorOnUI(tap.pos)){
            //get the UIElement gameobject the tap landed on
            GameObject objUI=IT_Utility.GetHoveredUIElement(tap.pos);
            Debug.Log("Cursor has landed on an UI element ("+objUI.name+")");
            objDetected=true;
        }

        //get the 2D sprite gameobject (uses 2DCollider) the tap landed on
        GameObject obj2D=IT_Utility.GetHovered2DObject(tap.pos);
        if(obj2D!=null){
            Debug.Log("Cursor has landed on a 2D object ("+obj2D.name+")");
            objDetected=true;
        }

        //get the 3D gameobject (uses default collider) the tap landed on
        GameObject obj3D=IT_Utility.GetHovered3DObject(tap.pos);
        if(obj3D!=null){
            Debug.Log("Cursor has landed on a 3D object ("+obj3D.name+")");
            objDetected=true;
        }

        if(!objDetected) Debug.Log("Cusror has landed on nothing");
    }
 public void Attack01(Tap tap)
 {
     Debug.Log("ATTACK 01");
     this.gameObject.transform.position = this.enemy.transform.position + new Vector3(0.0f, -1.0f);
     StopAllCoroutines();
     StartCoroutine(WaitToAttack01(attackDuration));
     Debug.Log("enemy health: " + enemyEn.health);
     enemyEn.AddjustCurrentHealth((int)-melee);
 }
Exemple #4
0
    void Start()
    {
        tap = GetComponent<Tap>();
        recordingManager = GameObject.FindObjectOfType(typeof(RecordingManager)) as RecordingManager;

        initial = renderer.material.color;
        transparent = initial;
        transparent.a = 0;
    }
    // Use this for initialization
    void Start()
    {
        //initiate the turret position on screen
        //turretPos = Camera.main.WorldToScreenPoint(turret.position);

        //fake a tap event to initiate the turret rotation and cursor
        Tap tap=new Tap(new Vector2(Screen.width/2, Screen.height/2));
        OnTap(tap);
    }
 void OnTap(Tap tap)
 {
     //RoatePlane(tap.pos);
     SelectShape(tap.pos);
 }
Exemple #7
0
        public SimpleFlexView()
        {
            this.Root.Padding    = 10;
            this.BackgroundBrush = new ColorBrush(SKColors.LightGray);

            this.Title = this.AddView(new Layout <Label>(new Label
            {
                TextSize = 40,
                Text     = "Title of the view"
            })
            {
                AutoSize = true,
            });

            this.Separator = this.AddView(new Layout <View>(new View
            {
                BackgroundBrush = new ColorBrush(SKColors.Black),
                CornerRadius    = 2,
            })
            {
                Height       = 4,
                AlignSelf    = Facebook.Yoga.YogaAlign.Stretch,
                MarginTop    = 10,
                MarginBottom = 10,
            });

            var row = new Layout <View>(new View()
            {
                ClipBounds = false,
            })
            {
                FlexDirection = Facebook.Yoga.YogaFlexDirection.Row,
            };

            this.AddView(row);

            this.Description = row.AddView(new Layout <Label>(new Label
            {
                TextSize        = 15,
                BackgroundBrush = new ColorBrush(SKColors.White),
                CornerRadius    = 50,
                ShadowSize      = new SKSize(4, 4),
                BorderSize      = 4,
                BorderBrush     = new ColorBrush(SKColors.Red),
                Text            = "Nam ut imperdiet nibh. Ut sollicitudin varius nibh, id ornare tortor convallis sed. Morbi volutpat, lacus efficitur volutpat lacinia, nibh velit ultricies neque, vel faucibus tellus neque at nibh. Nullam vitae tincidunt metus. Vestibulum nec nisl quis lorem tincidunt maximus eu vel lectus. Proin posuere augue molestie imperdiet scelerisque. Phasellus quis suscipit neque."
            })
            {
                Flex     = 1,
                AutoSize = true,
            });

            this.Icon = row.AddView(new Layout <Path>(new Path
            {
                Source     = IconPath.ArrowUp,
                StrokeSize = 5,
                ViewBox    = SKRect.Create(0, 0, 24, 24),
            })
            {
                AlignSelf  = Facebook.Yoga.YogaAlign.Center,
                MarginLeft = 10,
                Width      = 100,
                Height     = 100,
            });

            this.Image = this.AddView(new Layout <Image>(new Image
            {
                Source = "https://www.xamarin.com/content/images/pages/branding/assets/xamagon.png",
            })
            {
                Flex      = 1,
                MarginTop = 10,
            });

            this.Button = this.AddView(new Layout <Tap>(new Tap()
            {
                BackgroundBrush = new ColorBrush(SKColors.DeepPink),
                CornerRadius    = 5,
            })
            {
                Height = 100,
            });

            this.Button.Tapped   += OnButtonTapped;
            this.Button.Pressed  += (s, e) => ((Tap)s).BackgroundBrush = new ColorBrush(SKColors.LightPink);
            this.Button.Released += (s, e) => ((Tap)s).BackgroundBrush = new ColorBrush(SKColors.DeepPink);
        }
Exemple #8
0
 public DroneController tap()
 {
     this.droneConnection.sendCommand(Tap.tap());
     return(this);
 }
Exemple #9
0
 public static void ReadDataCallback(IAsyncResult asyncResult)
 {
     BytesRead = Tap.EndRead(asyncResult);
     // Console.WriteLine("Read "+ BytesRead.ToString());
     WaitObject.Set();
 }
Exemple #10
0
    IEnumerator TapCoroutine(Tap tap)
    {
        yield return new WaitForSeconds(maxMultiTapCount*maxMultiTapInterval);

        if(tapExisted==tap.count){
            tapExisted=0;
            if(onMultiTapE!=null) onMultiTapE(tap);
        }
    }
Exemple #11
0
 public int CreateTap(Tap tap)
 {
     throw new NotImplementedException();
 }
 private void OnLongTap(Tap tap)
 {
     for (int i = 0; i < this._listeners.Count; i++)
         this._listeners[i].OnLongTap(tap);
 }
 private void OnMultiTap(Tap tap)
 {
     StartCoroutine(GameStart());
 }
Exemple #14
0
 public void OnMultiTap(Tap tap)
 {
 }
Exemple #15
0
 /// <inheritdoc/>
 public override async Task RemoveAsync(TRoot item)
 {
     await Task.WhenAll(
         Inner.RemoveAsync(item),
         Tap.RemoveAsync(item)).ConfigureAwait(false);
 }
Exemple #16
0
 public void OnLongTap(Tap tap)
 {
 }
Exemple #17
0
 public void OnDoubleTap(Tap tap)
 {
 }
Exemple #18
0
 void HandleGestureonMultiTapE(Tap tap)
 {
     if (!PickObject(tap.pos)) {
         if (tap.count == 2) {
             isDragging = !isDragging;
             DisplayText("Dragging " + (isDragging ? "on" : "off"));
         }
     }
 }
Exemple #19
0
        /// <inheritdoc/>
        public override async Task RemoveAsync(TRoot item)
        {
            await Inner.RemoveAsync(item).ConfigureAwait(false);

            await Tap.RemoveAsync(item).ConfigureAwait(false);
        }
Exemple #20
0
 //called when a multi-Tap event is detected
 void OnMultiTap(Tap tap)
 {
     //do a raycast base on the position of the tap
     Ray ray = Camera.main.ScreenPointToRay(tap.pos);
     RaycastHit hit;
     if(Physics.Raycast(ray, out hit, Mathf.Infinity)){
         //if the tap lands on the shortTapObj, then shows the effect.
         if(hit.collider.transform==shortTapObj){
             //place the indicator at the object position and assign a random color to it
             Indicator.transform.position=shortTapObj.position;
             Indicator.startColor=GetRandomColor();
             //emit a set number of particle
             Indicator.Emit(30);
         }
         //if the tap lands on the doubleTapObj
         else if(hit.collider.transform==doubleTapObj){
             //check to make sure if the tap count matches
             if(tap.count==2){
                 //place the indicator at the object position and assign a random color to it
                 Indicator.transform.position=doubleTapObj.position;
                 Indicator.startColor=GetRandomColor();
                 //emit a set number of particle
                 Indicator.Emit(30);
             }
         }
     }
 }
Exemple #21
0
        protected override DifficultyAttributes Calculate(IBeatmap beatmap, Mod[] mods, double clockRate)
        {
            var hitObjects = beatmap.HitObjects as List <OsuHitObject>;

            double mapLength = 0;

            if (beatmap.HitObjects.Count > 0)
            {
                mapLength = (beatmap.HitObjects.Last().StartTime - beatmap.HitObjects.First().StartTime) / 1000 / clockRate;
            }

            double preemptNoClockRate = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450);
            var    noteDensities      = NoteDensity.CalculateNoteDensities(hitObjects, preemptNoClockRate);

            // Tap
            var tapAttributes = Tap.CalculateTapAttributes(hitObjects, clockRate);

            // Finger Control
            double fingerControlDiff = FingerControl.CalculateFingerControlDiff(hitObjects, clockRate);

            // Aim
            var aimAttributes = Aim.CalculateAimAttributes(hitObjects, clockRate, tapAttributes.StrainHistory, noteDensities);

            double tapSr           = tap_multiplier * Math.Pow(tapAttributes.TapDifficulty, sr_exponent);
            double aimSr           = aim_multiplier * Math.Pow(aimAttributes.FcProbabilityThroughput, sr_exponent);
            double fingerControlSr = finger_control_multiplier * Math.Pow(fingerControlDiff, sr_exponent);
            double sr = Mean.PowerMean(new[] { tapSr, aimSr, fingerControlSr }, 7) * 1.131;

            HitWindows hitWindows = new OsuHitWindows();

            hitWindows.SetDifficulty(beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty);

            // Todo: These int casts are temporary to achieve 1:1 results with osu!stable, and should be removed in the future
            double hitWindowGreat = (int)(hitWindows.WindowFor(HitResult.Great)) / clockRate;
            double preempt        = (int)BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450) / clockRate;

            int maxCombo = beatmap.HitObjects.Count;

            // Add the ticks + tail of the slider. 1 is subtracted because the head circle would be counted twice (once for the slider itself in the line above)
            maxCombo += beatmap.HitObjects.OfType <Slider>().Sum(s => s.NestedHitObjects.Count - 1);

            return(new OsuDifficultyAttributes
            {
                StarRating = sr,
                Mods = mods,
                Length = mapLength,

                TapSr = tapSr,
                TapDiff = tapAttributes.TapDifficulty,
                StreamNoteCount = tapAttributes.StreamNoteCount,
                MashTapDiff = tapAttributes.MashedTapDifficulty,

                FingerControlSr = fingerControlSr,
                FingerControlDiff = fingerControlDiff,

                AimSr = aimSr,
                AimDiff = aimAttributes.FcProbabilityThroughput,
                AimHiddenFactor = aimAttributes.HiddenFactor,
                ComboTps = aimAttributes.ComboThroughputs,
                MissTps = aimAttributes.MissThroughputs,
                MissCounts = aimAttributes.MissCounts,
                CheeseNoteCount = aimAttributes.CheeseNoteCount,
                CheeseLevels = aimAttributes.CheeseLevels,
                CheeseFactors = aimAttributes.CheeseFactors,

                ApproachRate = preempt > 1200 ? (1800 - preempt) / 120 : (1200 - preempt) / 150 + 5,
                OverallDifficulty = (80 - hitWindowGreat) / 6,
                MaxCombo = maxCombo
            });
        }
 private void OnMultiTap(Tap tap)
 {
     for (int i = 0; i < this._listeners.Count; i++)
         if (tap.count == 2)
             this._listeners[i].OnDoubleTap(tap);
         else
             this._listeners[i].OnMultiTap(tap);
 }
 //called when a tap is detected
 void OnTap(Tap tap)
 {
     print("Tap");
 }
 public void addCallback(Tap tap)
 {
     mTap = tap;
 }
Exemple #25
0
    //*****************************************************************************//
    //standard tap event
    public static void MultiTap(Tap tap)
    {
        if(tap.fingerCount==1){
            if(tap.count==1){
                if(onShortTapE!=null) onShortTapE(tap.pos);
            }
            else if(tap.count==2){
                if(onDoubleTapE!=null) onDoubleTapE(tap.pos);
            }

            if(onMultiTapE!=null) onMultiTapE(tap);
        }
        else{
            if(tap.fingerCount==2){
                if(tap.count==1){
                    DFShortTap(tap.pos);
                }
                else if(tap.count==2){
                    DFDoubleTap(tap.pos);
                }
            }

            if(onMFMultiTapE!=null) onMFMultiTapE(tap);
        }
    }
Exemple #26
0
 public static void Add(Tap tap)
 {
     TapSeries.Add(tap);
 }
Exemple #27
0
    //*****************************************************************************//
    //standard tap event
    public static void MultiTap(Tap tap)
    {
        if(tap.fingerCount==1){
            if(tap.count==1){
                if(onShortTapE!=null) onShortTapE(tap.pos);
            }
            else if(tap.count==2){
                if(onDoubleTapE!=null) onDoubleTapE(tap.pos);
            }

            if(instance.enableMultiTapFilter) instance.CheckMultiTap(tap);
            else if(onMultiTapE!=null) onMultiTapE(tap);
        }
        else{
            if(tap.fingerCount==2){
                if(tap.count==1){
                    DFShortTap(tap.pos);
                }
                else if(tap.count==2){
                    DFDoubleTap(tap.pos);
                }
            }

            if(instance.enableMultiTapFilter) instance.CheckMFMultiTap(tap);
            else if(onMFMultiTapE!=null) onMFMultiTapE(tap);
        }
    }
Exemple #28
0
 /// <summary>
 /// Raises the <see cref="Tap"/> event.
 /// </summary>
 /// <param name="fingerID">A value which identifies the finger which was tapped.</param>
 /// <param name="x">The x-coordinate at which the finger was tapped.</param>
 /// <param name="y">The y-coordinate at which the finger was tapped.</param>
 protected virtual void OnTap(Int64 fingerID, Single x, Single y) =>
 Tap?.Invoke(this, fingerID, x, y);
Exemple #29
0
 void tapEnd(Tap tap)
 {
     //TODO dire al mondo che cosa ho attivato e interagirci
 }
Exemple #30
0
    //called when a tap is detected
    void OnTap(Tap tap)
    {
        //if the tap is triggered by mouse, we want only left mouse button
        if(tap.isMouse && tap.index!=0) return;

        //get the relative vector between the turret and the tapPos
        Vector2 tempVector=tap.pos-turretPos;

        bool recalculateVector=false;

        //calculate the angle based on the relative vector
        float angle=Mathf.Asin(tempVector.y/tempVector.magnitude)*Mathf.Rad2Deg;

        //if the angle exceed what is permmited
        if(angle<minElevation || angle>maxElevation){
            //clamp the angle to what's within the limited value
            angle=Mathf.Clamp(angle, minElevation, maxElevation);
            //set this flag to true so we know we need to adjust the relative vector to fit the angle
            recalculateVector=true;
        }

        //set the turret rotation according to the angle,
        turret.rotation=Quaternion.Euler(-angle, turret.rotation.eulerAngles.y, turret.rotation.eulerAngles.z);

        //if the angle value is modified earlier, now modified the relative vector value to fit the angle
        if(recalculateVector){
            tempVector.x=Mathf.Cos(angle*Mathf.Deg2Rad);
            tempVector.y=Mathf.Sin(angle*Mathf.Deg2Rad);
        }

        //calculate the cursor position based on the turretPos,
        //which is basically 100 pixels away from turretPos in the direction of the relative vector
        Vector2 pos=turretPos+tempVector.normalized*100;
        //crosshair default pixel inset is (-35, -35, 70, 70) and it's transform is positioned at (0, 0, 0)
        crosshair.pixelInset=new Rect(pos.x-35, pos.y-35, 70, 70);
    }
Exemple #31
0
 public Office UpdateTap(int tapId, Tap tap)
 {
     throw new NotImplementedException();
 }
 /// <inheritdoc/>
 public override void Update(TRoot item)
 {
     Inner.Update(item);
     Tap.AddOrUpdate(item);
 }
Exemple #33
0
 public static void WriteDataCallback(IAsyncResult asyncResult)
 {
     Tap.EndWrite(asyncResult);
     WaitObject2.Set();
 }
 /// <inheritdoc/>
 public override void Remove(TRoot item)
 {
     Inner.Remove(item);
     Tap.Remove(item);
 }
Exemple #35
0
 void OnMultiTap(Tap tap)
 {
     if (tap.count == 2){DeselectShape(tap.pos);}
 }
 /// <inheritdoc/>
 public override void Remove(TIdentity id)
 {
     Inner.Remove(id);
     Tap.Remove(id);
 }
Exemple #37
0
 /// <summary>
 /// Pipes the input value in the given Action, i.e. invokes the given Action on the given value.
 /// returning the input value. Not really a genuine implementation of pipe, since it combines pipe with Tap.
 /// </summary>
 public static T Pipe <T>(this T input, Action <T> func) => Tap(func)(input);
    public IEnumerator Routine(TapDetector tapD)
    {
        tapDetector     = tapD;
        triggerTime     = Time.realtimeSinceStartup;
        startTimeCharge = Time.realtimeSinceStartup;
        yield return(new WaitForSeconds(0.075f));

        if (indexes.Count < 2)
        {
            routineEnded = true;
            yield break;
        }
        count  = indexes.Count;
        posAvg = Vector2.zero;
        for (int i = 0; i < positions.Count; i++)
        {
            posAvg += positions[i];
        }
        posAvg      /= (float)positions.Count;
        this.posList = new Vector2[positions.Count];
        positions.CopyTo(this.posList);
        indexList = new int[indexes.Count];
        indexes.CopyTo(indexList);
        bool  isOn     = true;
        float liftTime = -1f;

        while (isOn)
        {
            for (int j = 0; j < indexes.Count; j++)
            {
                Touch touch = IT_Gesture.GetTouch(indexes[j]);
                if (touch.phase == TouchPhase.Moved)
                {
                    isOn = false;
                }
                if (touch.position == Vector2.zero)
                {
                    if (indexes.Count == count)
                    {
                        liftTime = Time.realtimeSinceStartup;
                    }
                    indexes.RemoveAt(j);
                    j--;
                }
            }
            if (Time.realtimeSinceStartup - startTimeCharge > tapDetector.minChargeTime && chargeState == _ChargeState.Clear)
            {
                chargeState = _ChargeState.Charging;
                ChargedInfo cInfo3 = new ChargedInfo(val: Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / tapDetector.maxChargeTime), 0f, 1f), p: posAvg, posL: this.posList, inds: indexList);
                IT_Gesture.ChargeStart(cInfo3);
            }
            else if (chargeState == _ChargeState.Charging)
            {
                float       chargedValue = Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / tapDetector.maxChargeTime), 0f, 1f);
                ChargedInfo cInfo2       = new ChargedInfo(posAvg, this.posList, chargedValue, indexList);
                if (tapDetector.chargeMode == _ChargeMode.PingPong)
                {
                    if (chargedValue == 1f || chargedValue == 0f)
                    {
                        chargeDir *= -1;
                        if (chargeDir == 1)
                        {
                            chargeConst = 0;
                        }
                        else if (chargeDir == -1)
                        {
                            chargeConst = 1;
                        }
                        startTimeCharge = Time.realtimeSinceStartup;
                    }
                    IT_Gesture.Charging(cInfo2);
                }
                else if (chargedValue < 1f)
                {
                    IT_Gesture.Charging(cInfo2);
                }
                else
                {
                    cInfo2.percent = 1f;
                    if (tapDetector.chargeMode == _ChargeMode.Once)
                    {
                        chargeState = _ChargeState.Charged;
                        IT_Gesture.ChargeEnd(cInfo2);
                        startTimeCharge = float.PositiveInfinity;
                    }
                    else if (tapDetector.chargeMode == _ChargeMode.Clamp)
                    {
                        chargeState = _ChargeState.Charged;
                        IT_Gesture.Charging(cInfo2);
                    }
                    else if (tapDetector.chargeMode == _ChargeMode.Loop)
                    {
                        chargeState = _ChargeState.Clear;
                        IT_Gesture.ChargeEnd(cInfo2);
                        startTimeCharge = Time.realtimeSinceStartup;
                    }
                }
            }
            if (!longTap && Time.realtimeSinceStartup - triggerTime > tapDetector.longTapTime && indexes.Count == count)
            {
                Vector2[] posList2 = new Vector2[positions.Count];
                positions.CopyTo(posList2);
                Tap tap = new Tap(1, count, posList2, indexList);
                IT_Gesture.LongTap(tap);
                longTap = true;
            }
            if (indexes.Count < count && (Time.realtimeSinceStartup - liftTime > 0.075f || indexes.Count == 0))
            {
                if (indexes.Count == 0 && liftTime - triggerTime < tapDetector.shortTapTime + 0.1f)
                {
                    Vector2[] posList = new Vector2[positions.Count];
                    positions.CopyTo(posList);
                    tapDetector.CheckMultiTapMFTouch(count, posList, indexList);
                }
                break;
            }
            yield return(null);
        }
        if (chargeState == _ChargeState.Charging || (chargeState == _ChargeState.Charged && tapDetector.chargeMode != 0))
        {
            ChargedInfo cInfo = new ChargedInfo(val: Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / tapDetector.maxChargeTime), 0f, 1f), p: posAvg, posL: this.posList, inds: indexList);
            IT_Gesture.ChargeEnd(cInfo);
        }
        routineEnded = true;
    }
Exemple #39
0
        /// <inheritdoc/>
        public override async Task AddOrUpdateAsync(TRoot item)
        {
            await Inner.AddOrUpdateAsync(item).ConfigureAwait(false);

            await Tap.AddOrUpdateAsync(item).ConfigureAwait(false);
        }
Exemple #40
0
 private void OnMultiTap(Tap tap)
 {
     Application.LoadLevel(0);
 }
Exemple #41
0
        /// <inheritdoc/>
        public override async Task RemoveAsync(TIdentity id)
        {
            await Inner.RemoveAsync(id).ConfigureAwait(false);

            await Tap.RemoveAsync(id).ConfigureAwait(false);
        }
Exemple #42
0
 public Task <Tap> UpdateAsync(Tap resource, IRequestContext context, CancellationToken cancellation)
 {
     throw new NotImplementedException();
 }
Exemple #43
0
 /// <inheritdoc/>
 public override async Task UpdateAsync(TRoot item)
 {
     await Task.WhenAll(
         Inner.UpdateAsync(item),
         Tap.AddOrUpdateAsync(item)).ConfigureAwait(false);
 }
Exemple #44
0
 public Task <ResourceCreationResult <Tap, int> > CreateAsync(Tap resource, IRequestContext context, CancellationToken cancellation)
 {
     throw new NotImplementedException();
 }
Exemple #45
0
 /// <inheritdoc/>
 public override async Task RemoveAsync(TIdentity id)
 {
     await Task.WhenAll(
         Inner.RemoveAsync(id),
         Tap.RemoveAsync(id)).ConfigureAwait(false);
 }
Exemple #46
0
 private void Start()
 {
     game          = GameManager.Instance;
     tapController = Tap.Instance;
 }
 public decimal CalculateFare(Tap tapOn, Tap tapOff)
 {
     return(3);
 }
    public IEnumerator Routine(TapDetector tapD)
    {
        tapDetector = tapD;

        triggerTime     = Time.time;
        startTimeCharge = Time.time;

        yield return(new WaitForSeconds(0.075f));

        if (indexes.Count < 2)
        {
            routineEnded = true;
            yield break;
        }
        else
        {
            count = indexes.Count;

            posAvg = Vector2.zero;
            foreach (Vector2 p in positions)
            {
                posAvg += p;
            }
            posAvg /= positions.Count;

            posList = new Vector2[positions.Count];
            positions.CopyTo(posList);
            indexList = new int[indexes.Count];
            indexes.CopyTo(indexList);
        }

        bool isOn = true;

        float liftTime = -1;

        while (isOn)
        {
            for (int i = 0; i < indexes.Count; i++)
            {
                Touch touch = Gesture.GetTouch(indexes[i]);
                if (touch.phase == TouchPhase.Moved)
                {
                    isOn = false;
                }

                if (touch.position == Vector2.zero)
                {
                    if (indexes.Count == count)
                    {
                        liftTime = Time.time;
                    }
                    indexes.RemoveAt(i);
                    i--;
                }
            }

            if (Time.time - startTimeCharge > tapDetector.minChargeTime && chargeState == _ChargeState.Clear)
            {
                chargeState = _ChargeState.Charging;
                float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.time - startTimeCharge) / tapDetector.maxChargeTime), 0, 1);
                ChargedInfo cInfo        = new ChargedInfo(posAvg, posList, chargedValue, indexList);
                Gesture.ChargeStart(cInfo);
            }
            else if (chargeState == _ChargeState.Charging)
            {
                float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.time - startTimeCharge) / tapDetector.maxChargeTime), 0, 1);
                ChargedInfo cInfo        = new ChargedInfo(posAvg, posList, chargedValue, indexList);

                if (tapDetector.chargeMode == _ChargeMode.PingPong)
                {
                    if (chargedValue == 1 || chargedValue == 0)
                    {
                        chargeDir *= -1;
                        if (chargeDir == 1)
                        {
                            chargeConst = 0;
                        }
                        else if (chargeDir == -1)
                        {
                            chargeConst = 1;
                        }
                        startTimeCharge = Time.time;
                    }

                    Gesture.Charging(cInfo);
                }
                else
                {
                    if (chargedValue < 1.0f)
                    {
                        Gesture.Charging(cInfo);
                    }
                    else
                    {
                        cInfo.percent = 1.0f;

                        if (tapDetector.chargeMode == _ChargeMode.Once)
                        {
                            chargeState = _ChargeState.Charged;
                            Gesture.ChargeEnd(cInfo);
                            startTimeCharge = Mathf.Infinity;
                            chargedValue    = 0;
                        }
                        else if (tapDetector.chargeMode == _ChargeMode.Clamp)
                        {
                            chargeState = _ChargeState.Charged;
                            Gesture.Charging(cInfo);
                        }
                        else if (tapDetector.chargeMode == _ChargeMode.Loop)
                        {
                            chargeState = _ChargeState.Clear;
                            Gesture.ChargeEnd(cInfo);
                            startTimeCharge = Time.time;
                        }
                    }
                }
            }

            if (!longTap && Time.time - triggerTime > tapDetector.longTapTime)
            {
                if (indexes.Count == count)
                {
                    Vector2[] posList = new Vector2[positions.Count];
                    positions.CopyTo(posList);

                    Tap tap = new Tap(1, count, posList, indexList);
                    Gesture.LongTap(tap);
                    longTap = true;
                }
            }

            if (indexes.Count < count)
            {
                if (Time.time - liftTime > 0.075f || indexes.Count == 0)
                {
                    if (indexes.Count == 0)
                    {
                        if (liftTime - triggerTime < tapDetector.shortTapTime + 0.1f)
                        {
                            Vector2[] posList = new Vector2[positions.Count];
                            positions.CopyTo(posList);
                            //Tap tap=new Tap(1, count, posList);
                            //Gesture.MFShortTap(tap);
                            tapDetector.CheckMultiTapMFTouch(count, posList, indexList);
                        }
                    }
                    isOn = false;
                    break;
                }
            }

            yield return(null);
        }

        if (chargeState == _ChargeState.Charging || (chargeState == _ChargeState.Charged && tapDetector.chargeMode != _ChargeMode.Once))
        {
            float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.time - startTimeCharge) / tapDetector.maxChargeTime), 0, 1);
            ChargedInfo cInfo        = new ChargedInfo(posAvg, posList, chargedValue, indexList);
            Gesture.ChargeEnd(cInfo);
        }

        routineEnded = true;
    }
 public void OnMultiTap(Tap tap)
 {
     this._statusLabel.text = tap.ToString();
 }
        public MiniGrid(int semitoneShift) : base()
        {
            this.semitoneShift = semitoneShift;

            //No grid spacing
            this.ColumnSpacing   = 0;
            this.RowSpacing      = 0;
            this.BackgroundColor = Color.Black;
            //Using GridUnitType.Star means the squares will split the grid in half horizontally and vertically
            this.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            this.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });                                                                                                // Add in column definitions
            this.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            this.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });                                                                                            // Add in row definitions

            // Add in boxviews
            topLeft = new BoxView {
                BackgroundColor = NoNotesColor
            };
            topRight = new BoxView {
                BackgroundColor = NoNotesColor
            };
            bottomLeft = new BoxView {
                BackgroundColor = NoNotesColor
            };
            bottomRight = new BoxView {
                BackgroundColor = NoNotesColor
            };

            this.Children.Add(topLeft, 0, 0);
            this.Children.Add(topRight, 1, 0);
            this.Children.Add(bottomLeft, 0, 1);
            this.Children.Add(bottomRight, 1, 1);

            //When created the top left boxview will cover the whole grid
            Grid.SetColumnSpan(topLeft, 2);
            Grid.SetRowSpan(topLeft, 2);

            // Give the grid a tapGesture recognizer
            TapGestureRecognizer tgr = new TapGestureRecognizer()
            {
                Command = new Command(delegate()
                {
                    Tap.Invoke(this);
                })
            };

            //Add recognizer to the grid itself and each of the boxes
            this.GestureRecognizers.Add(tgr);
            topLeft.GestureRecognizers.Add(tgr);
            topRight.GestureRecognizers.Add(tgr);
            bottomLeft.GestureRecognizers.Add(tgr);
            bottomRight.GestureRecognizers.Add(tgr);
        }
Exemple #51
0
 //called when a long tap event is ended
 void OnLongTap(Tap tap)
 {
     //do a raycast base on the position of the tap
     Ray ray = Camera.main.ScreenPointToRay(tap.pos);
     RaycastHit hit;
     //if the tap lands on the longTapObj
     if(Physics.Raycast(ray, out hit, Mathf.Infinity)){
         if(hit.collider.transform==longTapObj){
             //place the indicator at the object position and assign a random color to it
             Indicator.transform.position=longTapObj.position;
             Indicator.startColor=GetRandomColor();
             //emit a set number of particle
             Indicator.Emit(30);
         }
     }
 }
 protected override IDuplexSessionChannel OnEndAcceptChannel(IAsyncResult result) => Tap.Complete <IDuplexSessionChannel>(result);
Exemple #53
0
 public static void LongTap(Tap tap)
 {
     if(tap.fingerCount>1){
         if(tap.fingerCount==2){
             if(onDFLongTapE!=null) onDFLongTapE(tap.pos);
         }
         if(onMFLongTapE!=null) onMFLongTapE(tap);
     }
     else{
         if(onLongTapE!=null) onLongTapE(tap);
     }
 }
Exemple #54
0
 protected virtual void OnTap(bool tapped)
 {
     Tap?.Invoke(this, tapped);
 }
Exemple #55
0
    void CheckMultiTap(Tap tap)
    {
        tapExisted+=1;

        if(tap.count==maxMultiTapCount){
            tapExisted=0;
            if(onMultiTapE!=null) onMultiTapE(tap);
        }
        else{
            StartCoroutine(TapCoroutine(tap));
        }
    }
 protected override void OnEndOpen(IAsyncResult result) => Tap.Complete(result);
Exemple #57
0
	public IEnumerator Routine(TapDetector tapD){
		tapDetector=tapD;
		
		triggerTime=Time.realtimeSinceStartup;
		startTimeCharge=Time.realtimeSinceStartup;
		
		yield return new WaitForSeconds(0.075f);
		if(indexes.Count<2){
			routineEnded=true;
			yield break;
		}
		else{
			count=indexes.Count;

			posAvg=Vector2.zero;
			//foreach(Vector2 p in positions) posAvg+=p;
			for(int i=0; i<positions.Count; i++) posAvg+=positions[i];
			posAvg/=positions.Count;
			
			posList = new Vector2[positions.Count];
  			positions.CopyTo( posList );
  			indexList = new int[indexes.Count];
  			indexes.CopyTo( indexList );		
		}
		
		bool isOn=true;
		
		float liftTime=-1;
		
		while(isOn){
			for(int i=0; i<indexes.Count; i++){
				Touch touch=IT_Gesture.GetTouch(indexes[i]);
				if(touch.phase==TouchPhase.Moved) isOn=false;
				
				if(touch.position==Vector2.zero){
					if(indexes.Count==count){
						liftTime=Time.realtimeSinceStartup;
					}
					indexes.RemoveAt(i);
					i--;
				}
			}
			
			if(Time.realtimeSinceStartup-startTimeCharge>tapDetector.minChargeTime && chargeState==_ChargeState.Clear){
				chargeState=_ChargeState.Charging;
				float chargedValue=Mathf.Clamp(chargeConst+chargeDir*((Time.realtimeSinceStartup-startTimeCharge)/tapDetector.maxChargeTime), 0, 1);
				ChargedInfo cInfo=new ChargedInfo(posAvg, posList, chargedValue, indexList);
				IT_Gesture.ChargeStart(cInfo);
			}
			else if(chargeState==_ChargeState.Charging){

				float chargedValue=Mathf.Clamp(chargeConst+chargeDir*((Time.realtimeSinceStartup-startTimeCharge)/tapDetector.maxChargeTime), 0, 1);
				ChargedInfo cInfo=new ChargedInfo(posAvg, posList, chargedValue, indexList);
				
				if(tapDetector.chargeMode==_ChargeMode.PingPong){
					if(chargedValue==1 || chargedValue==0){
						chargeDir*=-1;
						if(chargeDir==1) chargeConst=0;
						else if(chargeDir==-1) chargeConst=1;
						startTimeCharge=Time.realtimeSinceStartup;
					}
					
					IT_Gesture.Charging(cInfo);
				}
				else{
					if(chargedValue<1.0f){
						IT_Gesture.Charging(cInfo);
					}
					else{
						cInfo.percent=1.0f;
						
						if(tapDetector.chargeMode==_ChargeMode.Once){
							chargeState=_ChargeState.Charged;
							IT_Gesture.ChargeEnd(cInfo);
							startTimeCharge=Mathf.Infinity;
							chargedValue=0;
						}
						else if(tapDetector.chargeMode==_ChargeMode.Clamp){
							chargeState=_ChargeState.Charged;
							IT_Gesture.Charging(cInfo);
						}
						else if(tapDetector.chargeMode==_ChargeMode.Loop){
							chargeState=_ChargeState.Clear;
							IT_Gesture.ChargeEnd(cInfo);
							startTimeCharge=Time.realtimeSinceStartup;
						}
					}
				}

			}
			
			if(!longTap && Time.realtimeSinceStartup-triggerTime>tapDetector.longTapTime){
				if(indexes.Count==count){
					    
					Vector2[] posList = new Vector2[positions.Count];
  					positions.CopyTo( posList );
					
					Tap tap=new Tap(1, count, posList , indexList);
					IT_Gesture.LongTap(tap);
					longTap=true;
				}
			}
			
			if(indexes.Count<count){
				if(Time.realtimeSinceStartup-liftTime>0.075f || indexes.Count==0){
					if(indexes.Count==0){
						if(liftTime-triggerTime<tapDetector.shortTapTime+0.1f){
							Vector2[] posList = new Vector2[positions.Count];
		  					positions.CopyTo( posList );
							//Tap tap=new Tap(1, count, posList);
							//IT_Gesture.MFShortTap(tap);
							tapDetector.CheckMultiTapMFTouch(count, posList, indexList);
						}
					}
					isOn=false;
					break;
				}
			}
			
			yield return null;
		}
		
		if(chargeState==_ChargeState.Charging || (chargeState==_ChargeState.Charged && tapDetector.chargeMode!=_ChargeMode.Once)){
			float chargedValue=Mathf.Clamp(chargeConst+chargeDir*((Time.realtimeSinceStartup-startTimeCharge)/tapDetector.maxChargeTime), 0, 1);
			ChargedInfo cInfo=new ChargedInfo(posAvg, posList, chargedValue, indexList);
			IT_Gesture.ChargeEnd(cInfo);
		}
		
		routineEnded=true;
	}
Exemple #58
0
 void tapBegin(Tap tap)
 {
     //TODO boh?
 }