public void ArrowColliderEnterCallback(Collider collider, float attackPower) { if ((SlasheonUtility.IsLayerNameMatch(collider.gameObject, "Enemy"))) { MissionActor hitActor = collider.gameObject.GetComponent <MissionActor>(); hitActor.Damage(attackPower); _playerController.InstanceArrowDamageEffect(collider); } }
/// <summary> /// UIをタッチしているかを返す /// </summary> /// <param name="touchID"></param> /// <returns></returns> public bool IsUITouch(int touchID) { PointerEventData pointer = new PointerEventData(EventSystem.current); #if UNITY_IOS || UNITY_ANDROID Touch touch = new Touch(); for (int i = 0; i < Input.touches.Length; i++) { if (Input.touches[i].fingerId == touchID) { touch = Input.touches[i]; pointer.position = touch.position; List <RaycastResult> result = new List <RaycastResult>(); EventSystem.current.RaycastAll(pointer, result); //レイヤーでUIかを判定して整理する for (int j = 0; j < result.Count; j++) { if (SlasheonUtility.IsAnyLayerNameMatch(result[i].gameObject, SlasheonUtility.UILayer)) { //Debug.Log("UITouch:True id : " + touchID); return(true); } } } } //Debug.Log("IsUITouch:False :: id : " + touchID); return(false); #else pointer.position = Input.mousePosition; List <RaycastResult> result = new List <RaycastResult>(); EventSystem.current.RaycastAll(pointer, result); //レイヤーでUIかを判定して整理する for (int i = 0; i < result.Count; i++) { //一致していなければリストから除く if (SlasheonUtility.IsAnyLayerNameMatch(result[i].gameObject, SlasheonUtility.UILayer)) { return(true); } } return(false); #endif }
public void ExitColliderEnterEvent(Collider other, StageExitCollider script) { if (SlasheonUtility.IsLayerNameMatch(other.gameObject, "Player")) { switch (script.StageExitType) { case StageExitType.FieldChange: MissionSceneManager.Instance.ChangeStage(script.TargetKey); break; case StageExitType.ToHome: SceneControllManager.Instance.ChangeSceneAsync("HomeScene", true, true, true); break; case StageExitType.ExitMission: SceneControllManager.Instance.ChangeSceneAsync("HomeScene", true, true, true); break; default: break; } } }
public void SlashColliderEnterCallback(Collider collider) { if (_playerController.PlayerState.stamina < _playerController.PlayerState.consumptionStaminaSlashHit) { _playerController.SlashCollider.RemoveCollider(); return; } if ((SlasheonUtility.IsLayerNameMatch(collider.gameObject, "Enemy"))) { MissionActor hitActor = collider.gameObject.GetComponent <MissionActor>(); //一度の斬撃で複数回ダメージ判定しないように調整 int hitedCount = slashHitEnemyList.Where(x => x.transform.GetInstanceID() == hitActor.transform.GetInstanceID()).Count(); if (hitedCount == 0) { hitActor.Damage(_playerController.ActorState.attack); _playerController.InstanceSlashDamageEffect(collider, InputManager.Instance.GetTouchPosition(slashTouchID)); slashHitEnemyList.Add(hitActor); UpdateStamina(_playerController.PlayerState.consumptionStaminaSlashHit); } } }
private Vector3 TouchActionOnField() { int touchID = InputManager.Instance.GetAnyTouchBeginID(); if (touchID != -1) { if (!InputManager.Instance.IsUITouch(touchID)) { moveTouchID = touchID; } } if (moveTouchID != -1) { if (!_playerController.PlayerRotation.isRotationMoving) { if (InputManager.Instance.IsTouchEnd(moveTouchID)) { Vector3 touchPosition = InputManager.Instance.GetTouchPosition(moveTouchID); Ray ray = Camera.main.ScreenPointToRay(touchPosition); RaycastHit hit = new RaycastHit(); //Debug.DrawRay(ray.origin, ray.direction * raycastDistance, Color.red, 0.7f, false); if (Physics.Raycast(ray, out hit, raycastDistance)) { //Debug.Log("hit : " + LayerMask.LayerToName(hit.collider.gameObject.layer)); if (SlasheonUtility.IsLayerNameMatch(hit.collider.gameObject, "Field")) { _playerController.moveBeginPosition = _playerController.transform.position; _playerController.isMoving = true; return(hit.point); } } moveTouchID = -1; } } } return(Vector3.zero); }
/// <summary> /// Raycastで取得したUIを返す /// </summary> /// <returns></returns> public RaycastResult GetRaycastResult(int touchID) { PointerEventData pointer = new PointerEventData(EventSystem.current); #if UNITY_IOS || UNITY_ANDROID Touch touch = new Touch(); for (int i = 0; i < Input.touches.Length; i++) { if (Input.touches[i].fingerId == touchID) { touch = Input.touches[i]; pointer.position = touch.position; List <RaycastResult> result = new List <RaycastResult>(); EventSystem.current.RaycastAll(pointer, result); List <int> removeNums = new List <int>(); //レイヤーでUIかを判定して整理する for (int j = 0; j < result.Count; j++) { //一致していなければリストから除く if (SlasheonUtility.IsAnyLayerNameMatch(result[j].gameObject, SlasheonUtility.UILayer)) { removeNums.Add(i); } } for (int k = removeNums.Count - 1; k > 0; k--) { result.RemoveAt(k); } if (result.Count > 0) { return(result[0]); } else { return(new RaycastResult()); } } } return(new RaycastResult()); #else pointer.position = Input.mousePosition; List <RaycastResult> result = new List <RaycastResult>(); EventSystem.current.RaycastAll(pointer, result); List <int> removeNums = new List <int>(); //レイヤーでUIかを判定して整理する for (int i = 0; i < result.Count; i++) { //一致していなければリストから除く if (SlasheonUtility.IsAnyLayerNameMatch(result[i].gameObject, SlasheonUtility.UILayer)) { removeNums.Add(i); } } for (int i = removeNums.Count - 1; i > 0; i--) { //Debug.Log("取り除きます " + i); result.RemoveAt(i); } if (result.Count > 0) { return(result[0]); } else { return(new RaycastResult()); } #endif }