private void ProcessEnterStair(Collider col) { if (col.CompareTag("Stair")) { if (Input.GetKeyDown(KeyCode.W) && !isWalkOnStair && TimeLayer.EqualTimeLayer(pTimeLayer, col.GetComponentInParent <TimeLayer>())) { EnterStair(col); stairColliders = col.transform.parent.GetComponentsInChildren <BoxCollider>(); InitStairZone(); } } }
public void PushInceptState() { ActiveTimeLayer++; if (ActiveTimeLayer > TimeLayer.Third) { ActiveTimeLayer = TimeLayer.Third; } if (ActiveTimeLayer == TimeLayer.Second) { Camera.main.GetComponent <InceptShaderScript>().StartTransition(); } PlayerHandlerBehaviour.Instance.CreatePlayer(); }
void Start() { InitStatePriority(); pTimeLayer = transform.GetComponentInParent <TimeLayer>(); pBoxCollider = GetComponent <BoxCollider>(); animator = GetComponent <Animator>(); controller = GetComponent <Controller2D>(); interacitveManager = GameObject.FindObjectOfType <InteractiveManager>(); mainCamera = Camera.main; INIT_COLLIDER_OFFSET = pBoxCollider.center; SIT_COLLIDER_OFFSET = INIT_COLLIDER_OFFSET - Vector3.up * 0.08f; gravity = -5; }
public bool CheckCollideable(RaycastHit tmpHit) { if (pTimeLayer == null) { return(false); } if ((TimeLayer.EqualTimeLayer(pTimeLayer, tmpHit.transform.GetComponentInParent <TimeLayer>()) || tmpHit.transform.CompareTag("Ground") || tmpHit.transform.CompareTag("GrabableGround")) && tmpHit.transform != transform && !tmpHit.collider.isTrigger) { return(true); } return(false); }
public void PopInceptState() { ActiveTimeLayer--; if (ActiveTimeLayer < TimeLayer.First) { ActiveTimeLayer = TimeLayer.First; } if (ActiveTimeLayer == TimeLayer.First) { Camera.main.GetComponent <InceptShaderScript>().StartTransition(-1); } PlayerHandlerBehaviour.Instance.DestroyPlayer(); //TODO blending }
public TimeLayer this[int index] { get { if (index == 0) { return(this); } if (this.layers.ContainsKey(index)) { return(this.layers[index]); } TimeLayer timeLayer = new TimeLayer(); this.layers.Add(index, timeLayer); return(timeLayer); } }
bool IsVerticalCollision() { for (int i = 0; i < 3; i++) { var hits = Physics.RaycastAll(Vector3.up * pBoxCollider.bounds.max.y + Vector3.right * pBoxCollider.bounds.min.x * (i / 2), Vector2.up, (INIT_COLLIDER_SIZE.y - SIT_COLLIDER_SIZE.y), controller.collisionMask); for (int j = 0; j < hits.Length; j++) { var hit = hits[j]; if (hit.collider != null && TimeLayer.EqualTimeLayer(hit.collider.GetComponentInParent <TimeLayer>(), pTimeLayer)) { return(true); } } } return(false); }
/// <summary> /// Set the scaled time for the passed in time category /// </summary> /// <param name="timeCategory"></param> /// <param name="scaledTime"></param> public static void SetScaledTime(TimeLayer timeCategory, float scaledTime) { switch (timeCategory) { case TimeLayer.UnscaledDeltaTime: case TimeLayer.DeltaTime: //Debug.LogWarning("You can not change the scaled time of " + timeCategory.ToString()); return; default: timeScaleDictionary[timeCategory] = scaledTime; break; } foreach (TimeManagedObject timeObject in GameOverseer.Instance.GetTimeMangedList(timeCategory)) { timeObject.OnTimeLayerScaleUpdated(); } }
public void Alert() { var colliders = Physics2D.OverlapCircleAll(enemyObj.transform.position, alertRadius, 1 << LayerMask.NameToLayer("Enemy")); for (int i = 0; i < colliders.Length; i++) { var col = colliders [i]; if (TimeLayer.EqualTimeLayer(col.transform.GetComponentInParent <TimeLayer>(), enemyScript.pTimeLayer)) { Debug.Log("Alert Ready"); var hit = Physics2D.Raycast(enemyObj.transform.position + Vector3.up * 0.35f, (col.transform.position - enemyObj.transform.position).normalized, Vector2.Distance(col.transform.position, enemyObj.transform.position), 1 << LayerMask.NameToLayer("Collision")); if (hit.collider == null) { col.GetComponent <EnemyScript> ().GetSpecifiedState <SuspiciousState> (State.Suspicious).InitSuspiciousInfo(enemyScript.GetSpecifiedState <SuspiciousState> (State.Suspicious).targetPos, col.GetComponent <EnemyScript> ().moveSpeed * 0.5f); col.GetComponent <EnemyScript> ().SetState(State.Suspicious); } } } }
public void OnTriggerEnter2D(Collider2D coll) { RangedWeaponBehaviour weapon = coll.GetComponent <RangedWeaponBehaviour>(); OwnedByBehaviour owner = coll.gameObject.GetComponent <OwnedByBehaviour>(); if (owner != null && weapon != null && owner.Owner != Owner.Player) { TimeLayer collisionTimeLayer = coll.GetComponent <ActiveInTimeLayerBehaviour>().ActiveInTimeLayer; if (activeLayer.ActiveInTimeLayer == collisionTimeLayer || collisionTimeLayer == TimeLayer.All) { if (PlayerData.TakeHit(weapon.Data.Damage)) { Application.LoadLevel(Application.loadedLevel); } } } if (coll.tag == "KillCollider") { Application.LoadLevel(Application.loadedLevel); } }
public Collider FindOutNearestCollider(Collider[] cols) { float minDis = 0; int minIndex = 0; List <Collider> colList = new List <Collider>(); for (int i = 0; i < cols.Length; i++) { if (TimeLayer.EqualTimeLayer(cols[i].transform.GetComponentInParent <TimeLayer>(), pTimeLayer) || cols[i].transform.CompareTag("Ground") || cols[i].transform.CompareTag("GrabableGround")) { colList.Add(cols[i]); } } if (colList.Count == 0) { return(null); } else if (colList.Count == 1) { return(colList[0]); } // 충돌체가 여러 개 라면 else { minDis = Vector2.Distance(colList[0].transform.position, transform.position); minIndex = 0; for (int i = 1; i < colList.Count; i++) { if (Vector2.Distance(colList[i].transform.position, transform.position) <= minDis) { minDis = Vector2.Distance(colList[i].transform.position, transform.position); minIndex = i; } } return(colList[minIndex]); } }
//만약 탐지 가능한 객체(EqualTimeLayer == true)가 있으면 !null 요소가 만약 객체가 없으면 null public BrowseInfo[] Browse(float rayLen) { gBrowseHits = new RaycastHit[browseDensity][]; BrowseInfo[] bInfos = new BrowseInfo[0]; maxX = GetComponent <Collider>().bounds.max.x; maxY = GetComponent <Collider>().bounds.max.y; minX = GetComponent <Collider>().bounds.min.x; minY = GetComponent <Collider>().bounds.min.y; for (int i = 0; i < browseDensity; i++) { if (transform.localScale.x > 0) { gBrowseHits[i] = Physics.RaycastAll( new Vector3(minX - 0.1f, maxY - colYLen * (i / (browseDensity - 1)), transform.position.z), Vector3.right, rayLen + colXLen, browseMask); } else { gBrowseHits[i] = Physics.RaycastAll( new Vector3(maxX + 0.1f, maxY - colYLen * (i / (browseDensity - 1)), transform.position.z), Vector3.left, rayLen + colXLen, browseMask); } bInfos = new BrowseInfo[gBrowseHits[i].Length]; for (int j = 0; j < gBrowseHits[i].Length; j++) { if (gBrowseHits[i][j].collider != null) { if (TimeLayer.EqualTimeLayer(pTimeLayer, gBrowseHits[i][j].transform.GetComponentInParent <TimeLayer>())) { bInfos[j].InitBrowseInfo(gBrowseHits[i][j].collider.gameObject, gBrowseHits[i][j].distance, gBrowseHits[i][j].normal, gBrowseHits[i][j].point, gBrowseHits[i][j].transform.tag, gBrowseHits[i][j].transform.gameObject.layer); } } } } return(bInfos); }
public bool IsFindPlayer(float rayLen) { Browse(rayLen); for (int i = 0; i < browseDensity; i++) { for (int j = 0; j < gBrowseHits[i].Length; j++) { if (TimeLayer.EqualTimeLayer(pTimeLayer, gBrowseHits[i][j].collider.GetComponentInParent <TimeLayer>())) { if (gBrowseHits[i][j].collider.gameObject.layer == LayerMask.NameToLayer("Collision")) { break; } else if (gBrowseHits[i][j].collider.gameObject.layer == LayerMask.NameToLayer("Player")) { return(true); } } } } return(false); }
public float GetDistanceToGround() { for (int i = 0; i < 3; i++) { var origin = Vector3.up * pBoxCollider.bounds.min.y + Vector3.right * pBoxCollider.bounds.min.x + Vector3.right * pBoxCollider.size.x * (i / 2); Debug.DrawLine(Vector3.up * pBoxCollider.bounds.min.y + Vector3.right * pBoxCollider.bounds.min.x + Vector3.right * pBoxCollider.size.x * (i / 2), Vector3.up * pBoxCollider.bounds.min.y + Vector3.right * pBoxCollider.bounds.min.x + Vector3.right * pBoxCollider.size.x * (i / 2) + Vector3.down * 3, Color.red); var hits = Physics.RaycastAll(origin, Vector2.down, 3, controller.collisionMask); for (int j = 0; j < hits.Length; j++) { var hit = hits[j]; if (hit.collider != null && TimeLayer.EqualTimeLayer(hit.collider.GetComponentInParent <TimeLayer>(), pTimeLayer) || hit.collider.tag.Contains("Ground")) { return(hit.distance); } } } return(-1); }
void Awake() { ActiveInTimeLayer = GetComponent <ActiveInTimeLayerBehaviour>().ActiveInTimeLayer; }
public static bool EqualTimeLayer(TimeLayer obj1, TimeLayer obj2) { return((obj1.layerNum == obj2.layerNum) ? true : false); }
void Awake() { ActiveInTimeLayer = GetComponent <ActiveInTimeLayerBehaviour>().ActiveInTimeLayer; anim = GetComponent <Animator>(); sprite = GetComponent <SpriteRenderer>(); }
private bool IsCutsomEventTrigger(Collider col) { return(null != col.GetComponent <CustomEventTrigger> () && TimeLayer.EqualTimeLayer(gameObject, col.gameObject)); }
void HorizontalCollisions(ref Vector3 velocity) { float directionX = Mathf.Sign(velocity.x); float rayLength = Mathf.Abs(velocity.x) + skinWidth; for (int i = 0; i < horizontalRayCount; i++) { Vector3 rayOrigin = (directionX == -1) ? raycastOrigins.bottomLeft : raycastOrigins.bottomRight; rayOrigin += Vector3.up * (horizontalRaySpacing * i); RaycastHit hit; if (Physics.Raycast(rayOrigin, Vector3.right * directionX, out hit, rayLength, collisionMask)) { float slopeAngle = Vector3.Angle(hit.normal, Vector3.up); if (i == 0 && slopeAngle <= maxClimbAngle) { if (TimeLayer.EqualTimeLayer(pTimeLayer, hit.collider.transform.GetComponentInParent <TimeLayer> ()) || hit.collider.CompareTag("Ground") || hit.collider.CompareTag("GrabableGround") || hit.collider.CompareTag("Bound") || hit.collider.CompareTag("Stair")) { float distanceToSlopeStart = 0; ClimbSlope(ref velocity, slopeAngle); if (collisions.descendingSlope) { collisions.descendingSlope = false; velocity = collisions.velocityOld; } if (slopeAngle != collisions.slopeAngleOld) { distanceToSlopeStart = hit.distance - skinWidth; velocity.x -= distanceToSlopeStart * directionX; } velocity.x += distanceToSlopeStart * directionX; } } if (!collisions.climbingSlope || slopeAngle > maxClimbAngle) { if (TimeLayer.EqualTimeLayer(pTimeLayer, hit.collider.transform.GetComponentInParent <TimeLayer> ()) || hit.collider.CompareTag("Ground") || hit.collider.CompareTag("GrabableGround") || hit.collider.CompareTag("Bound") || hit.collider.CompareTag("Stair") || hit.collider.CompareTag("PassableCollision")) { velocity.x = (hit.distance - skinWidth) * directionX; collisions.left = directionX == -1; collisions.right = directionX == 1; rayLength = hit.distance; if (collisions.climbingSlope && isWalkOnStair) { velocity.y = Mathf.Tan(collisions.slopeAngle * Mathf.Deg2Rad) * Mathf.Abs(velocity.x); } } } } } }
void Start() { col = GetComponent <BoxCollider> (); pTimeLayer = transform.GetComponentInParent <TimeLayer> (); CalculateRaySpacing(); }
void VerticalCollisions(ref Vector3 velocity) { float directionY = Mathf.Sign(velocity.y); float rayLength = Mathf.Abs(velocity.y) + skinWidth; RaycastHit[][] browseHits = new RaycastHit[verticalRayCount][]; for (int i = 0; i < verticalRayCount; i++) { Vector3 rayOrigin = (directionY == -1) ? raycastOrigins.bottomLeft:raycastOrigins.topLeft; rayOrigin += Vector3.right * (verticalRaySpacing * i + velocity.x); browseHits[i] = Physics.RaycastAll(rayOrigin, Vector3.up * directionY, rayLength, collisionMask); for (int j = 0; j < browseHits[i].Length; j++) { var hit = browseHits [i] [j].collider; if (hit != null) { if (TimeLayer.EqualTimeLayer(hit.GetComponentInParent <TimeLayer> (), pTimeLayer) || hit.CompareTag("Ground") || hit.CompareTag("GrabableGround") || hit.CompareTag("Bound") || hit.CompareTag("Stair") || hit.CompareTag("PassableCollision")) { if (hit.CompareTag("PassableCollision") && velocity.y > 0 && (GetComponent <Player> ().isJump)) { break; } velocity.y = (browseHits [i] [j].distance - skinWidth) * directionY; rayLength = browseHits [i] [j].distance; if (collisions.climbingSlope) { velocity.x = velocity.y / Mathf.Tan(collisions.slopeAngle * Mathf.Deg2Rad) * Mathf.Sign(velocity.x); } collisions.below = directionY == -1; collisions.above = directionY == 1; } } } } if (collisions.climbingSlope) { float directionX = Mathf.Sign(velocity.x); rayLength = Mathf.Abs(velocity.x) + skinWidth; Vector3 rayOrigin = ((directionX == -1)?raycastOrigins.bottomLeft:raycastOrigins.bottomRight) + Vector3.up * velocity.y; RaycastHit hit; if (Physics.Raycast(rayOrigin, Vector3.right * directionX, out hit, rayLength, collisionMask)) { if (TimeLayer.EqualTimeLayer(hit.collider.transform.GetComponentInParent <TimeLayer>(), pTimeLayer) || hit.collider.CompareTag("Ground") || hit.collider.CompareTag("Bound") || hit.collider.CompareTag("Stair") || hit.collider.CompareTag("GrabbableGround") ) { if (isWalkOnStair) { float slopeAngle = Vector3.Angle(hit.normal, Vector3.up); if (slopeAngle != collisions.slopeAngle) { velocity.x = (hit.distance - skinWidth) * directionX; collisions.slopeAngle = slopeAngle; } } } } } }
void Awake() { _particles = GetComponentsInChildren <ParticleSystem>(); ActiveInTimeLayer = GetComponent <ActiveInTimeLayerBehaviour>().ActiveInTimeLayer; }
public void ChangeTimeLayer(TimeLayer changeToThisLayer) { }