protected void InitializeArrows(Vector3 offset) { if (Exists) { arrows = ArrowIndicator.GetArrowIndicator(Transform.position + Transform.rotation * offset, Vector3.forward, .5f); arrows.transform.SetParent(SceneGlobals.map_canvas.transform); arrows.parent_object = this; } }
public static ArrowIndicator GetArrowIndicator(Vector3 start, Vector3 vector, float thickness) { GameObject arrow_obj = Instantiate(Resources.Load("prefs/Arrow") as GameObject); ArrowIndicator indicator_instance = arrow_obj.GetComponent <ArrowIndicator>(); indicator_instance.Start_(); indicator_instance.VectorShape(start, vector, thickness); return(indicator_instance); }
public void ShowArrowIndicator(float effectRange, float angle) { if (this.arrowIndicatorGo == null) { this.arrowIndicatorGo = Instantiate <GameObject>(this.arrowIndicatorPf); this.arrowIndicator = arrowIndicatorGo.GetComponent <ArrowIndicator>(); } arrowIndicator.Show(effectRange, angle); }
public static void PopIndicator() { try { ArrowIndicator indicator = null; lock (s_indicators) { indicator = s_indicators.Pop(); } if (indicator != null) { Destroy(indicator.gameObject); } } catch (InvalidOperationException ex) { Debug.Log("the stack is empty"); } }
// Start is called before the first frame update void Start() { if (!nullValues) { string[] names = Input.GetJoystickNames(); foreach (string name in names) { if (name != "") { controllerPresent = true; Cursor.visible = false; } } player = GameObject.Find("Player").GetComponent <PlayerController>(); specials = player.gameObject.GetComponent <SpecialsManager>(); aerialListener = aerialCamera.GetComponent <AudioListener>(); mainListener = mainCamera.GetComponent <AudioListener>(); ObjMng = gameObject.GetComponent <ObjectivesManager>(); ArrInd = gameObject.GetComponent <ArrowIndicator>(); PhoneUI = GameObject.Find("PopUpPhone").GetComponent <PhoneUI>(); dataPost = GameObject.FindGameObjectWithTag("Data").GetComponent <DrivePost>(); int width = Screen.width; int height = Screen.height; float ratio = width / 1920; width = (int)(width * ratio); height = (int)(height * ratio); ArrInd.SetHideArrow(); #if UNITY_EDITOR Debug.Log("In Editor"); #else Screen.SetResolution(width, height, true); #endif } }
public void ClearLastIndicator() { ArrowIndicator.PopIndicator(); }
// Use this for initialization void Start() { // Get GameObject components & children rigid = GetComponent <Rigidbody2D> (); sprite = transform.Find("Sprite").gameObject; charSprite = sprite.transform.Find("Character").gameObject; animator = charSprite.GetComponent <Animator> (); sprend = charSprite.GetComponent <SpriteRenderer> (); bodyCollider = GetComponent <BoxCollider2D> (); point_manager = GetComponent <PointManager> (); ufo_manager = GetComponent <UFOManager> (); offscreen_arrow_manager = GetComponent <ArrowIndicator> (); jetpackObj = sprite.transform.Find("Jetpack").gameObject; jetpack_bar = GetComponent <JetpackBar> (); jetpack_bar.SetMaxFuel(jetpackFuelMax); // JF: Get highlightObject and disable. Enable if item is held later highlightObject = transform.Find("Highlight").gameObject; // highlightSprends = highlightObject.GetComponentsInChildren<SpriteRenderer> (); highlightObject.SetActive(false); // AW: Get arrow sprite for aiming shots and proj source aimArrowObject = transform.Find("Aiming").gameObject; aimArrowObject.SetActive(false); projSource = aimArrowObject.transform.Find("ProjectileSource").gameObject; // JF: Arrow and gun sprite for flipping aimSprend = aimArrowObject.transform.Find("ArrowSprite").GetComponent <SpriteRenderer> (); // AW: Get jetpack related variables jetpackFire = sprite.transform.Find("Jetpack").transform.Find("Fire").gameObject; jetpackFire.SetActive(false); jetpackFuelBar = sprite.transform.Find("Jetpack").transform.Find("JetpackBar").gameObject; jetpackFuelBar.SetActive(false); // Initializing internal jetpackFuelCurrent = jetpackFuelMax; // Raycast parameters itemLayer = LayerMask.GetMask("Items"); groundLayer = LayerMask.GetMask("Ground"); // Filling the function behavior map stateUpdateMap = new Dictionary <PlayerForm, Action> (); stateUpdateMap.Add(PlayerForm.Normal, NormalUpdate); stateUpdateMap.Add(PlayerForm.Setting, SettingUpdate); stateUpdateMap.Add(PlayerForm.Controlling, ControllingUpdate); stateUpdateMap.Add(PlayerForm.Respawning, RespawningUpdate); if (charSettings == null) { try { input = InputManager.Devices [int.Parse(playerNumStr) - 1]; } catch { Debug.Log("4 controllers are not connected. Assigning extra players to first player"); input = InputManager.Devices [0]; } } else { InitPlayerSettings(); } input.LeftStickX.LowerDeadZone = 0.2f; input.LeftStickY.LowerDeadZone = 0.5f; blockMask = LayerMask.GetMask("Team" + teamNum.ToString() + "Block"); // Have the UFOs bring in the players! Respawn(transform.position); }
/// <summary> /// Runs when instance starts /// </summary> private void Start() { indicator = this; this.resetPosition = GetComponent <Transform>().position; }
public IEnumerator DoProcessMidAirState_Energy() { Debug.Log("Show transfer of Elastic Potential Energy to Kinetic Energy that Launches the Cannon Ball and Observe Forces while in air"); if (failLaunch) { popup.Show(); yield break; } CanProcessNextStep = false; sliderLockOut = true; // Lockout physics config sliders midAirStep = MidAirStep.Launching; energyWidget.Show(); // Show Kinetic Energy Info float currentKineticEnergy = 0; energyWidget.UpdateKineticEnergy(currentKineticEnergy); // Show Draining of Elastic Potential Energy To Kinetic Energy (Kinetic Energy will equal the Elastic Potential Energy) float kineticEnergy = Kinetic_Energy_At_Launch(); float elasticEnergy = Kinetic_Energy_At_Launch(); const float drainSpeed = 0.05f; // Animate the depletion of Elastic Potential Energy and Gain of Kinetic Energy prior to Launch while (!EEMath.Approximately(elasticEnergy, 0, 0.001f) || !EEMath.Approximately(currentKineticEnergy, kineticEnergy, 0.001f)) { yield return(null); elasticEnergy = Mathf.Lerp(elasticEnergy, 0, drainSpeed); energyWidget.UpdateElasticEnergy(elasticEnergy); currentKineticEnergy = Mathf.Lerp(currentKineticEnergy, kineticEnergy, drainSpeed); energyWidget.UpdateKineticEnergy(currentKineticEnergy); } yield return(StartCoroutine(DoLerpCameraToTransform(catapult.step3CamTransform))); float velocity = Velocity_At_Time_Of_Launch(); float ratio = ratio_Of_DEPE_Over_DGPE(); catapult.ThrowBall(catapult.launchVector.up, velocity); while (!cannonBall.paused) { yield return(null); Transform riseMarker = Utils.CreateMarker(null, 0.1f, Color.red); riseMarker.position = cannonBall.transform.position; markers.Add(riseMarker.gameObject); // Catch when the ball has left max arc height if (cannonBall.rigidBody.velocity.y < 0) { if (!cannonBall.maxHeightReached) { cannonBall.maxHeightReached = true; Transform peakMarker = Utils.CreateMarker(null, 0.2f, Color.blue); peakMarker.position = cannonBall.prevPosition; markers.Add(peakMarker.gameObject); cannonBall.PauseInAir(); yield return(StartCoroutine(DoLerpCameraToTransform(cannonBall.step4CamTransform))); } } } midAirStep = MidAirStep.Maxheight; weightPoint = cannonBall.LeftWeightPoint; resultPoint = catapult.springVector; ArrowIndicator maxHeightVelocityArrow = Instantiate(arrowBasicFrontPivotPrefab).GetComponent <ArrowIndicator>(); maxHeightVelocityArrow.SetArrowTransform(cannonBall.PeakHightVelocityMarker); maxHeightVelocityArrow.bobbing = true; maxHeightVelocityArrow.Show(); vectorArrows.Add(maxHeightVelocityArrow); maxHeightVelocityArrow.infoWidget.UpdateInfoWidget(null, (float)Math.Round(cannonBall.currentVelocity.magnitude, 2), "Velocity", true); energyWidget.AttachToTransform(cannonBall.EnergyWidgetMarker_LeftOffset); energyWidget.infoWidget.ToggleElasticInfo(false); energyWidget.infoWidget.ToggleKineticInfo(false); energyWidget.UpdateGravEnergy(cannonBall.Gravitational_Potential_Energy()); CanProcessNextStep = true; yield return(new WaitUntil(() => { return (midAirStep == MidAirStep.SlopeDown); })); // wait for camera to complete lerping to Ball mid air position CanProcessNextStep = false; HideGizmoAndWidgets(); // Hide all force arrows in preperation for next view step distanceGizmo.Show(); yield return(StartCoroutine(DoLerpCameraToTransform(cannonBall.step5CamTransform))); cannonBall.Resume(); // Cannonball falling downward while (!cannonBall.paused) { Transform downMarker = Utils.CreateMarker(null, 0.1f, Color.green); downMarker.position = cannonBall.transform.position; markers.Add(downMarker.gameObject); yield return(null); RaycastHit hitResult; if (RaycastFromPos(cannonBall.transform.position, -cannonBall.transform.up, Mathf.Infinity, out hitResult, true)) { float diff = cannonBall.transform.position.y - hitResult.point.y; if (diff < DistanceFromGround_At_TimeOFLaunch) { cannonBall.PauseInAir(); } } } yield return(StartCoroutine(DoLerpCameraToTransform(cannonBall.step4CamTransform))); ArrowIndicator slopeDownVelocityArrow = Instantiate(arrowBasicBackPivotPrefab).GetComponent <ArrowIndicator>(); slopeDownVelocityArrow.bobbing = true; vectorArrows.Add(slopeDownVelocityArrow); OrientTransformToVector(ref cannonBall.ResultPoint_Centered, cannonBall.currentVelocity); slopeDownVelocityArrow.SetArrowTransform(cannonBall.ResultPoint_Centered); slopeDownVelocityArrow.Show(); slopeDownVelocityArrow.infoWidget.UpdateInfoWidget(null, (float)Math.Round(cannonBall.currentVelocity.magnitude, 2), "Velocity", true); energyWidget.AttachToTransform(cannonBall.EnergyWidgetMarker_RightOffset); energyWidget.infoWidget.ToggleElasticInfo(false); energyWidget.UpdateGravEnergy(cannonBall.Gravitational_Potential_Energy()); energyWidget.Show(); CanProcessNextStep = true; yield return(new WaitUntil(() => { return (midAirStep == MidAirStep.CompleteArc); })); // wait for camera to complete lerping to Ball mid air position CanProcessNextStep = false; HideGizmoAndWidgets(); distanceGizmo.Show(); yield return(StartCoroutine(DoLerpCameraToTransform(cannonBall.step5CamTransform))); // RE focus camera cannonBall.Resume(); // resume cannon ball trajectory // Draw the rest of the arc markers while (!cannonBall.paused && cannonBall.inAir) { Transform downMarker = Utils.CreateMarker(null, 0.1f, Color.green); downMarker.position = cannonBall.transform.position; markers.Add(downMarker.gameObject); yield return(null); } cannonBall.transform.rotation = Quaternion.identity; midAirStep = MidAirStep.Undefined; // Mid air step is over; // Freeze the ball's movement and rotation as soon as it makes contact with the ground; cannonBall.transform.rotation = Quaternion.identity; cannonBall.rigidBody.constraints = RigidbodyConstraints.FreezeAll; // Cheat to make Cannonball touch ground cannonBall.transform.position = new Vector3(cannonBall.transform.position.x, 0.425f, cannonBall.transform.position.z); yield return(StartCoroutine(DoProcessStoppedState_Energy())); activeCoroutine = null; }
public IEnumerator DoProcessMidAirState_Forces() { sliderLockOut = true; // Ensure that we cannot manipulate physics attributes after launch Debug.Log("Launch Cannon Ball and Observe Forces while in air"); if (failLaunch) { popup.Show(); yield break; } HideGizmoAndWidgets(); distanceGizmo.Show(); CanProcessNextStep = false; midAirStep = MidAirStep.Launching; yield return(StartCoroutine(DoLerpCameraToTransform(catapult.step3CamTransform))); float velocity = Velocity_At_Time_Of_Launch(); float ratio = ratio_Of_DEPE_Over_DGPE(); catapult.ThrowBall(catapult.launchVector.up, velocity); while (!cannonBall.paused) { yield return(null); Transform riseMarker = Utils.CreateMarker(null, 0.1f, Color.red); riseMarker.position = cannonBall.transform.position; markers.Add(riseMarker.gameObject); // Catch when the ball has left max arc height if (cannonBall.rigidBody.velocity.y < 0) { if (!cannonBall.maxHeightReached) { cannonBall.maxHeightReached = true; Transform peakMarker = Utils.CreateMarker(null, 0.2f, Color.blue); peakMarker.position = cannonBall.prevPosition; markers.Add(peakMarker.gameObject); cannonBall.PauseInAir(); yield return(StartCoroutine(DoLerpCameraToTransform(cannonBall.step4CamTransform))); } } } //yield return new WaitUntil(() => { return !camLerping; }); // wait for camera to complete lerping to Ball mid air position midAirStep = MidAirStep.Maxheight; weightPoint = cannonBall.LeftWeightPoint; resultPoint = catapult.springVector; ArrowIndicator maxHeightVelocityArrow = Instantiate(arrowBasicFrontPivotPrefab).GetComponent <ArrowIndicator>(); maxHeightVelocityArrow.SetArrowTransform(cannonBall.PeakHightVelocityMarker); maxHeightVelocityArrow.bobbing = true; maxHeightVelocityArrow.Show(); vectorArrows.Add(maxHeightVelocityArrow); maxHeightVelocityArrow.infoWidget.UpdateInfoWidget(null, (float)Math.Round(cannonBall.currentVelocity.magnitude, 2), "Velocity", true); gravArrow.SetArrowTransform(cannonBall.CenterWeightPoint); gravArrow.Show(); CanProcessNextStep = true; yield return(new WaitUntil(() => { return (midAirStep == MidAirStep.SlopeDown); })); // wait for camera to complete lerping to Ball mid air position CanProcessNextStep = false; HideGizmoAndWidgets(); // Hide all force arrows in preperation for next view step distanceGizmo.Show(); yield return(StartCoroutine(DoLerpCameraToTransform(cannonBall.step5CamTransform))); cannonBall.Resume(); // Cannonball falling downward while (!cannonBall.paused) { Transform downMarker = Utils.CreateMarker(null, 0.1f, Color.green); downMarker.position = cannonBall.transform.position; markers.Add(downMarker.gameObject); yield return(null); RaycastHit hitResult; if (RaycastFromPos(cannonBall.transform.position, -cannonBall.transform.up, Mathf.Infinity, out hitResult, true)) { float diff = cannonBall.transform.position.y - hitResult.point.y; if (diff < DistanceFromGround_At_TimeOFLaunch) { cannonBall.PauseInAir(); } } } yield return(StartCoroutine(DoLerpCameraToTransform(cannonBall.step4CamTransform))); gravArrow.SetArrowTransform(cannonBall.CenterWeightPoint); gravArrow.Show(); ArrowIndicator slopeDownVelocityArrow = Instantiate(arrowBasicBackPivotPrefab).GetComponent <ArrowIndicator>(); slopeDownVelocityArrow.bobbing = true; vectorArrows.Add(slopeDownVelocityArrow); OrientTransformToVector(ref cannonBall.ResultPoint_Centered, cannonBall.currentVelocity); slopeDownVelocityArrow.SetArrowTransform(cannonBall.ResultPoint_Centered); slopeDownVelocityArrow.Show(); slopeDownVelocityArrow.infoWidget.UpdateInfoWidget(null, (float)Math.Round(cannonBall.currentVelocity.magnitude, 2), "Velocity", true); CanProcessNextStep = true; yield return(new WaitUntil(() => { return (midAirStep == MidAirStep.CompleteArc); })); // wait for camera to complete lerping to Ball mid air position CanProcessNextStep = false; HideGizmoAndWidgets(); distanceGizmo.Show(); yield return(StartCoroutine(DoLerpCameraToTransform(cannonBall.step5CamTransform))); // RE focus camera cannonBall.Resume(); // resume cannon ball trajectory // Draw the rest of the arc markers while (!cannonBall.paused && cannonBall.inAir) { Transform downMarker = Utils.CreateMarker(null, 0.1f, Color.green); downMarker.position = cannonBall.transform.position; markers.Add(downMarker.gameObject); yield return(null); } yield return(new WaitUntil(() => { return (cannonBall.rigidBody.velocity == Vector3.zero); })); // wait for camera to complete lerping to Ball mid air position CanProcessNextStep = true; cannonBall.transform.rotation = Quaternion.identity; midAirStep = MidAirStep.Undefined; // Mid air step is over; activeCoroutine = null; }