public void LevelChanged(int loadedLevel) { currentCamDirManager = levelCamDirManagers[loadedLevel]; lcdm = currentCamDirManager.GetComponent <LevelCamDirectionsManager>(); directionPoints = currentCamDirManager.GetComponentsInChildren <DirectionPoint>(); currentDirPoint = directionPoints[0]; }
public Vector3 FindLocationBehindObject(CacheObject obj) { float rotation = FindDirection(FunkyGame.Hero.Position, obj.Position, true); Vector3 startLocation = MathEx.GetPointAt(obj.Position, obj.Radius, rotation); DirectionPoint dp = new DirectionPoint(startLocation, rotation, 35f); LocationalRects.Add(new GPRectangle(dp)); DirectionPoint dp2 = new DirectionPoint(startLocation, MathEx.WrapAngle(rotation + 0.7f), 35f); LocationalRects.Add(new GPRectangle(dp2)); DirectionPoint dp3 = new DirectionPoint(startLocation, MathEx.WrapAngle(rotation - 0.7f), 35f); LocationalRects.Add(new GPRectangle(dp3)); List <GridPoint> blacklisted = new List <GridPoint>(); Vector3 safespot = Vector3.Zero; foreach (var gpr in LocationalRects) { bool found = gpr.TryFindSafeSpot(FunkyGame.Hero.Position, out safespot, Vector3.Zero, PointCheckingFlags.AvoidanceIntersection | PointCheckingFlags.RaycastWalkable, blacklisted); if (found) { break; } } return(safespot); }
protected override void Start() { base.Start(); var comps = GetComponentInChildren<ItemPointScript>(); if (comps == null) Debug.LogErrorFormat("No speak point defined for {0}! ", gameObject.name); else { SpeakerPoint = comps.GetPoint(Controller.CharacterZPosition); } }
protected override void Start() { base.Start(); var comps = GetComponentInChildren<ItemPointScript>(); if (comps == null) return; ObjectPoint = comps.GetPoint(Controller.CharacterZPosition); //we can have multiple itemUseOnScripts, so Destroy is definitelly not a good idea // Destroy(comps); }
public static bool ArePointEqual(DirectionPoint a, DirectionPoint b) { if (ReferenceEquals(a, b)) { return true; } // If one is null, but not both, return false. if (((object)a == null) || ((object)b == null)) { return false; } // Return true if the fields match: return a.StartPoint == b.StartPoint && a.Direction == b.Direction; }
protected override void Start() { base.Start(); var comps = GetComponentInChildren<ItemPointScript>(); if (comps == null) Debug.LogErrorFormat("No object item point defined for {0}! ", gameObject.name); else { ObjectPoint = comps.GetPoint(Controller.CharacterZPosition); // we can have multiple object trying to init using this point //Destroy(comps); } InspectController = GetComponent<InspectObjectController>(); if (InspectController == null) Debug.LogErrorFormat("No InspectObjectController defined for {0}! ", gameObject.name); }
private void Update() { transform.position = puck.transform.position; Camera.main.transform.LookAt(puck.transform.position); List <float> pointsDistances = new List <float>(); for (int i = 0; i < lcdm.dirPoints.Count; i++) { pointsDistances.Add(Vector3.Distance(transform.position, lcdm.dirPoints[i].transform.position)); } pointsDistances.Sort(); for (int i = 0; i < lcdm.dirPoints.Count; i++) { if (pointsDistances[0] == Vector3.Distance(transform.position, lcdm.dirPoints[i].transform.position)) { if (lcdm.dirPoints[i].GetComponent <DirectionPoint>().isLast == false) { currentDirPoint = lcdm.dirPoints[i].GetComponent <DirectionPoint>(); } else { currentDirPoint = lcdm.dirPoints[i - 1].GetComponent <DirectionPoint>(); } } } transform.rotation = Quaternion.Slerp(transform.rotation, currentDirPoint.lookRotation, cameraRotationSpeed * Time.deltaTime); Debug.DrawRay(transform.position, Vector3.forward * 0.5f, Color.red); Debug.DrawRay(transform.position, Vector3.forward * -0.5f, Color.red); Debug.DrawRay(transform.position, Vector3.right * 0.5f, Color.red); Debug.DrawRay(transform.position, Vector3.right * -0.5f, Color.red); }