public void OnTapStop(Toucher toucher, Vector2 position) { if (CurrentState == State.Move) { CurrentState = State.Idle; } }
public void OnTapStay(Toucher toucher, Vector2 touchPos) { if (CurrentState == State.Move) { Move(touchPos); } }
public void OnDoubleTap(Toucher toucher, Vector2 position) { if ((CurrentState == State.Idle || CurrentState == State.Emotion) && toucher == _toucher) { CurrentState = State.Tickles; } }
private void Awake() { _hexMesh = GetComponentInChildren <HexMesh>(); _toucher = Instantiate(_toucher); _toucher.TouchedCell += OnCellTouched; _cells = new HexCell[_width * _height]; for (int z = 0; z < _height; z++) { for (int x = 0; x < _width; x++) { _cells[x + z * _height] = CreateCell(x, z); SetNeigbor(x, z); } } for (int z = 0; z < _height; z++) { for (int x = 0; x < _width; x++) { var cell = _cells[x + z * _height]; cell.SetMarkText(cell.GetRealNeigborCount().ToString()); } } }
public void OnTapStart(Toucher toucher, Vector2 touchPos) { if (_game.Boomon.CurrentState == BoomonController.State.Idle) { Play(); } }
public void Stream() { Init(); var input = string.Empty; while (!input.Equals("q", StringComparison.OrdinalIgnoreCase)) { Hub.Reporter.WriteMenu(); input = Console.ReadLine(); if (input.Equals("a", StringComparison.OrdinalIgnoreCase)) { Toucher.TouchAllAssemblyFiles(SlnProjObj); } else if (input.Equals("W", StringComparison.OrdinalIgnoreCase)) { Hub.Reporter.ListWatched(SlnProjObj); } else if (input.Equals("i", StringComparison.OrdinalIgnoreCase)) { Hub.Reporter.ListIgnored(SlnProjObj); } else if (input.Equals("u", StringComparison.OrdinalIgnoreCase)) { Hub.Reporter.ListUpStream(SlnProjObj); } } }
void Awake() { tin = GameObject.FindGameObjectWithTag("GameController").GetComponent <Toucher>(); noiseAmt = new float[noiseRings.Length]; ringTime = new float[noiseRings.Length]; timeSinceLastRing = 0.0f; loudestNoiseSinceRing = 0.0f; }
//---------------------------------------------------------------------------------- #region Events.Toucher public void OnTapStart(Toucher toucher, Vector2 touchPos) { if (toucher != null || CurrentState != State.Idle && CurrentState != State.Emotion) { return; } CurrentState = State.Move; }
private void Shoot(Toucher toucher, Vector2 pos) { if (!_canBeShot) { return; } Animator.SetTrigger(_shootTriggerName); AudioSource.PlayOneShot(_shootClip); _canBeShot = false; }
private void OnTriggerExit2D(Collider2D collision) { Toucher toucher = collision.GetComponent <Toucher>(); if (toucher == null) { return; } onTouchExit.OnNext(toucher); }
/// <summary> /// 対象がInteractorなら、対象に自身を登録する。 /// </summary> /// <param name="interactor"></param> public void RegisterToInteractor(Toucher toucher) { Interactor interactor = toucher.GetComponent <Interactor>(); if (interactor == null) { return; } interactor.SetTarget(this); }
/// <summary> /// ToucherのInteract対象を削除する。 /// </summary> /// <param name="toucher"></param> public void RemoveFromInteractor(Toucher toucher) { Interactor interactor = toucher.GetComponent <Interactor>(); if (interactor == null) { return; } interactor.RemoveTarget(); }
/// <summary> /// /// </summary> /// <param name="toucher"></param> /// <param name="position"></param> private void OnObjectTapStay(Toucher toucher, Vector2 position) { if (toucher != null) { toucher.OnTapStay(toucher, position); } for (int i = _broadcastListeners.Count - 1; i >= 0; --i) { if (_broadcastListeners[i] != toucher) { _broadcastListeners[i].OnTapStay(toucher, position); } } }
/// <summary> /// /// </summary> /// <param name="toucher"></param> /// <param name="position"></param> private void OnObjectDoubleTap(Toucher toucher, Vector2 position) { Log("OnObjectDoubleTap"); if (toucher != null) { toucher.OnDoubleTap(toucher, position); } for (int i = _broadcastListeners.Count - 1; i >= 0; --i) { if (_broadcastListeners[i] != toucher) { _broadcastListeners[i].OnDoubleTap(toucher, position); } } }
void GenerateToucher(GameObject finger, bool isRightHand) { finger.tag = "Player"; BoxCollider fingerCollider = finger.AddComponent <BoxCollider>(); fingerCollider.isTrigger = true; fingerCollider.center = new Vector3(0.015f, 0f, 0f); fingerCollider.size = new Vector3(0.03f, 0.015f, 0.015f); Rigidbody finderRigidbody = finger.AddComponent <Rigidbody>(); finderRigidbody.useGravity = false; Toucher fingerToucher = finger.AddComponent <Toucher>(); fingerToucher.isRightHand = isRightHand; }
//============================================== #region Private Methods private Toucher FindToucherAtPosition(Vector2 position) { Toucher toucher = null; Ray ray = Camera.main.ScreenPointToRay(position); RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo, _objectDistanceMax, _touchLayerMask)) { toucher = hitInfo.collider.gameObject.GetComponent <Toucher>(); } if (!_selfListeners.Contains(toucher) && !_broadcastListeners.Contains(toucher)) { toucher = null; } return(toucher); }
/// <summary> /// /// </summary> /// <param name="toucher"></param> /// <param name="position"></param> /// <param name="direction"></param> /// <param name="speedRatio"></param> private void OnObjectSwipe(Toucher toucher, Vector2 position, Vector2 direction, float speedRatio) { if (!_selfListeners.Contains(toucher) && !_broadcastListeners.Contains(toucher)) { toucher = null; } if (toucher != null) { toucher.OnSwipe(toucher, position, direction, speedRatio); } for (int i = _broadcastListeners.Count - 1; i >= 0; --i) { if (_broadcastListeners[i] != toucher) { _broadcastListeners[i].OnSwipe(toucher, position, direction, speedRatio); } } }
public void OnSwipe(Toucher toucher, Vector2 position, Vector2 direction, float speedRatio) { Log("OnSwipe"); if (toucher != _toucher) { return; } float throwDegress = Mathf.Atan(direction.y / Mathf.Abs(direction.x)) * Mathf.Rad2Deg; if (throwDegress > _setup.ThrowDegreesMin) { Throw(position, direction, speedRatio); } else { CurrentState = State.Move; } }
public override void OnSwipe(Toucher toucher, Vector2 position, Vector2 direction, float speedRatio) { if (toucher != gameObject) { if (toucher != null) { return; } Vector2 myScreenPos = Camera.main.WorldToScreenPoint(_rigid.position); if ((myScreenPos - position).sqrMagnitude > _inchesSqrMax) { return; } } Vector3 touchPosition = Camera.main.ScreenToWorldPoint(position); Throw(CalcThrowVelocity(direction, speedRatio), touchPosition); }
public virtual void OnDoubleTap(Toucher toucher, Vector2 position) { }
public virtual void OnSwipe(Toucher toucher, Vector2 position, Vector2 direction, float speedRatio) { _swipe.Invoke(toucher, position, direction, speedRatio); }
public virtual void OnDoubleTap(Toucher toucher, Vector2 position) { _doubleTap.Invoke(toucher, position); }
public virtual void OnTapStay(Toucher toucher, Vector2 position) { _tapStay.Invoke(toucher, position); }
public virtual void OnTapStart(Toucher toucher, Vector2 touchPos) { _tapStart.Invoke(toucher, touchPos); }
public virtual void OnTapStay(Toucher toucher, Vector2 position) { }
void Start() { tin = GameObject.FindGameObjectWithTag("GameController").GetComponent <Toucher>(); startPos = transform.position; followCam = GetComponentInChildren <Camera>(); }
/// <summary> /// 触れたとき。 /// </summary> /// <param name="toucher"></param> private void OnTouchEnter(Toucher toucher) { interactable.RegisterToInteractor(toucher); animator.SetBool(aKeyCanInteract, true); }
void Awake() { tin = GameObject.FindGameObjectWithTag("GameController").GetComponent <Toucher>(); spCol = GetComponent <SphereCollider>(); }
/// <summary> /// 離れたとき。 /// </summary> /// <param name="toucher"></param> private void OnTouchExit(Toucher toucher) { interactable.RemoveFromInteractor(toucher); animator.SetBool(aKeyCanInteract, false); }