/// <summary> /// Handle behaviours on input /// </summary> /// <param name="haptiQ"></param> /// <returns></returns> public Tuple<BEHAVIOUR_RULES, IBehaviour, IBehaviour> handleInput(HaptiQ haptiQ) { if (this.Parent != null) { Tuple<STATE, IBehaviour> HaptiQState = _HaptiQBehaviours.ContainsKey(haptiQ.getID()) ? _HaptiQBehaviours[haptiQ.getID()] : null; if (pointIsInside(haptiQ.position)) { IBehaviour prevBehaviour = HaptiQState != null ? HaptiQState.Item2 : null; IBehaviour currentBehaviour = chooseBehaviour(haptiQ); currentBehaviour.updateNext(prevBehaviour); BEHAVIOUR_RULES rule = BEHAVIOUR_RULES.SUBS; if (currentBehaviour.Equals(prevBehaviour)) { rule = BEHAVIOUR_RULES.NOPE; } _HaptiQBehaviours[haptiQ.getID()] = new Tuple<STATE, IBehaviour>(STATE.down, currentBehaviour); return new Tuple<BEHAVIOUR_RULES, IBehaviour, IBehaviour>(rule, currentBehaviour, prevBehaviour); } else if (HaptiQState != null && HaptiQState.Item1 == STATE.down) { IBehaviour prevBehaviour = HaptiQState.Item2; IBehaviour currentBehaviour = new BasicBehaviour(haptiQ, BasicBehaviour.TYPES.flat); BEHAVIOUR_RULES rule = BEHAVIOUR_RULES.SUBS; if (currentBehaviour.Equals(prevBehaviour)) { rule = BEHAVIOUR_RULES.NOPE; } _HaptiQBehaviours[haptiQ.getID()] = new Tuple<STATE, IBehaviour>(STATE.up, currentBehaviour); return new Tuple<BEHAVIOUR_RULES, IBehaviour, IBehaviour>(rule, currentBehaviour, prevBehaviour); } } Tuple<BEHAVIOUR_RULES, IBehaviour, IBehaviour> retval = new Tuple<BEHAVIOUR_RULES, IBehaviour, IBehaviour>(BEHAVIOUR_RULES.REMOVE, _HaptiQBehaviours.ContainsKey(haptiQ.getID()) ? _HaptiQBehaviours[haptiQ.getID()].Item2 : null, null); _HaptiQBehaviours[haptiQ.getID()] = new Tuple<STATE, IBehaviour>(STATE.up, null); return retval; }